babylon.module.d.ts 5.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111
  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. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. let Epsilon: number;
  272. export { Epsilon };
  273. /**
  274. * Class used to hold a RBG color
  275. */
  276. export class Color3 {
  277. /**
  278. * Defines the red component (between 0 and 1, default is 0)
  279. */
  280. r: number;
  281. /**
  282. * Defines the green component (between 0 and 1, default is 0)
  283. */
  284. g: number;
  285. /**
  286. * Defines the blue component (between 0 and 1, default is 0)
  287. */
  288. b: number;
  289. /**
  290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  291. * @param r defines the red component (between 0 and 1, default is 0)
  292. * @param g defines the green component (between 0 and 1, default is 0)
  293. * @param b defines the blue component (between 0 and 1, default is 0)
  294. */
  295. constructor(
  296. /**
  297. * Defines the red component (between 0 and 1, default is 0)
  298. */
  299. r?: number,
  300. /**
  301. * Defines the green component (between 0 and 1, default is 0)
  302. */
  303. g?: number,
  304. /**
  305. * Defines the blue component (between 0 and 1, default is 0)
  306. */
  307. b?: number);
  308. /**
  309. * Creates a string with the Color3 current values
  310. * @returns the string representation of the Color3 object
  311. */
  312. toString(): string;
  313. /**
  314. * Returns the string "Color3"
  315. * @returns "Color3"
  316. */
  317. getClassName(): string;
  318. /**
  319. * Compute the Color3 hash code
  320. * @returns an unique number that can be used to hash Color3 objects
  321. */
  322. getHashCode(): number;
  323. /**
  324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  325. * @param array defines the array where to store the r,g,b components
  326. * @param index defines an optional index in the target array to define where to start storing values
  327. * @returns the current Color3 object
  328. */
  329. toArray(array: FloatArray, index?: number): Color3;
  330. /**
  331. * Returns a new Color4 object from the current Color3 and the given alpha
  332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  333. * @returns a new Color4 object
  334. */
  335. toColor4(alpha?: number): Color4;
  336. /**
  337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  338. * @returns the new array
  339. */
  340. asArray(): number[];
  341. /**
  342. * Returns the luminance value
  343. * @returns a float value
  344. */
  345. toLuminance(): number;
  346. /**
  347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  348. * @param otherColor defines the second operand
  349. * @returns the new Color3 object
  350. */
  351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  352. /**
  353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  354. * @param otherColor defines the second operand
  355. * @param result defines the Color3 object where to store the result
  356. * @returns the current Color3
  357. */
  358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  359. /**
  360. * Determines equality between Color3 objects
  361. * @param otherColor defines the second operand
  362. * @returns true if the rgb values are equal to the given ones
  363. */
  364. equals(otherColor: DeepImmutable<Color3>): boolean;
  365. /**
  366. * Determines equality between the current Color3 object and a set of r,b,g values
  367. * @param r defines the red component to check
  368. * @param g defines the green component to check
  369. * @param b defines the blue component to check
  370. * @returns true if the rgb values are equal to the given ones
  371. */
  372. equalsFloats(r: number, g: number, b: number): boolean;
  373. /**
  374. * Multiplies in place each rgb value by scale
  375. * @param scale defines the scaling factor
  376. * @returns the updated Color3
  377. */
  378. scale(scale: number): Color3;
  379. /**
  380. * Multiplies the rgb values by scale and stores the result into "result"
  381. * @param scale defines the scaling factor
  382. * @param result defines the Color3 object where to store the result
  383. * @returns the unmodified current Color3
  384. */
  385. scaleToRef(scale: number, result: Color3): Color3;
  386. /**
  387. * Scale the current Color3 values by a factor and add the result to a given Color3
  388. * @param scale defines the scale factor
  389. * @param result defines color to store the result into
  390. * @returns the unmodified current Color3
  391. */
  392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  393. /**
  394. * Clamps the rgb values by the min and max values and stores the result into "result"
  395. * @param min defines minimum clamping value (default is 0)
  396. * @param max defines maximum clamping value (default is 1)
  397. * @param result defines color to store the result into
  398. * @returns the original Color3
  399. */
  400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  401. /**
  402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  403. * @param otherColor defines the second operand
  404. * @returns the new Color3
  405. */
  406. add(otherColor: DeepImmutable<Color3>): Color3;
  407. /**
  408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  409. * @param otherColor defines the second operand
  410. * @param result defines Color3 object to store the result into
  411. * @returns the unmodified current Color3
  412. */
  413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  414. /**
  415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  416. * @param otherColor defines the second operand
  417. * @returns the new Color3
  418. */
  419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  420. /**
  421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  422. * @param otherColor defines the second operand
  423. * @param result defines Color3 object to store the result into
  424. * @returns the unmodified current Color3
  425. */
  426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  427. /**
  428. * Copy the current object
  429. * @returns a new Color3 copied the current one
  430. */
  431. clone(): Color3;
  432. /**
  433. * Copies the rgb values from the source in the current Color3
  434. * @param source defines the source Color3 object
  435. * @returns the updated Color3 object
  436. */
  437. copyFrom(source: DeepImmutable<Color3>): Color3;
  438. /**
  439. * Updates the Color3 rgb values from the given floats
  440. * @param r defines the red component to read from
  441. * @param g defines the green component to read from
  442. * @param b defines the blue component to read from
  443. * @returns the current Color3 object
  444. */
  445. copyFromFloats(r: number, g: number, b: number): Color3;
  446. /**
  447. * Updates the Color3 rgb values from the given floats
  448. * @param r defines the red component to read from
  449. * @param g defines the green component to read from
  450. * @param b defines the blue component to read from
  451. * @returns the current Color3 object
  452. */
  453. set(r: number, g: number, b: number): Color3;
  454. /**
  455. * Compute the Color3 hexadecimal code as a string
  456. * @returns a string containing the hexadecimal representation of the Color3 object
  457. */
  458. toHexString(): string;
  459. /**
  460. * Computes a new Color3 converted from the current one to linear space
  461. * @returns a new Color3 object
  462. */
  463. toLinearSpace(): Color3;
  464. /**
  465. * Converts current color in rgb space to HSV values
  466. * @returns a new color3 representing the HSV values
  467. */
  468. toHSV(): Color3;
  469. /**
  470. * Converts current color in rgb space to HSV values
  471. * @param result defines the Color3 where to store the HSV values
  472. */
  473. toHSVToRef(result: Color3): void;
  474. /**
  475. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the linear space version
  477. * @returns the unmodified Color3
  478. */
  479. toLinearSpaceToRef(convertedColor: Color3): Color3;
  480. /**
  481. * Computes a new Color3 converted from the current one to gamma space
  482. * @returns a new Color3 object
  483. */
  484. toGammaSpace(): Color3;
  485. /**
  486. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  487. * @param convertedColor defines the Color3 object where to store the gamma space version
  488. * @returns the unmodified Color3
  489. */
  490. toGammaSpaceToRef(convertedColor: Color3): Color3;
  491. private static _BlackReadOnly;
  492. /**
  493. * Convert Hue, saturation and value to a Color3 (RGB)
  494. * @param hue defines the hue
  495. * @param saturation defines the saturation
  496. * @param value defines the value
  497. * @param result defines the Color3 where to store the RGB values
  498. */
  499. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  500. /**
  501. * Creates a new Color3 from the string containing valid hexadecimal values
  502. * @param hex defines a string containing valid hexadecimal values
  503. * @returns a new Color3 object
  504. */
  505. static FromHexString(hex: string): Color3;
  506. /**
  507. * Creates a new Color3 from the starting index of the given array
  508. * @param array defines the source array
  509. * @param offset defines an offset in the source array
  510. * @returns a new Color3 object
  511. */
  512. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  513. /**
  514. * Creates a new Color3 from integer values (< 256)
  515. * @param r defines the red component to read from (value between 0 and 255)
  516. * @param g defines the green component to read from (value between 0 and 255)
  517. * @param b defines the blue component to read from (value between 0 and 255)
  518. * @returns a new Color3 object
  519. */
  520. static FromInts(r: number, g: number, b: number): Color3;
  521. /**
  522. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  523. * @param start defines the start Color3 value
  524. * @param end defines the end Color3 value
  525. * @param amount defines the gradient value between start and end
  526. * @returns a new Color3 object
  527. */
  528. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  529. /**
  530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  531. * @param left defines the start value
  532. * @param right defines the end value
  533. * @param amount defines the gradient factor
  534. * @param result defines the Color3 object where to store the result
  535. */
  536. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  537. /**
  538. * Returns a Color3 value containing a red color
  539. * @returns a new Color3 object
  540. */
  541. static Red(): Color3;
  542. /**
  543. * Returns a Color3 value containing a green color
  544. * @returns a new Color3 object
  545. */
  546. static Green(): Color3;
  547. /**
  548. * Returns a Color3 value containing a blue color
  549. * @returns a new Color3 object
  550. */
  551. static Blue(): Color3;
  552. /**
  553. * Returns a Color3 value containing a black color
  554. * @returns a new Color3 object
  555. */
  556. static Black(): Color3;
  557. /**
  558. * Gets a Color3 value containing a black color that must not be updated
  559. */
  560. static readonly BlackReadOnly: DeepImmutable<Color3>;
  561. /**
  562. * Returns a Color3 value containing a white color
  563. * @returns a new Color3 object
  564. */
  565. static White(): Color3;
  566. /**
  567. * Returns a Color3 value containing a purple color
  568. * @returns a new Color3 object
  569. */
  570. static Purple(): Color3;
  571. /**
  572. * Returns a Color3 value containing a magenta color
  573. * @returns a new Color3 object
  574. */
  575. static Magenta(): Color3;
  576. /**
  577. * Returns a Color3 value containing a yellow color
  578. * @returns a new Color3 object
  579. */
  580. static Yellow(): Color3;
  581. /**
  582. * Returns a Color3 value containing a gray color
  583. * @returns a new Color3 object
  584. */
  585. static Gray(): Color3;
  586. /**
  587. * Returns a Color3 value containing a teal color
  588. * @returns a new Color3 object
  589. */
  590. static Teal(): Color3;
  591. /**
  592. * Returns a Color3 value containing a random color
  593. * @returns a new Color3 object
  594. */
  595. static Random(): Color3;
  596. }
  597. /**
  598. * Class used to hold a RBGA color
  599. */
  600. export class Color4 {
  601. /**
  602. * Defines the red component (between 0 and 1, default is 0)
  603. */
  604. r: number;
  605. /**
  606. * Defines the green component (between 0 and 1, default is 0)
  607. */
  608. g: number;
  609. /**
  610. * Defines the blue component (between 0 and 1, default is 0)
  611. */
  612. b: number;
  613. /**
  614. * Defines the alpha component (between 0 and 1, default is 1)
  615. */
  616. a: number;
  617. /**
  618. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  619. * @param r defines the red component (between 0 and 1, default is 0)
  620. * @param g defines the green component (between 0 and 1, default is 0)
  621. * @param b defines the blue component (between 0 and 1, default is 0)
  622. * @param a defines the alpha component (between 0 and 1, default is 1)
  623. */
  624. constructor(
  625. /**
  626. * Defines the red component (between 0 and 1, default is 0)
  627. */
  628. r?: number,
  629. /**
  630. * Defines the green component (between 0 and 1, default is 0)
  631. */
  632. g?: number,
  633. /**
  634. * Defines the blue component (between 0 and 1, default is 0)
  635. */
  636. b?: number,
  637. /**
  638. * Defines the alpha component (between 0 and 1, default is 1)
  639. */
  640. a?: number);
  641. /**
  642. * Adds in place the given Color4 values to the current Color4 object
  643. * @param right defines the second operand
  644. * @returns the current updated Color4 object
  645. */
  646. addInPlace(right: DeepImmutable<Color4>): Color4;
  647. /**
  648. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  649. * @returns the new array
  650. */
  651. asArray(): number[];
  652. /**
  653. * Stores from the starting index in the given array the Color4 successive values
  654. * @param array defines the array where to store the r,g,b components
  655. * @param index defines an optional index in the target array to define where to start storing values
  656. * @returns the current Color4 object
  657. */
  658. toArray(array: number[], index?: number): Color4;
  659. /**
  660. * Determines equality between Color4 objects
  661. * @param otherColor defines the second operand
  662. * @returns true if the rgba values are equal to the given ones
  663. */
  664. equals(otherColor: DeepImmutable<Color4>): boolean;
  665. /**
  666. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  667. * @param right defines the second operand
  668. * @returns a new Color4 object
  669. */
  670. add(right: DeepImmutable<Color4>): Color4;
  671. /**
  672. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  673. * @param right defines the second operand
  674. * @returns a new Color4 object
  675. */
  676. subtract(right: DeepImmutable<Color4>): Color4;
  677. /**
  678. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  679. * @param right defines the second operand
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the current Color4 object
  682. */
  683. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  684. /**
  685. * Creates a new Color4 with the current Color4 values multiplied by scale
  686. * @param scale defines the scaling factor to apply
  687. * @returns a new Color4 object
  688. */
  689. scale(scale: number): Color4;
  690. /**
  691. * Multiplies the current Color4 values by scale and stores the result in "result"
  692. * @param scale defines the scaling factor to apply
  693. * @param result defines the Color4 object where to store the result
  694. * @returns the current unmodified Color4
  695. */
  696. scaleToRef(scale: number, result: Color4): Color4;
  697. /**
  698. * Scale the current Color4 values by a factor and add the result to a given Color4
  699. * @param scale defines the scale factor
  700. * @param result defines the Color4 object where to store the result
  701. * @returns the unmodified current Color4
  702. */
  703. scaleAndAddToRef(scale: number, result: Color4): Color4;
  704. /**
  705. * Clamps the rgb values by the min and max values and stores the result into "result"
  706. * @param min defines minimum clamping value (default is 0)
  707. * @param max defines maximum clamping value (default is 1)
  708. * @param result defines color to store the result into.
  709. * @returns the cuurent Color4
  710. */
  711. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  712. /**
  713. * Multipy an Color4 value by another and return a new Color4 object
  714. * @param color defines the Color4 value to multiply by
  715. * @returns a new Color4 object
  716. */
  717. multiply(color: Color4): Color4;
  718. /**
  719. * Multipy a Color4 value by another and push the result in a reference value
  720. * @param color defines the Color4 value to multiply by
  721. * @param result defines the Color4 to fill the result in
  722. * @returns the result Color4
  723. */
  724. multiplyToRef(color: Color4, result: Color4): Color4;
  725. /**
  726. * Creates a string with the Color4 current values
  727. * @returns the string representation of the Color4 object
  728. */
  729. toString(): string;
  730. /**
  731. * Returns the string "Color4"
  732. * @returns "Color4"
  733. */
  734. getClassName(): string;
  735. /**
  736. * Compute the Color4 hash code
  737. * @returns an unique number that can be used to hash Color4 objects
  738. */
  739. getHashCode(): number;
  740. /**
  741. * Creates a new Color4 copied from the current one
  742. * @returns a new Color4 object
  743. */
  744. clone(): Color4;
  745. /**
  746. * Copies the given Color4 values into the current one
  747. * @param source defines the source Color4 object
  748. * @returns the current updated Color4 object
  749. */
  750. copyFrom(source: Color4): Color4;
  751. /**
  752. * Copies the given float values into the current one
  753. * @param r defines the red component to read from
  754. * @param g defines the green component to read from
  755. * @param b defines the blue component to read from
  756. * @param a defines the alpha component to read from
  757. * @returns the current updated Color4 object
  758. */
  759. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  760. /**
  761. * Copies the given float values into the current one
  762. * @param r defines the red component to read from
  763. * @param g defines the green component to read from
  764. * @param b defines the blue component to read from
  765. * @param a defines the alpha component to read from
  766. * @returns the current updated Color4 object
  767. */
  768. set(r: number, g: number, b: number, a: number): Color4;
  769. /**
  770. * Compute the Color4 hexadecimal code as a string
  771. * @returns a string containing the hexadecimal representation of the Color4 object
  772. */
  773. toHexString(): string;
  774. /**
  775. * Computes a new Color4 converted from the current one to linear space
  776. * @returns a new Color4 object
  777. */
  778. toLinearSpace(): Color4;
  779. /**
  780. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  781. * @param convertedColor defines the Color4 object where to store the linear space version
  782. * @returns the unmodified Color4
  783. */
  784. toLinearSpaceToRef(convertedColor: Color4): Color4;
  785. /**
  786. * Computes a new Color4 converted from the current one to gamma space
  787. * @returns a new Color4 object
  788. */
  789. toGammaSpace(): Color4;
  790. /**
  791. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  792. * @param convertedColor defines the Color4 object where to store the gamma space version
  793. * @returns the unmodified Color4
  794. */
  795. toGammaSpaceToRef(convertedColor: Color4): Color4;
  796. /**
  797. * Creates a new Color4 from the string containing valid hexadecimal values
  798. * @param hex defines a string containing valid hexadecimal values
  799. * @returns a new Color4 object
  800. */
  801. static FromHexString(hex: string): Color4;
  802. /**
  803. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  804. * @param left defines the start value
  805. * @param right defines the end value
  806. * @param amount defines the gradient factor
  807. * @returns a new Color4 object
  808. */
  809. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  810. /**
  811. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  812. * @param left defines the start value
  813. * @param right defines the end value
  814. * @param amount defines the gradient factor
  815. * @param result defines the Color4 object where to store data
  816. */
  817. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  818. /**
  819. * Creates a new Color4 from a Color3 and an alpha value
  820. * @param color3 defines the source Color3 to read from
  821. * @param alpha defines the alpha component (1.0 by default)
  822. * @returns a new Color4 object
  823. */
  824. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  825. /**
  826. * Creates a new Color4 from the starting index element of the given array
  827. * @param array defines the source array to read from
  828. * @param offset defines the offset in the source array
  829. * @returns a new Color4 object
  830. */
  831. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  832. /**
  833. * Creates a new Color3 from integer values (< 256)
  834. * @param r defines the red component to read from (value between 0 and 255)
  835. * @param g defines the green component to read from (value between 0 and 255)
  836. * @param b defines the blue component to read from (value between 0 and 255)
  837. * @param a defines the alpha component to read from (value between 0 and 255)
  838. * @returns a new Color3 object
  839. */
  840. static FromInts(r: number, g: number, b: number, a: number): Color4;
  841. /**
  842. * Check the content of a given array and convert it to an array containing RGBA data
  843. * If the original array was already containing count * 4 values then it is returned directly
  844. * @param colors defines the array to check
  845. * @param count defines the number of RGBA data to expect
  846. * @returns an array containing count * 4 values (RGBA)
  847. */
  848. static CheckColors4(colors: number[], count: number): number[];
  849. }
  850. /**
  851. * Class representing a vector containing 2 coordinates
  852. */
  853. export class Vector2 {
  854. /** defines the first coordinate */
  855. x: number;
  856. /** defines the second coordinate */
  857. y: number;
  858. /**
  859. * Creates a new Vector2 from the given x and y coordinates
  860. * @param x defines the first coordinate
  861. * @param y defines the second coordinate
  862. */
  863. constructor(
  864. /** defines the first coordinate */
  865. x?: number,
  866. /** defines the second coordinate */
  867. y?: number);
  868. /**
  869. * Gets a string with the Vector2 coordinates
  870. * @returns a string with the Vector2 coordinates
  871. */
  872. toString(): string;
  873. /**
  874. * Gets class name
  875. * @returns the string "Vector2"
  876. */
  877. getClassName(): string;
  878. /**
  879. * Gets current vector hash code
  880. * @returns the Vector2 hash code as a number
  881. */
  882. getHashCode(): number;
  883. /**
  884. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  885. * @param array defines the source array
  886. * @param index defines the offset in source array
  887. * @returns the current Vector2
  888. */
  889. toArray(array: FloatArray, index?: number): Vector2;
  890. /**
  891. * Copy the current vector to an array
  892. * @returns a new array with 2 elements: the Vector2 coordinates.
  893. */
  894. asArray(): number[];
  895. /**
  896. * Sets the Vector2 coordinates with the given Vector2 coordinates
  897. * @param source defines the source Vector2
  898. * @returns the current updated Vector2
  899. */
  900. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the Vector2 coordinates with the given floats
  903. * @param x defines the first coordinate
  904. * @param y defines the second coordinate
  905. * @returns the current updated Vector2
  906. */
  907. copyFromFloats(x: number, y: number): Vector2;
  908. /**
  909. * Sets the Vector2 coordinates with the given floats
  910. * @param x defines the first coordinate
  911. * @param y defines the second coordinate
  912. * @returns the current updated Vector2
  913. */
  914. set(x: number, y: number): Vector2;
  915. /**
  916. * Add another vector with the current one
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  919. */
  920. add(otherVector: DeepImmutable<Vector2>): Vector2;
  921. /**
  922. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  923. * @param otherVector defines the other vector
  924. * @param result defines the target vector
  925. * @returns the unmodified current Vector2
  926. */
  927. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  928. /**
  929. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  930. * @param otherVector defines the other vector
  931. * @returns the current updated Vector2
  932. */
  933. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  934. /**
  935. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  936. * @param otherVector defines the other vector
  937. * @returns a new Vector2
  938. */
  939. addVector3(otherVector: Vector3): Vector2;
  940. /**
  941. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  942. * @param otherVector defines the other vector
  943. * @returns a new Vector2
  944. */
  945. subtract(otherVector: Vector2): Vector2;
  946. /**
  947. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  948. * @param otherVector defines the other vector
  949. * @param result defines the target vector
  950. * @returns the unmodified current Vector2
  951. */
  952. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  953. /**
  954. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @returns the current updated Vector2
  957. */
  958. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  959. /**
  960. * Multiplies in place the current Vector2 coordinates by the given ones
  961. * @param otherVector defines the other vector
  962. * @returns the current updated Vector2
  963. */
  964. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  971. /**
  972. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  980. * @param x defines the first coordinate
  981. * @param y defines the second coordinate
  982. * @returns a new Vector2
  983. */
  984. multiplyByFloats(x: number, y: number): Vector2;
  985. /**
  986. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  987. * @param otherVector defines the other vector
  988. * @returns a new Vector2
  989. */
  990. divide(otherVector: Vector2): Vector2;
  991. /**
  992. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  993. * @param otherVector defines the other vector
  994. * @param result defines the target vector
  995. * @returns the unmodified current Vector2
  996. */
  997. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  998. /**
  999. * Divides the current Vector2 coordinates by the given ones
  1000. * @param otherVector defines the other vector
  1001. * @returns the current updated Vector2
  1002. */
  1003. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1004. /**
  1005. * Gets a new Vector2 with current Vector2 negated coordinates
  1006. * @returns a new Vector2
  1007. */
  1008. negate(): Vector2;
  1009. /**
  1010. * Multiply the Vector2 coordinates by scale
  1011. * @param scale defines the scaling factor
  1012. * @returns the current updated Vector2
  1013. */
  1014. scaleInPlace(scale: number): Vector2;
  1015. /**
  1016. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1017. * @param scale defines the scaling factor
  1018. * @returns a new Vector2
  1019. */
  1020. scale(scale: number): Vector2;
  1021. /**
  1022. * Scale the current Vector2 values by a factor to a given Vector2
  1023. * @param scale defines the scale factor
  1024. * @param result defines the Vector2 object where to store the result
  1025. * @returns the unmodified current Vector2
  1026. */
  1027. scaleToRef(scale: number, result: Vector2): Vector2;
  1028. /**
  1029. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1030. * @param scale defines the scale factor
  1031. * @param result defines the Vector2 object where to store the result
  1032. * @returns the unmodified current Vector2
  1033. */
  1034. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1035. /**
  1036. * Gets a boolean if two vectors are equals
  1037. * @param otherVector defines the other vector
  1038. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1039. */
  1040. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1041. /**
  1042. * Gets a boolean if two vectors are equals (using an epsilon value)
  1043. * @param otherVector defines the other vector
  1044. * @param epsilon defines the minimal distance to consider equality
  1045. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1046. */
  1047. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1048. /**
  1049. * Gets a new Vector2 from current Vector2 floored values
  1050. * @returns a new Vector2
  1051. */
  1052. floor(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 from current Vector2 floored values
  1055. * @returns a new Vector2
  1056. */
  1057. fract(): Vector2;
  1058. /**
  1059. * Gets the length of the vector
  1060. * @returns the vector length (float)
  1061. */
  1062. length(): number;
  1063. /**
  1064. * Gets the vector squared length
  1065. * @returns the vector squared length (float)
  1066. */
  1067. lengthSquared(): number;
  1068. /**
  1069. * Normalize the vector
  1070. * @returns the current updated Vector2
  1071. */
  1072. normalize(): Vector2;
  1073. /**
  1074. * Gets a new Vector2 copied from the Vector2
  1075. * @returns a new Vector2
  1076. */
  1077. clone(): Vector2;
  1078. /**
  1079. * Gets a new Vector2(0, 0)
  1080. * @returns a new Vector2
  1081. */
  1082. static Zero(): Vector2;
  1083. /**
  1084. * Gets a new Vector2(1, 1)
  1085. * @returns a new Vector2
  1086. */
  1087. static One(): Vector2;
  1088. /**
  1089. * Gets a new Vector2 set from the given index element of the given array
  1090. * @param array defines the data source
  1091. * @param offset defines the offset in the data source
  1092. * @returns a new Vector2
  1093. */
  1094. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1095. /**
  1096. * Sets "result" from the given index element of the given array
  1097. * @param array defines the data source
  1098. * @param offset defines the offset in the data source
  1099. * @param result defines the target vector
  1100. */
  1101. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1102. /**
  1103. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1104. * @param value1 defines 1st point of control
  1105. * @param value2 defines 2nd point of control
  1106. * @param value3 defines 3rd point of control
  1107. * @param value4 defines 4th point of control
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * 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".
  1114. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1115. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1116. * @param value defines the value to clamp
  1117. * @param min defines the lower limit
  1118. * @param max defines the upper limit
  1119. * @returns a new Vector2
  1120. */
  1121. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1122. /**
  1123. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1124. * @param value1 defines the 1st control point
  1125. * @param tangent1 defines the outgoing tangent
  1126. * @param value2 defines the 2nd control point
  1127. * @param tangent2 defines the incoming tangent
  1128. * @param amount defines the interpolation factor
  1129. * @returns a new Vector2
  1130. */
  1131. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1132. /**
  1133. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1134. * @param start defines the start vector
  1135. * @param end defines the end vector
  1136. * @param amount defines the interpolation factor
  1137. * @returns a new Vector2
  1138. */
  1139. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1140. /**
  1141. * Gets the dot product of the vector "left" and the vector "right"
  1142. * @param left defines first vector
  1143. * @param right defines second vector
  1144. * @returns the dot product (float)
  1145. */
  1146. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1147. /**
  1148. * Returns a new Vector2 equal to the normalized given vector
  1149. * @param vector defines the vector to normalize
  1150. * @returns a new Vector2
  1151. */
  1152. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1153. /**
  1154. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1155. * @param left defines 1st vector
  1156. * @param right defines 2nd vector
  1157. * @returns a new Vector2
  1158. */
  1159. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1160. /**
  1161. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1162. * @param left defines 1st vector
  1163. * @param right defines 2nd vector
  1164. * @returns a new Vector2
  1165. */
  1166. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1167. /**
  1168. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1169. * @param vector defines the vector to transform
  1170. * @param transformation defines the matrix to apply
  1171. * @returns a new Vector2
  1172. */
  1173. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1174. /**
  1175. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1176. * @param vector defines the vector to transform
  1177. * @param transformation defines the matrix to apply
  1178. * @param result defines the target vector
  1179. */
  1180. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1181. /**
  1182. * Determines if a given vector is included in a triangle
  1183. * @param p defines the vector to test
  1184. * @param p0 defines 1st triangle point
  1185. * @param p1 defines 2nd triangle point
  1186. * @param p2 defines 3rd triangle point
  1187. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1188. */
  1189. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1190. /**
  1191. * Gets the distance between the vectors "value1" and "value2"
  1192. * @param value1 defines first vector
  1193. * @param value2 defines second vector
  1194. * @returns the distance between vectors
  1195. */
  1196. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1197. /**
  1198. * Returns the squared distance between the vectors "value1" and "value2"
  1199. * @param value1 defines first vector
  1200. * @param value2 defines second vector
  1201. * @returns the squared distance between vectors
  1202. */
  1203. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1204. /**
  1205. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1206. * @param value1 defines first vector
  1207. * @param value2 defines second vector
  1208. * @returns a new Vector2
  1209. */
  1210. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1211. /**
  1212. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1213. * @param p defines the middle point
  1214. * @param segA defines one point of the segment
  1215. * @param segB defines the other point of the segment
  1216. * @returns the shortest distance
  1217. */
  1218. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1219. }
  1220. /**
  1221. * Classed used to store (x,y,z) vector representation
  1222. * A Vector3 is the main object used in 3D geometry
  1223. * It can represent etiher the coordinates of a point the space, either a direction
  1224. * Reminder: js uses a left handed forward facing system
  1225. */
  1226. export class Vector3 {
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x: number;
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y: number;
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z: number;
  1239. private static _UpReadOnly;
  1240. private static _ZeroReadOnly;
  1241. /**
  1242. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1243. * @param x defines the first coordinates (on X axis)
  1244. * @param y defines the second coordinates (on Y axis)
  1245. * @param z defines the third coordinates (on Z axis)
  1246. */
  1247. constructor(
  1248. /**
  1249. * Defines the first coordinates (on X axis)
  1250. */
  1251. x?: number,
  1252. /**
  1253. * Defines the second coordinates (on Y axis)
  1254. */
  1255. y?: number,
  1256. /**
  1257. * Defines the third coordinates (on Z axis)
  1258. */
  1259. z?: number);
  1260. /**
  1261. * Creates a string representation of the Vector3
  1262. * @returns a string with the Vector3 coordinates.
  1263. */
  1264. toString(): string;
  1265. /**
  1266. * Gets the class name
  1267. * @returns the string "Vector3"
  1268. */
  1269. getClassName(): string;
  1270. /**
  1271. * Creates the Vector3 hash code
  1272. * @returns a number which tends to be unique between Vector3 instances
  1273. */
  1274. getHashCode(): number;
  1275. /**
  1276. * Creates an array containing three elements : the coordinates of the Vector3
  1277. * @returns a new array of numbers
  1278. */
  1279. asArray(): number[];
  1280. /**
  1281. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1282. * @param array defines the destination array
  1283. * @param index defines the offset in the destination array
  1284. * @returns the current Vector3
  1285. */
  1286. toArray(array: FloatArray, index?: number): Vector3;
  1287. /**
  1288. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1289. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1290. */
  1291. toQuaternion(): Quaternion;
  1292. /**
  1293. * Adds the given vector to the current Vector3
  1294. * @param otherVector defines the second operand
  1295. * @returns the current updated Vector3
  1296. */
  1297. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1298. /**
  1299. * Adds the given coordinates to the current Vector3
  1300. * @param x defines the x coordinate of the operand
  1301. * @param y defines the y coordinate of the operand
  1302. * @param z defines the z coordinate of the operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1306. /**
  1307. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1314. * @param otherVector defines the second operand
  1315. * @param result defines the Vector3 object where to store the result
  1316. * @returns the current Vector3
  1317. */
  1318. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Subtract the given vector from the current Vector3
  1321. * @param otherVector defines the second operand
  1322. * @returns the current updated Vector3
  1323. */
  1324. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1325. /**
  1326. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1327. * @param otherVector defines the second operand
  1328. * @returns the resulting Vector3
  1329. */
  1330. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1331. /**
  1332. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1333. * @param otherVector defines the second operand
  1334. * @param result defines the Vector3 object where to store the result
  1335. * @returns the current Vector3
  1336. */
  1337. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1338. /**
  1339. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1340. * @param x defines the x coordinate of the operand
  1341. * @param y defines the y coordinate of the operand
  1342. * @param z defines the z coordinate of the operand
  1343. * @returns the resulting Vector3
  1344. */
  1345. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1346. /**
  1347. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1348. * @param x defines the x coordinate of the operand
  1349. * @param y defines the y coordinate of the operand
  1350. * @param z defines the z coordinate of the operand
  1351. * @param result defines the Vector3 object where to store the result
  1352. * @returns the current Vector3
  1353. */
  1354. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1355. /**
  1356. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1357. * @returns a new Vector3
  1358. */
  1359. negate(): Vector3;
  1360. /**
  1361. * Multiplies the Vector3 coordinates by the float "scale"
  1362. * @param scale defines the multiplier factor
  1363. * @returns the current updated Vector3
  1364. */
  1365. scaleInPlace(scale: number): Vector3;
  1366. /**
  1367. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1368. * @param scale defines the multiplier factor
  1369. * @returns a new Vector3
  1370. */
  1371. scale(scale: number): Vector3;
  1372. /**
  1373. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1374. * @param scale defines the multiplier factor
  1375. * @param result defines the Vector3 object where to store the result
  1376. * @returns the current Vector3
  1377. */
  1378. scaleToRef(scale: number, result: Vector3): Vector3;
  1379. /**
  1380. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1381. * @param scale defines the scale factor
  1382. * @param result defines the Vector3 object where to store the result
  1383. * @returns the unmodified current Vector3
  1384. */
  1385. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1386. /**
  1387. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1388. * @param otherVector defines the second operand
  1389. * @returns true if both vectors are equals
  1390. */
  1391. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1392. /**
  1393. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1394. * @param otherVector defines the second operand
  1395. * @param epsilon defines the minimal distance to define values as equals
  1396. * @returns true if both vectors are distant less than epsilon
  1397. */
  1398. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1399. /**
  1400. * Returns true if the current Vector3 coordinates equals the given floats
  1401. * @param x defines the x coordinate of the operand
  1402. * @param y defines the y coordinate of the operand
  1403. * @param z defines the z coordinate of the operand
  1404. * @returns true if both vectors are equals
  1405. */
  1406. equalsToFloats(x: number, y: number, z: number): boolean;
  1407. /**
  1408. * Multiplies the current Vector3 coordinates by the given ones
  1409. * @param otherVector defines the second operand
  1410. * @returns the current updated Vector3
  1411. */
  1412. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1413. /**
  1414. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1428. * @param x defines the x coordinate of the operand
  1429. * @param y defines the y coordinate of the operand
  1430. * @param z defines the z coordinate of the operand
  1431. * @returns the new Vector3
  1432. */
  1433. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1434. /**
  1435. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1436. * @param otherVector defines the second operand
  1437. * @returns the new Vector3
  1438. */
  1439. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1442. * @param otherVector defines the second operand
  1443. * @param result defines the Vector3 object where to store the result
  1444. * @returns the current Vector3
  1445. */
  1446. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1447. /**
  1448. * Divides the current Vector3 coordinates by the given ones.
  1449. * @param otherVector defines the second operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. divideInPlace(otherVector: Vector3): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1455. * @param other defines the second operand
  1456. * @returns the current updated Vector3
  1457. */
  1458. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1459. /**
  1460. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1461. * @param other defines the second operand
  1462. * @returns the current updated Vector3
  1463. */
  1464. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1465. /**
  1466. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1467. * @param x defines the x coordinate of the operand
  1468. * @param y defines the y coordinate of the operand
  1469. * @param z defines the z coordinate of the operand
  1470. * @returns the current updated Vector3
  1471. */
  1472. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1473. /**
  1474. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1475. * @param x defines the x coordinate of the operand
  1476. * @param y defines the y coordinate of the operand
  1477. * @param z defines the z coordinate of the operand
  1478. * @returns the current updated Vector3
  1479. */
  1480. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1481. /**
  1482. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1483. * Check if is non uniform within a certain amount of decimal places to account for this
  1484. * @param epsilon the amount the values can differ
  1485. * @returns if the the vector is non uniform to a certain number of decimal places
  1486. */
  1487. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1488. /**
  1489. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1490. */
  1491. readonly isNonUniform: boolean;
  1492. /**
  1493. * Gets a new Vector3 from current Vector3 floored values
  1494. * @returns a new Vector3
  1495. */
  1496. floor(): Vector3;
  1497. /**
  1498. * Gets a new Vector3 from current Vector3 floored values
  1499. * @returns a new Vector3
  1500. */
  1501. fract(): Vector3;
  1502. /**
  1503. * Gets the length of the Vector3
  1504. * @returns the length of the Vector3
  1505. */
  1506. length(): number;
  1507. /**
  1508. * Gets the squared length of the Vector3
  1509. * @returns squared length of the Vector3
  1510. */
  1511. lengthSquared(): number;
  1512. /**
  1513. * Normalize the current Vector3.
  1514. * Please note that this is an in place operation.
  1515. * @returns the current updated Vector3
  1516. */
  1517. normalize(): Vector3;
  1518. /**
  1519. * Reorders the x y z properties of the vector in place
  1520. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1521. * @returns the current updated vector
  1522. */
  1523. reorderInPlace(order: string): this;
  1524. /**
  1525. * Rotates the vector around 0,0,0 by a quaternion
  1526. * @param quaternion the rotation quaternion
  1527. * @param result vector to store the result
  1528. * @returns the resulting vector
  1529. */
  1530. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1531. /**
  1532. * Rotates a vector around a given point
  1533. * @param quaternion the rotation quaternion
  1534. * @param point the point to rotate around
  1535. * @param result vector to store the result
  1536. * @returns the resulting vector
  1537. */
  1538. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 with the given input length.
  1541. * Please note that this is an in place operation.
  1542. * @param len the length of the vector
  1543. * @returns the current updated Vector3
  1544. */
  1545. normalizeFromLength(len: number): Vector3;
  1546. /**
  1547. * Normalize the current Vector3 to a new vector
  1548. * @returns the new Vector3
  1549. */
  1550. normalizeToNew(): Vector3;
  1551. /**
  1552. * Normalize the current Vector3 to the reference
  1553. * @param reference define the Vector3 to update
  1554. * @returns the updated Vector3
  1555. */
  1556. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1557. /**
  1558. * Creates a new Vector3 copied from the current Vector3
  1559. * @returns the new Vector3
  1560. */
  1561. clone(): Vector3;
  1562. /**
  1563. * Copies the given vector coordinates to the current Vector3 ones
  1564. * @param source defines the source Vector3
  1565. * @returns the current updated Vector3
  1566. */
  1567. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1568. /**
  1569. * Copies the given floats to the current Vector3 coordinates
  1570. * @param x defines the x coordinate of the operand
  1571. * @param y defines the y coordinate of the operand
  1572. * @param z defines the z coordinate of the operand
  1573. * @returns the current updated Vector3
  1574. */
  1575. copyFromFloats(x: number, y: number, z: number): Vector3;
  1576. /**
  1577. * Copies the given floats to the current Vector3 coordinates
  1578. * @param x defines the x coordinate of the operand
  1579. * @param y defines the y coordinate of the operand
  1580. * @param z defines the z coordinate of the operand
  1581. * @returns the current updated Vector3
  1582. */
  1583. set(x: number, y: number, z: number): Vector3;
  1584. /**
  1585. * Copies the given float to the current Vector3 coordinates
  1586. * @param v defines the x, y and z coordinates of the operand
  1587. * @returns the current updated Vector3
  1588. */
  1589. setAll(v: number): Vector3;
  1590. /**
  1591. * Get the clip factor between two vectors
  1592. * @param vector0 defines the first operand
  1593. * @param vector1 defines the second operand
  1594. * @param axis defines the axis to use
  1595. * @param size defines the size along the axis
  1596. * @returns the clip factor
  1597. */
  1598. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1599. /**
  1600. * Get angle between two vectors
  1601. * @param vector0 angle between vector0 and vector1
  1602. * @param vector1 angle between vector0 and vector1
  1603. * @param normal direction of the normal
  1604. * @return the angle between vector0 and vector1
  1605. */
  1606. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given array
  1609. * @param array defines the source array
  1610. * @param offset defines the offset in the source array
  1611. * @returns the new Vector3
  1612. */
  1613. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1614. /**
  1615. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1616. * This function is deprecated. Use FromArray instead
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @returns the new Vector3
  1620. */
  1621. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1624. * @param array defines the source array
  1625. * @param offset defines the offset in the source array
  1626. * @param result defines the Vector3 where to store the result
  1627. */
  1628. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1629. /**
  1630. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1631. * This function is deprecated. Use FromArrayToRef instead.
  1632. * @param array defines the source array
  1633. * @param offset defines the offset in the source array
  1634. * @param result defines the Vector3 where to store the result
  1635. */
  1636. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1637. /**
  1638. * Sets the given vector "result" with the given floats.
  1639. * @param x defines the x coordinate of the source
  1640. * @param y defines the y coordinate of the source
  1641. * @param z defines the z coordinate of the source
  1642. * @param result defines the Vector3 where to store the result
  1643. */
  1644. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1647. * @returns a new empty Vector3
  1648. */
  1649. static Zero(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1652. * @returns a new unit Vector3
  1653. */
  1654. static One(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1657. * @returns a new up Vector3
  1658. */
  1659. static Up(): Vector3;
  1660. /**
  1661. * Gets a up Vector3 that must not be updated
  1662. */
  1663. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1664. /**
  1665. * Gets a zero Vector3 that must not be updated
  1666. */
  1667. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1668. /**
  1669. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1670. * @returns a new down Vector3
  1671. */
  1672. static Down(): Vector3;
  1673. /**
  1674. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1675. * @returns a new forward Vector3
  1676. */
  1677. static Forward(): Vector3;
  1678. /**
  1679. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1680. * @returns a new forward Vector3
  1681. */
  1682. static Backward(): Vector3;
  1683. /**
  1684. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1685. * @returns a new right Vector3
  1686. */
  1687. static Right(): Vector3;
  1688. /**
  1689. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1690. * @returns a new left Vector3
  1691. */
  1692. static Left(): Vector3;
  1693. /**
  1694. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1695. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1696. * @param vector defines the Vector3 to transform
  1697. * @param transformation defines the transformation matrix
  1698. * @returns the transformed Vector3
  1699. */
  1700. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1701. /**
  1702. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1703. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1704. * @param vector defines the Vector3 to transform
  1705. * @param transformation defines the transformation matrix
  1706. * @param result defines the Vector3 where to store the result
  1707. */
  1708. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1709. /**
  1710. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1711. * This method computes tranformed coordinates only, not transformed direction vectors
  1712. * @param x define the x coordinate of the source vector
  1713. * @param y define the y coordinate of the source vector
  1714. * @param z define the z coordinate of the source vector
  1715. * @param transformation defines the transformation matrix
  1716. * @param result defines the Vector3 where to store the result
  1717. */
  1718. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1719. /**
  1720. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1721. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1722. * @param vector defines the Vector3 to transform
  1723. * @param transformation defines the transformation matrix
  1724. * @returns the new Vector3
  1725. */
  1726. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1727. /**
  1728. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1730. * @param vector defines the Vector3 to transform
  1731. * @param transformation defines the transformation matrix
  1732. * @param result defines the Vector3 where to store the result
  1733. */
  1734. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1735. /**
  1736. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1737. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1738. * @param x define the x coordinate of the source vector
  1739. * @param y define the y coordinate of the source vector
  1740. * @param z define the z coordinate of the source vector
  1741. * @param transformation defines the transformation matrix
  1742. * @param result defines the Vector3 where to store the result
  1743. */
  1744. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1745. /**
  1746. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1747. * @param value1 defines the first control point
  1748. * @param value2 defines the second control point
  1749. * @param value3 defines the third control point
  1750. * @param value4 defines the fourth control point
  1751. * @param amount defines the amount on the spline to use
  1752. * @returns the new Vector3
  1753. */
  1754. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1755. /**
  1756. * 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"
  1757. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1758. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1759. * @param value defines the current value
  1760. * @param min defines the lower range value
  1761. * @param max defines the upper range value
  1762. * @returns the new Vector3
  1763. */
  1764. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1765. /**
  1766. * 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"
  1767. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1768. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1769. * @param value defines the current value
  1770. * @param min defines the lower range value
  1771. * @param max defines the upper range value
  1772. * @param result defines the Vector3 where to store the result
  1773. */
  1774. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1775. /**
  1776. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1777. * @param value1 defines the first control point
  1778. * @param tangent1 defines the first tangent vector
  1779. * @param value2 defines the second control point
  1780. * @param tangent2 defines the second tangent vector
  1781. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1782. * @returns the new Vector3
  1783. */
  1784. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1785. /**
  1786. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1787. * @param start defines the start value
  1788. * @param end defines the end value
  1789. * @param amount max defines amount between both (between 0 and 1)
  1790. * @returns the new Vector3
  1791. */
  1792. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1795. * @param start defines the start value
  1796. * @param end defines the end value
  1797. * @param amount max defines amount between both (between 0 and 1)
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1801. /**
  1802. * Returns the dot product (float) between the vectors "left" and "right"
  1803. * @param left defines the left operand
  1804. * @param right defines the right operand
  1805. * @returns the dot product
  1806. */
  1807. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1808. /**
  1809. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1810. * The cross product is then orthogonal to both "left" and "right"
  1811. * @param left defines the left operand
  1812. * @param right defines the right operand
  1813. * @returns the cross product
  1814. */
  1815. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1816. /**
  1817. * Sets the given vector "result" with the cross product of "left" and "right"
  1818. * The cross product is then orthogonal to both "left" and "right"
  1819. * @param left defines the left operand
  1820. * @param right defines the right operand
  1821. * @param result defines the Vector3 where to store the result
  1822. */
  1823. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1824. /**
  1825. * Returns a new Vector3 as the normalization of the given vector
  1826. * @param vector defines the Vector3 to normalize
  1827. * @returns the new Vector3
  1828. */
  1829. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1830. /**
  1831. * Sets the given vector "result" with the normalization of the given first vector
  1832. * @param vector defines the Vector3 to normalize
  1833. * @param result defines the Vector3 where to store the result
  1834. */
  1835. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1836. /**
  1837. * Project a Vector3 onto screen space
  1838. * @param vector defines the Vector3 to project
  1839. * @param world defines the world matrix to use
  1840. * @param transform defines the transform (view x projection) matrix to use
  1841. * @param viewport defines the screen viewport to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1845. /** @hidden */
  1846. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1847. /**
  1848. * Unproject from screen space to object space
  1849. * @param source defines the screen space Vector3 to use
  1850. * @param viewportWidth defines the current width of the viewport
  1851. * @param viewportHeight defines the current height of the viewport
  1852. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1853. * @param transform defines the transform (view x projection) matrix to use
  1854. * @returns the new Vector3
  1855. */
  1856. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1857. /**
  1858. * Unproject from screen space to object space
  1859. * @param source defines the screen space Vector3 to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @returns the new Vector3
  1866. */
  1867. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1868. /**
  1869. * Unproject from screen space to object space
  1870. * @param source defines the screen space Vector3 to use
  1871. * @param viewportWidth defines the current width of the viewport
  1872. * @param viewportHeight defines the current height of the viewport
  1873. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1874. * @param view defines the view matrix to use
  1875. * @param projection defines the projection matrix to use
  1876. * @param result defines the Vector3 where to store the result
  1877. */
  1878. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1879. /**
  1880. * Unproject from screen space to object space
  1881. * @param sourceX defines the screen space x coordinate to use
  1882. * @param sourceY defines the screen space y coordinate to use
  1883. * @param sourceZ defines the screen space z coordinate to use
  1884. * @param viewportWidth defines the current width of the viewport
  1885. * @param viewportHeight defines the current height of the viewport
  1886. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1887. * @param view defines the view matrix to use
  1888. * @param projection defines the projection matrix to use
  1889. * @param result defines the Vector3 where to store the result
  1890. */
  1891. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1892. /**
  1893. * Gets the minimal coordinate values between two Vector3
  1894. * @param left defines the first operand
  1895. * @param right defines the second operand
  1896. * @returns the new Vector3
  1897. */
  1898. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1899. /**
  1900. * Gets the maximal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Returns the distance between the vectors "value1" and "value2"
  1908. * @param value1 defines the first operand
  1909. * @param value2 defines the second operand
  1910. * @returns the distance
  1911. */
  1912. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1913. /**
  1914. * Returns the squared distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the squared distance
  1918. */
  1919. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns a new Vector3 located at the center between "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the new Vector3
  1925. */
  1926. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1927. /**
  1928. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1929. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1930. * to something in order to rotate it from its local system to the given target system
  1931. * Note: axis1, axis2 and axis3 are normalized during this operation
  1932. * @param axis1 defines the first axis
  1933. * @param axis2 defines the second axis
  1934. * @param axis3 defines the third axis
  1935. * @returns a new Vector3
  1936. */
  1937. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1938. /**
  1939. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1940. * @param axis1 defines the first axis
  1941. * @param axis2 defines the second axis
  1942. * @param axis3 defines the third axis
  1943. * @param ref defines the Vector3 where to store the result
  1944. */
  1945. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1946. }
  1947. /**
  1948. * Vector4 class created for EulerAngle class conversion to Quaternion
  1949. */
  1950. export class Vector4 {
  1951. /** x value of the vector */
  1952. x: number;
  1953. /** y value of the vector */
  1954. y: number;
  1955. /** z value of the vector */
  1956. z: number;
  1957. /** w value of the vector */
  1958. w: number;
  1959. /**
  1960. * Creates a Vector4 object from the given floats.
  1961. * @param x x value of the vector
  1962. * @param y y value of the vector
  1963. * @param z z value of the vector
  1964. * @param w w value of the vector
  1965. */
  1966. constructor(
  1967. /** x value of the vector */
  1968. x: number,
  1969. /** y value of the vector */
  1970. y: number,
  1971. /** z value of the vector */
  1972. z: number,
  1973. /** w value of the vector */
  1974. w: number);
  1975. /**
  1976. * Returns the string with the Vector4 coordinates.
  1977. * @returns a string containing all the vector values
  1978. */
  1979. toString(): string;
  1980. /**
  1981. * Returns the string "Vector4".
  1982. * @returns "Vector4"
  1983. */
  1984. getClassName(): string;
  1985. /**
  1986. * Returns the Vector4 hash code.
  1987. * @returns a unique hash code
  1988. */
  1989. getHashCode(): number;
  1990. /**
  1991. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1992. * @returns the resulting array
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Populates the given array from the given index with the Vector4 coordinates.
  1997. * @param array array to populate
  1998. * @param index index of the array to start at (default: 0)
  1999. * @returns the Vector4.
  2000. */
  2001. toArray(array: FloatArray, index?: number): Vector4;
  2002. /**
  2003. * Adds the given vector to the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the updated Vector4.
  2006. */
  2007. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2010. * @param otherVector the vector to add
  2011. * @returns the resulting vector
  2012. */
  2013. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2014. /**
  2015. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2016. * @param otherVector the vector to add
  2017. * @param result the vector to store the result
  2018. * @returns the current Vector4.
  2019. */
  2020. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2021. /**
  2022. * Subtract in place the given vector from the current Vector4.
  2023. * @param otherVector the vector to subtract
  2024. * @returns the updated Vector4.
  2025. */
  2026. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2027. /**
  2028. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2029. * @param otherVector the vector to add
  2030. * @returns the new vector with the result
  2031. */
  2032. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2033. /**
  2034. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2035. * @param otherVector the vector to subtract
  2036. * @param result the vector to store the result
  2037. * @returns the current Vector4.
  2038. */
  2039. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. */
  2043. /**
  2044. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2045. * @param x value to subtract
  2046. * @param y value to subtract
  2047. * @param z value to subtract
  2048. * @param w value to subtract
  2049. * @returns new vector containing the result
  2050. */
  2051. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2052. /**
  2053. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2054. * @param x value to subtract
  2055. * @param y value to subtract
  2056. * @param z value to subtract
  2057. * @param w value to subtract
  2058. * @param result the vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2062. /**
  2063. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2064. * @returns a new vector with the negated values
  2065. */
  2066. negate(): Vector4;
  2067. /**
  2068. * Multiplies the current Vector4 coordinates by scale (float).
  2069. * @param scale the number to scale with
  2070. * @returns the updated Vector4.
  2071. */
  2072. scaleInPlace(scale: number): Vector4;
  2073. /**
  2074. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2075. * @param scale the number to scale with
  2076. * @returns a new vector with the result
  2077. */
  2078. scale(scale: number): Vector4;
  2079. /**
  2080. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2081. * @param scale the number to scale with
  2082. * @param result a vector to store the result in
  2083. * @returns the current Vector4.
  2084. */
  2085. scaleToRef(scale: number, result: Vector4): Vector4;
  2086. /**
  2087. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2088. * @param scale defines the scale factor
  2089. * @param result defines the Vector4 object where to store the result
  2090. * @returns the unmodified current Vector4
  2091. */
  2092. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2095. * @param otherVector the vector to compare against
  2096. * @returns true if they are equal
  2097. */
  2098. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2099. /**
  2100. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2101. * @param otherVector vector to compare against
  2102. * @param epsilon (Default: very small number)
  2103. * @returns true if they are equal
  2104. */
  2105. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2106. /**
  2107. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2108. * @param x x value to compare against
  2109. * @param y y value to compare against
  2110. * @param z z value to compare against
  2111. * @param w w value to compare against
  2112. * @returns true if equal
  2113. */
  2114. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2115. /**
  2116. * Multiplies in place the current Vector4 by the given one.
  2117. * @param otherVector vector to multiple with
  2118. * @returns the updated Vector4.
  2119. */
  2120. multiplyInPlace(otherVector: Vector4): Vector4;
  2121. /**
  2122. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2123. * @param otherVector vector to multiple with
  2124. * @returns resulting new vector
  2125. */
  2126. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2127. /**
  2128. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2129. * @param otherVector vector to multiple with
  2130. * @param result vector to store the result
  2131. * @returns the current Vector4.
  2132. */
  2133. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2134. /**
  2135. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2136. * @param x x value multiply with
  2137. * @param y y value multiply with
  2138. * @param z z value multiply with
  2139. * @param w w value multiply with
  2140. * @returns resulting new vector
  2141. */
  2142. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2143. /**
  2144. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2145. * @param otherVector vector to devide with
  2146. * @returns resulting new vector
  2147. */
  2148. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2151. * @param otherVector vector to devide with
  2152. * @param result vector to store the result
  2153. * @returns the current Vector4.
  2154. */
  2155. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2156. /**
  2157. * Divides the current Vector3 coordinates by the given ones.
  2158. * @param otherVector vector to devide with
  2159. * @returns the updated Vector3.
  2160. */
  2161. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2162. /**
  2163. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2164. * @param other defines the second operand
  2165. * @returns the current updated Vector4
  2166. */
  2167. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2168. /**
  2169. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2170. * @param other defines the second operand
  2171. * @returns the current updated Vector4
  2172. */
  2173. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2174. /**
  2175. * Gets a new Vector4 from current Vector4 floored values
  2176. * @returns a new Vector4
  2177. */
  2178. floor(): Vector4;
  2179. /**
  2180. * Gets a new Vector4 from current Vector3 floored values
  2181. * @returns a new Vector4
  2182. */
  2183. fract(): Vector4;
  2184. /**
  2185. * Returns the Vector4 length (float).
  2186. * @returns the length
  2187. */
  2188. length(): number;
  2189. /**
  2190. * Returns the Vector4 squared length (float).
  2191. * @returns the length squared
  2192. */
  2193. lengthSquared(): number;
  2194. /**
  2195. * Normalizes in place the Vector4.
  2196. * @returns the updated Vector4.
  2197. */
  2198. normalize(): Vector4;
  2199. /**
  2200. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2201. * @returns this converted to a new vector3
  2202. */
  2203. toVector3(): Vector3;
  2204. /**
  2205. * Returns a new Vector4 copied from the current one.
  2206. * @returns the new cloned vector
  2207. */
  2208. clone(): Vector4;
  2209. /**
  2210. * Updates the current Vector4 with the given one coordinates.
  2211. * @param source the source vector to copy from
  2212. * @returns the updated Vector4.
  2213. */
  2214. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2215. /**
  2216. * Updates the current Vector4 coordinates with the given floats.
  2217. * @param x float to copy from
  2218. * @param y float to copy from
  2219. * @param z float to copy from
  2220. * @param w float to copy from
  2221. * @returns the updated Vector4.
  2222. */
  2223. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2224. /**
  2225. * Updates the current Vector4 coordinates with the given floats.
  2226. * @param x float to set from
  2227. * @param y float to set from
  2228. * @param z float to set from
  2229. * @param w float to set from
  2230. * @returns the updated Vector4.
  2231. */
  2232. set(x: number, y: number, z: number, w: number): Vector4;
  2233. /**
  2234. * Copies the given float to the current Vector3 coordinates
  2235. * @param v defines the x, y, z and w coordinates of the operand
  2236. * @returns the current updated Vector3
  2237. */
  2238. setAll(v: number): Vector4;
  2239. /**
  2240. * Returns a new Vector4 set from the starting index of the given array.
  2241. * @param array the array to pull values from
  2242. * @param offset the offset into the array to start at
  2243. * @returns the new vector
  2244. */
  2245. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2246. /**
  2247. * Updates the given vector "result" from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @param result the vector to store the result in
  2251. */
  2252. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given Float32Array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" coordinates from the given floats.
  2262. * @param x float to set from
  2263. * @param y float to set from
  2264. * @param z float to set from
  2265. * @param w float to set from
  2266. * @param result the vector to the floats in
  2267. */
  2268. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2269. /**
  2270. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2271. * @returns the new vector
  2272. */
  2273. static Zero(): Vector4;
  2274. /**
  2275. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2276. * @returns the new vector
  2277. */
  2278. static One(): Vector4;
  2279. /**
  2280. * Returns a new normalized Vector4 from the given one.
  2281. * @param vector the vector to normalize
  2282. * @returns the vector
  2283. */
  2284. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2285. /**
  2286. * Updates the given vector "result" from the normalization of the given one.
  2287. * @param vector the vector to normalize
  2288. * @param result the vector to store the result in
  2289. */
  2290. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2291. /**
  2292. * Returns a vector with the minimum values from the left and right vectors
  2293. * @param left left vector to minimize
  2294. * @param right right vector to minimize
  2295. * @returns a new vector with the minimum of the left and right vector values
  2296. */
  2297. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2298. /**
  2299. * Returns a vector with the maximum values from the left and right vectors
  2300. * @param left left vector to maximize
  2301. * @param right right vector to maximize
  2302. * @returns a new vector with the maximum of the left and right vector values
  2303. */
  2304. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns the distance (float) between the vectors "value1" and "value2".
  2307. * @param value1 value to calulate the distance between
  2308. * @param value2 value to calulate the distance between
  2309. * @return the distance between the two vectors
  2310. */
  2311. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2312. /**
  2313. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors squared
  2317. */
  2318. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the center between
  2322. * @param value2 value to calulate the center between
  2323. * @return the center between the two vectors
  2324. */
  2325. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2326. /**
  2327. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2328. * This methods computes transformed normalized direction vectors only.
  2329. * @param vector the vector to transform
  2330. * @param transformation the transformation matrix to apply
  2331. * @returns the new vector
  2332. */
  2333. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2334. /**
  2335. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2336. * This methods computes transformed normalized direction vectors only.
  2337. * @param vector the vector to transform
  2338. * @param transformation the transformation matrix to apply
  2339. * @param result the vector to store the result in
  2340. */
  2341. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2342. /**
  2343. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2344. * This methods computes transformed normalized direction vectors only.
  2345. * @param x value to transform
  2346. * @param y value to transform
  2347. * @param z value to transform
  2348. * @param w value to transform
  2349. * @param transformation the transformation matrix to apply
  2350. * @param result the vector to store the results in
  2351. */
  2352. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2353. /**
  2354. * Creates a new Vector4 from a Vector3
  2355. * @param source defines the source data
  2356. * @param w defines the 4th component (default is 0)
  2357. * @returns a new Vector4
  2358. */
  2359. static FromVector3(source: Vector3, w?: number): Vector4;
  2360. }
  2361. /**
  2362. * Interface for the size containing width and height
  2363. */
  2364. export interface ISize {
  2365. /**
  2366. * Width
  2367. */
  2368. width: number;
  2369. /**
  2370. * Heighht
  2371. */
  2372. height: number;
  2373. }
  2374. /**
  2375. * Size containing widht and height
  2376. */
  2377. export class Size implements ISize {
  2378. /**
  2379. * Width
  2380. */
  2381. width: number;
  2382. /**
  2383. * Height
  2384. */
  2385. height: number;
  2386. /**
  2387. * Creates a Size object from the given width and height (floats).
  2388. * @param width width of the new size
  2389. * @param height height of the new size
  2390. */
  2391. constructor(width: number, height: number);
  2392. /**
  2393. * Returns a string with the Size width and height
  2394. * @returns a string with the Size width and height
  2395. */
  2396. toString(): string;
  2397. /**
  2398. * "Size"
  2399. * @returns the string "Size"
  2400. */
  2401. getClassName(): string;
  2402. /**
  2403. * Returns the Size hash code.
  2404. * @returns a hash code for a unique width and height
  2405. */
  2406. getHashCode(): number;
  2407. /**
  2408. * Updates the current size from the given one.
  2409. * @param src the given size
  2410. */
  2411. copyFrom(src: Size): void;
  2412. /**
  2413. * Updates in place the current Size from the given floats.
  2414. * @param width width of the new size
  2415. * @param height height of the new size
  2416. * @returns the updated Size.
  2417. */
  2418. copyFromFloats(width: number, height: number): Size;
  2419. /**
  2420. * Updates in place the current Size from the given floats.
  2421. * @param width width to set
  2422. * @param height height to set
  2423. * @returns the updated Size.
  2424. */
  2425. set(width: number, height: number): Size;
  2426. /**
  2427. * Multiplies the width and height by numbers
  2428. * @param w factor to multiple the width by
  2429. * @param h factor to multiple the height by
  2430. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2431. */
  2432. multiplyByFloats(w: number, h: number): Size;
  2433. /**
  2434. * Clones the size
  2435. * @returns a new Size copied from the given one.
  2436. */
  2437. clone(): Size;
  2438. /**
  2439. * True if the current Size and the given one width and height are strictly equal.
  2440. * @param other the other size to compare against
  2441. * @returns True if the current Size and the given one width and height are strictly equal.
  2442. */
  2443. equals(other: Size): boolean;
  2444. /**
  2445. * The surface of the Size : width * height (float).
  2446. */
  2447. readonly surface: number;
  2448. /**
  2449. * Create a new size of zero
  2450. * @returns a new Size set to (0.0, 0.0)
  2451. */
  2452. static Zero(): Size;
  2453. /**
  2454. * Sums the width and height of two sizes
  2455. * @param otherSize size to add to this size
  2456. * @returns a new Size set as the addition result of the current Size and the given one.
  2457. */
  2458. add(otherSize: Size): Size;
  2459. /**
  2460. * Subtracts the width and height of two
  2461. * @param otherSize size to subtract to this size
  2462. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2463. */
  2464. subtract(otherSize: Size): Size;
  2465. /**
  2466. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2467. * @param start starting size to lerp between
  2468. * @param end end size to lerp between
  2469. * @param amount amount to lerp between the start and end values
  2470. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2471. */
  2472. static Lerp(start: Size, end: Size, amount: number): Size;
  2473. }
  2474. /**
  2475. * Class used to store quaternion data
  2476. * @see https://en.wikipedia.org/wiki/Quaternion
  2477. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2478. */
  2479. export class Quaternion {
  2480. /** defines the first component (0 by default) */
  2481. x: number;
  2482. /** defines the second component (0 by default) */
  2483. y: number;
  2484. /** defines the third component (0 by default) */
  2485. z: number;
  2486. /** defines the fourth component (1.0 by default) */
  2487. w: number;
  2488. /**
  2489. * Creates a new Quaternion from the given floats
  2490. * @param x defines the first component (0 by default)
  2491. * @param y defines the second component (0 by default)
  2492. * @param z defines the third component (0 by default)
  2493. * @param w defines the fourth component (1.0 by default)
  2494. */
  2495. constructor(
  2496. /** defines the first component (0 by default) */
  2497. x?: number,
  2498. /** defines the second component (0 by default) */
  2499. y?: number,
  2500. /** defines the third component (0 by default) */
  2501. z?: number,
  2502. /** defines the fourth component (1.0 by default) */
  2503. w?: number);
  2504. /**
  2505. * Gets a string representation for the current quaternion
  2506. * @returns a string with the Quaternion coordinates
  2507. */
  2508. toString(): string;
  2509. /**
  2510. * Gets the class name of the quaternion
  2511. * @returns the string "Quaternion"
  2512. */
  2513. getClassName(): string;
  2514. /**
  2515. * Gets a hash code for this quaternion
  2516. * @returns the quaternion hash code
  2517. */
  2518. getHashCode(): number;
  2519. /**
  2520. * Copy the quaternion to an array
  2521. * @returns a new array populated with 4 elements from the quaternion coordinates
  2522. */
  2523. asArray(): number[];
  2524. /**
  2525. * Check if two quaternions are equals
  2526. * @param otherQuaternion defines the second operand
  2527. * @return true if the current quaternion and the given one coordinates are strictly equals
  2528. */
  2529. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2530. /**
  2531. * Clone the current quaternion
  2532. * @returns a new quaternion copied from the current one
  2533. */
  2534. clone(): Quaternion;
  2535. /**
  2536. * Copy a quaternion to the current one
  2537. * @param other defines the other quaternion
  2538. * @returns the updated current quaternion
  2539. */
  2540. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Updates the current quaternion with the given float coordinates
  2543. * @param x defines the x coordinate
  2544. * @param y defines the y coordinate
  2545. * @param z defines the z coordinate
  2546. * @param w defines the w coordinate
  2547. * @returns the updated current quaternion
  2548. */
  2549. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2550. /**
  2551. * Updates the current quaternion from the given float coordinates
  2552. * @param x defines the x coordinate
  2553. * @param y defines the y coordinate
  2554. * @param z defines the z coordinate
  2555. * @param w defines the w coordinate
  2556. * @returns the updated current quaternion
  2557. */
  2558. set(x: number, y: number, z: number, w: number): Quaternion;
  2559. /**
  2560. * Adds two quaternions
  2561. * @param other defines the second operand
  2562. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2563. */
  2564. add(other: DeepImmutable<Quaternion>): Quaternion;
  2565. /**
  2566. * Add a quaternion to the current one
  2567. * @param other defines the quaternion to add
  2568. * @returns the current quaternion
  2569. */
  2570. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2571. /**
  2572. * Subtract two quaternions
  2573. * @param other defines the second operand
  2574. * @returns a new quaternion as the subtraction result of the given one from the current one
  2575. */
  2576. subtract(other: Quaternion): Quaternion;
  2577. /**
  2578. * Multiplies the current quaternion by a scale factor
  2579. * @param value defines the scale factor
  2580. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2581. */
  2582. scale(value: number): Quaternion;
  2583. /**
  2584. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2585. * @param scale defines the scale factor
  2586. * @param result defines the Quaternion object where to store the result
  2587. * @returns the unmodified current quaternion
  2588. */
  2589. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2590. /**
  2591. * Multiplies in place the current quaternion by a scale factor
  2592. * @param value defines the scale factor
  2593. * @returns the current modified quaternion
  2594. */
  2595. scaleInPlace(value: number): Quaternion;
  2596. /**
  2597. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2598. * @param scale defines the scale factor
  2599. * @param result defines the Quaternion object where to store the result
  2600. * @returns the unmodified current quaternion
  2601. */
  2602. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2603. /**
  2604. * Multiplies two quaternions
  2605. * @param q1 defines the second operand
  2606. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2607. */
  2608. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2609. /**
  2610. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2611. * @param q1 defines the second operand
  2612. * @param result defines the target quaternion
  2613. * @returns the current quaternion
  2614. */
  2615. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2616. /**
  2617. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2618. * @param q1 defines the second operand
  2619. * @returns the currentupdated quaternion
  2620. */
  2621. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2622. /**
  2623. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2624. * @param ref defines the target quaternion
  2625. * @returns the current quaternion
  2626. */
  2627. conjugateToRef(ref: Quaternion): Quaternion;
  2628. /**
  2629. * Conjugates in place (1-q) the current quaternion
  2630. * @returns the current updated quaternion
  2631. */
  2632. conjugateInPlace(): Quaternion;
  2633. /**
  2634. * Conjugates in place (1-q) the current quaternion
  2635. * @returns a new quaternion
  2636. */
  2637. conjugate(): Quaternion;
  2638. /**
  2639. * Gets length of current quaternion
  2640. * @returns the quaternion length (float)
  2641. */
  2642. length(): number;
  2643. /**
  2644. * Normalize in place the current quaternion
  2645. * @returns the current updated quaternion
  2646. */
  2647. normalize(): Quaternion;
  2648. /**
  2649. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2650. * @param order is a reserved parameter and is ignore for now
  2651. * @returns a new Vector3 containing the Euler angles
  2652. */
  2653. toEulerAngles(order?: string): Vector3;
  2654. /**
  2655. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2656. * @param result defines the vector which will be filled with the Euler angles
  2657. * @param order is a reserved parameter and is ignore for now
  2658. * @returns the current unchanged quaternion
  2659. */
  2660. toEulerAnglesToRef(result: Vector3): Quaternion;
  2661. /**
  2662. * Updates the given rotation matrix with the current quaternion values
  2663. * @param result defines the target matrix
  2664. * @returns the current unchanged quaternion
  2665. */
  2666. toRotationMatrix(result: Matrix): Quaternion;
  2667. /**
  2668. * Updates the current quaternion from the given rotation matrix values
  2669. * @param matrix defines the source matrix
  2670. * @returns the current updated quaternion
  2671. */
  2672. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2673. /**
  2674. * Creates a new quaternion from a rotation matrix
  2675. * @param matrix defines the source matrix
  2676. * @returns a new quaternion created from the given rotation matrix values
  2677. */
  2678. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2679. /**
  2680. * Updates the given quaternion with the given rotation matrix values
  2681. * @param matrix defines the source matrix
  2682. * @param result defines the target quaternion
  2683. */
  2684. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2685. /**
  2686. * Returns the dot product (float) between the quaternions "left" and "right"
  2687. * @param left defines the left operand
  2688. * @param right defines the right operand
  2689. * @returns the dot product
  2690. */
  2691. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2692. /**
  2693. * Checks if the two quaternions are close to each other
  2694. * @param quat0 defines the first quaternion to check
  2695. * @param quat1 defines the second quaternion to check
  2696. * @returns true if the two quaternions are close to each other
  2697. */
  2698. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2699. /**
  2700. * Creates an empty quaternion
  2701. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2702. */
  2703. static Zero(): Quaternion;
  2704. /**
  2705. * Inverse a given quaternion
  2706. * @param q defines the source quaternion
  2707. * @returns a new quaternion as the inverted current quaternion
  2708. */
  2709. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2710. /**
  2711. * Inverse a given quaternion
  2712. * @param q defines the source quaternion
  2713. * @param result the quaternion the result will be stored in
  2714. * @returns the result quaternion
  2715. */
  2716. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2717. /**
  2718. * Creates an identity quaternion
  2719. * @returns the identity quaternion
  2720. */
  2721. static Identity(): Quaternion;
  2722. /**
  2723. * Gets a boolean indicating if the given quaternion is identity
  2724. * @param quaternion defines the quaternion to check
  2725. * @returns true if the quaternion is identity
  2726. */
  2727. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2728. /**
  2729. * Creates a quaternion from a rotation around an axis
  2730. * @param axis defines the axis to use
  2731. * @param angle defines the angle to use
  2732. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2733. */
  2734. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2735. /**
  2736. * Creates a rotation around an axis and stores it into the given quaternion
  2737. * @param axis defines the axis to use
  2738. * @param angle defines the angle to use
  2739. * @param result defines the target quaternion
  2740. * @returns the target quaternion
  2741. */
  2742. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Creates a new quaternion from data stored into an array
  2745. * @param array defines the data source
  2746. * @param offset defines the offset in the source array where the data starts
  2747. * @returns a new quaternion
  2748. */
  2749. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2750. /**
  2751. * Create a quaternion from Euler rotation angles
  2752. * @param x Pitch
  2753. * @param y Yaw
  2754. * @param z Roll
  2755. * @returns the new Quaternion
  2756. */
  2757. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2758. /**
  2759. * Updates a quaternion from Euler rotation angles
  2760. * @param x Pitch
  2761. * @param y Yaw
  2762. * @param z Roll
  2763. * @param result the quaternion to store the result
  2764. * @returns the updated quaternion
  2765. */
  2766. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2767. /**
  2768. * Create a quaternion from Euler rotation vector
  2769. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2770. * @returns the new Quaternion
  2771. */
  2772. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2773. /**
  2774. * Updates a quaternion from Euler rotation vector
  2775. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2776. * @param result the quaternion to store the result
  2777. * @returns the updated quaternion
  2778. */
  2779. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2782. * @param yaw defines the rotation around Y axis
  2783. * @param pitch defines the rotation around X axis
  2784. * @param roll defines the rotation around Z axis
  2785. * @returns the new quaternion
  2786. */
  2787. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2788. /**
  2789. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2790. * @param yaw defines the rotation around Y axis
  2791. * @param pitch defines the rotation around X axis
  2792. * @param roll defines the rotation around Z axis
  2793. * @param result defines the target quaternion
  2794. */
  2795. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2796. /**
  2797. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2798. * @param alpha defines the rotation around first axis
  2799. * @param beta defines the rotation around second axis
  2800. * @param gamma defines the rotation around third axis
  2801. * @returns the new quaternion
  2802. */
  2803. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2804. /**
  2805. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2806. * @param alpha defines the rotation around first axis
  2807. * @param beta defines the rotation around second axis
  2808. * @param gamma defines the rotation around third axis
  2809. * @param result defines the target quaternion
  2810. */
  2811. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2812. /**
  2813. * 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)
  2814. * @param axis1 defines the first axis
  2815. * @param axis2 defines the second axis
  2816. * @param axis3 defines the third axis
  2817. * @returns the new quaternion
  2818. */
  2819. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2820. /**
  2821. * 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
  2822. * @param axis1 defines the first axis
  2823. * @param axis2 defines the second axis
  2824. * @param axis3 defines the third axis
  2825. * @param ref defines the target quaternion
  2826. */
  2827. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2828. /**
  2829. * Interpolates between two quaternions
  2830. * @param left defines first quaternion
  2831. * @param right defines second quaternion
  2832. * @param amount defines the gradient to use
  2833. * @returns the new interpolated quaternion
  2834. */
  2835. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2836. /**
  2837. * Interpolates between two quaternions and stores it into a target quaternion
  2838. * @param left defines first quaternion
  2839. * @param right defines second quaternion
  2840. * @param amount defines the gradient to use
  2841. * @param result defines the target quaternion
  2842. */
  2843. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2844. /**
  2845. * Interpolate between two quaternions using Hermite interpolation
  2846. * @param value1 defines first quaternion
  2847. * @param tangent1 defines the incoming tangent
  2848. * @param value2 defines second quaternion
  2849. * @param tangent2 defines the outgoing tangent
  2850. * @param amount defines the target quaternion
  2851. * @returns the new interpolated quaternion
  2852. */
  2853. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2854. }
  2855. /**
  2856. * Class used to store matrix data (4x4)
  2857. */
  2858. export class Matrix {
  2859. private static _updateFlagSeed;
  2860. private static _identityReadOnly;
  2861. private _isIdentity;
  2862. private _isIdentityDirty;
  2863. private _isIdentity3x2;
  2864. private _isIdentity3x2Dirty;
  2865. /**
  2866. * Gets the update flag of the matrix which is an unique number for the matrix.
  2867. * It will be incremented every time the matrix data change.
  2868. * You can use it to speed the comparison between two versions of the same matrix.
  2869. */
  2870. updateFlag: number;
  2871. private readonly _m;
  2872. /**
  2873. * Gets the internal data of the matrix
  2874. */
  2875. readonly m: DeepImmutable<Float32Array>;
  2876. /** @hidden */
  2877. _markAsUpdated(): void;
  2878. /** @hidden */
  2879. private _updateIdentityStatus;
  2880. /**
  2881. * Creates an empty matrix (filled with zeros)
  2882. */
  2883. constructor();
  2884. /**
  2885. * Check if the current matrix is identity
  2886. * @returns true is the matrix is the identity matrix
  2887. */
  2888. isIdentity(): boolean;
  2889. /**
  2890. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2891. * @returns true is the matrix is the identity matrix
  2892. */
  2893. isIdentityAs3x2(): boolean;
  2894. /**
  2895. * Gets the determinant of the matrix
  2896. * @returns the matrix determinant
  2897. */
  2898. determinant(): number;
  2899. /**
  2900. * Returns the matrix as a Float32Array
  2901. * @returns the matrix underlying array
  2902. */
  2903. toArray(): DeepImmutable<Float32Array>;
  2904. /**
  2905. * Returns the matrix as a Float32Array
  2906. * @returns the matrix underlying array.
  2907. */
  2908. asArray(): DeepImmutable<Float32Array>;
  2909. /**
  2910. * Inverts the current matrix in place
  2911. * @returns the current inverted matrix
  2912. */
  2913. invert(): Matrix;
  2914. /**
  2915. * Sets all the matrix elements to zero
  2916. * @returns the current matrix
  2917. */
  2918. reset(): Matrix;
  2919. /**
  2920. * Adds the current matrix with a second one
  2921. * @param other defines the matrix to add
  2922. * @returns a new matrix as the addition of the current matrix and the given one
  2923. */
  2924. add(other: DeepImmutable<Matrix>): Matrix;
  2925. /**
  2926. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2927. * @param other defines the matrix to add
  2928. * @param result defines the target matrix
  2929. * @returns the current matrix
  2930. */
  2931. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2932. /**
  2933. * Adds in place the given matrix to the current matrix
  2934. * @param other defines the second operand
  2935. * @returns the current updated matrix
  2936. */
  2937. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2938. /**
  2939. * Sets the given matrix to the current inverted Matrix
  2940. * @param other defines the target matrix
  2941. * @returns the unmodified current matrix
  2942. */
  2943. invertToRef(other: Matrix): Matrix;
  2944. /**
  2945. * add a value at the specified position in the current Matrix
  2946. * @param index the index of the value within the matrix. between 0 and 15.
  2947. * @param value the value to be added
  2948. * @returns the current updated matrix
  2949. */
  2950. addAtIndex(index: number, value: number): Matrix;
  2951. /**
  2952. * mutiply the specified position in the current Matrix by a value
  2953. * @param index the index of the value within the matrix. between 0 and 15.
  2954. * @param value the value to be added
  2955. * @returns the current updated matrix
  2956. */
  2957. multiplyAtIndex(index: number, value: number): Matrix;
  2958. /**
  2959. * Inserts the translation vector (using 3 floats) in the current matrix
  2960. * @param x defines the 1st component of the translation
  2961. * @param y defines the 2nd component of the translation
  2962. * @param z defines the 3rd component of the translation
  2963. * @returns the current updated matrix
  2964. */
  2965. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2966. /**
  2967. * Adds the translation vector (using 3 floats) in the current matrix
  2968. * @param x defines the 1st component of the translation
  2969. * @param y defines the 2nd component of the translation
  2970. * @param z defines the 3rd component of the translation
  2971. * @returns the current updated matrix
  2972. */
  2973. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2974. /**
  2975. * Inserts the translation vector in the current matrix
  2976. * @param vector3 defines the translation to insert
  2977. * @returns the current updated matrix
  2978. */
  2979. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2980. /**
  2981. * Gets the translation value of the current matrix
  2982. * @returns a new Vector3 as the extracted translation from the matrix
  2983. */
  2984. getTranslation(): Vector3;
  2985. /**
  2986. * Fill a Vector3 with the extracted translation from the matrix
  2987. * @param result defines the Vector3 where to store the translation
  2988. * @returns the current matrix
  2989. */
  2990. getTranslationToRef(result: Vector3): Matrix;
  2991. /**
  2992. * Remove rotation and scaling part from the matrix
  2993. * @returns the updated matrix
  2994. */
  2995. removeRotationAndScaling(): Matrix;
  2996. /**
  2997. * Multiply two matrices
  2998. * @param other defines the second operand
  2999. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3000. */
  3001. multiply(other: DeepImmutable<Matrix>): Matrix;
  3002. /**
  3003. * Copy the current matrix from the given one
  3004. * @param other defines the source matrix
  3005. * @returns the current updated matrix
  3006. */
  3007. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3008. /**
  3009. * Populates the given array from the starting index with the current matrix values
  3010. * @param array defines the target array
  3011. * @param offset defines the offset in the target array where to start storing values
  3012. * @returns the current matrix
  3013. */
  3014. copyToArray(array: Float32Array, offset?: number): Matrix;
  3015. /**
  3016. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3017. * @param other defines the second operand
  3018. * @param result defines the matrix where to store the multiplication
  3019. * @returns the current matrix
  3020. */
  3021. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3022. /**
  3023. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3024. * @param other defines the second operand
  3025. * @param result defines the array where to store the multiplication
  3026. * @param offset defines the offset in the target array where to start storing values
  3027. * @returns the current matrix
  3028. */
  3029. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3030. /**
  3031. * Check equality between this matrix and a second one
  3032. * @param value defines the second matrix to compare
  3033. * @returns true is the current matrix and the given one values are strictly equal
  3034. */
  3035. equals(value: DeepImmutable<Matrix>): boolean;
  3036. /**
  3037. * Clone the current matrix
  3038. * @returns a new matrix from the current matrix
  3039. */
  3040. clone(): Matrix;
  3041. /**
  3042. * Returns the name of the current matrix class
  3043. * @returns the string "Matrix"
  3044. */
  3045. getClassName(): string;
  3046. /**
  3047. * Gets the hash code of the current matrix
  3048. * @returns the hash code
  3049. */
  3050. getHashCode(): number;
  3051. /**
  3052. * Decomposes the current Matrix into a translation, rotation and scaling components
  3053. * @param scale defines the scale vector3 given as a reference to update
  3054. * @param rotation defines the rotation quaternion given as a reference to update
  3055. * @param translation defines the translation vector3 given as a reference to update
  3056. * @returns true if operation was successful
  3057. */
  3058. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3059. /**
  3060. * Gets specific row of the matrix
  3061. * @param index defines the number of the row to get
  3062. * @returns the index-th row of the current matrix as a new Vector4
  3063. */
  3064. getRow(index: number): Nullable<Vector4>;
  3065. /**
  3066. * Sets the index-th row of the current matrix to the vector4 values
  3067. * @param index defines the number of the row to set
  3068. * @param row defines the target vector4
  3069. * @returns the updated current matrix
  3070. */
  3071. setRow(index: number, row: Vector4): Matrix;
  3072. /**
  3073. * Compute the transpose of the matrix
  3074. * @returns the new transposed matrix
  3075. */
  3076. transpose(): Matrix;
  3077. /**
  3078. * Compute the transpose of the matrix and store it in a given matrix
  3079. * @param result defines the target matrix
  3080. * @returns the current matrix
  3081. */
  3082. transposeToRef(result: Matrix): Matrix;
  3083. /**
  3084. * Sets the index-th row of the current matrix with the given 4 x float values
  3085. * @param index defines the row index
  3086. * @param x defines the x component to set
  3087. * @param y defines the y component to set
  3088. * @param z defines the z component to set
  3089. * @param w defines the w component to set
  3090. * @returns the updated current matrix
  3091. */
  3092. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3093. /**
  3094. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3095. * @param scale defines the scale factor
  3096. * @returns a new matrix
  3097. */
  3098. scale(scale: number): Matrix;
  3099. /**
  3100. * Scale the current matrix values by a factor to a given result matrix
  3101. * @param scale defines the scale factor
  3102. * @param result defines the matrix to store the result
  3103. * @returns the current matrix
  3104. */
  3105. scaleToRef(scale: number, result: Matrix): Matrix;
  3106. /**
  3107. * Scale the current matrix values by a factor and add the result to a given matrix
  3108. * @param scale defines the scale factor
  3109. * @param result defines the Matrix to store the result
  3110. * @returns the current matrix
  3111. */
  3112. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3113. /**
  3114. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3115. * @param ref matrix to store the result
  3116. */
  3117. toNormalMatrix(ref: Matrix): void;
  3118. /**
  3119. * Gets only rotation part of the current matrix
  3120. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3121. */
  3122. getRotationMatrix(): Matrix;
  3123. /**
  3124. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3125. * @param result defines the target matrix to store data to
  3126. * @returns the current matrix
  3127. */
  3128. getRotationMatrixToRef(result: Matrix): Matrix;
  3129. /**
  3130. * Toggles model matrix from being right handed to left handed in place and vice versa
  3131. */
  3132. toggleModelMatrixHandInPlace(): void;
  3133. /**
  3134. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3135. */
  3136. toggleProjectionMatrixHandInPlace(): void;
  3137. /**
  3138. * Creates a matrix from an array
  3139. * @param array defines the source array
  3140. * @param offset defines an offset in the source array
  3141. * @returns a new Matrix set from the starting index of the given array
  3142. */
  3143. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3144. /**
  3145. * Copy the content of an array into a given matrix
  3146. * @param array defines the source array
  3147. * @param offset defines an offset in the source array
  3148. * @param result defines the target matrix
  3149. */
  3150. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3151. /**
  3152. * Stores an array into a matrix after having multiplied each component by a given factor
  3153. * @param array defines the source array
  3154. * @param offset defines the offset in the source array
  3155. * @param scale defines the scaling factor
  3156. * @param result defines the target matrix
  3157. */
  3158. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3159. /**
  3160. * Gets an identity matrix that must not be updated
  3161. */
  3162. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3163. /**
  3164. * Stores a list of values (16) inside a given matrix
  3165. * @param initialM11 defines 1st value of 1st row
  3166. * @param initialM12 defines 2nd value of 1st row
  3167. * @param initialM13 defines 3rd value of 1st row
  3168. * @param initialM14 defines 4th value of 1st row
  3169. * @param initialM21 defines 1st value of 2nd row
  3170. * @param initialM22 defines 2nd value of 2nd row
  3171. * @param initialM23 defines 3rd value of 2nd row
  3172. * @param initialM24 defines 4th value of 2nd row
  3173. * @param initialM31 defines 1st value of 3rd row
  3174. * @param initialM32 defines 2nd value of 3rd row
  3175. * @param initialM33 defines 3rd value of 3rd row
  3176. * @param initialM34 defines 4th value of 3rd row
  3177. * @param initialM41 defines 1st value of 4th row
  3178. * @param initialM42 defines 2nd value of 4th row
  3179. * @param initialM43 defines 3rd value of 4th row
  3180. * @param initialM44 defines 4th value of 4th row
  3181. * @param result defines the target matrix
  3182. */
  3183. 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;
  3184. /**
  3185. * Creates new matrix from a list of values (16)
  3186. * @param initialM11 defines 1st value of 1st row
  3187. * @param initialM12 defines 2nd value of 1st row
  3188. * @param initialM13 defines 3rd value of 1st row
  3189. * @param initialM14 defines 4th value of 1st row
  3190. * @param initialM21 defines 1st value of 2nd row
  3191. * @param initialM22 defines 2nd value of 2nd row
  3192. * @param initialM23 defines 3rd value of 2nd row
  3193. * @param initialM24 defines 4th value of 2nd row
  3194. * @param initialM31 defines 1st value of 3rd row
  3195. * @param initialM32 defines 2nd value of 3rd row
  3196. * @param initialM33 defines 3rd value of 3rd row
  3197. * @param initialM34 defines 4th value of 3rd row
  3198. * @param initialM41 defines 1st value of 4th row
  3199. * @param initialM42 defines 2nd value of 4th row
  3200. * @param initialM43 defines 3rd value of 4th row
  3201. * @param initialM44 defines 4th value of 4th row
  3202. * @returns the new matrix
  3203. */
  3204. 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;
  3205. /**
  3206. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3207. * @param scale defines the scale vector3
  3208. * @param rotation defines the rotation quaternion
  3209. * @param translation defines the translation vector3
  3210. * @returns a new matrix
  3211. */
  3212. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3213. /**
  3214. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3215. * @param scale defines the scale vector3
  3216. * @param rotation defines the rotation quaternion
  3217. * @param translation defines the translation vector3
  3218. * @param result defines the target matrix
  3219. */
  3220. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3221. /**
  3222. * Creates a new identity matrix
  3223. * @returns a new identity matrix
  3224. */
  3225. static Identity(): Matrix;
  3226. /**
  3227. * Creates a new identity matrix and stores the result in a given matrix
  3228. * @param result defines the target matrix
  3229. */
  3230. static IdentityToRef(result: Matrix): void;
  3231. /**
  3232. * Creates a new zero matrix
  3233. * @returns a new zero matrix
  3234. */
  3235. static Zero(): Matrix;
  3236. /**
  3237. * Creates a new rotation matrix for "angle" radians around the X axis
  3238. * @param angle defines the angle (in radians) to use
  3239. * @return the new matrix
  3240. */
  3241. static RotationX(angle: number): Matrix;
  3242. /**
  3243. * Creates a new matrix as the invert of a given matrix
  3244. * @param source defines the source matrix
  3245. * @returns the new matrix
  3246. */
  3247. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3248. /**
  3249. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3250. * @param angle defines the angle (in radians) to use
  3251. * @param result defines the target matrix
  3252. */
  3253. static RotationXToRef(angle: number, result: Matrix): void;
  3254. /**
  3255. * Creates a new rotation matrix for "angle" radians around the Y axis
  3256. * @param angle defines the angle (in radians) to use
  3257. * @return the new matrix
  3258. */
  3259. static RotationY(angle: number): Matrix;
  3260. /**
  3261. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3262. * @param angle defines the angle (in radians) to use
  3263. * @param result defines the target matrix
  3264. */
  3265. static RotationYToRef(angle: number, result: Matrix): void;
  3266. /**
  3267. * Creates a new rotation matrix for "angle" radians around the Z axis
  3268. * @param angle defines the angle (in radians) to use
  3269. * @return the new matrix
  3270. */
  3271. static RotationZ(angle: number): Matrix;
  3272. /**
  3273. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3274. * @param angle defines the angle (in radians) to use
  3275. * @param result defines the target matrix
  3276. */
  3277. static RotationZToRef(angle: number, result: Matrix): void;
  3278. /**
  3279. * Creates a new rotation matrix for "angle" radians around the given axis
  3280. * @param axis defines the axis to use
  3281. * @param angle defines the angle (in radians) to use
  3282. * @return the new matrix
  3283. */
  3284. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3285. /**
  3286. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3287. * @param axis defines the axis to use
  3288. * @param angle defines the angle (in radians) to use
  3289. * @param result defines the target matrix
  3290. */
  3291. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3292. /**
  3293. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3294. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3295. * @param from defines the vector to align
  3296. * @param to defines the vector to align to
  3297. * @param result defines the target matrix
  3298. */
  3299. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3300. /**
  3301. * Creates a rotation matrix
  3302. * @param yaw defines the yaw angle in radians (Y axis)
  3303. * @param pitch defines the pitch angle in radians (X axis)
  3304. * @param roll defines the roll angle in radians (X axis)
  3305. * @returns the new rotation matrix
  3306. */
  3307. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3308. /**
  3309. * Creates a rotation matrix and stores it in a given matrix
  3310. * @param yaw defines the yaw angle in radians (Y axis)
  3311. * @param pitch defines the pitch angle in radians (X axis)
  3312. * @param roll defines the roll angle in radians (X axis)
  3313. * @param result defines the target matrix
  3314. */
  3315. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3316. /**
  3317. * Creates a scaling matrix
  3318. * @param x defines the scale factor on X axis
  3319. * @param y defines the scale factor on Y axis
  3320. * @param z defines the scale factor on Z axis
  3321. * @returns the new matrix
  3322. */
  3323. static Scaling(x: number, y: number, z: number): Matrix;
  3324. /**
  3325. * Creates a scaling matrix and stores it in a given matrix
  3326. * @param x defines the scale factor on X axis
  3327. * @param y defines the scale factor on Y axis
  3328. * @param z defines the scale factor on Z axis
  3329. * @param result defines the target matrix
  3330. */
  3331. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3332. /**
  3333. * Creates a translation matrix
  3334. * @param x defines the translation on X axis
  3335. * @param y defines the translation on Y axis
  3336. * @param z defines the translationon Z axis
  3337. * @returns the new matrix
  3338. */
  3339. static Translation(x: number, y: number, z: number): Matrix;
  3340. /**
  3341. * Creates a translation matrix and stores it in a given matrix
  3342. * @param x defines the translation on X axis
  3343. * @param y defines the translation on Y axis
  3344. * @param z defines the translationon Z axis
  3345. * @param result defines the target matrix
  3346. */
  3347. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3348. /**
  3349. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3350. * @param startValue defines the start value
  3351. * @param endValue defines the end value
  3352. * @param gradient defines the gradient factor
  3353. * @returns the new matrix
  3354. */
  3355. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3356. /**
  3357. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3358. * @param startValue defines the start value
  3359. * @param endValue defines the end value
  3360. * @param gradient defines the gradient factor
  3361. * @param result defines the Matrix object where to store data
  3362. */
  3363. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3364. /**
  3365. * Builds a new matrix whose values are computed by:
  3366. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3367. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3368. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3369. * @param startValue defines the first matrix
  3370. * @param endValue defines the second matrix
  3371. * @param gradient defines the gradient between the two matrices
  3372. * @returns the new matrix
  3373. */
  3374. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3375. /**
  3376. * Update a matrix to values which are computed by:
  3377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3380. * @param startValue defines the first matrix
  3381. * @param endValue defines the second matrix
  3382. * @param gradient defines the gradient between the two matrices
  3383. * @param result defines the target matrix
  3384. */
  3385. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3386. /**
  3387. * 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"
  3388. * This function works in left handed mode
  3389. * @param eye defines the final position of the entity
  3390. * @param target defines where the entity should look at
  3391. * @param up defines the up vector for the entity
  3392. * @returns the new matrix
  3393. */
  3394. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3395. /**
  3396. * 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".
  3397. * This function works in left handed mode
  3398. * @param eye defines the final position of the entity
  3399. * @param target defines where the entity should look at
  3400. * @param up defines the up vector for the entity
  3401. * @param result defines the target matrix
  3402. */
  3403. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3404. /**
  3405. * 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"
  3406. * This function works in right handed mode
  3407. * @param eye defines the final position of the entity
  3408. * @param target defines where the entity should look at
  3409. * @param up defines the up vector for the entity
  3410. * @returns the new matrix
  3411. */
  3412. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3413. /**
  3414. * 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".
  3415. * This function works in right handed mode
  3416. * @param eye defines the final position of the entity
  3417. * @param target defines where the entity should look at
  3418. * @param up defines the up vector for the entity
  3419. * @param result defines the target matrix
  3420. */
  3421. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3422. /**
  3423. * Create a left-handed orthographic projection matrix
  3424. * @param width defines the viewport width
  3425. * @param height defines the viewport height
  3426. * @param znear defines the near clip plane
  3427. * @param zfar defines the far clip plane
  3428. * @returns a new matrix as a left-handed orthographic projection matrix
  3429. */
  3430. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3431. /**
  3432. * Store a left-handed orthographic projection to a given matrix
  3433. * @param width defines the viewport width
  3434. * @param height defines the viewport height
  3435. * @param znear defines the near clip plane
  3436. * @param zfar defines the far clip plane
  3437. * @param result defines the target matrix
  3438. */
  3439. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3440. /**
  3441. * Create a left-handed orthographic projection matrix
  3442. * @param left defines the viewport left coordinate
  3443. * @param right defines the viewport right coordinate
  3444. * @param bottom defines the viewport bottom coordinate
  3445. * @param top defines the viewport top coordinate
  3446. * @param znear defines the near clip plane
  3447. * @param zfar defines the far clip plane
  3448. * @returns a new matrix as a left-handed orthographic projection matrix
  3449. */
  3450. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3451. /**
  3452. * Stores a left-handed orthographic projection into a given matrix
  3453. * @param left defines the viewport left coordinate
  3454. * @param right defines the viewport right coordinate
  3455. * @param bottom defines the viewport bottom coordinate
  3456. * @param top defines the viewport top coordinate
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @param result defines the target matrix
  3460. */
  3461. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3462. /**
  3463. * Creates a right-handed orthographic projection matrix
  3464. * @param left defines the viewport left coordinate
  3465. * @param right defines the viewport right coordinate
  3466. * @param bottom defines the viewport bottom coordinate
  3467. * @param top defines the viewport top coordinate
  3468. * @param znear defines the near clip plane
  3469. * @param zfar defines the far clip plane
  3470. * @returns a new matrix as a right-handed orthographic projection matrix
  3471. */
  3472. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3473. /**
  3474. * Stores a right-handed orthographic projection into a given matrix
  3475. * @param left defines the viewport left coordinate
  3476. * @param right defines the viewport right coordinate
  3477. * @param bottom defines the viewport bottom coordinate
  3478. * @param top defines the viewport top coordinate
  3479. * @param znear defines the near clip plane
  3480. * @param zfar defines the far clip plane
  3481. * @param result defines the target matrix
  3482. */
  3483. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3484. /**
  3485. * Creates a left-handed perspective projection matrix
  3486. * @param width defines the viewport width
  3487. * @param height defines the viewport height
  3488. * @param znear defines the near clip plane
  3489. * @param zfar defines the far clip plane
  3490. * @returns a new matrix as a left-handed perspective projection matrix
  3491. */
  3492. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3493. /**
  3494. * Creates a left-handed perspective projection matrix
  3495. * @param fov defines the horizontal field of view
  3496. * @param aspect defines the aspect ratio
  3497. * @param znear defines the near clip plane
  3498. * @param zfar defines the far clip plane
  3499. * @returns a new matrix as a left-handed perspective projection matrix
  3500. */
  3501. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3502. /**
  3503. * Stores a left-handed perspective projection into a given matrix
  3504. * @param fov defines the horizontal field of view
  3505. * @param aspect defines the aspect ratio
  3506. * @param znear defines the near clip plane
  3507. * @param zfar defines the far clip plane
  3508. * @param result defines the target matrix
  3509. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3510. */
  3511. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3512. /**
  3513. * Creates a right-handed perspective projection matrix
  3514. * @param fov defines the horizontal field of view
  3515. * @param aspect defines the aspect ratio
  3516. * @param znear defines the near clip plane
  3517. * @param zfar defines the far clip plane
  3518. * @returns a new matrix as a right-handed perspective projection matrix
  3519. */
  3520. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3521. /**
  3522. * Stores a right-handed perspective projection into a given matrix
  3523. * @param fov defines the horizontal field of view
  3524. * @param aspect defines the aspect ratio
  3525. * @param znear defines the near clip plane
  3526. * @param zfar defines the far clip plane
  3527. * @param result defines the target matrix
  3528. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3529. */
  3530. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3531. /**
  3532. * Stores a perspective projection for WebVR info a given matrix
  3533. * @param fov defines the field of view
  3534. * @param znear defines the near clip plane
  3535. * @param zfar defines the far clip plane
  3536. * @param result defines the target matrix
  3537. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3538. */
  3539. static PerspectiveFovWebVRToRef(fov: {
  3540. upDegrees: number;
  3541. downDegrees: number;
  3542. leftDegrees: number;
  3543. rightDegrees: number;
  3544. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3545. /**
  3546. * Computes a complete transformation matrix
  3547. * @param viewport defines the viewport to use
  3548. * @param world defines the world matrix
  3549. * @param view defines the view matrix
  3550. * @param projection defines the projection matrix
  3551. * @param zmin defines the near clip plane
  3552. * @param zmax defines the far clip plane
  3553. * @returns the transformation matrix
  3554. */
  3555. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3556. /**
  3557. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3558. * @param matrix defines the matrix to use
  3559. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3560. */
  3561. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3562. /**
  3563. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3564. * @param matrix defines the matrix to use
  3565. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3566. */
  3567. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3568. /**
  3569. * Compute the transpose of a given matrix
  3570. * @param matrix defines the matrix to transpose
  3571. * @returns the new matrix
  3572. */
  3573. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3574. /**
  3575. * Compute the transpose of a matrix and store it in a target matrix
  3576. * @param matrix defines the matrix to transpose
  3577. * @param result defines the target matrix
  3578. */
  3579. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3580. /**
  3581. * Computes a reflection matrix from a plane
  3582. * @param plane defines the reflection plane
  3583. * @returns a new matrix
  3584. */
  3585. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3586. /**
  3587. * Computes a reflection matrix from a plane
  3588. * @param plane defines the reflection plane
  3589. * @param result defines the target matrix
  3590. */
  3591. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3592. /**
  3593. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3594. * @param xaxis defines the value of the 1st axis
  3595. * @param yaxis defines the value of the 2nd axis
  3596. * @param zaxis defines the value of the 3rd axis
  3597. * @param result defines the target matrix
  3598. */
  3599. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3600. /**
  3601. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3602. * @param quat defines the quaternion to use
  3603. * @param result defines the target matrix
  3604. */
  3605. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3606. }
  3607. /**
  3608. * Represens a plane by the equation ax + by + cz + d = 0
  3609. */
  3610. export class Plane {
  3611. /**
  3612. * Normal of the plane (a,b,c)
  3613. */
  3614. normal: Vector3;
  3615. /**
  3616. * d component of the plane
  3617. */
  3618. d: number;
  3619. /**
  3620. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3621. * @param a a component of the plane
  3622. * @param b b component of the plane
  3623. * @param c c component of the plane
  3624. * @param d d component of the plane
  3625. */
  3626. constructor(a: number, b: number, c: number, d: number);
  3627. /**
  3628. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3629. */
  3630. asArray(): number[];
  3631. /**
  3632. * @returns a new plane copied from the current Plane.
  3633. */
  3634. clone(): Plane;
  3635. /**
  3636. * @returns the string "Plane".
  3637. */
  3638. getClassName(): string;
  3639. /**
  3640. * @returns the Plane hash code.
  3641. */
  3642. getHashCode(): number;
  3643. /**
  3644. * Normalize the current Plane in place.
  3645. * @returns the updated Plane.
  3646. */
  3647. normalize(): Plane;
  3648. /**
  3649. * Applies a transformation the plane and returns the result
  3650. * @param transformation the transformation matrix to be applied to the plane
  3651. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3652. */
  3653. transform(transformation: DeepImmutable<Matrix>): Plane;
  3654. /**
  3655. * Calcualtte the dot product between the point and the plane normal
  3656. * @param point point to calculate the dot product with
  3657. * @returns the dot product (float) of the point coordinates and the plane normal.
  3658. */
  3659. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3660. /**
  3661. * Updates the current Plane from the plane defined by the three given points.
  3662. * @param point1 one of the points used to contruct the plane
  3663. * @param point2 one of the points used to contruct the plane
  3664. * @param point3 one of the points used to contruct the plane
  3665. * @returns the updated Plane.
  3666. */
  3667. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3668. /**
  3669. * Checks if the plane is facing a given direction
  3670. * @param direction the direction to check if the plane is facing
  3671. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3672. * @returns True is the vector "direction" is the same side than the plane normal.
  3673. */
  3674. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3675. /**
  3676. * Calculates the distance to a point
  3677. * @param point point to calculate distance to
  3678. * @returns the signed distance (float) from the given point to the Plane.
  3679. */
  3680. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3681. /**
  3682. * Creates a plane from an array
  3683. * @param array the array to create a plane from
  3684. * @returns a new Plane from the given array.
  3685. */
  3686. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3687. /**
  3688. * Creates a plane from three points
  3689. * @param point1 point used to create the plane
  3690. * @param point2 point used to create the plane
  3691. * @param point3 point used to create the plane
  3692. * @returns a new Plane defined by the three given points.
  3693. */
  3694. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3695. /**
  3696. * Creates a plane from an origin point and a normal
  3697. * @param origin origin of the plane to be constructed
  3698. * @param normal normal of the plane to be constructed
  3699. * @returns a new Plane the normal vector to this plane at the given origin point.
  3700. * Note : the vector "normal" is updated because normalized.
  3701. */
  3702. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3703. /**
  3704. * Calculates the distance from a plane and a point
  3705. * @param origin origin of the plane to be constructed
  3706. * @param normal normal of the plane to be constructed
  3707. * @param point point to calculate distance to
  3708. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3709. */
  3710. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3711. }
  3712. /**
  3713. * Class used to represent a viewport on screen
  3714. */
  3715. export class Viewport {
  3716. /** viewport left coordinate */
  3717. x: number;
  3718. /** viewport top coordinate */
  3719. y: number;
  3720. /**viewport width */
  3721. width: number;
  3722. /** viewport height */
  3723. height: number;
  3724. /**
  3725. * Creates a Viewport object located at (x, y) and sized (width, height)
  3726. * @param x defines viewport left coordinate
  3727. * @param y defines viewport top coordinate
  3728. * @param width defines the viewport width
  3729. * @param height defines the viewport height
  3730. */
  3731. constructor(
  3732. /** viewport left coordinate */
  3733. x: number,
  3734. /** viewport top coordinate */
  3735. y: number,
  3736. /**viewport width */
  3737. width: number,
  3738. /** viewport height */
  3739. height: number);
  3740. /**
  3741. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3742. * @param renderWidth defines the rendering width
  3743. * @param renderHeight defines the rendering height
  3744. * @returns a new Viewport
  3745. */
  3746. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3747. /**
  3748. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3749. * @param renderWidth defines the rendering width
  3750. * @param renderHeight defines the rendering height
  3751. * @param ref defines the target viewport
  3752. * @returns the current viewport
  3753. */
  3754. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3755. /**
  3756. * Returns a new Viewport copied from the current one
  3757. * @returns a new Viewport
  3758. */
  3759. clone(): Viewport;
  3760. }
  3761. /**
  3762. * Reprasents a camera frustum
  3763. */
  3764. export class Frustum {
  3765. /**
  3766. * Gets the planes representing the frustum
  3767. * @param transform matrix to be applied to the returned planes
  3768. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3769. */
  3770. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3771. /**
  3772. * Gets the near frustum plane transformed by the transform matrix
  3773. * @param transform transformation matrix to be applied to the resulting frustum plane
  3774. * @param frustumPlane the resuling frustum plane
  3775. */
  3776. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3777. /**
  3778. * Gets the far frustum plane transformed by the transform matrix
  3779. * @param transform transformation matrix to be applied to the resulting frustum plane
  3780. * @param frustumPlane the resuling frustum plane
  3781. */
  3782. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3783. /**
  3784. * Gets the left frustum plane transformed by the transform matrix
  3785. * @param transform transformation matrix to be applied to the resulting frustum plane
  3786. * @param frustumPlane the resuling frustum plane
  3787. */
  3788. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3789. /**
  3790. * Gets the right frustum plane transformed by the transform matrix
  3791. * @param transform transformation matrix to be applied to the resulting frustum plane
  3792. * @param frustumPlane the resuling frustum plane
  3793. */
  3794. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3795. /**
  3796. * Gets the top frustum plane transformed by the transform matrix
  3797. * @param transform transformation matrix to be applied to the resulting frustum plane
  3798. * @param frustumPlane the resuling frustum plane
  3799. */
  3800. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3801. /**
  3802. * Gets the bottom frustum plane transformed by the transform matrix
  3803. * @param transform transformation matrix to be applied to the resulting frustum plane
  3804. * @param frustumPlane the resuling frustum plane
  3805. */
  3806. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3807. /**
  3808. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3809. * @param transform transformation matrix to be applied to the resulting frustum planes
  3810. * @param frustumPlanes the resuling frustum planes
  3811. */
  3812. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3813. }
  3814. /** Defines supported spaces */
  3815. export enum Space {
  3816. /** Local (object) space */
  3817. LOCAL = 0,
  3818. /** World space */
  3819. WORLD = 1,
  3820. /** Bone space */
  3821. BONE = 2
  3822. }
  3823. /** Defines the 3 main axes */
  3824. export class Axis {
  3825. /** X axis */
  3826. static X: Vector3;
  3827. /** Y axis */
  3828. static Y: Vector3;
  3829. /** Z axis */
  3830. static Z: Vector3;
  3831. }
  3832. /** Class used to represent a Bezier curve */
  3833. export class BezierCurve {
  3834. /**
  3835. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3836. * @param t defines the time
  3837. * @param x1 defines the left coordinate on X axis
  3838. * @param y1 defines the left coordinate on Y axis
  3839. * @param x2 defines the right coordinate on X axis
  3840. * @param y2 defines the right coordinate on Y axis
  3841. * @returns the interpolated value
  3842. */
  3843. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3844. }
  3845. /**
  3846. * Defines potential orientation for back face culling
  3847. */
  3848. export enum Orientation {
  3849. /**
  3850. * Clockwise
  3851. */
  3852. CW = 0,
  3853. /** Counter clockwise */
  3854. CCW = 1
  3855. }
  3856. /**
  3857. * Defines angle representation
  3858. */
  3859. export class Angle {
  3860. private _radians;
  3861. /**
  3862. * Creates an Angle object of "radians" radians (float).
  3863. * @param radians the angle in radians
  3864. */
  3865. constructor(radians: number);
  3866. /**
  3867. * Get value in degrees
  3868. * @returns the Angle value in degrees (float)
  3869. */
  3870. degrees(): number;
  3871. /**
  3872. * Get value in radians
  3873. * @returns the Angle value in radians (float)
  3874. */
  3875. radians(): number;
  3876. /**
  3877. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3878. * @param a defines first vector
  3879. * @param b defines second vector
  3880. * @returns a new Angle
  3881. */
  3882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3883. /**
  3884. * Gets a new Angle object from the given float in radians
  3885. * @param radians defines the angle value in radians
  3886. * @returns a new Angle
  3887. */
  3888. static FromRadians(radians: number): Angle;
  3889. /**
  3890. * Gets a new Angle object from the given float in degrees
  3891. * @param degrees defines the angle value in degrees
  3892. * @returns a new Angle
  3893. */
  3894. static FromDegrees(degrees: number): Angle;
  3895. }
  3896. /**
  3897. * This represents an arc in a 2d space.
  3898. */
  3899. export class Arc2 {
  3900. /** Defines the start point of the arc */
  3901. startPoint: Vector2;
  3902. /** Defines the mid point of the arc */
  3903. midPoint: Vector2;
  3904. /** Defines the end point of the arc */
  3905. endPoint: Vector2;
  3906. /**
  3907. * Defines the center point of the arc.
  3908. */
  3909. centerPoint: Vector2;
  3910. /**
  3911. * Defines the radius of the arc.
  3912. */
  3913. radius: number;
  3914. /**
  3915. * Defines the angle of the arc (from mid point to end point).
  3916. */
  3917. angle: Angle;
  3918. /**
  3919. * Defines the start angle of the arc (from start point to middle point).
  3920. */
  3921. startAngle: Angle;
  3922. /**
  3923. * Defines the orientation of the arc (clock wise/counter clock wise).
  3924. */
  3925. orientation: Orientation;
  3926. /**
  3927. * Creates an Arc object from the three given points : start, middle and end.
  3928. * @param startPoint Defines the start point of the arc
  3929. * @param midPoint Defines the midlle point of the arc
  3930. * @param endPoint Defines the end point of the arc
  3931. */
  3932. constructor(
  3933. /** Defines the start point of the arc */
  3934. startPoint: Vector2,
  3935. /** Defines the mid point of the arc */
  3936. midPoint: Vector2,
  3937. /** Defines the end point of the arc */
  3938. endPoint: Vector2);
  3939. }
  3940. /**
  3941. * Represents a 2D path made up of multiple 2D points
  3942. */
  3943. export class Path2 {
  3944. private _points;
  3945. private _length;
  3946. /**
  3947. * If the path start and end point are the same
  3948. */
  3949. closed: boolean;
  3950. /**
  3951. * Creates a Path2 object from the starting 2D coordinates x and y.
  3952. * @param x the starting points x value
  3953. * @param y the starting points y value
  3954. */
  3955. constructor(x: number, y: number);
  3956. /**
  3957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3958. * @param x the added points x value
  3959. * @param y the added points y value
  3960. * @returns the updated Path2.
  3961. */
  3962. addLineTo(x: number, y: number): Path2;
  3963. /**
  3964. * 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.
  3965. * @param midX middle point x value
  3966. * @param midY middle point y value
  3967. * @param endX end point x value
  3968. * @param endY end point y value
  3969. * @param numberOfSegments (default: 36)
  3970. * @returns the updated Path2.
  3971. */
  3972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3973. /**
  3974. * Closes the Path2.
  3975. * @returns the Path2.
  3976. */
  3977. close(): Path2;
  3978. /**
  3979. * Gets the sum of the distance between each sequential point in the path
  3980. * @returns the Path2 total length (float).
  3981. */
  3982. length(): number;
  3983. /**
  3984. * Gets the points which construct the path
  3985. * @returns the Path2 internal array of points.
  3986. */
  3987. getPoints(): Vector2[];
  3988. /**
  3989. * Retreives the point at the distance aways from the starting point
  3990. * @param normalizedLengthPosition the length along the path to retreive the point from
  3991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3992. */
  3993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3994. /**
  3995. * Creates a new path starting from an x and y position
  3996. * @param x starting x value
  3997. * @param y starting y value
  3998. * @returns a new Path2 starting at the coordinates (x, y).
  3999. */
  4000. static StartingAt(x: number, y: number): Path2;
  4001. }
  4002. /**
  4003. * Represents a 3D path made up of multiple 3D points
  4004. */
  4005. export class Path3D {
  4006. /**
  4007. * an array of Vector3, the curve axis of the Path3D
  4008. */
  4009. path: Vector3[];
  4010. private _curve;
  4011. private _distances;
  4012. private _tangents;
  4013. private _normals;
  4014. private _binormals;
  4015. private _raw;
  4016. /**
  4017. * new Path3D(path, normal, raw)
  4018. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4019. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4020. * @param path an array of Vector3, the curve axis of the Path3D
  4021. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4022. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4023. */
  4024. constructor(
  4025. /**
  4026. * an array of Vector3, the curve axis of the Path3D
  4027. */
  4028. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4029. /**
  4030. * Returns the Path3D array of successive Vector3 designing its curve.
  4031. * @returns the Path3D array of successive Vector3 designing its curve.
  4032. */
  4033. getCurve(): Vector3[];
  4034. /**
  4035. * Returns an array populated with tangent vectors on each Path3D curve point.
  4036. * @returns an array populated with tangent vectors on each Path3D curve point.
  4037. */
  4038. getTangents(): Vector3[];
  4039. /**
  4040. * Returns an array populated with normal vectors on each Path3D curve point.
  4041. * @returns an array populated with normal vectors on each Path3D curve point.
  4042. */
  4043. getNormals(): Vector3[];
  4044. /**
  4045. * Returns an array populated with binormal vectors on each Path3D curve point.
  4046. * @returns an array populated with binormal vectors on each Path3D curve point.
  4047. */
  4048. getBinormals(): Vector3[];
  4049. /**
  4050. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4051. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4052. */
  4053. getDistances(): number[];
  4054. /**
  4055. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4056. * @param path path which all values are copied into the curves points
  4057. * @param firstNormal which should be projected onto the curve
  4058. * @returns the same object updated.
  4059. */
  4060. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4061. private _compute;
  4062. private _getFirstNonNullVector;
  4063. private _getLastNonNullVector;
  4064. private _normalVector;
  4065. }
  4066. /**
  4067. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4068. * A Curve3 is designed from a series of successive Vector3.
  4069. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4070. */
  4071. export class Curve3 {
  4072. private _points;
  4073. private _length;
  4074. /**
  4075. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4076. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4077. * @param v1 (Vector3) the control point
  4078. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4079. * @param nbPoints (integer) the wanted number of points in the curve
  4080. * @returns the created Curve3
  4081. */
  4082. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4083. /**
  4084. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4085. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4086. * @param v1 (Vector3) the first control point
  4087. * @param v2 (Vector3) the second control point
  4088. * @param v3 (Vector3) the end point of the Cubic Bezier
  4089. * @param nbPoints (integer) the wanted number of points in the curve
  4090. * @returns the created Curve3
  4091. */
  4092. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4093. /**
  4094. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4095. * @param p1 (Vector3) the origin point of the Hermite Spline
  4096. * @param t1 (Vector3) the tangent vector at the origin point
  4097. * @param p2 (Vector3) the end point of the Hermite Spline
  4098. * @param t2 (Vector3) the tangent vector at the end point
  4099. * @param nbPoints (integer) the wanted number of points in the curve
  4100. * @returns the created Curve3
  4101. */
  4102. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4103. /**
  4104. * Returns a Curve3 object along a CatmullRom Spline curve :
  4105. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4106. * @param nbPoints (integer) the wanted number of points between each curve control points
  4107. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4108. * @returns the created Curve3
  4109. */
  4110. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4111. /**
  4112. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4113. * A Curve3 is designed from a series of successive Vector3.
  4114. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4115. * @param points points which make up the curve
  4116. */
  4117. constructor(points: Vector3[]);
  4118. /**
  4119. * @returns the Curve3 stored array of successive Vector3
  4120. */
  4121. getPoints(): Vector3[];
  4122. /**
  4123. * @returns the computed length (float) of the curve.
  4124. */
  4125. length(): number;
  4126. /**
  4127. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4128. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4129. * curveA and curveB keep unchanged.
  4130. * @param curve the curve to continue from this curve
  4131. * @returns the newly constructed curve
  4132. */
  4133. continue(curve: DeepImmutable<Curve3>): Curve3;
  4134. private _computeLength;
  4135. }
  4136. /**
  4137. * Contains position and normal vectors for a vertex
  4138. */
  4139. export class PositionNormalVertex {
  4140. /** the position of the vertex (defaut: 0,0,0) */
  4141. position: Vector3;
  4142. /** the normal of the vertex (defaut: 0,1,0) */
  4143. normal: Vector3;
  4144. /**
  4145. * Creates a PositionNormalVertex
  4146. * @param position the position of the vertex (defaut: 0,0,0)
  4147. * @param normal the normal of the vertex (defaut: 0,1,0)
  4148. */
  4149. constructor(
  4150. /** the position of the vertex (defaut: 0,0,0) */
  4151. position?: Vector3,
  4152. /** the normal of the vertex (defaut: 0,1,0) */
  4153. normal?: Vector3);
  4154. /**
  4155. * Clones the PositionNormalVertex
  4156. * @returns the cloned PositionNormalVertex
  4157. */
  4158. clone(): PositionNormalVertex;
  4159. }
  4160. /**
  4161. * Contains position, normal and uv vectors for a vertex
  4162. */
  4163. export class PositionNormalTextureVertex {
  4164. /** the position of the vertex (defaut: 0,0,0) */
  4165. position: Vector3;
  4166. /** the normal of the vertex (defaut: 0,1,0) */
  4167. normal: Vector3;
  4168. /** the uv of the vertex (default: 0,0) */
  4169. uv: Vector2;
  4170. /**
  4171. * Creates a PositionNormalTextureVertex
  4172. * @param position the position of the vertex (defaut: 0,0,0)
  4173. * @param normal the normal of the vertex (defaut: 0,1,0)
  4174. * @param uv the uv of the vertex (default: 0,0)
  4175. */
  4176. constructor(
  4177. /** the position of the vertex (defaut: 0,0,0) */
  4178. position?: Vector3,
  4179. /** the normal of the vertex (defaut: 0,1,0) */
  4180. normal?: Vector3,
  4181. /** the uv of the vertex (default: 0,0) */
  4182. uv?: Vector2);
  4183. /**
  4184. * Clones the PositionNormalTextureVertex
  4185. * @returns the cloned PositionNormalTextureVertex
  4186. */
  4187. clone(): PositionNormalTextureVertex;
  4188. }
  4189. /**
  4190. * @hidden
  4191. */
  4192. export class Tmp {
  4193. static Color3: Color3[];
  4194. static Color4: Color4[];
  4195. static Vector2: Vector2[];
  4196. static Vector3: Vector3[];
  4197. static Vector4: Vector4[];
  4198. static Quaternion: Quaternion[];
  4199. static Matrix: Matrix[];
  4200. }
  4201. }
  4202. declare module "babylonjs/Offline/IOfflineProvider" {
  4203. /**
  4204. * Class used to enable access to offline support
  4205. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4206. */
  4207. export interface IOfflineProvider {
  4208. /**
  4209. * Gets a boolean indicating if scene must be saved in the database
  4210. */
  4211. enableSceneOffline: boolean;
  4212. /**
  4213. * Gets a boolean indicating if textures must be saved in the database
  4214. */
  4215. enableTexturesOffline: boolean;
  4216. /**
  4217. * Open the offline support and make it available
  4218. * @param successCallback defines the callback to call on success
  4219. * @param errorCallback defines the callback to call on error
  4220. */
  4221. open(successCallback: () => void, errorCallback: () => void): void;
  4222. /**
  4223. * Loads an image from the offline support
  4224. * @param url defines the url to load from
  4225. * @param image defines the target DOM image
  4226. */
  4227. loadImage(url: string, image: HTMLImageElement): void;
  4228. /**
  4229. * Loads a file from offline support
  4230. * @param url defines the URL to load from
  4231. * @param sceneLoaded defines a callback to call on success
  4232. * @param progressCallBack defines a callback to call when progress changed
  4233. * @param errorCallback defines a callback to call on error
  4234. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4235. */
  4236. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4237. }
  4238. }
  4239. declare module "babylonjs/Misc/observable" {
  4240. import { Nullable } from "babylonjs/types";
  4241. /**
  4242. * A class serves as a medium between the observable and its observers
  4243. */
  4244. export class EventState {
  4245. /**
  4246. * Create a new EventState
  4247. * @param mask defines the mask associated with this state
  4248. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4249. * @param target defines the original target of the state
  4250. * @param currentTarget defines the current target of the state
  4251. */
  4252. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4253. /**
  4254. * Initialize the current event state
  4255. * @param mask defines the mask associated with this state
  4256. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4257. * @param target defines the original target of the state
  4258. * @param currentTarget defines the current target of the state
  4259. * @returns the current event state
  4260. */
  4261. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4262. /**
  4263. * An Observer can set this property to true to prevent subsequent observers of being notified
  4264. */
  4265. skipNextObservers: boolean;
  4266. /**
  4267. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4268. */
  4269. mask: number;
  4270. /**
  4271. * The object that originally notified the event
  4272. */
  4273. target?: any;
  4274. /**
  4275. * The current object in the bubbling phase
  4276. */
  4277. currentTarget?: any;
  4278. /**
  4279. * This will be populated with the return value of the last function that was executed.
  4280. * If it is the first function in the callback chain it will be the event data.
  4281. */
  4282. lastReturnValue?: any;
  4283. }
  4284. /**
  4285. * Represent an Observer registered to a given Observable object.
  4286. */
  4287. export class Observer<T> {
  4288. /**
  4289. * Defines the callback to call when the observer is notified
  4290. */
  4291. callback: (eventData: T, eventState: EventState) => void;
  4292. /**
  4293. * Defines the mask of the observer (used to filter notifications)
  4294. */
  4295. mask: number;
  4296. /**
  4297. * Defines the current scope used to restore the JS context
  4298. */
  4299. scope: any;
  4300. /** @hidden */
  4301. _willBeUnregistered: boolean;
  4302. /**
  4303. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4304. */
  4305. unregisterOnNextCall: boolean;
  4306. /**
  4307. * Creates a new observer
  4308. * @param callback defines the callback to call when the observer is notified
  4309. * @param mask defines the mask of the observer (used to filter notifications)
  4310. * @param scope defines the current scope used to restore the JS context
  4311. */
  4312. constructor(
  4313. /**
  4314. * Defines the callback to call when the observer is notified
  4315. */
  4316. callback: (eventData: T, eventState: EventState) => void,
  4317. /**
  4318. * Defines the mask of the observer (used to filter notifications)
  4319. */
  4320. mask: number,
  4321. /**
  4322. * Defines the current scope used to restore the JS context
  4323. */
  4324. scope?: any);
  4325. }
  4326. /**
  4327. * Represent a list of observers registered to multiple Observables object.
  4328. */
  4329. export class MultiObserver<T> {
  4330. private _observers;
  4331. private _observables;
  4332. /**
  4333. * Release associated resources
  4334. */
  4335. dispose(): void;
  4336. /**
  4337. * Raise a callback when one of the observable will notify
  4338. * @param observables defines a list of observables to watch
  4339. * @param callback defines the callback to call on notification
  4340. * @param mask defines the mask used to filter notifications
  4341. * @param scope defines the current scope used to restore the JS context
  4342. * @returns the new MultiObserver
  4343. */
  4344. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4345. }
  4346. /**
  4347. * The Observable class is a simple implementation of the Observable pattern.
  4348. *
  4349. * 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.
  4350. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4351. * 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).
  4352. * 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.
  4353. */
  4354. export class Observable<T> {
  4355. private _observers;
  4356. private _eventState;
  4357. private _onObserverAdded;
  4358. /**
  4359. * Gets the list of observers
  4360. */
  4361. readonly observers: Array<Observer<T>>;
  4362. /**
  4363. * Creates a new observable
  4364. * @param onObserverAdded defines a callback to call when a new observer is added
  4365. */
  4366. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4367. /**
  4368. * Create a new Observer with the specified callback
  4369. * @param callback the callback that will be executed for that Observer
  4370. * @param mask the mask used to filter observers
  4371. * @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.
  4372. * @param scope optional scope for the callback to be called from
  4373. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4374. * @returns the new observer created for the callback
  4375. */
  4376. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4377. /**
  4378. * Create a new Observer with the specified callback and unregisters after the next notification
  4379. * @param callback the callback that will be executed for that Observer
  4380. * @returns the new observer created for the callback
  4381. */
  4382. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4383. /**
  4384. * Remove an Observer from the Observable object
  4385. * @param observer the instance of the Observer to remove
  4386. * @returns false if it doesn't belong to this Observable
  4387. */
  4388. remove(observer: Nullable<Observer<T>>): boolean;
  4389. /**
  4390. * Remove a callback from the Observable object
  4391. * @param callback the callback to remove
  4392. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4393. * @returns false if it doesn't belong to this Observable
  4394. */
  4395. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4396. private _deferUnregister;
  4397. private _remove;
  4398. /**
  4399. * Moves the observable to the top of the observer list making it get called first when notified
  4400. * @param observer the observer to move
  4401. */
  4402. makeObserverTopPriority(observer: Observer<T>): void;
  4403. /**
  4404. * Moves the observable to the bottom of the observer list making it get called last when notified
  4405. * @param observer the observer to move
  4406. */
  4407. makeObserverBottomPriority(observer: Observer<T>): void;
  4408. /**
  4409. * Notify all Observers by calling their respective callback with the given data
  4410. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4411. * @param eventData defines the data to send to all observers
  4412. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4413. * @param target defines the original target of the state
  4414. * @param currentTarget defines the current target of the state
  4415. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4416. */
  4417. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4418. /**
  4419. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4420. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4421. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4422. * and it is crucial that all callbacks will be executed.
  4423. * The order of the callbacks is kept, callbacks are not executed parallel.
  4424. *
  4425. * @param eventData The data to be sent to each callback
  4426. * @param mask is used to filter observers defaults to -1
  4427. * @param target defines the callback target (see EventState)
  4428. * @param currentTarget defines he current object in the bubbling phase
  4429. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4430. */
  4431. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4432. /**
  4433. * Notify a specific observer
  4434. * @param observer defines the observer to notify
  4435. * @param eventData defines the data to be sent to each callback
  4436. * @param mask is used to filter observers defaults to -1
  4437. */
  4438. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4439. /**
  4440. * Gets a boolean indicating if the observable has at least one observer
  4441. * @returns true is the Observable has at least one Observer registered
  4442. */
  4443. hasObservers(): boolean;
  4444. /**
  4445. * Clear the list of observers
  4446. */
  4447. clear(): void;
  4448. /**
  4449. * Clone the current observable
  4450. * @returns a new observable
  4451. */
  4452. clone(): Observable<T>;
  4453. /**
  4454. * Does this observable handles observer registered with a given mask
  4455. * @param mask defines the mask to be tested
  4456. * @return whether or not one observer registered with the given mask is handeled
  4457. **/
  4458. hasSpecificMask(mask?: number): boolean;
  4459. }
  4460. }
  4461. declare module "babylonjs/Misc/filesInputStore" {
  4462. /**
  4463. * Class used to help managing file picking and drag'n'drop
  4464. * File Storage
  4465. */
  4466. export class FilesInputStore {
  4467. /**
  4468. * List of files ready to be loaded
  4469. */
  4470. static FilesToLoad: {
  4471. [key: string]: File;
  4472. };
  4473. }
  4474. }
  4475. declare module "babylonjs/Engines/constants" {
  4476. /** Defines the cross module used constants to avoid circular dependncies */
  4477. export class Constants {
  4478. /** Defines that alpha blending is disabled */
  4479. static readonly ALPHA_DISABLE: number;
  4480. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4481. static readonly ALPHA_ADD: number;
  4482. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4483. static readonly ALPHA_COMBINE: number;
  4484. /** Defines that alpha blending to DEST - SRC * DEST */
  4485. static readonly ALPHA_SUBTRACT: number;
  4486. /** Defines that alpha blending to SRC * DEST */
  4487. static readonly ALPHA_MULTIPLY: number;
  4488. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4489. static readonly ALPHA_MAXIMIZED: number;
  4490. /** Defines that alpha blending to SRC + DEST */
  4491. static readonly ALPHA_ONEONE: number;
  4492. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4493. static readonly ALPHA_PREMULTIPLIED: number;
  4494. /**
  4495. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4496. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4497. */
  4498. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4499. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4500. static readonly ALPHA_INTERPOLATE: number;
  4501. /**
  4502. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4503. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4504. */
  4505. static readonly ALPHA_SCREENMODE: number;
  4506. /** Defines that the ressource is not delayed*/
  4507. static readonly DELAYLOADSTATE_NONE: number;
  4508. /** Defines that the ressource was successfully delay loaded */
  4509. static readonly DELAYLOADSTATE_LOADED: number;
  4510. /** Defines that the ressource is currently delay loading */
  4511. static readonly DELAYLOADSTATE_LOADING: number;
  4512. /** Defines that the ressource is delayed and has not started loading */
  4513. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4515. static readonly NEVER: number;
  4516. /** 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 */
  4517. static readonly ALWAYS: number;
  4518. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4519. static readonly LESS: number;
  4520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4521. static readonly EQUAL: number;
  4522. /** 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 */
  4523. static readonly LEQUAL: number;
  4524. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4525. static readonly GREATER: number;
  4526. /** 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 */
  4527. static readonly GEQUAL: number;
  4528. /** 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 */
  4529. static readonly NOTEQUAL: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be kept */
  4531. static readonly KEEP: number;
  4532. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4533. static readonly REPLACE: number;
  4534. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4535. static readonly INCR: number;
  4536. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4537. static readonly DECR: number;
  4538. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4539. static readonly INVERT: number;
  4540. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4541. static readonly INCR_WRAP: number;
  4542. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4543. static readonly DECR_WRAP: number;
  4544. /** Texture is not repeating outside of 0..1 UVs */
  4545. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4546. /** Texture is repeating outside of 0..1 UVs */
  4547. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4548. /** Texture is repeating and mirrored */
  4549. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4550. /** ALPHA */
  4551. static readonly TEXTUREFORMAT_ALPHA: number;
  4552. /** LUMINANCE */
  4553. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4554. /** LUMINANCE_ALPHA */
  4555. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4556. /** RGB */
  4557. static readonly TEXTUREFORMAT_RGB: number;
  4558. /** RGBA */
  4559. static readonly TEXTUREFORMAT_RGBA: number;
  4560. /** RED */
  4561. static readonly TEXTUREFORMAT_RED: number;
  4562. /** RED (2nd reference) */
  4563. static readonly TEXTUREFORMAT_R: number;
  4564. /** RG */
  4565. static readonly TEXTUREFORMAT_RG: number;
  4566. /** RED_INTEGER */
  4567. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4568. /** RED_INTEGER (2nd reference) */
  4569. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4570. /** RG_INTEGER */
  4571. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4572. /** RGB_INTEGER */
  4573. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4574. /** RGBA_INTEGER */
  4575. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4576. /** UNSIGNED_BYTE */
  4577. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4578. /** UNSIGNED_BYTE (2nd reference) */
  4579. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4580. /** FLOAT */
  4581. static readonly TEXTURETYPE_FLOAT: number;
  4582. /** HALF_FLOAT */
  4583. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4584. /** BYTE */
  4585. static readonly TEXTURETYPE_BYTE: number;
  4586. /** SHORT */
  4587. static readonly TEXTURETYPE_SHORT: number;
  4588. /** UNSIGNED_SHORT */
  4589. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4590. /** INT */
  4591. static readonly TEXTURETYPE_INT: number;
  4592. /** UNSIGNED_INT */
  4593. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4594. /** UNSIGNED_SHORT_4_4_4_4 */
  4595. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4596. /** UNSIGNED_SHORT_5_5_5_1 */
  4597. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4598. /** UNSIGNED_SHORT_5_6_5 */
  4599. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4600. /** UNSIGNED_INT_2_10_10_10_REV */
  4601. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4602. /** UNSIGNED_INT_24_8 */
  4603. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4604. /** UNSIGNED_INT_10F_11F_11F_REV */
  4605. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4606. /** UNSIGNED_INT_5_9_9_9_REV */
  4607. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4608. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4609. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4610. /** nearest is mag = nearest and min = nearest and mip = linear */
  4611. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4612. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4613. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4614. /** Trilinear is mag = linear and min = linear and mip = linear */
  4615. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4616. /** nearest is mag = nearest and min = nearest and mip = linear */
  4617. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4618. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4619. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4620. /** Trilinear is mag = linear and min = linear and mip = linear */
  4621. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4622. /** mag = nearest and min = nearest and mip = nearest */
  4623. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4624. /** mag = nearest and min = linear and mip = nearest */
  4625. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4626. /** mag = nearest and min = linear and mip = linear */
  4627. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4628. /** mag = nearest and min = linear and mip = none */
  4629. static readonly TEXTURE_NEAREST_LINEAR: number;
  4630. /** mag = nearest and min = nearest and mip = none */
  4631. static readonly TEXTURE_NEAREST_NEAREST: number;
  4632. /** mag = linear and min = nearest and mip = nearest */
  4633. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4634. /** mag = linear and min = nearest and mip = linear */
  4635. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4636. /** mag = linear and min = linear and mip = none */
  4637. static readonly TEXTURE_LINEAR_LINEAR: number;
  4638. /** mag = linear and min = nearest and mip = none */
  4639. static readonly TEXTURE_LINEAR_NEAREST: number;
  4640. /** Explicit coordinates mode */
  4641. static readonly TEXTURE_EXPLICIT_MODE: number;
  4642. /** Spherical coordinates mode */
  4643. static readonly TEXTURE_SPHERICAL_MODE: number;
  4644. /** Planar coordinates mode */
  4645. static readonly TEXTURE_PLANAR_MODE: number;
  4646. /** Cubic coordinates mode */
  4647. static readonly TEXTURE_CUBIC_MODE: number;
  4648. /** Projection coordinates mode */
  4649. static readonly TEXTURE_PROJECTION_MODE: number;
  4650. /** Skybox coordinates mode */
  4651. static readonly TEXTURE_SKYBOX_MODE: number;
  4652. /** Inverse Cubic coordinates mode */
  4653. static readonly TEXTURE_INVCUBIC_MODE: number;
  4654. /** Equirectangular coordinates mode */
  4655. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4656. /** Equirectangular Fixed coordinates mode */
  4657. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4658. /** Equirectangular Fixed Mirrored coordinates mode */
  4659. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4660. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4661. static readonly SCALEMODE_FLOOR: number;
  4662. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4663. static readonly SCALEMODE_NEAREST: number;
  4664. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4665. static readonly SCALEMODE_CEILING: number;
  4666. /**
  4667. * The dirty texture flag value
  4668. */
  4669. static readonly MATERIAL_TextureDirtyFlag: number;
  4670. /**
  4671. * The dirty light flag value
  4672. */
  4673. static readonly MATERIAL_LightDirtyFlag: number;
  4674. /**
  4675. * The dirty fresnel flag value
  4676. */
  4677. static readonly MATERIAL_FresnelDirtyFlag: number;
  4678. /**
  4679. * The dirty attribute flag value
  4680. */
  4681. static readonly MATERIAL_AttributesDirtyFlag: number;
  4682. /**
  4683. * The dirty misc flag value
  4684. */
  4685. static readonly MATERIAL_MiscDirtyFlag: number;
  4686. /**
  4687. * The all dirty flag value
  4688. */
  4689. static readonly MATERIAL_AllDirtyFlag: number;
  4690. /**
  4691. * Returns the triangle fill mode
  4692. */
  4693. static readonly MATERIAL_TriangleFillMode: number;
  4694. /**
  4695. * Returns the wireframe mode
  4696. */
  4697. static readonly MATERIAL_WireFrameFillMode: number;
  4698. /**
  4699. * Returns the point fill mode
  4700. */
  4701. static readonly MATERIAL_PointFillMode: number;
  4702. /**
  4703. * Returns the point list draw mode
  4704. */
  4705. static readonly MATERIAL_PointListDrawMode: number;
  4706. /**
  4707. * Returns the line list draw mode
  4708. */
  4709. static readonly MATERIAL_LineListDrawMode: number;
  4710. /**
  4711. * Returns the line loop draw mode
  4712. */
  4713. static readonly MATERIAL_LineLoopDrawMode: number;
  4714. /**
  4715. * Returns the line strip draw mode
  4716. */
  4717. static readonly MATERIAL_LineStripDrawMode: number;
  4718. /**
  4719. * Returns the triangle strip draw mode
  4720. */
  4721. static readonly MATERIAL_TriangleStripDrawMode: number;
  4722. /**
  4723. * Returns the triangle fan draw mode
  4724. */
  4725. static readonly MATERIAL_TriangleFanDrawMode: number;
  4726. /**
  4727. * Stores the clock-wise side orientation
  4728. */
  4729. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4730. /**
  4731. * Stores the counter clock-wise side orientation
  4732. */
  4733. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4734. /**
  4735. * Nothing
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_NothingTrigger: number;
  4739. /**
  4740. * On pick
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnPickTrigger: number;
  4744. /**
  4745. * On left pick
  4746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4747. */
  4748. static readonly ACTION_OnLeftPickTrigger: number;
  4749. /**
  4750. * On right pick
  4751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4752. */
  4753. static readonly ACTION_OnRightPickTrigger: number;
  4754. /**
  4755. * On center pick
  4756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4757. */
  4758. static readonly ACTION_OnCenterPickTrigger: number;
  4759. /**
  4760. * On pick down
  4761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4762. */
  4763. static readonly ACTION_OnPickDownTrigger: number;
  4764. /**
  4765. * On double pick
  4766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4767. */
  4768. static readonly ACTION_OnDoublePickTrigger: number;
  4769. /**
  4770. * On pick up
  4771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4772. */
  4773. static readonly ACTION_OnPickUpTrigger: number;
  4774. /**
  4775. * On pick out.
  4776. * This trigger will only be raised if you also declared a OnPickDown
  4777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4778. */
  4779. static readonly ACTION_OnPickOutTrigger: number;
  4780. /**
  4781. * On long press
  4782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4783. */
  4784. static readonly ACTION_OnLongPressTrigger: number;
  4785. /**
  4786. * On pointer over
  4787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4788. */
  4789. static readonly ACTION_OnPointerOverTrigger: number;
  4790. /**
  4791. * On pointer out
  4792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4793. */
  4794. static readonly ACTION_OnPointerOutTrigger: number;
  4795. /**
  4796. * On every frame
  4797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4798. */
  4799. static readonly ACTION_OnEveryFrameTrigger: number;
  4800. /**
  4801. * On intersection enter
  4802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4803. */
  4804. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4805. /**
  4806. * On intersection exit
  4807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4808. */
  4809. static readonly ACTION_OnIntersectionExitTrigger: number;
  4810. /**
  4811. * On key down
  4812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4813. */
  4814. static readonly ACTION_OnKeyDownTrigger: number;
  4815. /**
  4816. * On key up
  4817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4818. */
  4819. static readonly ACTION_OnKeyUpTrigger: number;
  4820. /**
  4821. * Billboard mode will only apply to Y axis
  4822. */
  4823. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4824. /**
  4825. * Billboard mode will apply to all axes
  4826. */
  4827. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4828. /**
  4829. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4830. */
  4831. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4832. /**
  4833. * Gets or sets base Assets URL
  4834. */
  4835. static PARTICLES_BaseAssetsUrl: string;
  4836. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4837. * Test order :
  4838. * Is the bounding sphere outside the frustum ?
  4839. * If not, are the bounding box vertices outside the frustum ?
  4840. * It not, then the cullable object is in the frustum.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4843. /** Culling strategy : Bounding Sphere Only.
  4844. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4845. * It's also less accurate than the standard because some not visible objects can still be selected.
  4846. * Test : is the bounding sphere outside the frustum ?
  4847. * If not, then the cullable object is in the frustum.
  4848. */
  4849. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4850. /** Culling strategy : Optimistic Inclusion.
  4851. * This in an inclusion test first, then the standard exclusion test.
  4852. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4853. * 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.
  4854. * Anyway, it's as accurate as the standard strategy.
  4855. * Test :
  4856. * Is the cullable object bounding sphere center in the frustum ?
  4857. * If not, apply the default culling strategy.
  4858. */
  4859. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4860. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4861. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4862. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4863. * 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.
  4864. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4865. * Test :
  4866. * Is the cullable object bounding sphere center in the frustum ?
  4867. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4868. */
  4869. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4870. /**
  4871. * No logging while loading
  4872. */
  4873. static readonly SCENELOADER_NO_LOGGING: number;
  4874. /**
  4875. * Minimal logging while loading
  4876. */
  4877. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4878. /**
  4879. * Summary logging while loading
  4880. */
  4881. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4882. /**
  4883. * Detailled logging while loading
  4884. */
  4885. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4886. }
  4887. }
  4888. declare module "babylonjs/Misc/domManagement" {
  4889. /**
  4890. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4891. * Babylon.js
  4892. */
  4893. export class DomManagement {
  4894. /**
  4895. * Checks if the window object exists
  4896. * @returns true if the window object exists
  4897. */
  4898. static IsWindowObjectExist(): boolean;
  4899. /**
  4900. * Extracts text content from a DOM element hierarchy
  4901. * @param element defines the root element
  4902. * @returns a string
  4903. */
  4904. static GetDOMTextContent(element: HTMLElement): string;
  4905. }
  4906. }
  4907. declare module "babylonjs/Misc/logger" {
  4908. /**
  4909. * Logger used througouht the application to allow configuration of
  4910. * the log level required for the messages.
  4911. */
  4912. export class Logger {
  4913. /**
  4914. * No log
  4915. */
  4916. static readonly NoneLogLevel: number;
  4917. /**
  4918. * Only message logs
  4919. */
  4920. static readonly MessageLogLevel: number;
  4921. /**
  4922. * Only warning logs
  4923. */
  4924. static readonly WarningLogLevel: number;
  4925. /**
  4926. * Only error logs
  4927. */
  4928. static readonly ErrorLogLevel: number;
  4929. /**
  4930. * All logs
  4931. */
  4932. static readonly AllLogLevel: number;
  4933. private static _LogCache;
  4934. /**
  4935. * Gets a value indicating the number of loading errors
  4936. * @ignorenaming
  4937. */
  4938. static errorsCount: number;
  4939. /**
  4940. * Callback called when a new log is added
  4941. */
  4942. static OnNewCacheEntry: (entry: string) => void;
  4943. private static _AddLogEntry;
  4944. private static _FormatMessage;
  4945. private static _LogDisabled;
  4946. private static _LogEnabled;
  4947. private static _WarnDisabled;
  4948. private static _WarnEnabled;
  4949. private static _ErrorDisabled;
  4950. private static _ErrorEnabled;
  4951. /**
  4952. * Log a message to the console
  4953. */
  4954. static Log: (message: string) => void;
  4955. /**
  4956. * Write a warning message to the console
  4957. */
  4958. static Warn: (message: string) => void;
  4959. /**
  4960. * Write an error message to the console
  4961. */
  4962. static Error: (message: string) => void;
  4963. /**
  4964. * Gets current log cache (list of logs)
  4965. */
  4966. static readonly LogCache: string;
  4967. /**
  4968. * Clears the log cache
  4969. */
  4970. static ClearLogCache(): void;
  4971. /**
  4972. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4973. */
  4974. static LogLevels: number;
  4975. }
  4976. }
  4977. declare module "babylonjs/Misc/typeStore" {
  4978. /** @hidden */
  4979. export class _TypeStore {
  4980. /** @hidden */
  4981. static RegisteredTypes: {
  4982. [key: string]: Object;
  4983. };
  4984. /** @hidden */
  4985. static GetClass(fqdn: string): any;
  4986. }
  4987. }
  4988. declare module "babylonjs/Misc/deepCopier" {
  4989. /**
  4990. * Class containing a set of static utilities functions for deep copy.
  4991. */
  4992. export class DeepCopier {
  4993. /**
  4994. * Tries to copy an object by duplicating every property
  4995. * @param source defines the source object
  4996. * @param destination defines the target object
  4997. * @param doNotCopyList defines a list of properties to avoid
  4998. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4999. */
  5000. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  5001. }
  5002. }
  5003. declare module "babylonjs/Misc/precisionDate" {
  5004. /**
  5005. * Class containing a set of static utilities functions for precision date
  5006. */
  5007. export class PrecisionDate {
  5008. /**
  5009. * Gets either window.performance.now() if supported or Date.now() else
  5010. */
  5011. static readonly Now: number;
  5012. }
  5013. }
  5014. declare module "babylonjs/Misc/devTools" {
  5015. /** @hidden */
  5016. export class _DevTools {
  5017. static WarnImport(name: string): string;
  5018. }
  5019. }
  5020. declare module "babylonjs/Misc/webRequest" {
  5021. /**
  5022. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5023. */
  5024. export class WebRequest {
  5025. private _xhr;
  5026. /**
  5027. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5028. * i.e. when loading files, where the server/service expects an Authorization header
  5029. */
  5030. static CustomRequestHeaders: {
  5031. [key: string]: string;
  5032. };
  5033. /**
  5034. * Add callback functions in this array to update all the requests before they get sent to the network
  5035. */
  5036. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  5037. private _injectCustomRequestHeaders;
  5038. /**
  5039. * Gets or sets a function to be called when loading progress changes
  5040. */
  5041. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5042. /**
  5043. * Returns client's state
  5044. */
  5045. readonly readyState: number;
  5046. /**
  5047. * Returns client's status
  5048. */
  5049. readonly status: number;
  5050. /**
  5051. * Returns client's status as a text
  5052. */
  5053. readonly statusText: string;
  5054. /**
  5055. * Returns client's response
  5056. */
  5057. readonly response: any;
  5058. /**
  5059. * Returns client's response url
  5060. */
  5061. readonly responseURL: string;
  5062. /**
  5063. * Returns client's response as text
  5064. */
  5065. readonly responseText: string;
  5066. /**
  5067. * Gets or sets the expected response type
  5068. */
  5069. responseType: XMLHttpRequestResponseType;
  5070. /** @hidden */
  5071. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5072. /** @hidden */
  5073. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5074. /**
  5075. * Cancels any network activity
  5076. */
  5077. abort(): void;
  5078. /**
  5079. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5080. * @param body defines an optional request body
  5081. */
  5082. send(body?: Document | BodyInit | null): void;
  5083. /**
  5084. * Sets the request method, request URL
  5085. * @param method defines the method to use (GET, POST, etc..)
  5086. * @param url defines the url to connect with
  5087. */
  5088. open(method: string, url: string): void;
  5089. }
  5090. }
  5091. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5092. /**
  5093. * Class used to evalaute queries containing `and` and `or` operators
  5094. */
  5095. export class AndOrNotEvaluator {
  5096. /**
  5097. * Evaluate a query
  5098. * @param query defines the query to evaluate
  5099. * @param evaluateCallback defines the callback used to filter result
  5100. * @returns true if the query matches
  5101. */
  5102. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5103. private static _HandleParenthesisContent;
  5104. private static _SimplifyNegation;
  5105. }
  5106. }
  5107. declare module "babylonjs/Misc/tags" {
  5108. /**
  5109. * Class used to store custom tags
  5110. */
  5111. export class Tags {
  5112. /**
  5113. * Adds support for tags on the given object
  5114. * @param obj defines the object to use
  5115. */
  5116. static EnableFor(obj: any): void;
  5117. /**
  5118. * Removes tags support
  5119. * @param obj defines the object to use
  5120. */
  5121. static DisableFor(obj: any): void;
  5122. /**
  5123. * Gets a boolean indicating if the given object has tags
  5124. * @param obj defines the object to use
  5125. * @returns a boolean
  5126. */
  5127. static HasTags(obj: any): boolean;
  5128. /**
  5129. * Gets the tags available on a given object
  5130. * @param obj defines the object to use
  5131. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5132. * @returns the tags
  5133. */
  5134. static GetTags(obj: any, asString?: boolean): any;
  5135. /**
  5136. * Adds tags to an object
  5137. * @param obj defines the object to use
  5138. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5139. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5140. */
  5141. static AddTagsTo(obj: any, tagsString: string): void;
  5142. /**
  5143. * @hidden
  5144. */
  5145. static _AddTagTo(obj: any, tag: string): void;
  5146. /**
  5147. * Removes specific tags from a specific object
  5148. * @param obj defines the object to use
  5149. * @param tagsString defines the tags to remove
  5150. */
  5151. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5152. /**
  5153. * @hidden
  5154. */
  5155. static _RemoveTagFrom(obj: any, tag: string): void;
  5156. /**
  5157. * Defines if tags hosted on an object match a given query
  5158. * @param obj defines the object to use
  5159. * @param tagsQuery defines the tag query
  5160. * @returns a boolean
  5161. */
  5162. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5163. }
  5164. }
  5165. declare module "babylonjs/Materials/materialDefines" {
  5166. /**
  5167. * Manages the defines for the Material
  5168. */
  5169. export class MaterialDefines {
  5170. /** @hidden */
  5171. protected _keys: string[];
  5172. private _isDirty;
  5173. /** @hidden */
  5174. _renderId: number;
  5175. /** @hidden */
  5176. _areLightsDirty: boolean;
  5177. /** @hidden */
  5178. _areAttributesDirty: boolean;
  5179. /** @hidden */
  5180. _areTexturesDirty: boolean;
  5181. /** @hidden */
  5182. _areFresnelDirty: boolean;
  5183. /** @hidden */
  5184. _areMiscDirty: boolean;
  5185. /** @hidden */
  5186. _areImageProcessingDirty: boolean;
  5187. /** @hidden */
  5188. _normals: boolean;
  5189. /** @hidden */
  5190. _uvs: boolean;
  5191. /** @hidden */
  5192. _needNormals: boolean;
  5193. /** @hidden */
  5194. _needUVs: boolean;
  5195. [id: string]: any;
  5196. /**
  5197. * Specifies if the material needs to be re-calculated
  5198. */
  5199. readonly isDirty: boolean;
  5200. /**
  5201. * Marks the material to indicate that it has been re-calculated
  5202. */
  5203. markAsProcessed(): void;
  5204. /**
  5205. * Marks the material to indicate that it needs to be re-calculated
  5206. */
  5207. markAsUnprocessed(): void;
  5208. /**
  5209. * Marks the material to indicate all of its defines need to be re-calculated
  5210. */
  5211. markAllAsDirty(): void;
  5212. /**
  5213. * Marks the material to indicate that image processing needs to be re-calculated
  5214. */
  5215. markAsImageProcessingDirty(): void;
  5216. /**
  5217. * Marks the material to indicate the lights need to be re-calculated
  5218. */
  5219. markAsLightDirty(): void;
  5220. /**
  5221. * Marks the attribute state as changed
  5222. */
  5223. markAsAttributesDirty(): void;
  5224. /**
  5225. * Marks the texture state as changed
  5226. */
  5227. markAsTexturesDirty(): void;
  5228. /**
  5229. * Marks the fresnel state as changed
  5230. */
  5231. markAsFresnelDirty(): void;
  5232. /**
  5233. * Marks the misc state as changed
  5234. */
  5235. markAsMiscDirty(): void;
  5236. /**
  5237. * Rebuilds the material defines
  5238. */
  5239. rebuild(): void;
  5240. /**
  5241. * Specifies if two material defines are equal
  5242. * @param other - A material define instance to compare to
  5243. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5244. */
  5245. isEqual(other: MaterialDefines): boolean;
  5246. /**
  5247. * Clones this instance's defines to another instance
  5248. * @param other - material defines to clone values to
  5249. */
  5250. cloneTo(other: MaterialDefines): void;
  5251. /**
  5252. * Resets the material define values
  5253. */
  5254. reset(): void;
  5255. /**
  5256. * Converts the material define values to a string
  5257. * @returns - String of material define information
  5258. */
  5259. toString(): string;
  5260. }
  5261. }
  5262. declare module "babylonjs/Engines/IPipelineContext" {
  5263. /**
  5264. * Class used to store and describe the pipeline context associated with an effect
  5265. */
  5266. export interface IPipelineContext {
  5267. /**
  5268. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5269. */
  5270. isAsync: boolean;
  5271. /**
  5272. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5273. */
  5274. isReady: boolean;
  5275. /** @hidden */
  5276. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5277. }
  5278. }
  5279. declare module "babylonjs/Meshes/dataBuffer" {
  5280. /**
  5281. * Class used to store gfx data (like WebGLBuffer)
  5282. */
  5283. export class DataBuffer {
  5284. /**
  5285. * Gets or sets the number of objects referencing this buffer
  5286. */
  5287. references: number;
  5288. /** Gets or sets the size of the underlying buffer */
  5289. capacity: number;
  5290. /**
  5291. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5292. */
  5293. is32Bits: boolean;
  5294. /**
  5295. * Gets the underlying buffer
  5296. */
  5297. readonly underlyingResource: any;
  5298. }
  5299. }
  5300. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  5301. /** @hidden */
  5302. export interface IShaderProcessor {
  5303. attributeProcessor?: (attribute: string) => string;
  5304. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5305. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5306. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5307. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5308. lineProcessor?: (line: string, isFragment: boolean) => string;
  5309. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5310. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5311. }
  5312. }
  5313. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  5314. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  5315. /** @hidden */
  5316. export interface ProcessingOptions {
  5317. defines: string[];
  5318. indexParameters: any;
  5319. isFragment: boolean;
  5320. shouldUseHighPrecisionShader: boolean;
  5321. supportsUniformBuffers: boolean;
  5322. shadersRepository: string;
  5323. includesShadersStore: {
  5324. [key: string]: string;
  5325. };
  5326. processor?: IShaderProcessor;
  5327. version: string;
  5328. platformName: string;
  5329. lookForClosingBracketForUniformBuffer?: boolean;
  5330. }
  5331. }
  5332. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  5333. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5334. /** @hidden */
  5335. export class ShaderCodeNode {
  5336. line: string;
  5337. children: ShaderCodeNode[];
  5338. additionalDefineKey?: string;
  5339. additionalDefineValue?: string;
  5340. isValid(preprocessors: {
  5341. [key: string]: string;
  5342. }): boolean;
  5343. process(preprocessors: {
  5344. [key: string]: string;
  5345. }, options: ProcessingOptions): string;
  5346. }
  5347. }
  5348. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  5349. /** @hidden */
  5350. export class ShaderCodeCursor {
  5351. private _lines;
  5352. lineIndex: number;
  5353. readonly currentLine: string;
  5354. readonly canRead: boolean;
  5355. lines: string[];
  5356. }
  5357. }
  5358. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  5359. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5360. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5361. /** @hidden */
  5362. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5363. process(preprocessors: {
  5364. [key: string]: string;
  5365. }, options: ProcessingOptions): string;
  5366. }
  5367. }
  5368. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  5369. /** @hidden */
  5370. export class ShaderDefineExpression {
  5371. isTrue(preprocessors: {
  5372. [key: string]: string;
  5373. }): boolean;
  5374. }
  5375. }
  5376. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  5377. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5378. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5379. /** @hidden */
  5380. export class ShaderCodeTestNode extends ShaderCodeNode {
  5381. testExpression: ShaderDefineExpression;
  5382. isValid(preprocessors: {
  5383. [key: string]: string;
  5384. }): boolean;
  5385. }
  5386. }
  5387. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  5388. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5389. /** @hidden */
  5390. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5391. define: string;
  5392. not: boolean;
  5393. constructor(define: string, not?: boolean);
  5394. isTrue(preprocessors: {
  5395. [key: string]: string;
  5396. }): boolean;
  5397. }
  5398. }
  5399. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  5400. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5401. /** @hidden */
  5402. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5403. leftOperand: ShaderDefineExpression;
  5404. rightOperand: ShaderDefineExpression;
  5405. isTrue(preprocessors: {
  5406. [key: string]: string;
  5407. }): boolean;
  5408. }
  5409. }
  5410. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  5411. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5412. /** @hidden */
  5413. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5414. leftOperand: ShaderDefineExpression;
  5415. rightOperand: ShaderDefineExpression;
  5416. isTrue(preprocessors: {
  5417. [key: string]: string;
  5418. }): boolean;
  5419. }
  5420. }
  5421. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  5422. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5423. /** @hidden */
  5424. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5425. define: string;
  5426. operand: string;
  5427. testValue: string;
  5428. constructor(define: string, operand: string, testValue: string);
  5429. isTrue(preprocessors: {
  5430. [key: string]: string;
  5431. }): boolean;
  5432. }
  5433. }
  5434. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5435. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5436. /** @hidden */
  5437. export class ShaderProcessor {
  5438. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5439. private static _ProcessPrecision;
  5440. private static _ExtractOperation;
  5441. private static _BuildSubExpression;
  5442. private static _BuildExpression;
  5443. private static _MoveCursorWithinIf;
  5444. private static _MoveCursor;
  5445. private static _EvaluatePreProcessors;
  5446. private static _PreparePreProcessors;
  5447. private static _ProcessShaderConversion;
  5448. private static _ProcessIncludes;
  5449. }
  5450. }
  5451. declare module "babylonjs/Misc/performanceMonitor" {
  5452. /**
  5453. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5454. */
  5455. export class PerformanceMonitor {
  5456. private _enabled;
  5457. private _rollingFrameTime;
  5458. private _lastFrameTimeMs;
  5459. /**
  5460. * constructor
  5461. * @param frameSampleSize The number of samples required to saturate the sliding window
  5462. */
  5463. constructor(frameSampleSize?: number);
  5464. /**
  5465. * Samples current frame
  5466. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5467. */
  5468. sampleFrame(timeMs?: number): void;
  5469. /**
  5470. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5471. */
  5472. readonly averageFrameTime: number;
  5473. /**
  5474. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5475. */
  5476. readonly averageFrameTimeVariance: number;
  5477. /**
  5478. * Returns the frame time of the most recent frame
  5479. */
  5480. readonly instantaneousFrameTime: number;
  5481. /**
  5482. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5483. */
  5484. readonly averageFPS: number;
  5485. /**
  5486. * Returns the average framerate in frames per second using the most recent frame time
  5487. */
  5488. readonly instantaneousFPS: number;
  5489. /**
  5490. * Returns true if enough samples have been taken to completely fill the sliding window
  5491. */
  5492. readonly isSaturated: boolean;
  5493. /**
  5494. * Enables contributions to the sliding window sample set
  5495. */
  5496. enable(): void;
  5497. /**
  5498. * Disables contributions to the sliding window sample set
  5499. * Samples will not be interpolated over the disabled period
  5500. */
  5501. disable(): void;
  5502. /**
  5503. * Returns true if sampling is enabled
  5504. */
  5505. readonly isEnabled: boolean;
  5506. /**
  5507. * Resets performance monitor
  5508. */
  5509. reset(): void;
  5510. }
  5511. /**
  5512. * RollingAverage
  5513. *
  5514. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5515. */
  5516. export class RollingAverage {
  5517. /**
  5518. * Current average
  5519. */
  5520. average: number;
  5521. /**
  5522. * Current variance
  5523. */
  5524. variance: number;
  5525. protected _samples: Array<number>;
  5526. protected _sampleCount: number;
  5527. protected _pos: number;
  5528. protected _m2: number;
  5529. /**
  5530. * constructor
  5531. * @param length The number of samples required to saturate the sliding window
  5532. */
  5533. constructor(length: number);
  5534. /**
  5535. * Adds a sample to the sample set
  5536. * @param v The sample value
  5537. */
  5538. add(v: number): void;
  5539. /**
  5540. * Returns previously added values or null if outside of history or outside the sliding window domain
  5541. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5542. * @return Value previously recorded with add() or null if outside of range
  5543. */
  5544. history(i: number): number;
  5545. /**
  5546. * Returns true if enough samples have been taken to completely fill the sliding window
  5547. * @return true if sample-set saturated
  5548. */
  5549. isSaturated(): boolean;
  5550. /**
  5551. * Resets the rolling average (equivalent to 0 samples taken so far)
  5552. */
  5553. reset(): void;
  5554. /**
  5555. * Wraps a value around the sample range boundaries
  5556. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5557. * @return Wrapped position in sample range
  5558. */
  5559. protected _wrapPosition(i: number): number;
  5560. }
  5561. }
  5562. declare module "babylonjs/Misc/stringDictionary" {
  5563. import { Nullable } from "babylonjs/types";
  5564. /**
  5565. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5566. * The underlying implementation relies on an associative array to ensure the best performances.
  5567. * The value can be anything including 'null' but except 'undefined'
  5568. */
  5569. export class StringDictionary<T> {
  5570. /**
  5571. * This will clear this dictionary and copy the content from the 'source' one.
  5572. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5573. * @param source the dictionary to take the content from and copy to this dictionary
  5574. */
  5575. copyFrom(source: StringDictionary<T>): void;
  5576. /**
  5577. * Get a value based from its key
  5578. * @param key the given key to get the matching value from
  5579. * @return the value if found, otherwise undefined is returned
  5580. */
  5581. get(key: string): T | undefined;
  5582. /**
  5583. * Get a value from its key or add it if it doesn't exist.
  5584. * This method will ensure you that a given key/data will be present in the dictionary.
  5585. * @param key the given key to get the matching value from
  5586. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5587. * The factory will only be invoked if there's no data for the given key.
  5588. * @return the value corresponding to the key.
  5589. */
  5590. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5591. /**
  5592. * Get a value from its key if present in the dictionary otherwise add it
  5593. * @param key the key to get the value from
  5594. * @param val if there's no such key/value pair in the dictionary add it with this value
  5595. * @return the value corresponding to the key
  5596. */
  5597. getOrAdd(key: string, val: T): T;
  5598. /**
  5599. * Check if there's a given key in the dictionary
  5600. * @param key the key to check for
  5601. * @return true if the key is present, false otherwise
  5602. */
  5603. contains(key: string): boolean;
  5604. /**
  5605. * Add a new key and its corresponding value
  5606. * @param key the key to add
  5607. * @param value the value corresponding to the key
  5608. * @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
  5609. */
  5610. add(key: string, value: T): boolean;
  5611. /**
  5612. * Update a specific value associated to a key
  5613. * @param key defines the key to use
  5614. * @param value defines the value to store
  5615. * @returns true if the value was updated (or false if the key was not found)
  5616. */
  5617. set(key: string, value: T): boolean;
  5618. /**
  5619. * Get the element of the given key and remove it from the dictionary
  5620. * @param key defines the key to search
  5621. * @returns the value associated with the key or null if not found
  5622. */
  5623. getAndRemove(key: string): Nullable<T>;
  5624. /**
  5625. * Remove a key/value from the dictionary.
  5626. * @param key the key to remove
  5627. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5628. */
  5629. remove(key: string): boolean;
  5630. /**
  5631. * Clear the whole content of the dictionary
  5632. */
  5633. clear(): void;
  5634. /**
  5635. * Gets the current count
  5636. */
  5637. readonly count: number;
  5638. /**
  5639. * Execute a callback on each key/val of the dictionary.
  5640. * Note that you can remove any element in this dictionary in the callback implementation
  5641. * @param callback the callback to execute on a given key/value pair
  5642. */
  5643. forEach(callback: (key: string, val: T) => void): void;
  5644. /**
  5645. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5646. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5647. * Note that you can remove any element in this dictionary in the callback implementation
  5648. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5649. * @returns the first item
  5650. */
  5651. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5652. private _count;
  5653. private _data;
  5654. }
  5655. }
  5656. declare module "babylonjs/Misc/promise" {
  5657. /**
  5658. * Helper class that provides a small promise polyfill
  5659. */
  5660. export class PromisePolyfill {
  5661. /**
  5662. * Static function used to check if the polyfill is required
  5663. * If this is the case then the function will inject the polyfill to window.Promise
  5664. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5665. */
  5666. static Apply(force?: boolean): void;
  5667. }
  5668. }
  5669. declare module "babylonjs/Meshes/buffer" {
  5670. import { Nullable, DataArray } from "babylonjs/types";
  5671. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5672. /**
  5673. * Class used to store data that will be store in GPU memory
  5674. */
  5675. export class Buffer {
  5676. private _engine;
  5677. private _buffer;
  5678. /** @hidden */
  5679. _data: Nullable<DataArray>;
  5680. private _updatable;
  5681. private _instanced;
  5682. /**
  5683. * Gets the byte stride.
  5684. */
  5685. readonly byteStride: number;
  5686. /**
  5687. * Constructor
  5688. * @param engine the engine
  5689. * @param data the data to use for this buffer
  5690. * @param updatable whether the data is updatable
  5691. * @param stride the stride (optional)
  5692. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5693. * @param instanced whether the buffer is instanced (optional)
  5694. * @param useBytes set to true if the stride in in bytes (optional)
  5695. */
  5696. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5697. /**
  5698. * Create a new VertexBuffer based on the current buffer
  5699. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5700. * @param offset defines offset in the buffer (0 by default)
  5701. * @param size defines the size in floats of attributes (position is 3 for instance)
  5702. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5703. * @param instanced defines if the vertex buffer contains indexed data
  5704. * @param useBytes defines if the offset and stride are in bytes
  5705. * @returns the new vertex buffer
  5706. */
  5707. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5708. /**
  5709. * Gets a boolean indicating if the Buffer is updatable?
  5710. * @returns true if the buffer is updatable
  5711. */
  5712. isUpdatable(): boolean;
  5713. /**
  5714. * Gets current buffer's data
  5715. * @returns a DataArray or null
  5716. */
  5717. getData(): Nullable<DataArray>;
  5718. /**
  5719. * Gets underlying native buffer
  5720. * @returns underlying native buffer
  5721. */
  5722. getBuffer(): Nullable<DataBuffer>;
  5723. /**
  5724. * Gets the stride in float32 units (i.e. byte stride / 4).
  5725. * May not be an integer if the byte stride is not divisible by 4.
  5726. * DEPRECATED. Use byteStride instead.
  5727. * @returns the stride in float32 units
  5728. */
  5729. getStrideSize(): number;
  5730. /**
  5731. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5732. * @param data defines the data to store
  5733. */
  5734. create(data?: Nullable<DataArray>): void;
  5735. /** @hidden */
  5736. _rebuild(): void;
  5737. /**
  5738. * Update current buffer data
  5739. * @param data defines the data to store
  5740. */
  5741. update(data: DataArray): void;
  5742. /**
  5743. * Updates the data directly.
  5744. * @param data the new data
  5745. * @param offset the new offset
  5746. * @param vertexCount the vertex count (optional)
  5747. * @param useBytes set to true if the offset is in bytes
  5748. */
  5749. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5750. /**
  5751. * Release all resources
  5752. */
  5753. dispose(): void;
  5754. }
  5755. /**
  5756. * Specialized buffer used to store vertex data
  5757. */
  5758. export class VertexBuffer {
  5759. /** @hidden */
  5760. _buffer: Buffer;
  5761. private _kind;
  5762. private _size;
  5763. private _ownsBuffer;
  5764. private _instanced;
  5765. private _instanceDivisor;
  5766. /**
  5767. * The byte type.
  5768. */
  5769. static readonly BYTE: number;
  5770. /**
  5771. * The unsigned byte type.
  5772. */
  5773. static readonly UNSIGNED_BYTE: number;
  5774. /**
  5775. * The short type.
  5776. */
  5777. static readonly SHORT: number;
  5778. /**
  5779. * The unsigned short type.
  5780. */
  5781. static readonly UNSIGNED_SHORT: number;
  5782. /**
  5783. * The integer type.
  5784. */
  5785. static readonly INT: number;
  5786. /**
  5787. * The unsigned integer type.
  5788. */
  5789. static readonly UNSIGNED_INT: number;
  5790. /**
  5791. * The float type.
  5792. */
  5793. static readonly FLOAT: number;
  5794. /**
  5795. * Gets or sets the instance divisor when in instanced mode
  5796. */
  5797. instanceDivisor: number;
  5798. /**
  5799. * Gets the byte stride.
  5800. */
  5801. readonly byteStride: number;
  5802. /**
  5803. * Gets the byte offset.
  5804. */
  5805. readonly byteOffset: number;
  5806. /**
  5807. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5808. */
  5809. readonly normalized: boolean;
  5810. /**
  5811. * Gets the data type of each component in the array.
  5812. */
  5813. readonly type: number;
  5814. /**
  5815. * Constructor
  5816. * @param engine the engine
  5817. * @param data the data to use for this vertex buffer
  5818. * @param kind the vertex buffer kind
  5819. * @param updatable whether the data is updatable
  5820. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5821. * @param stride the stride (optional)
  5822. * @param instanced whether the buffer is instanced (optional)
  5823. * @param offset the offset of the data (optional)
  5824. * @param size the number of components (optional)
  5825. * @param type the type of the component (optional)
  5826. * @param normalized whether the data contains normalized data (optional)
  5827. * @param useBytes set to true if stride and offset are in bytes (optional)
  5828. */
  5829. 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);
  5830. /** @hidden */
  5831. _rebuild(): void;
  5832. /**
  5833. * Returns the kind of the VertexBuffer (string)
  5834. * @returns a string
  5835. */
  5836. getKind(): string;
  5837. /**
  5838. * Gets a boolean indicating if the VertexBuffer is updatable?
  5839. * @returns true if the buffer is updatable
  5840. */
  5841. isUpdatable(): boolean;
  5842. /**
  5843. * Gets current buffer's data
  5844. * @returns a DataArray or null
  5845. */
  5846. getData(): Nullable<DataArray>;
  5847. /**
  5848. * Gets underlying native buffer
  5849. * @returns underlying native buffer
  5850. */
  5851. getBuffer(): Nullable<DataBuffer>;
  5852. /**
  5853. * Gets the stride in float32 units (i.e. byte stride / 4).
  5854. * May not be an integer if the byte stride is not divisible by 4.
  5855. * DEPRECATED. Use byteStride instead.
  5856. * @returns the stride in float32 units
  5857. */
  5858. getStrideSize(): number;
  5859. /**
  5860. * Returns the offset as a multiple of the type byte length.
  5861. * DEPRECATED. Use byteOffset instead.
  5862. * @returns the offset in bytes
  5863. */
  5864. getOffset(): number;
  5865. /**
  5866. * Returns the number of components per vertex attribute (integer)
  5867. * @returns the size in float
  5868. */
  5869. getSize(): number;
  5870. /**
  5871. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5872. * @returns true if this buffer is instanced
  5873. */
  5874. getIsInstanced(): boolean;
  5875. /**
  5876. * Returns the instancing divisor, zero for non-instanced (integer).
  5877. * @returns a number
  5878. */
  5879. getInstanceDivisor(): number;
  5880. /**
  5881. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5882. * @param data defines the data to store
  5883. */
  5884. create(data?: DataArray): void;
  5885. /**
  5886. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5887. * This function will create a new buffer if the current one is not updatable
  5888. * @param data defines the data to store
  5889. */
  5890. update(data: DataArray): void;
  5891. /**
  5892. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5893. * Returns the directly updated WebGLBuffer.
  5894. * @param data the new data
  5895. * @param offset the new offset
  5896. * @param useBytes set to true if the offset is in bytes
  5897. */
  5898. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5899. /**
  5900. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5901. */
  5902. dispose(): void;
  5903. /**
  5904. * Enumerates each value of this vertex buffer as numbers.
  5905. * @param count the number of values to enumerate
  5906. * @param callback the callback function called for each value
  5907. */
  5908. forEach(count: number, callback: (value: number, index: number) => void): void;
  5909. /**
  5910. * Positions
  5911. */
  5912. static readonly PositionKind: string;
  5913. /**
  5914. * Normals
  5915. */
  5916. static readonly NormalKind: string;
  5917. /**
  5918. * Tangents
  5919. */
  5920. static readonly TangentKind: string;
  5921. /**
  5922. * Texture coordinates
  5923. */
  5924. static readonly UVKind: string;
  5925. /**
  5926. * Texture coordinates 2
  5927. */
  5928. static readonly UV2Kind: string;
  5929. /**
  5930. * Texture coordinates 3
  5931. */
  5932. static readonly UV3Kind: string;
  5933. /**
  5934. * Texture coordinates 4
  5935. */
  5936. static readonly UV4Kind: string;
  5937. /**
  5938. * Texture coordinates 5
  5939. */
  5940. static readonly UV5Kind: string;
  5941. /**
  5942. * Texture coordinates 6
  5943. */
  5944. static readonly UV6Kind: string;
  5945. /**
  5946. * Colors
  5947. */
  5948. static readonly ColorKind: string;
  5949. /**
  5950. * Matrix indices (for bones)
  5951. */
  5952. static readonly MatricesIndicesKind: string;
  5953. /**
  5954. * Matrix weights (for bones)
  5955. */
  5956. static readonly MatricesWeightsKind: string;
  5957. /**
  5958. * Additional matrix indices (for bones)
  5959. */
  5960. static readonly MatricesIndicesExtraKind: string;
  5961. /**
  5962. * Additional matrix weights (for bones)
  5963. */
  5964. static readonly MatricesWeightsExtraKind: string;
  5965. /**
  5966. * Deduces the stride given a kind.
  5967. * @param kind The kind string to deduce
  5968. * @returns The deduced stride
  5969. */
  5970. static DeduceStride(kind: string): number;
  5971. /**
  5972. * Gets the byte length of the given type.
  5973. * @param type the type
  5974. * @returns the number of bytes
  5975. */
  5976. static GetTypeByteLength(type: number): number;
  5977. /**
  5978. * Enumerates each value of the given parameters as numbers.
  5979. * @param data the data to enumerate
  5980. * @param byteOffset the byte offset of the data
  5981. * @param byteStride the byte stride of the data
  5982. * @param componentCount the number of components per element
  5983. * @param componentType the type of the component
  5984. * @param count the number of values to enumerate
  5985. * @param normalized whether the data is normalized
  5986. * @param callback the callback function called for each value
  5987. */
  5988. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5989. private static _GetFloatValue;
  5990. }
  5991. }
  5992. declare module "babylonjs/Maths/sphericalPolynomial" {
  5993. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5994. /**
  5995. * Class representing spherical harmonics coefficients to the 3rd degree
  5996. */
  5997. export class SphericalHarmonics {
  5998. /**
  5999. * Defines whether or not the harmonics have been prescaled for rendering.
  6000. */
  6001. preScaled: boolean;
  6002. /**
  6003. * The l0,0 coefficients of the spherical harmonics
  6004. */
  6005. l00: Vector3;
  6006. /**
  6007. * The l1,-1 coefficients of the spherical harmonics
  6008. */
  6009. l1_1: Vector3;
  6010. /**
  6011. * The l1,0 coefficients of the spherical harmonics
  6012. */
  6013. l10: Vector3;
  6014. /**
  6015. * The l1,1 coefficients of the spherical harmonics
  6016. */
  6017. l11: Vector3;
  6018. /**
  6019. * The l2,-2 coefficients of the spherical harmonics
  6020. */
  6021. l2_2: Vector3;
  6022. /**
  6023. * The l2,-1 coefficients of the spherical harmonics
  6024. */
  6025. l2_1: Vector3;
  6026. /**
  6027. * The l2,0 coefficients of the spherical harmonics
  6028. */
  6029. l20: Vector3;
  6030. /**
  6031. * The l2,1 coefficients of the spherical harmonics
  6032. */
  6033. l21: Vector3;
  6034. /**
  6035. * The l2,2 coefficients of the spherical harmonics
  6036. */
  6037. l22: Vector3;
  6038. /**
  6039. * Adds a light to the spherical harmonics
  6040. * @param direction the direction of the light
  6041. * @param color the color of the light
  6042. * @param deltaSolidAngle the delta solid angle of the light
  6043. */
  6044. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6045. /**
  6046. * Scales the spherical harmonics by the given amount
  6047. * @param scale the amount to scale
  6048. */
  6049. scaleInPlace(scale: number): void;
  6050. /**
  6051. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6052. *
  6053. * ```
  6054. * E_lm = A_l * L_lm
  6055. * ```
  6056. *
  6057. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6058. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6059. * the scaling factors are given in equation 9.
  6060. */
  6061. convertIncidentRadianceToIrradiance(): void;
  6062. /**
  6063. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6064. *
  6065. * ```
  6066. * L = (1/pi) * E * rho
  6067. * ```
  6068. *
  6069. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6070. */
  6071. convertIrradianceToLambertianRadiance(): void;
  6072. /**
  6073. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6074. * required operations at run time.
  6075. *
  6076. * This is simply done by scaling back the SH with Ylm constants parameter.
  6077. * The trigonometric part being applied by the shader at run time.
  6078. */
  6079. preScaleForRendering(): void;
  6080. /**
  6081. * Constructs a spherical harmonics from an array.
  6082. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6083. * @returns the spherical harmonics
  6084. */
  6085. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6086. /**
  6087. * Gets the spherical harmonics from polynomial
  6088. * @param polynomial the spherical polynomial
  6089. * @returns the spherical harmonics
  6090. */
  6091. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6092. }
  6093. /**
  6094. * Class representing spherical polynomial coefficients to the 3rd degree
  6095. */
  6096. export class SphericalPolynomial {
  6097. private _harmonics;
  6098. /**
  6099. * The spherical harmonics used to create the polynomials.
  6100. */
  6101. readonly preScaledHarmonics: SphericalHarmonics;
  6102. /**
  6103. * The x coefficients of the spherical polynomial
  6104. */
  6105. x: Vector3;
  6106. /**
  6107. * The y coefficients of the spherical polynomial
  6108. */
  6109. y: Vector3;
  6110. /**
  6111. * The z coefficients of the spherical polynomial
  6112. */
  6113. z: Vector3;
  6114. /**
  6115. * The xx coefficients of the spherical polynomial
  6116. */
  6117. xx: Vector3;
  6118. /**
  6119. * The yy coefficients of the spherical polynomial
  6120. */
  6121. yy: Vector3;
  6122. /**
  6123. * The zz coefficients of the spherical polynomial
  6124. */
  6125. zz: Vector3;
  6126. /**
  6127. * The xy coefficients of the spherical polynomial
  6128. */
  6129. xy: Vector3;
  6130. /**
  6131. * The yz coefficients of the spherical polynomial
  6132. */
  6133. yz: Vector3;
  6134. /**
  6135. * The zx coefficients of the spherical polynomial
  6136. */
  6137. zx: Vector3;
  6138. /**
  6139. * Adds an ambient color to the spherical polynomial
  6140. * @param color the color to add
  6141. */
  6142. addAmbient(color: Color3): void;
  6143. /**
  6144. * Scales the spherical polynomial by the given amount
  6145. * @param scale the amount to scale
  6146. */
  6147. scaleInPlace(scale: number): void;
  6148. /**
  6149. * Gets the spherical polynomial from harmonics
  6150. * @param harmonics the spherical harmonics
  6151. * @returns the spherical polynomial
  6152. */
  6153. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6154. /**
  6155. * Constructs a spherical polynomial from an array.
  6156. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6157. * @returns the spherical polynomial
  6158. */
  6159. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6160. }
  6161. }
  6162. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  6163. import { Nullable } from "babylonjs/types";
  6164. /**
  6165. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6166. */
  6167. export interface CubeMapInfo {
  6168. /**
  6169. * The pixel array for the front face.
  6170. * This is stored in format, left to right, up to down format.
  6171. */
  6172. front: Nullable<ArrayBufferView>;
  6173. /**
  6174. * The pixel array for the back face.
  6175. * This is stored in format, left to right, up to down format.
  6176. */
  6177. back: Nullable<ArrayBufferView>;
  6178. /**
  6179. * The pixel array for the left face.
  6180. * This is stored in format, left to right, up to down format.
  6181. */
  6182. left: Nullable<ArrayBufferView>;
  6183. /**
  6184. * The pixel array for the right face.
  6185. * This is stored in format, left to right, up to down format.
  6186. */
  6187. right: Nullable<ArrayBufferView>;
  6188. /**
  6189. * The pixel array for the up face.
  6190. * This is stored in format, left to right, up to down format.
  6191. */
  6192. up: Nullable<ArrayBufferView>;
  6193. /**
  6194. * The pixel array for the down face.
  6195. * This is stored in format, left to right, up to down format.
  6196. */
  6197. down: Nullable<ArrayBufferView>;
  6198. /**
  6199. * The size of the cubemap stored.
  6200. *
  6201. * Each faces will be size * size pixels.
  6202. */
  6203. size: number;
  6204. /**
  6205. * The format of the texture.
  6206. *
  6207. * RGBA, RGB.
  6208. */
  6209. format: number;
  6210. /**
  6211. * The type of the texture data.
  6212. *
  6213. * UNSIGNED_INT, FLOAT.
  6214. */
  6215. type: number;
  6216. /**
  6217. * Specifies whether the texture is in gamma space.
  6218. */
  6219. gammaSpace: boolean;
  6220. }
  6221. /**
  6222. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6223. */
  6224. export class PanoramaToCubeMapTools {
  6225. private static FACE_FRONT;
  6226. private static FACE_BACK;
  6227. private static FACE_RIGHT;
  6228. private static FACE_LEFT;
  6229. private static FACE_DOWN;
  6230. private static FACE_UP;
  6231. /**
  6232. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6233. *
  6234. * @param float32Array The source data.
  6235. * @param inputWidth The width of the input panorama.
  6236. * @param inputHeight The height of the input panorama.
  6237. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6238. * @return The cubemap data
  6239. */
  6240. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6241. private static CreateCubemapTexture;
  6242. private static CalcProjectionSpherical;
  6243. }
  6244. }
  6245. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6246. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6248. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6249. /**
  6250. * Helper class dealing with the extraction of spherical polynomial dataArray
  6251. * from a cube map.
  6252. */
  6253. export class CubeMapToSphericalPolynomialTools {
  6254. private static FileFaces;
  6255. /**
  6256. * Converts a texture to the according Spherical Polynomial data.
  6257. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6258. *
  6259. * @param texture The texture to extract the information from.
  6260. * @return The Spherical Polynomial data.
  6261. */
  6262. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6263. /**
  6264. * Converts a cubemap to the according Spherical Polynomial data.
  6265. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6266. *
  6267. * @param cubeInfo The Cube map to extract the information from.
  6268. * @return The Spherical Polynomial data.
  6269. */
  6270. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6271. }
  6272. }
  6273. declare module "babylonjs/Engines/engineStore" {
  6274. import { Nullable } from "babylonjs/types";
  6275. import { Engine } from "babylonjs/Engines/engine";
  6276. import { Scene } from "babylonjs/scene";
  6277. /**
  6278. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6279. * during the life time of the application.
  6280. */
  6281. export class EngineStore {
  6282. /** Gets the list of created engines */
  6283. static Instances: import("babylonjs/Engines/engine").Engine[];
  6284. /** @hidden */
  6285. static _LastCreatedScene: Nullable<Scene>;
  6286. /**
  6287. * Gets the latest created engine
  6288. */
  6289. static readonly LastCreatedEngine: Nullable<Engine>;
  6290. /**
  6291. * Gets the latest created scene
  6292. */
  6293. static readonly LastCreatedScene: Nullable<Scene>;
  6294. }
  6295. }
  6296. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6297. /**
  6298. * Define options used to create a render target texture
  6299. */
  6300. export class RenderTargetCreationOptions {
  6301. /**
  6302. * Specifies is mipmaps must be generated
  6303. */
  6304. generateMipMaps?: boolean;
  6305. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6306. generateDepthBuffer?: boolean;
  6307. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6308. generateStencilBuffer?: boolean;
  6309. /** Defines texture type (int by default) */
  6310. type?: number;
  6311. /** Defines sampling mode (trilinear by default) */
  6312. samplingMode?: number;
  6313. /** Defines format (RGBA by default) */
  6314. format?: number;
  6315. }
  6316. }
  6317. declare module "babylonjs/States/alphaCullingState" {
  6318. /**
  6319. * @hidden
  6320. **/
  6321. export class _AlphaState {
  6322. private _isAlphaBlendDirty;
  6323. private _isBlendFunctionParametersDirty;
  6324. private _isBlendEquationParametersDirty;
  6325. private _isBlendConstantsDirty;
  6326. private _alphaBlend;
  6327. private _blendFunctionParameters;
  6328. private _blendEquationParameters;
  6329. private _blendConstants;
  6330. /**
  6331. * Initializes the state.
  6332. */
  6333. constructor();
  6334. readonly isDirty: boolean;
  6335. alphaBlend: boolean;
  6336. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6337. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6338. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6339. reset(): void;
  6340. apply(gl: WebGLRenderingContext): void;
  6341. }
  6342. }
  6343. declare module "babylonjs/States/depthCullingState" {
  6344. import { Nullable } from "babylonjs/types";
  6345. /**
  6346. * @hidden
  6347. **/
  6348. export class _DepthCullingState {
  6349. private _isDepthTestDirty;
  6350. private _isDepthMaskDirty;
  6351. private _isDepthFuncDirty;
  6352. private _isCullFaceDirty;
  6353. private _isCullDirty;
  6354. private _isZOffsetDirty;
  6355. private _isFrontFaceDirty;
  6356. private _depthTest;
  6357. private _depthMask;
  6358. private _depthFunc;
  6359. private _cull;
  6360. private _cullFace;
  6361. private _zOffset;
  6362. private _frontFace;
  6363. /**
  6364. * Initializes the state.
  6365. */
  6366. constructor();
  6367. readonly isDirty: boolean;
  6368. zOffset: number;
  6369. cullFace: Nullable<number>;
  6370. cull: Nullable<boolean>;
  6371. depthFunc: Nullable<number>;
  6372. depthMask: boolean;
  6373. depthTest: boolean;
  6374. frontFace: Nullable<number>;
  6375. reset(): void;
  6376. apply(gl: WebGLRenderingContext): void;
  6377. }
  6378. }
  6379. declare module "babylonjs/States/stencilState" {
  6380. /**
  6381. * @hidden
  6382. **/
  6383. export class _StencilState {
  6384. /** 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 */
  6385. static readonly ALWAYS: number;
  6386. /** Passed to stencilOperation to specify that stencil value must be kept */
  6387. static readonly KEEP: number;
  6388. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6389. static readonly REPLACE: number;
  6390. private _isStencilTestDirty;
  6391. private _isStencilMaskDirty;
  6392. private _isStencilFuncDirty;
  6393. private _isStencilOpDirty;
  6394. private _stencilTest;
  6395. private _stencilMask;
  6396. private _stencilFunc;
  6397. private _stencilFuncRef;
  6398. private _stencilFuncMask;
  6399. private _stencilOpStencilFail;
  6400. private _stencilOpDepthFail;
  6401. private _stencilOpStencilDepthPass;
  6402. readonly isDirty: boolean;
  6403. stencilFunc: number;
  6404. stencilFuncRef: number;
  6405. stencilFuncMask: number;
  6406. stencilOpStencilFail: number;
  6407. stencilOpDepthFail: number;
  6408. stencilOpStencilDepthPass: number;
  6409. stencilMask: number;
  6410. stencilTest: boolean;
  6411. constructor();
  6412. reset(): void;
  6413. apply(gl: WebGLRenderingContext): void;
  6414. }
  6415. }
  6416. declare module "babylonjs/States/index" {
  6417. export * from "babylonjs/States/alphaCullingState";
  6418. export * from "babylonjs/States/depthCullingState";
  6419. export * from "babylonjs/States/stencilState";
  6420. }
  6421. declare module "babylonjs/Instrumentation/timeToken" {
  6422. import { Nullable } from "babylonjs/types";
  6423. /**
  6424. * @hidden
  6425. **/
  6426. export class _TimeToken {
  6427. _startTimeQuery: Nullable<WebGLQuery>;
  6428. _endTimeQuery: Nullable<WebGLQuery>;
  6429. _timeElapsedQuery: Nullable<WebGLQuery>;
  6430. _timeElapsedQueryEnded: boolean;
  6431. }
  6432. }
  6433. declare module "babylonjs/Materials/Textures/internalTexture" {
  6434. import { Observable } from "babylonjs/Misc/observable";
  6435. import { Nullable, int } from "babylonjs/types";
  6436. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6437. import { Engine } from "babylonjs/Engines/engine";
  6438. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6439. /**
  6440. * Class used to store data associated with WebGL texture data for the engine
  6441. * This class should not be used directly
  6442. */
  6443. export class InternalTexture {
  6444. /** @hidden */
  6445. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6446. /**
  6447. * The source of the texture data is unknown
  6448. */
  6449. static DATASOURCE_UNKNOWN: number;
  6450. /**
  6451. * Texture data comes from an URL
  6452. */
  6453. static DATASOURCE_URL: number;
  6454. /**
  6455. * Texture data is only used for temporary storage
  6456. */
  6457. static DATASOURCE_TEMP: number;
  6458. /**
  6459. * Texture data comes from raw data (ArrayBuffer)
  6460. */
  6461. static DATASOURCE_RAW: number;
  6462. /**
  6463. * Texture content is dynamic (video or dynamic texture)
  6464. */
  6465. static DATASOURCE_DYNAMIC: number;
  6466. /**
  6467. * Texture content is generated by rendering to it
  6468. */
  6469. static DATASOURCE_RENDERTARGET: number;
  6470. /**
  6471. * Texture content is part of a multi render target process
  6472. */
  6473. static DATASOURCE_MULTIRENDERTARGET: number;
  6474. /**
  6475. * Texture data comes from a cube data file
  6476. */
  6477. static DATASOURCE_CUBE: number;
  6478. /**
  6479. * Texture data comes from a raw cube data
  6480. */
  6481. static DATASOURCE_CUBERAW: number;
  6482. /**
  6483. * Texture data come from a prefiltered cube data file
  6484. */
  6485. static DATASOURCE_CUBEPREFILTERED: number;
  6486. /**
  6487. * Texture content is raw 3D data
  6488. */
  6489. static DATASOURCE_RAW3D: number;
  6490. /**
  6491. * Texture content is a depth texture
  6492. */
  6493. static DATASOURCE_DEPTHTEXTURE: number;
  6494. /**
  6495. * Texture data comes from a raw cube data encoded with RGBD
  6496. */
  6497. static DATASOURCE_CUBERAW_RGBD: number;
  6498. /**
  6499. * Defines if the texture is ready
  6500. */
  6501. isReady: boolean;
  6502. /**
  6503. * Defines if the texture is a cube texture
  6504. */
  6505. isCube: boolean;
  6506. /**
  6507. * Defines if the texture contains 3D data
  6508. */
  6509. is3D: boolean;
  6510. /**
  6511. * Defines if the texture contains multiview data
  6512. */
  6513. isMultiview: boolean;
  6514. /**
  6515. * Gets the URL used to load this texture
  6516. */
  6517. url: string;
  6518. /**
  6519. * Gets the sampling mode of the texture
  6520. */
  6521. samplingMode: number;
  6522. /**
  6523. * Gets a boolean indicating if the texture needs mipmaps generation
  6524. */
  6525. generateMipMaps: boolean;
  6526. /**
  6527. * Gets the number of samples used by the texture (WebGL2+ only)
  6528. */
  6529. samples: number;
  6530. /**
  6531. * Gets the type of the texture (int, float...)
  6532. */
  6533. type: number;
  6534. /**
  6535. * Gets the format of the texture (RGB, RGBA...)
  6536. */
  6537. format: number;
  6538. /**
  6539. * Observable called when the texture is loaded
  6540. */
  6541. onLoadedObservable: Observable<InternalTexture>;
  6542. /**
  6543. * Gets the width of the texture
  6544. */
  6545. width: number;
  6546. /**
  6547. * Gets the height of the texture
  6548. */
  6549. height: number;
  6550. /**
  6551. * Gets the depth of the texture
  6552. */
  6553. depth: number;
  6554. /**
  6555. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6556. */
  6557. baseWidth: number;
  6558. /**
  6559. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6560. */
  6561. baseHeight: number;
  6562. /**
  6563. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6564. */
  6565. baseDepth: number;
  6566. /**
  6567. * Gets a boolean indicating if the texture is inverted on Y axis
  6568. */
  6569. invertY: boolean;
  6570. /** @hidden */
  6571. _invertVScale: boolean;
  6572. /** @hidden */
  6573. _associatedChannel: number;
  6574. /** @hidden */
  6575. _dataSource: number;
  6576. /** @hidden */
  6577. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6578. /** @hidden */
  6579. _bufferView: Nullable<ArrayBufferView>;
  6580. /** @hidden */
  6581. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6582. /** @hidden */
  6583. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6584. /** @hidden */
  6585. _size: number;
  6586. /** @hidden */
  6587. _extension: string;
  6588. /** @hidden */
  6589. _files: Nullable<string[]>;
  6590. /** @hidden */
  6591. _workingCanvas: Nullable<HTMLCanvasElement>;
  6592. /** @hidden */
  6593. _workingContext: Nullable<CanvasRenderingContext2D>;
  6594. /** @hidden */
  6595. _framebuffer: Nullable<WebGLFramebuffer>;
  6596. /** @hidden */
  6597. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6598. /** @hidden */
  6599. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6600. /** @hidden */
  6601. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6602. /** @hidden */
  6603. _attachments: Nullable<number[]>;
  6604. /** @hidden */
  6605. _cachedCoordinatesMode: Nullable<number>;
  6606. /** @hidden */
  6607. _cachedWrapU: Nullable<number>;
  6608. /** @hidden */
  6609. _cachedWrapV: Nullable<number>;
  6610. /** @hidden */
  6611. _cachedWrapR: Nullable<number>;
  6612. /** @hidden */
  6613. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6614. /** @hidden */
  6615. _isDisabled: boolean;
  6616. /** @hidden */
  6617. _compression: Nullable<string>;
  6618. /** @hidden */
  6619. _generateStencilBuffer: boolean;
  6620. /** @hidden */
  6621. _generateDepthBuffer: boolean;
  6622. /** @hidden */
  6623. _comparisonFunction: number;
  6624. /** @hidden */
  6625. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6626. /** @hidden */
  6627. _lodGenerationScale: number;
  6628. /** @hidden */
  6629. _lodGenerationOffset: number;
  6630. /** @hidden */
  6631. _colorTextureArray: Nullable<WebGLTexture>;
  6632. /** @hidden */
  6633. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6634. /** @hidden */
  6635. _lodTextureHigh: Nullable<BaseTexture>;
  6636. /** @hidden */
  6637. _lodTextureMid: Nullable<BaseTexture>;
  6638. /** @hidden */
  6639. _lodTextureLow: Nullable<BaseTexture>;
  6640. /** @hidden */
  6641. _isRGBD: boolean;
  6642. /** @hidden */
  6643. _linearSpecularLOD: boolean;
  6644. /** @hidden */
  6645. _irradianceTexture: Nullable<BaseTexture>;
  6646. /** @hidden */
  6647. _webGLTexture: Nullable<WebGLTexture>;
  6648. /** @hidden */
  6649. _references: number;
  6650. private _engine;
  6651. /**
  6652. * Gets the Engine the texture belongs to.
  6653. * @returns The babylon engine
  6654. */
  6655. getEngine(): Engine;
  6656. /**
  6657. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6658. */
  6659. readonly dataSource: number;
  6660. /**
  6661. * Creates a new InternalTexture
  6662. * @param engine defines the engine to use
  6663. * @param dataSource defines the type of data that will be used
  6664. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6665. */
  6666. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6667. /**
  6668. * Increments the number of references (ie. the number of Texture that point to it)
  6669. */
  6670. incrementReferences(): void;
  6671. /**
  6672. * Change the size of the texture (not the size of the content)
  6673. * @param width defines the new width
  6674. * @param height defines the new height
  6675. * @param depth defines the new depth (1 by default)
  6676. */
  6677. updateSize(width: int, height: int, depth?: int): void;
  6678. /** @hidden */
  6679. _rebuild(): void;
  6680. /** @hidden */
  6681. _swapAndDie(target: InternalTexture): void;
  6682. /**
  6683. * Dispose the current allocated resources
  6684. */
  6685. dispose(): void;
  6686. }
  6687. }
  6688. declare module "babylonjs/Animations/easing" {
  6689. /**
  6690. * This represents the main contract an easing function should follow.
  6691. * Easing functions are used throughout the animation system.
  6692. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6693. */
  6694. export interface IEasingFunction {
  6695. /**
  6696. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6697. * of the easing function.
  6698. * The link below provides some of the most common examples of easing functions.
  6699. * @see https://easings.net/
  6700. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6701. * @returns the corresponding value on the curve defined by the easing function
  6702. */
  6703. ease(gradient: number): number;
  6704. }
  6705. /**
  6706. * Base class used for every default easing function.
  6707. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6708. */
  6709. export class EasingFunction implements IEasingFunction {
  6710. /**
  6711. * Interpolation follows the mathematical formula associated with the easing function.
  6712. */
  6713. static readonly EASINGMODE_EASEIN: number;
  6714. /**
  6715. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6716. */
  6717. static readonly EASINGMODE_EASEOUT: number;
  6718. /**
  6719. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6720. */
  6721. static readonly EASINGMODE_EASEINOUT: number;
  6722. private _easingMode;
  6723. /**
  6724. * Sets the easing mode of the current function.
  6725. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6726. */
  6727. setEasingMode(easingMode: number): void;
  6728. /**
  6729. * Gets the current easing mode.
  6730. * @returns the easing mode
  6731. */
  6732. getEasingMode(): number;
  6733. /**
  6734. * @hidden
  6735. */
  6736. easeInCore(gradient: number): number;
  6737. /**
  6738. * Given an input gradient between 0 and 1, this returns the corresponding value
  6739. * of the easing function.
  6740. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6741. * @returns the corresponding value on the curve defined by the easing function
  6742. */
  6743. ease(gradient: number): number;
  6744. }
  6745. /**
  6746. * Easing function with a circle shape (see link below).
  6747. * @see https://easings.net/#easeInCirc
  6748. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6749. */
  6750. export class CircleEase extends EasingFunction implements IEasingFunction {
  6751. /** @hidden */
  6752. easeInCore(gradient: number): number;
  6753. }
  6754. /**
  6755. * Easing function with a ease back shape (see link below).
  6756. * @see https://easings.net/#easeInBack
  6757. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6758. */
  6759. export class BackEase extends EasingFunction implements IEasingFunction {
  6760. /** Defines the amplitude of the function */
  6761. amplitude: number;
  6762. /**
  6763. * Instantiates a back ease easing
  6764. * @see https://easings.net/#easeInBack
  6765. * @param amplitude Defines the amplitude of the function
  6766. */
  6767. constructor(
  6768. /** Defines the amplitude of the function */
  6769. amplitude?: number);
  6770. /** @hidden */
  6771. easeInCore(gradient: number): number;
  6772. }
  6773. /**
  6774. * Easing function with a bouncing shape (see link below).
  6775. * @see https://easings.net/#easeInBounce
  6776. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6777. */
  6778. export class BounceEase extends EasingFunction implements IEasingFunction {
  6779. /** Defines the number of bounces */
  6780. bounces: number;
  6781. /** Defines the amplitude of the bounce */
  6782. bounciness: number;
  6783. /**
  6784. * Instantiates a bounce easing
  6785. * @see https://easings.net/#easeInBounce
  6786. * @param bounces Defines the number of bounces
  6787. * @param bounciness Defines the amplitude of the bounce
  6788. */
  6789. constructor(
  6790. /** Defines the number of bounces */
  6791. bounces?: number,
  6792. /** Defines the amplitude of the bounce */
  6793. bounciness?: number);
  6794. /** @hidden */
  6795. easeInCore(gradient: number): number;
  6796. }
  6797. /**
  6798. * Easing function with a power of 3 shape (see link below).
  6799. * @see https://easings.net/#easeInCubic
  6800. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6801. */
  6802. export class CubicEase extends EasingFunction implements IEasingFunction {
  6803. /** @hidden */
  6804. easeInCore(gradient: number): number;
  6805. }
  6806. /**
  6807. * Easing function with an elastic shape (see link below).
  6808. * @see https://easings.net/#easeInElastic
  6809. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6810. */
  6811. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6812. /** Defines the number of oscillations*/
  6813. oscillations: number;
  6814. /** Defines the amplitude of the oscillations*/
  6815. springiness: number;
  6816. /**
  6817. * Instantiates an elastic easing function
  6818. * @see https://easings.net/#easeInElastic
  6819. * @param oscillations Defines the number of oscillations
  6820. * @param springiness Defines the amplitude of the oscillations
  6821. */
  6822. constructor(
  6823. /** Defines the number of oscillations*/
  6824. oscillations?: number,
  6825. /** Defines the amplitude of the oscillations*/
  6826. springiness?: number);
  6827. /** @hidden */
  6828. easeInCore(gradient: number): number;
  6829. }
  6830. /**
  6831. * Easing function with an exponential shape (see link below).
  6832. * @see https://easings.net/#easeInExpo
  6833. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6834. */
  6835. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6836. /** Defines the exponent of the function */
  6837. exponent: number;
  6838. /**
  6839. * Instantiates an exponential easing function
  6840. * @see https://easings.net/#easeInExpo
  6841. * @param exponent Defines the exponent of the function
  6842. */
  6843. constructor(
  6844. /** Defines the exponent of the function */
  6845. exponent?: number);
  6846. /** @hidden */
  6847. easeInCore(gradient: number): number;
  6848. }
  6849. /**
  6850. * Easing function with a power shape (see link below).
  6851. * @see https://easings.net/#easeInQuad
  6852. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6853. */
  6854. export class PowerEase extends EasingFunction implements IEasingFunction {
  6855. /** Defines the power of the function */
  6856. power: number;
  6857. /**
  6858. * Instantiates an power base easing function
  6859. * @see https://easings.net/#easeInQuad
  6860. * @param power Defines the power of the function
  6861. */
  6862. constructor(
  6863. /** Defines the power of the function */
  6864. power?: number);
  6865. /** @hidden */
  6866. easeInCore(gradient: number): number;
  6867. }
  6868. /**
  6869. * Easing function with a power of 2 shape (see link below).
  6870. * @see https://easings.net/#easeInQuad
  6871. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6872. */
  6873. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6874. /** @hidden */
  6875. easeInCore(gradient: number): number;
  6876. }
  6877. /**
  6878. * Easing function with a power of 4 shape (see link below).
  6879. * @see https://easings.net/#easeInQuart
  6880. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6881. */
  6882. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6883. /** @hidden */
  6884. easeInCore(gradient: number): number;
  6885. }
  6886. /**
  6887. * Easing function with a power of 5 shape (see link below).
  6888. * @see https://easings.net/#easeInQuint
  6889. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6890. */
  6891. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6892. /** @hidden */
  6893. easeInCore(gradient: number): number;
  6894. }
  6895. /**
  6896. * Easing function with a sin shape (see link below).
  6897. * @see https://easings.net/#easeInSine
  6898. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6899. */
  6900. export class SineEase extends EasingFunction implements IEasingFunction {
  6901. /** @hidden */
  6902. easeInCore(gradient: number): number;
  6903. }
  6904. /**
  6905. * Easing function with a bezier shape (see link below).
  6906. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6907. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6908. */
  6909. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6910. /** Defines the x component of the start tangent in the bezier curve */
  6911. x1: number;
  6912. /** Defines the y component of the start tangent in the bezier curve */
  6913. y1: number;
  6914. /** Defines the x component of the end tangent in the bezier curve */
  6915. x2: number;
  6916. /** Defines the y component of the end tangent in the bezier curve */
  6917. y2: number;
  6918. /**
  6919. * Instantiates a bezier function
  6920. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6921. * @param x1 Defines the x component of the start tangent in the bezier curve
  6922. * @param y1 Defines the y component of the start tangent in the bezier curve
  6923. * @param x2 Defines the x component of the end tangent in the bezier curve
  6924. * @param y2 Defines the y component of the end tangent in the bezier curve
  6925. */
  6926. constructor(
  6927. /** Defines the x component of the start tangent in the bezier curve */
  6928. x1?: number,
  6929. /** Defines the y component of the start tangent in the bezier curve */
  6930. y1?: number,
  6931. /** Defines the x component of the end tangent in the bezier curve */
  6932. x2?: number,
  6933. /** Defines the y component of the end tangent in the bezier curve */
  6934. y2?: number);
  6935. /** @hidden */
  6936. easeInCore(gradient: number): number;
  6937. }
  6938. }
  6939. declare module "babylonjs/Animations/animationKey" {
  6940. /**
  6941. * Defines an interface which represents an animation key frame
  6942. */
  6943. export interface IAnimationKey {
  6944. /**
  6945. * Frame of the key frame
  6946. */
  6947. frame: number;
  6948. /**
  6949. * Value at the specifies key frame
  6950. */
  6951. value: any;
  6952. /**
  6953. * The input tangent for the cubic hermite spline
  6954. */
  6955. inTangent?: any;
  6956. /**
  6957. * The output tangent for the cubic hermite spline
  6958. */
  6959. outTangent?: any;
  6960. /**
  6961. * The animation interpolation type
  6962. */
  6963. interpolation?: AnimationKeyInterpolation;
  6964. }
  6965. /**
  6966. * Enum for the animation key frame interpolation type
  6967. */
  6968. export enum AnimationKeyInterpolation {
  6969. /**
  6970. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6971. */
  6972. STEP = 1
  6973. }
  6974. }
  6975. declare module "babylonjs/Animations/animationRange" {
  6976. /**
  6977. * Represents the range of an animation
  6978. */
  6979. export class AnimationRange {
  6980. /**The name of the animation range**/
  6981. name: string;
  6982. /**The starting frame of the animation */
  6983. from: number;
  6984. /**The ending frame of the animation*/
  6985. to: number;
  6986. /**
  6987. * Initializes the range of an animation
  6988. * @param name The name of the animation range
  6989. * @param from The starting frame of the animation
  6990. * @param to The ending frame of the animation
  6991. */
  6992. constructor(
  6993. /**The name of the animation range**/
  6994. name: string,
  6995. /**The starting frame of the animation */
  6996. from: number,
  6997. /**The ending frame of the animation*/
  6998. to: number);
  6999. /**
  7000. * Makes a copy of the animation range
  7001. * @returns A copy of the animation range
  7002. */
  7003. clone(): AnimationRange;
  7004. }
  7005. }
  7006. declare module "babylonjs/Animations/animationEvent" {
  7007. /**
  7008. * Composed of a frame, and an action function
  7009. */
  7010. export class AnimationEvent {
  7011. /** The frame for which the event is triggered **/
  7012. frame: number;
  7013. /** The event to perform when triggered **/
  7014. action: (currentFrame: number) => void;
  7015. /** Specifies if the event should be triggered only once**/
  7016. onlyOnce?: boolean | undefined;
  7017. /**
  7018. * Specifies if the animation event is done
  7019. */
  7020. isDone: boolean;
  7021. /**
  7022. * Initializes the animation event
  7023. * @param frame The frame for which the event is triggered
  7024. * @param action The event to perform when triggered
  7025. * @param onlyOnce Specifies if the event should be triggered only once
  7026. */
  7027. constructor(
  7028. /** The frame for which the event is triggered **/
  7029. frame: number,
  7030. /** The event to perform when triggered **/
  7031. action: (currentFrame: number) => void,
  7032. /** Specifies if the event should be triggered only once**/
  7033. onlyOnce?: boolean | undefined);
  7034. /** @hidden */
  7035. _clone(): AnimationEvent;
  7036. }
  7037. }
  7038. declare module "babylonjs/Behaviors/behavior" {
  7039. import { Nullable } from "babylonjs/types";
  7040. /**
  7041. * Interface used to define a behavior
  7042. */
  7043. export interface Behavior<T> {
  7044. /** gets or sets behavior's name */
  7045. name: string;
  7046. /**
  7047. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7048. */
  7049. init(): void;
  7050. /**
  7051. * Called when the behavior is attached to a target
  7052. * @param target defines the target where the behavior is attached to
  7053. */
  7054. attach(target: T): void;
  7055. /**
  7056. * Called when the behavior is detached from its target
  7057. */
  7058. detach(): void;
  7059. }
  7060. /**
  7061. * Interface implemented by classes supporting behaviors
  7062. */
  7063. export interface IBehaviorAware<T> {
  7064. /**
  7065. * Attach a behavior
  7066. * @param behavior defines the behavior to attach
  7067. * @returns the current host
  7068. */
  7069. addBehavior(behavior: Behavior<T>): T;
  7070. /**
  7071. * Remove a behavior from the current object
  7072. * @param behavior defines the behavior to detach
  7073. * @returns the current host
  7074. */
  7075. removeBehavior(behavior: Behavior<T>): T;
  7076. /**
  7077. * Gets a behavior using its name to search
  7078. * @param name defines the name to search
  7079. * @returns the behavior or null if not found
  7080. */
  7081. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7082. }
  7083. }
  7084. declare module "babylonjs/Collisions/intersectionInfo" {
  7085. import { Nullable } from "babylonjs/types";
  7086. /**
  7087. * @hidden
  7088. */
  7089. export class IntersectionInfo {
  7090. bu: Nullable<number>;
  7091. bv: Nullable<number>;
  7092. distance: number;
  7093. faceId: number;
  7094. subMeshId: number;
  7095. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7096. }
  7097. }
  7098. declare module "babylonjs/Culling/boundingSphere" {
  7099. import { DeepImmutable } from "babylonjs/types";
  7100. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7101. /**
  7102. * Class used to store bounding sphere information
  7103. */
  7104. export class BoundingSphere {
  7105. /**
  7106. * Gets the center of the bounding sphere in local space
  7107. */
  7108. readonly center: Vector3;
  7109. /**
  7110. * Radius of the bounding sphere in local space
  7111. */
  7112. radius: number;
  7113. /**
  7114. * Gets the center of the bounding sphere in world space
  7115. */
  7116. readonly centerWorld: Vector3;
  7117. /**
  7118. * Radius of the bounding sphere in world space
  7119. */
  7120. radiusWorld: number;
  7121. /**
  7122. * Gets the minimum vector in local space
  7123. */
  7124. readonly minimum: Vector3;
  7125. /**
  7126. * Gets the maximum vector in local space
  7127. */
  7128. readonly maximum: Vector3;
  7129. private _worldMatrix;
  7130. private static readonly TmpVector3;
  7131. /**
  7132. * Creates a new bounding sphere
  7133. * @param min defines the minimum vector (in local space)
  7134. * @param max defines the maximum vector (in local space)
  7135. * @param worldMatrix defines the new world matrix
  7136. */
  7137. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7138. /**
  7139. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7140. * @param min defines the new minimum vector (in local space)
  7141. * @param max defines the new maximum vector (in local space)
  7142. * @param worldMatrix defines the new world matrix
  7143. */
  7144. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7145. /**
  7146. * Scale the current bounding sphere by applying a scale factor
  7147. * @param factor defines the scale factor to apply
  7148. * @returns the current bounding box
  7149. */
  7150. scale(factor: number): BoundingSphere;
  7151. /**
  7152. * Gets the world matrix of the bounding box
  7153. * @returns a matrix
  7154. */
  7155. getWorldMatrix(): DeepImmutable<Matrix>;
  7156. /** @hidden */
  7157. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7158. /**
  7159. * Tests if the bounding sphere is intersecting the frustum planes
  7160. * @param frustumPlanes defines the frustum planes to test
  7161. * @returns true if there is an intersection
  7162. */
  7163. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7164. /**
  7165. * Tests if the bounding sphere center is in between the frustum planes.
  7166. * Used for optimistic fast inclusion.
  7167. * @param frustumPlanes defines the frustum planes to test
  7168. * @returns true if the sphere center is in between the frustum planes
  7169. */
  7170. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7171. /**
  7172. * Tests if a point is inside the bounding sphere
  7173. * @param point defines the point to test
  7174. * @returns true if the point is inside the bounding sphere
  7175. */
  7176. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7177. /**
  7178. * Checks if two sphere intersct
  7179. * @param sphere0 sphere 0
  7180. * @param sphere1 sphere 1
  7181. * @returns true if the speres intersect
  7182. */
  7183. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7184. }
  7185. }
  7186. declare module "babylonjs/Culling/boundingBox" {
  7187. import { DeepImmutable } from "babylonjs/types";
  7188. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7189. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7190. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7191. /**
  7192. * Class used to store bounding box information
  7193. */
  7194. export class BoundingBox implements ICullable {
  7195. /**
  7196. * Gets the 8 vectors representing the bounding box in local space
  7197. */
  7198. readonly vectors: Vector3[];
  7199. /**
  7200. * Gets the center of the bounding box in local space
  7201. */
  7202. readonly center: Vector3;
  7203. /**
  7204. * Gets the center of the bounding box in world space
  7205. */
  7206. readonly centerWorld: Vector3;
  7207. /**
  7208. * Gets the extend size in local space
  7209. */
  7210. readonly extendSize: Vector3;
  7211. /**
  7212. * Gets the extend size in world space
  7213. */
  7214. readonly extendSizeWorld: Vector3;
  7215. /**
  7216. * Gets the OBB (object bounding box) directions
  7217. */
  7218. readonly directions: Vector3[];
  7219. /**
  7220. * Gets the 8 vectors representing the bounding box in world space
  7221. */
  7222. readonly vectorsWorld: Vector3[];
  7223. /**
  7224. * Gets the minimum vector in world space
  7225. */
  7226. readonly minimumWorld: Vector3;
  7227. /**
  7228. * Gets the maximum vector in world space
  7229. */
  7230. readonly maximumWorld: Vector3;
  7231. /**
  7232. * Gets the minimum vector in local space
  7233. */
  7234. readonly minimum: Vector3;
  7235. /**
  7236. * Gets the maximum vector in local space
  7237. */
  7238. readonly maximum: Vector3;
  7239. private _worldMatrix;
  7240. private static readonly TmpVector3;
  7241. /**
  7242. * @hidden
  7243. */
  7244. _tag: number;
  7245. /**
  7246. * Creates a new bounding box
  7247. * @param min defines the minimum vector (in local space)
  7248. * @param max defines the maximum vector (in local space)
  7249. * @param worldMatrix defines the new world matrix
  7250. */
  7251. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7252. /**
  7253. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7254. * @param min defines the new minimum vector (in local space)
  7255. * @param max defines the new maximum vector (in local space)
  7256. * @param worldMatrix defines the new world matrix
  7257. */
  7258. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7259. /**
  7260. * Scale the current bounding box by applying a scale factor
  7261. * @param factor defines the scale factor to apply
  7262. * @returns the current bounding box
  7263. */
  7264. scale(factor: number): BoundingBox;
  7265. /**
  7266. * Gets the world matrix of the bounding box
  7267. * @returns a matrix
  7268. */
  7269. getWorldMatrix(): DeepImmutable<Matrix>;
  7270. /** @hidden */
  7271. _update(world: DeepImmutable<Matrix>): void;
  7272. /**
  7273. * Tests if the bounding box is intersecting the frustum planes
  7274. * @param frustumPlanes defines the frustum planes to test
  7275. * @returns true if there is an intersection
  7276. */
  7277. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7278. /**
  7279. * Tests if the bounding box is entirely inside the frustum planes
  7280. * @param frustumPlanes defines the frustum planes to test
  7281. * @returns true if there is an inclusion
  7282. */
  7283. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7284. /**
  7285. * Tests if a point is inside the bounding box
  7286. * @param point defines the point to test
  7287. * @returns true if the point is inside the bounding box
  7288. */
  7289. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7290. /**
  7291. * Tests if the bounding box intersects with a bounding sphere
  7292. * @param sphere defines the sphere to test
  7293. * @returns true if there is an intersection
  7294. */
  7295. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7296. /**
  7297. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7298. * @param min defines the min vector to use
  7299. * @param max defines the max vector to use
  7300. * @returns true if there is an intersection
  7301. */
  7302. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7303. /**
  7304. * Tests if two bounding boxes are intersections
  7305. * @param box0 defines the first box to test
  7306. * @param box1 defines the second box to test
  7307. * @returns true if there is an intersection
  7308. */
  7309. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7310. /**
  7311. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7312. * @param minPoint defines the minimum vector of the bounding box
  7313. * @param maxPoint defines the maximum vector of the bounding box
  7314. * @param sphereCenter defines the sphere center
  7315. * @param sphereRadius defines the sphere radius
  7316. * @returns true if there is an intersection
  7317. */
  7318. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7319. /**
  7320. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7321. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7322. * @param frustumPlanes defines the frustum planes to test
  7323. * @return true if there is an inclusion
  7324. */
  7325. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7326. /**
  7327. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7328. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7329. * @param frustumPlanes defines the frustum planes to test
  7330. * @return true if there is an intersection
  7331. */
  7332. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7333. }
  7334. }
  7335. declare module "babylonjs/Collisions/collider" {
  7336. import { Nullable, IndicesArray } from "babylonjs/types";
  7337. import { Vector3, Plane } from "babylonjs/Maths/math";
  7338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7339. /** @hidden */
  7340. export class Collider {
  7341. /** Define if a collision was found */
  7342. collisionFound: boolean;
  7343. /**
  7344. * Define last intersection point in local space
  7345. */
  7346. intersectionPoint: Vector3;
  7347. /**
  7348. * Define last collided mesh
  7349. */
  7350. collidedMesh: Nullable<AbstractMesh>;
  7351. private _collisionPoint;
  7352. private _planeIntersectionPoint;
  7353. private _tempVector;
  7354. private _tempVector2;
  7355. private _tempVector3;
  7356. private _tempVector4;
  7357. private _edge;
  7358. private _baseToVertex;
  7359. private _destinationPoint;
  7360. private _slidePlaneNormal;
  7361. private _displacementVector;
  7362. /** @hidden */
  7363. _radius: Vector3;
  7364. /** @hidden */
  7365. _retry: number;
  7366. private _velocity;
  7367. private _basePoint;
  7368. private _epsilon;
  7369. /** @hidden */
  7370. _velocityWorldLength: number;
  7371. /** @hidden */
  7372. _basePointWorld: Vector3;
  7373. private _velocityWorld;
  7374. private _normalizedVelocity;
  7375. /** @hidden */
  7376. _initialVelocity: Vector3;
  7377. /** @hidden */
  7378. _initialPosition: Vector3;
  7379. private _nearestDistance;
  7380. private _collisionMask;
  7381. collisionMask: number;
  7382. /**
  7383. * Gets the plane normal used to compute the sliding response (in local space)
  7384. */
  7385. readonly slidePlaneNormal: Vector3;
  7386. /** @hidden */
  7387. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7388. /** @hidden */
  7389. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7390. /** @hidden */
  7391. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7392. /** @hidden */
  7393. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7394. /** @hidden */
  7395. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7396. /** @hidden */
  7397. _getResponse(pos: Vector3, vel: Vector3): void;
  7398. }
  7399. }
  7400. declare module "babylonjs/Culling/boundingInfo" {
  7401. import { DeepImmutable } from "babylonjs/types";
  7402. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7403. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7404. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7405. import { Collider } from "babylonjs/Collisions/collider";
  7406. /**
  7407. * Interface for cullable objects
  7408. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7409. */
  7410. export interface ICullable {
  7411. /**
  7412. * Checks if the object or part of the object is in the frustum
  7413. * @param frustumPlanes Camera near/planes
  7414. * @returns true if the object is in frustum otherwise false
  7415. */
  7416. isInFrustum(frustumPlanes: Plane[]): boolean;
  7417. /**
  7418. * Checks if a cullable object (mesh...) is in the camera frustum
  7419. * Unlike isInFrustum this cheks the full bounding box
  7420. * @param frustumPlanes Camera near/planes
  7421. * @returns true if the object is in frustum otherwise false
  7422. */
  7423. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7424. }
  7425. /**
  7426. * Info for a bounding data of a mesh
  7427. */
  7428. export class BoundingInfo implements ICullable {
  7429. /**
  7430. * Bounding box for the mesh
  7431. */
  7432. readonly boundingBox: BoundingBox;
  7433. /**
  7434. * Bounding sphere for the mesh
  7435. */
  7436. readonly boundingSphere: BoundingSphere;
  7437. private _isLocked;
  7438. private static readonly TmpVector3;
  7439. /**
  7440. * Constructs bounding info
  7441. * @param minimum min vector of the bounding box/sphere
  7442. * @param maximum max vector of the bounding box/sphere
  7443. * @param worldMatrix defines the new world matrix
  7444. */
  7445. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7446. /**
  7447. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7448. * @param min defines the new minimum vector (in local space)
  7449. * @param max defines the new maximum vector (in local space)
  7450. * @param worldMatrix defines the new world matrix
  7451. */
  7452. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7453. /**
  7454. * min vector of the bounding box/sphere
  7455. */
  7456. readonly minimum: Vector3;
  7457. /**
  7458. * max vector of the bounding box/sphere
  7459. */
  7460. readonly maximum: Vector3;
  7461. /**
  7462. * If the info is locked and won't be updated to avoid perf overhead
  7463. */
  7464. isLocked: boolean;
  7465. /**
  7466. * Updates the bounding sphere and box
  7467. * @param world world matrix to be used to update
  7468. */
  7469. update(world: DeepImmutable<Matrix>): void;
  7470. /**
  7471. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7472. * @param center New center of the bounding info
  7473. * @param extend New extend of the bounding info
  7474. * @returns the current bounding info
  7475. */
  7476. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7477. /**
  7478. * Scale the current bounding info by applying a scale factor
  7479. * @param factor defines the scale factor to apply
  7480. * @returns the current bounding info
  7481. */
  7482. scale(factor: number): BoundingInfo;
  7483. /**
  7484. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7485. * @param frustumPlanes defines the frustum to test
  7486. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7487. * @returns true if the bounding info is in the frustum planes
  7488. */
  7489. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7490. /**
  7491. * Gets the world distance between the min and max points of the bounding box
  7492. */
  7493. readonly diagonalLength: number;
  7494. /**
  7495. * Checks if a cullable object (mesh...) is in the camera frustum
  7496. * Unlike isInFrustum this cheks the full bounding box
  7497. * @param frustumPlanes Camera near/planes
  7498. * @returns true if the object is in frustum otherwise false
  7499. */
  7500. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7501. /** @hidden */
  7502. _checkCollision(collider: Collider): boolean;
  7503. /**
  7504. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7505. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7506. * @param point the point to check intersection with
  7507. * @returns if the point intersects
  7508. */
  7509. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7510. /**
  7511. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7512. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7513. * @param boundingInfo the bounding info to check intersection with
  7514. * @param precise if the intersection should be done using OBB
  7515. * @returns if the bounding info intersects
  7516. */
  7517. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7518. }
  7519. }
  7520. declare module "babylonjs/Misc/smartArray" {
  7521. /**
  7522. * Defines an array and its length.
  7523. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7524. */
  7525. export interface ISmartArrayLike<T> {
  7526. /**
  7527. * The data of the array.
  7528. */
  7529. data: Array<T>;
  7530. /**
  7531. * The active length of the array.
  7532. */
  7533. length: number;
  7534. }
  7535. /**
  7536. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7537. */
  7538. export class SmartArray<T> implements ISmartArrayLike<T> {
  7539. /**
  7540. * The full set of data from the array.
  7541. */
  7542. data: Array<T>;
  7543. /**
  7544. * The active length of the array.
  7545. */
  7546. length: number;
  7547. protected _id: number;
  7548. /**
  7549. * Instantiates a Smart Array.
  7550. * @param capacity defines the default capacity of the array.
  7551. */
  7552. constructor(capacity: number);
  7553. /**
  7554. * Pushes a value at the end of the active data.
  7555. * @param value defines the object to push in the array.
  7556. */
  7557. push(value: T): void;
  7558. /**
  7559. * Iterates over the active data and apply the lambda to them.
  7560. * @param func defines the action to apply on each value.
  7561. */
  7562. forEach(func: (content: T) => void): void;
  7563. /**
  7564. * Sorts the full sets of data.
  7565. * @param compareFn defines the comparison function to apply.
  7566. */
  7567. sort(compareFn: (a: T, b: T) => number): void;
  7568. /**
  7569. * Resets the active data to an empty array.
  7570. */
  7571. reset(): void;
  7572. /**
  7573. * Releases all the data from the array as well as the array.
  7574. */
  7575. dispose(): void;
  7576. /**
  7577. * Concats the active data with a given array.
  7578. * @param array defines the data to concatenate with.
  7579. */
  7580. concat(array: any): void;
  7581. /**
  7582. * Returns the position of a value in the active data.
  7583. * @param value defines the value to find the index for
  7584. * @returns the index if found in the active data otherwise -1
  7585. */
  7586. indexOf(value: T): number;
  7587. /**
  7588. * Returns whether an element is part of the active data.
  7589. * @param value defines the value to look for
  7590. * @returns true if found in the active data otherwise false
  7591. */
  7592. contains(value: T): boolean;
  7593. private static _GlobalId;
  7594. }
  7595. /**
  7596. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7597. * The data in this array can only be present once
  7598. */
  7599. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7600. private _duplicateId;
  7601. /**
  7602. * Pushes a value at the end of the active data.
  7603. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7604. * @param value defines the object to push in the array.
  7605. */
  7606. push(value: T): void;
  7607. /**
  7608. * Pushes a value at the end of the active data.
  7609. * If the data is already present, it won t be added again
  7610. * @param value defines the object to push in the array.
  7611. * @returns true if added false if it was already present
  7612. */
  7613. pushNoDuplicate(value: T): boolean;
  7614. /**
  7615. * Resets the active data to an empty array.
  7616. */
  7617. reset(): void;
  7618. /**
  7619. * Concats the active data with a given array.
  7620. * This ensures no dupplicate will be present in the result.
  7621. * @param array defines the data to concatenate with.
  7622. */
  7623. concatWithNoDuplicate(array: any): void;
  7624. }
  7625. }
  7626. declare module "babylonjs/Misc/iInspectable" {
  7627. /**
  7628. * Enum that determines the text-wrapping mode to use.
  7629. */
  7630. export enum InspectableType {
  7631. /**
  7632. * Checkbox for booleans
  7633. */
  7634. Checkbox = 0,
  7635. /**
  7636. * Sliders for numbers
  7637. */
  7638. Slider = 1,
  7639. /**
  7640. * Vector3
  7641. */
  7642. Vector3 = 2,
  7643. /**
  7644. * Quaternions
  7645. */
  7646. Quaternion = 3,
  7647. /**
  7648. * Color3
  7649. */
  7650. Color3 = 4,
  7651. /**
  7652. * String
  7653. */
  7654. String = 5
  7655. }
  7656. /**
  7657. * Interface used to define custom inspectable properties.
  7658. * This interface is used by the inspector to display custom property grids
  7659. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7660. */
  7661. export interface IInspectable {
  7662. /**
  7663. * Gets the label to display
  7664. */
  7665. label: string;
  7666. /**
  7667. * Gets the name of the property to edit
  7668. */
  7669. propertyName: string;
  7670. /**
  7671. * Gets the type of the editor to use
  7672. */
  7673. type: InspectableType;
  7674. /**
  7675. * Gets the minimum value of the property when using in "slider" mode
  7676. */
  7677. min?: number;
  7678. /**
  7679. * Gets the maximum value of the property when using in "slider" mode
  7680. */
  7681. max?: number;
  7682. /**
  7683. * Gets the setp to use when using in "slider" mode
  7684. */
  7685. step?: number;
  7686. }
  7687. }
  7688. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7689. import { Nullable } from "babylonjs/types";
  7690. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7691. /**
  7692. * This represents the required contract to create a new type of texture loader.
  7693. */
  7694. export interface IInternalTextureLoader {
  7695. /**
  7696. * Defines wether the loader supports cascade loading the different faces.
  7697. */
  7698. supportCascades: boolean;
  7699. /**
  7700. * This returns if the loader support the current file information.
  7701. * @param extension defines the file extension of the file being loaded
  7702. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7703. * @param fallback defines the fallback internal texture if any
  7704. * @param isBase64 defines whether the texture is encoded as a base64
  7705. * @param isBuffer defines whether the texture data are stored as a buffer
  7706. * @returns true if the loader can load the specified file
  7707. */
  7708. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7709. /**
  7710. * Transform the url before loading if required.
  7711. * @param rootUrl the url of the texture
  7712. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7713. * @returns the transformed texture
  7714. */
  7715. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7716. /**
  7717. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7718. * @param rootUrl the url of the texture
  7719. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7720. * @returns the fallback texture
  7721. */
  7722. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7723. /**
  7724. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7725. * @param data contains the texture data
  7726. * @param texture defines the BabylonJS internal texture
  7727. * @param createPolynomials will be true if polynomials have been requested
  7728. * @param onLoad defines the callback to trigger once the texture is ready
  7729. * @param onError defines the callback to trigger in case of error
  7730. */
  7731. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7732. /**
  7733. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7734. * @param data contains the texture data
  7735. * @param texture defines the BabylonJS internal texture
  7736. * @param callback defines the method to call once ready to upload
  7737. */
  7738. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7739. }
  7740. }
  7741. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7742. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7743. import { Nullable } from "babylonjs/types";
  7744. import { Scene } from "babylonjs/scene";
  7745. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7746. module "babylonjs/Engines/engine" {
  7747. interface Engine {
  7748. /**
  7749. * Creates a depth stencil cube texture.
  7750. * This is only available in WebGL 2.
  7751. * @param size The size of face edge in the cube texture.
  7752. * @param options The options defining the cube texture.
  7753. * @returns The cube texture
  7754. */
  7755. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7756. /**
  7757. * Creates a cube texture
  7758. * @param rootUrl defines the url where the files to load is located
  7759. * @param scene defines the current scene
  7760. * @param files defines the list of files to load (1 per face)
  7761. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7762. * @param onLoad defines an optional callback raised when the texture is loaded
  7763. * @param onError defines an optional callback raised if there is an issue to load the texture
  7764. * @param format defines the format of the data
  7765. * @param forcedExtension defines the extension to use to pick the right loader
  7766. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7767. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7768. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7769. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7770. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7771. * @returns the cube texture as an InternalTexture
  7772. */
  7773. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7774. /**
  7775. * Creates a cube texture
  7776. * @param rootUrl defines the url where the files to load is located
  7777. * @param scene defines the current scene
  7778. * @param files defines the list of files to load (1 per face)
  7779. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7780. * @param onLoad defines an optional callback raised when the texture is loaded
  7781. * @param onError defines an optional callback raised if there is an issue to load the texture
  7782. * @param format defines the format of the data
  7783. * @param forcedExtension defines the extension to use to pick the right loader
  7784. * @returns the cube texture as an InternalTexture
  7785. */
  7786. 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;
  7787. /**
  7788. * Creates a cube texture
  7789. * @param rootUrl defines the url where the files to load is located
  7790. * @param scene defines the current scene
  7791. * @param files defines the list of files to load (1 per face)
  7792. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7793. * @param onLoad defines an optional callback raised when the texture is loaded
  7794. * @param onError defines an optional callback raised if there is an issue to load the texture
  7795. * @param format defines the format of the data
  7796. * @param forcedExtension defines the extension to use to pick the right loader
  7797. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7798. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7799. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7800. * @returns the cube texture as an InternalTexture
  7801. */
  7802. 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;
  7803. /** @hidden */
  7804. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7805. /** @hidden */
  7806. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7807. /** @hidden */
  7808. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7809. /** @hidden */
  7810. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7811. }
  7812. }
  7813. }
  7814. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7815. import { Nullable } from "babylonjs/types";
  7816. import { Scene } from "babylonjs/scene";
  7817. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  7818. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7819. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7820. /**
  7821. * Class for creating a cube texture
  7822. */
  7823. export class CubeTexture extends BaseTexture {
  7824. private _delayedOnLoad;
  7825. /**
  7826. * The url of the texture
  7827. */
  7828. url: string;
  7829. /**
  7830. * Gets or sets the center of the bounding box associated with the cube texture.
  7831. * It must define where the camera used to render the texture was set
  7832. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7833. */
  7834. boundingBoxPosition: Vector3;
  7835. private _boundingBoxSize;
  7836. /**
  7837. * Gets or sets the size of the bounding box associated with the cube texture
  7838. * When defined, the cubemap will switch to local mode
  7839. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7840. * @example https://www.babylonjs-playground.com/#RNASML
  7841. */
  7842. /**
  7843. * Returns the bounding box size
  7844. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7845. */
  7846. boundingBoxSize: Vector3;
  7847. protected _rotationY: number;
  7848. /**
  7849. * Sets texture matrix rotation angle around Y axis in radians.
  7850. */
  7851. /**
  7852. * Gets texture matrix rotation angle around Y axis radians.
  7853. */
  7854. rotationY: number;
  7855. /**
  7856. * Are mip maps generated for this texture or not.
  7857. */
  7858. readonly noMipmap: boolean;
  7859. private _noMipmap;
  7860. private _files;
  7861. private _extensions;
  7862. private _textureMatrix;
  7863. private _format;
  7864. private _createPolynomials;
  7865. /** @hidden */
  7866. _prefiltered: boolean;
  7867. /**
  7868. * Creates a cube texture from an array of image urls
  7869. * @param files defines an array of image urls
  7870. * @param scene defines the hosting scene
  7871. * @param noMipmap specifies if mip maps are not used
  7872. * @returns a cube texture
  7873. */
  7874. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7875. /**
  7876. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7877. * @param url defines the url of the prefiltered texture
  7878. * @param scene defines the scene the texture is attached to
  7879. * @param forcedExtension defines the extension of the file if different from the url
  7880. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7881. * @return the prefiltered texture
  7882. */
  7883. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7884. /**
  7885. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7886. * as prefiltered data.
  7887. * @param rootUrl defines the url of the texture or the root name of the six images
  7888. * @param scene defines the scene the texture is attached to
  7889. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7890. * @param noMipmap defines if mipmaps should be created or not
  7891. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7892. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7893. * @param onError defines a callback triggered in case of error during load
  7894. * @param format defines the internal format to use for the texture once loaded
  7895. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7896. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7897. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7898. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7899. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7900. * @return the cube texture
  7901. */
  7902. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7903. /**
  7904. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7905. */
  7906. readonly isPrefiltered: boolean;
  7907. /**
  7908. * Get the current class name of the texture useful for serialization or dynamic coding.
  7909. * @returns "CubeTexture"
  7910. */
  7911. getClassName(): string;
  7912. /**
  7913. * Update the url (and optional buffer) of this texture if url was null during construction.
  7914. * @param url the url of the texture
  7915. * @param forcedExtension defines the extension to use
  7916. * @param onLoad callback called when the texture is loaded (defaults to null)
  7917. */
  7918. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7919. /**
  7920. * Delays loading of the cube texture
  7921. * @param forcedExtension defines the extension to use
  7922. */
  7923. delayLoad(forcedExtension?: string): void;
  7924. /**
  7925. * Returns the reflection texture matrix
  7926. * @returns the reflection texture matrix
  7927. */
  7928. getReflectionTextureMatrix(): Matrix;
  7929. /**
  7930. * Sets the reflection texture matrix
  7931. * @param value Reflection texture matrix
  7932. */
  7933. setReflectionTextureMatrix(value: Matrix): void;
  7934. /**
  7935. * Parses text to create a cube texture
  7936. * @param parsedTexture define the serialized text to read from
  7937. * @param scene defines the hosting scene
  7938. * @param rootUrl defines the root url of the cube texture
  7939. * @returns a cube texture
  7940. */
  7941. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7942. /**
  7943. * Makes a clone, or deep copy, of the cube texture
  7944. * @returns a new cube texture
  7945. */
  7946. clone(): CubeTexture;
  7947. }
  7948. }
  7949. declare module "babylonjs/Shaders/postprocess.vertex" {
  7950. /** @hidden */
  7951. export var postprocessVertexShader: {
  7952. name: string;
  7953. shader: string;
  7954. };
  7955. }
  7956. declare module "babylonjs/Cameras/targetCamera" {
  7957. import { Nullable } from "babylonjs/types";
  7958. import { Camera } from "babylonjs/Cameras/camera";
  7959. import { Scene } from "babylonjs/scene";
  7960. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  7961. /**
  7962. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7963. * This is the base of the follow, arc rotate cameras and Free camera
  7964. * @see http://doc.babylonjs.com/features/cameras
  7965. */
  7966. export class TargetCamera extends Camera {
  7967. private static _RigCamTransformMatrix;
  7968. private static _TargetTransformMatrix;
  7969. private static _TargetFocalPoint;
  7970. /**
  7971. * Define the current direction the camera is moving to
  7972. */
  7973. cameraDirection: Vector3;
  7974. /**
  7975. * Define the current rotation the camera is rotating to
  7976. */
  7977. cameraRotation: Vector2;
  7978. /**
  7979. * When set, the up vector of the camera will be updated by the rotation of the camera
  7980. */
  7981. updateUpVectorFromRotation: boolean;
  7982. private _tmpQuaternion;
  7983. /**
  7984. * Define the current rotation of the camera
  7985. */
  7986. rotation: Vector3;
  7987. /**
  7988. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7989. */
  7990. rotationQuaternion: Quaternion;
  7991. /**
  7992. * Define the current speed of the camera
  7993. */
  7994. speed: number;
  7995. /**
  7996. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7997. * around all axis.
  7998. */
  7999. noRotationConstraint: boolean;
  8000. /**
  8001. * Define the current target of the camera as an object or a position.
  8002. */
  8003. lockedTarget: any;
  8004. /** @hidden */
  8005. _currentTarget: Vector3;
  8006. /** @hidden */
  8007. _initialFocalDistance: number;
  8008. /** @hidden */
  8009. _viewMatrix: Matrix;
  8010. /** @hidden */
  8011. _camMatrix: Matrix;
  8012. /** @hidden */
  8013. _cameraTransformMatrix: Matrix;
  8014. /** @hidden */
  8015. _cameraRotationMatrix: Matrix;
  8016. /** @hidden */
  8017. _referencePoint: Vector3;
  8018. /** @hidden */
  8019. _transformedReferencePoint: Vector3;
  8020. protected _globalCurrentTarget: Vector3;
  8021. protected _globalCurrentUpVector: Vector3;
  8022. /** @hidden */
  8023. _reset: () => void;
  8024. private _defaultUp;
  8025. /**
  8026. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8027. * This is the base of the follow, arc rotate cameras and Free camera
  8028. * @see http://doc.babylonjs.com/features/cameras
  8029. * @param name Defines the name of the camera in the scene
  8030. * @param position Defines the start position of the camera in the scene
  8031. * @param scene Defines the scene the camera belongs to
  8032. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8033. */
  8034. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8035. /**
  8036. * Gets the position in front of the camera at a given distance.
  8037. * @param distance The distance from the camera we want the position to be
  8038. * @returns the position
  8039. */
  8040. getFrontPosition(distance: number): Vector3;
  8041. /** @hidden */
  8042. _getLockedTargetPosition(): Nullable<Vector3>;
  8043. private _storedPosition;
  8044. private _storedRotation;
  8045. private _storedRotationQuaternion;
  8046. /**
  8047. * Store current camera state of the camera (fov, position, rotation, etc..)
  8048. * @returns the camera
  8049. */
  8050. storeState(): Camera;
  8051. /**
  8052. * Restored camera state. You must call storeState() first
  8053. * @returns whether it was successful or not
  8054. * @hidden
  8055. */
  8056. _restoreStateValues(): boolean;
  8057. /** @hidden */
  8058. _initCache(): void;
  8059. /** @hidden */
  8060. _updateCache(ignoreParentClass?: boolean): void;
  8061. /** @hidden */
  8062. _isSynchronizedViewMatrix(): boolean;
  8063. /** @hidden */
  8064. _computeLocalCameraSpeed(): number;
  8065. /**
  8066. * Defines the target the camera should look at.
  8067. * @param target Defines the new target as a Vector or a mesh
  8068. */
  8069. setTarget(target: Vector3): void;
  8070. /**
  8071. * Return the current target position of the camera. This value is expressed in local space.
  8072. * @returns the target position
  8073. */
  8074. getTarget(): Vector3;
  8075. /** @hidden */
  8076. _decideIfNeedsToMove(): boolean;
  8077. /** @hidden */
  8078. _updatePosition(): void;
  8079. /** @hidden */
  8080. _checkInputs(): void;
  8081. protected _updateCameraRotationMatrix(): void;
  8082. /**
  8083. * 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)
  8084. * @returns the current camera
  8085. */
  8086. private _rotateUpVectorWithCameraRotationMatrix;
  8087. private _cachedRotationZ;
  8088. private _cachedQuaternionRotationZ;
  8089. /** @hidden */
  8090. _getViewMatrix(): Matrix;
  8091. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8092. /**
  8093. * @hidden
  8094. */
  8095. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8096. /**
  8097. * @hidden
  8098. */
  8099. _updateRigCameras(): void;
  8100. private _getRigCamPositionAndTarget;
  8101. /**
  8102. * Gets the current object class name.
  8103. * @return the class name
  8104. */
  8105. getClassName(): string;
  8106. }
  8107. }
  8108. declare module "babylonjs/Cameras/cameraInputsManager" {
  8109. import { Nullable } from "babylonjs/types";
  8110. import { Camera } from "babylonjs/Cameras/camera";
  8111. /**
  8112. * @ignore
  8113. * This is a list of all the different input types that are available in the application.
  8114. * Fo instance: ArcRotateCameraGamepadInput...
  8115. */
  8116. export var CameraInputTypes: {};
  8117. /**
  8118. * This is the contract to implement in order to create a new input class.
  8119. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8120. */
  8121. export interface ICameraInput<TCamera extends Camera> {
  8122. /**
  8123. * Defines the camera the input is attached to.
  8124. */
  8125. camera: Nullable<TCamera>;
  8126. /**
  8127. * Gets the class name of the current intput.
  8128. * @returns the class name
  8129. */
  8130. getClassName(): string;
  8131. /**
  8132. * Get the friendly name associated with the input class.
  8133. * @returns the input friendly name
  8134. */
  8135. getSimpleName(): string;
  8136. /**
  8137. * Attach the input controls to a specific dom element to get the input from.
  8138. * @param element Defines the element the controls should be listened from
  8139. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8140. */
  8141. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8142. /**
  8143. * Detach the current controls from the specified dom element.
  8144. * @param element Defines the element to stop listening the inputs from
  8145. */
  8146. detachControl(element: Nullable<HTMLElement>): void;
  8147. /**
  8148. * Update the current camera state depending on the inputs that have been used this frame.
  8149. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8150. */
  8151. checkInputs?: () => void;
  8152. }
  8153. /**
  8154. * Represents a map of input types to input instance or input index to input instance.
  8155. */
  8156. export interface CameraInputsMap<TCamera extends Camera> {
  8157. /**
  8158. * Accessor to the input by input type.
  8159. */
  8160. [name: string]: ICameraInput<TCamera>;
  8161. /**
  8162. * Accessor to the input by input index.
  8163. */
  8164. [idx: number]: ICameraInput<TCamera>;
  8165. }
  8166. /**
  8167. * This represents the input manager used within a camera.
  8168. * It helps dealing with all the different kind of input attached to a camera.
  8169. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8170. */
  8171. export class CameraInputsManager<TCamera extends Camera> {
  8172. /**
  8173. * Defines the list of inputs attahed to the camera.
  8174. */
  8175. attached: CameraInputsMap<TCamera>;
  8176. /**
  8177. * Defines the dom element the camera is collecting inputs from.
  8178. * This is null if the controls have not been attached.
  8179. */
  8180. attachedElement: Nullable<HTMLElement>;
  8181. /**
  8182. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8183. */
  8184. noPreventDefault: boolean;
  8185. /**
  8186. * Defined the camera the input manager belongs to.
  8187. */
  8188. camera: TCamera;
  8189. /**
  8190. * Update the current camera state depending on the inputs that have been used this frame.
  8191. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8192. */
  8193. checkInputs: () => void;
  8194. /**
  8195. * Instantiate a new Camera Input Manager.
  8196. * @param camera Defines the camera the input manager blongs to
  8197. */
  8198. constructor(camera: TCamera);
  8199. /**
  8200. * Add an input method to a camera
  8201. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8202. * @param input camera input method
  8203. */
  8204. add(input: ICameraInput<TCamera>): void;
  8205. /**
  8206. * Remove a specific input method from a camera
  8207. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8208. * @param inputToRemove camera input method
  8209. */
  8210. remove(inputToRemove: ICameraInput<TCamera>): void;
  8211. /**
  8212. * Remove a specific input type from a camera
  8213. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8214. * @param inputType the type of the input to remove
  8215. */
  8216. removeByType(inputType: string): void;
  8217. private _addCheckInputs;
  8218. /**
  8219. * Attach the input controls to the currently attached dom element to listen the events from.
  8220. * @param input Defines the input to attach
  8221. */
  8222. attachInput(input: ICameraInput<TCamera>): void;
  8223. /**
  8224. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8225. * @param element Defines the dom element to collect the events from
  8226. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8227. */
  8228. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8229. /**
  8230. * Detach the current manager inputs controls from a specific dom element.
  8231. * @param element Defines the dom element to collect the events from
  8232. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8233. */
  8234. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8235. /**
  8236. * Rebuild the dynamic inputCheck function from the current list of
  8237. * defined inputs in the manager.
  8238. */
  8239. rebuildInputCheck(): void;
  8240. /**
  8241. * Remove all attached input methods from a camera
  8242. */
  8243. clear(): void;
  8244. /**
  8245. * Serialize the current input manager attached to a camera.
  8246. * This ensures than once parsed,
  8247. * the input associated to the camera will be identical to the current ones
  8248. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8249. */
  8250. serialize(serializedCamera: any): void;
  8251. /**
  8252. * Parses an input manager serialized JSON to restore the previous list of inputs
  8253. * and states associated to a camera.
  8254. * @param parsedCamera Defines the JSON to parse
  8255. */
  8256. parse(parsedCamera: any): void;
  8257. }
  8258. }
  8259. declare module "babylonjs/Events/keyboardEvents" {
  8260. /**
  8261. * Gather the list of keyboard event types as constants.
  8262. */
  8263. export class KeyboardEventTypes {
  8264. /**
  8265. * The keydown event is fired when a key becomes active (pressed).
  8266. */
  8267. static readonly KEYDOWN: number;
  8268. /**
  8269. * The keyup event is fired when a key has been released.
  8270. */
  8271. static readonly KEYUP: number;
  8272. }
  8273. /**
  8274. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8275. */
  8276. export class KeyboardInfo {
  8277. /**
  8278. * Defines the type of event (KeyboardEventTypes)
  8279. */
  8280. type: number;
  8281. /**
  8282. * Defines the related dom event
  8283. */
  8284. event: KeyboardEvent;
  8285. /**
  8286. * Instantiates a new keyboard info.
  8287. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8288. * @param type Defines the type of event (KeyboardEventTypes)
  8289. * @param event Defines the related dom event
  8290. */
  8291. constructor(
  8292. /**
  8293. * Defines the type of event (KeyboardEventTypes)
  8294. */
  8295. type: number,
  8296. /**
  8297. * Defines the related dom event
  8298. */
  8299. event: KeyboardEvent);
  8300. }
  8301. /**
  8302. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8303. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8304. */
  8305. export class KeyboardInfoPre extends KeyboardInfo {
  8306. /**
  8307. * Defines the type of event (KeyboardEventTypes)
  8308. */
  8309. type: number;
  8310. /**
  8311. * Defines the related dom event
  8312. */
  8313. event: KeyboardEvent;
  8314. /**
  8315. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8316. */
  8317. skipOnPointerObservable: boolean;
  8318. /**
  8319. * Instantiates a new keyboard pre info.
  8320. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8321. * @param type Defines the type of event (KeyboardEventTypes)
  8322. * @param event Defines the related dom event
  8323. */
  8324. constructor(
  8325. /**
  8326. * Defines the type of event (KeyboardEventTypes)
  8327. */
  8328. type: number,
  8329. /**
  8330. * Defines the related dom event
  8331. */
  8332. event: KeyboardEvent);
  8333. }
  8334. }
  8335. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8336. import { Nullable } from "babylonjs/types";
  8337. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8338. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8339. /**
  8340. * Manage the keyboard inputs to control the movement of a free camera.
  8341. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8342. */
  8343. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8344. /**
  8345. * Defines the camera the input is attached to.
  8346. */
  8347. camera: FreeCamera;
  8348. /**
  8349. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8350. */
  8351. keysUp: number[];
  8352. /**
  8353. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8354. */
  8355. keysDown: number[];
  8356. /**
  8357. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8358. */
  8359. keysLeft: number[];
  8360. /**
  8361. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8362. */
  8363. keysRight: number[];
  8364. private _keys;
  8365. private _onCanvasBlurObserver;
  8366. private _onKeyboardObserver;
  8367. private _engine;
  8368. private _scene;
  8369. /**
  8370. * Attach the input controls to a specific dom element to get the input from.
  8371. * @param element Defines the element the controls should be listened from
  8372. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8373. */
  8374. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8375. /**
  8376. * Detach the current controls from the specified dom element.
  8377. * @param element Defines the element to stop listening the inputs from
  8378. */
  8379. detachControl(element: Nullable<HTMLElement>): void;
  8380. /**
  8381. * Update the current camera state depending on the inputs that have been used this frame.
  8382. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8383. */
  8384. checkInputs(): void;
  8385. /**
  8386. * Gets the class name of the current intput.
  8387. * @returns the class name
  8388. */
  8389. getClassName(): string;
  8390. /** @hidden */
  8391. _onLostFocus(): void;
  8392. /**
  8393. * Get the friendly name associated with the input class.
  8394. * @returns the input friendly name
  8395. */
  8396. getSimpleName(): string;
  8397. }
  8398. }
  8399. declare module "babylonjs/Materials/multiMaterial" {
  8400. import { Nullable } from "babylonjs/types";
  8401. import { Scene } from "babylonjs/scene";
  8402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8403. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  8404. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8405. import { Material } from "babylonjs/Materials/material";
  8406. /**
  8407. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8408. * separate meshes. This can be use to improve performances.
  8409. * @see http://doc.babylonjs.com/how_to/multi_materials
  8410. */
  8411. export class MultiMaterial extends Material {
  8412. private _subMaterials;
  8413. /**
  8414. * Gets or Sets the list of Materials used within the multi material.
  8415. * They need to be ordered according to the submeshes order in the associated mesh
  8416. */
  8417. subMaterials: Nullable<Material>[];
  8418. /**
  8419. * Function used to align with Node.getChildren()
  8420. * @returns the list of Materials used within the multi material
  8421. */
  8422. getChildren(): Nullable<Material>[];
  8423. /**
  8424. * Instantiates a new Multi Material
  8425. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8426. * separate meshes. This can be use to improve performances.
  8427. * @see http://doc.babylonjs.com/how_to/multi_materials
  8428. * @param name Define the name in the scene
  8429. * @param scene Define the scene the material belongs to
  8430. */
  8431. constructor(name: string, scene: Scene);
  8432. private _hookArray;
  8433. /**
  8434. * Get one of the submaterial by its index in the submaterials array
  8435. * @param index The index to look the sub material at
  8436. * @returns The Material if the index has been defined
  8437. */
  8438. getSubMaterial(index: number): Nullable<Material>;
  8439. /**
  8440. * Get the list of active textures for the whole sub materials list.
  8441. * @returns All the textures that will be used during the rendering
  8442. */
  8443. getActiveTextures(): BaseTexture[];
  8444. /**
  8445. * Gets the current class name of the material e.g. "MultiMaterial"
  8446. * Mainly use in serialization.
  8447. * @returns the class name
  8448. */
  8449. getClassName(): string;
  8450. /**
  8451. * Checks if the material is ready to render the requested sub mesh
  8452. * @param mesh Define the mesh the submesh belongs to
  8453. * @param subMesh Define the sub mesh to look readyness for
  8454. * @param useInstances Define whether or not the material is used with instances
  8455. * @returns true if ready, otherwise false
  8456. */
  8457. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  8458. /**
  8459. * Clones the current material and its related sub materials
  8460. * @param name Define the name of the newly cloned material
  8461. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  8462. * @returns the cloned material
  8463. */
  8464. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  8465. /**
  8466. * Serializes the materials into a JSON representation.
  8467. * @returns the JSON representation
  8468. */
  8469. serialize(): any;
  8470. /**
  8471. * Dispose the material and release its associated resources
  8472. * @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)
  8473. * @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)
  8474. * @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)
  8475. */
  8476. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  8477. /**
  8478. * Creates a MultiMaterial from parsed MultiMaterial data.
  8479. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  8480. * @param scene defines the hosting scene
  8481. * @returns a new MultiMaterial
  8482. */
  8483. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  8484. }
  8485. }
  8486. declare module "babylonjs/Loading/sceneLoaderFlags" {
  8487. /**
  8488. * Class used to represent data loading progression
  8489. */
  8490. export class SceneLoaderFlags {
  8491. private static _ForceFullSceneLoadingForIncremental;
  8492. private static _ShowLoadingScreen;
  8493. private static _CleanBoneMatrixWeights;
  8494. private static _loggingLevel;
  8495. /**
  8496. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  8497. */
  8498. static ForceFullSceneLoadingForIncremental: boolean;
  8499. /**
  8500. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  8501. */
  8502. static ShowLoadingScreen: boolean;
  8503. /**
  8504. * Defines the current logging level (while loading the scene)
  8505. * @ignorenaming
  8506. */
  8507. static loggingLevel: number;
  8508. /**
  8509. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  8510. */
  8511. static CleanBoneMatrixWeights: boolean;
  8512. }
  8513. }
  8514. declare module "babylonjs/Meshes/transformNode" {
  8515. import { DeepImmutable } from "babylonjs/types";
  8516. import { Observable } from "babylonjs/Misc/observable";
  8517. import { Nullable } from "babylonjs/types";
  8518. import { Camera } from "babylonjs/Cameras/camera";
  8519. import { Scene } from "babylonjs/scene";
  8520. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  8521. import { Node } from "babylonjs/node";
  8522. import { Bone } from "babylonjs/Bones/bone";
  8523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8524. /**
  8525. * 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.
  8526. * @see https://doc.babylonjs.com/how_to/transformnode
  8527. */
  8528. export class TransformNode extends Node {
  8529. /**
  8530. * Object will not rotate to face the camera
  8531. */
  8532. static BILLBOARDMODE_NONE: number;
  8533. /**
  8534. * Object will rotate to face the camera but only on the x axis
  8535. */
  8536. static BILLBOARDMODE_X: number;
  8537. /**
  8538. * Object will rotate to face the camera but only on the y axis
  8539. */
  8540. static BILLBOARDMODE_Y: number;
  8541. /**
  8542. * Object will rotate to face the camera but only on the z axis
  8543. */
  8544. static BILLBOARDMODE_Z: number;
  8545. /**
  8546. * Object will rotate to face the camera
  8547. */
  8548. static BILLBOARDMODE_ALL: number;
  8549. private _forward;
  8550. private _forwardInverted;
  8551. private _up;
  8552. private _right;
  8553. private _rightInverted;
  8554. private _position;
  8555. private _rotation;
  8556. private _rotationQuaternion;
  8557. protected _scaling: Vector3;
  8558. protected _isDirty: boolean;
  8559. private _transformToBoneReferal;
  8560. private _billboardMode;
  8561. /**
  8562. * Gets or sets the billboard mode. Default is 0.
  8563. *
  8564. * | Value | Type | Description |
  8565. * | --- | --- | --- |
  8566. * | 0 | BILLBOARDMODE_NONE | |
  8567. * | 1 | BILLBOARDMODE_X | |
  8568. * | 2 | BILLBOARDMODE_Y | |
  8569. * | 4 | BILLBOARDMODE_Z | |
  8570. * | 7 | BILLBOARDMODE_ALL | |
  8571. *
  8572. */
  8573. billboardMode: number;
  8574. private _preserveParentRotationForBillboard;
  8575. /**
  8576. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  8577. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  8578. */
  8579. preserveParentRotationForBillboard: boolean;
  8580. /**
  8581. * 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
  8582. */
  8583. scalingDeterminant: number;
  8584. private _infiniteDistance;
  8585. /**
  8586. * Gets or sets the distance of the object to max, often used by skybox
  8587. */
  8588. infiniteDistance: boolean;
  8589. /**
  8590. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8591. * By default the system will update normals to compensate
  8592. */
  8593. ignoreNonUniformScaling: boolean;
  8594. /**
  8595. * 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
  8596. */
  8597. reIntegrateRotationIntoRotationQuaternion: boolean;
  8598. /** @hidden */
  8599. _poseMatrix: Nullable<Matrix>;
  8600. /** @hidden */
  8601. _localMatrix: Matrix;
  8602. private _usePivotMatrix;
  8603. private _absolutePosition;
  8604. private _pivotMatrix;
  8605. private _pivotMatrixInverse;
  8606. protected _postMultiplyPivotMatrix: boolean;
  8607. protected _isWorldMatrixFrozen: boolean;
  8608. /** @hidden */
  8609. _indexInSceneTransformNodesArray: number;
  8610. /**
  8611. * An event triggered after the world matrix is updated
  8612. */
  8613. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8614. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8615. /**
  8616. * Gets a string identifying the name of the class
  8617. * @returns "TransformNode" string
  8618. */
  8619. getClassName(): string;
  8620. /**
  8621. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8622. */
  8623. position: Vector3;
  8624. /**
  8625. * 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)).
  8626. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8627. */
  8628. rotation: Vector3;
  8629. /**
  8630. * 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)).
  8631. */
  8632. scaling: Vector3;
  8633. /**
  8634. * 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).
  8635. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8636. */
  8637. rotationQuaternion: Nullable<Quaternion>;
  8638. /**
  8639. * The forward direction of that transform in world space.
  8640. */
  8641. readonly forward: Vector3;
  8642. /**
  8643. * The up direction of that transform in world space.
  8644. */
  8645. readonly up: Vector3;
  8646. /**
  8647. * The right direction of that transform in world space.
  8648. */
  8649. readonly right: Vector3;
  8650. /**
  8651. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8652. * @param matrix the matrix to copy the pose from
  8653. * @returns this TransformNode.
  8654. */
  8655. updatePoseMatrix(matrix: Matrix): TransformNode;
  8656. /**
  8657. * Returns the mesh Pose matrix.
  8658. * @returns the pose matrix
  8659. */
  8660. getPoseMatrix(): Matrix;
  8661. /** @hidden */
  8662. _isSynchronized(): boolean;
  8663. /** @hidden */
  8664. _initCache(): void;
  8665. /**
  8666. * Flag the transform node as dirty (Forcing it to update everything)
  8667. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8668. * @returns this transform node
  8669. */
  8670. markAsDirty(property: string): TransformNode;
  8671. /**
  8672. * Returns the current mesh absolute position.
  8673. * Returns a Vector3.
  8674. */
  8675. readonly absolutePosition: Vector3;
  8676. /**
  8677. * Sets a new matrix to apply before all other transformation
  8678. * @param matrix defines the transform matrix
  8679. * @returns the current TransformNode
  8680. */
  8681. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8682. /**
  8683. * Sets a new pivot matrix to the current node
  8684. * @param matrix defines the new pivot matrix to use
  8685. * @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
  8686. * @returns the current TransformNode
  8687. */
  8688. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8689. /**
  8690. * Returns the mesh pivot matrix.
  8691. * Default : Identity.
  8692. * @returns the matrix
  8693. */
  8694. getPivotMatrix(): Matrix;
  8695. /**
  8696. * Prevents the World matrix to be computed any longer.
  8697. * @returns the TransformNode.
  8698. */
  8699. freezeWorldMatrix(): TransformNode;
  8700. /**
  8701. * Allows back the World matrix computation.
  8702. * @returns the TransformNode.
  8703. */
  8704. unfreezeWorldMatrix(): this;
  8705. /**
  8706. * True if the World matrix has been frozen.
  8707. */
  8708. readonly isWorldMatrixFrozen: boolean;
  8709. /**
  8710. * Retuns the mesh absolute position in the World.
  8711. * @returns a Vector3.
  8712. */
  8713. getAbsolutePosition(): Vector3;
  8714. /**
  8715. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8716. * @param absolutePosition the absolute position to set
  8717. * @returns the TransformNode.
  8718. */
  8719. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8720. /**
  8721. * Sets the mesh position in its local space.
  8722. * @param vector3 the position to set in localspace
  8723. * @returns the TransformNode.
  8724. */
  8725. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8726. /**
  8727. * Returns the mesh position in the local space from the current World matrix values.
  8728. * @returns a new Vector3.
  8729. */
  8730. getPositionExpressedInLocalSpace(): Vector3;
  8731. /**
  8732. * Translates the mesh along the passed Vector3 in its local space.
  8733. * @param vector3 the distance to translate in localspace
  8734. * @returns the TransformNode.
  8735. */
  8736. locallyTranslate(vector3: Vector3): TransformNode;
  8737. private static _lookAtVectorCache;
  8738. /**
  8739. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8740. * @param targetPoint the position (must be in same space as current mesh) to look at
  8741. * @param yawCor optional yaw (y-axis) correction in radians
  8742. * @param pitchCor optional pitch (x-axis) correction in radians
  8743. * @param rollCor optional roll (z-axis) correction in radians
  8744. * @param space the choosen space of the target
  8745. * @returns the TransformNode.
  8746. */
  8747. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8748. /**
  8749. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8750. * This Vector3 is expressed in the World space.
  8751. * @param localAxis axis to rotate
  8752. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8753. */
  8754. getDirection(localAxis: Vector3): Vector3;
  8755. /**
  8756. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8757. * localAxis is expressed in the mesh local space.
  8758. * result is computed in the Wordl space from the mesh World matrix.
  8759. * @param localAxis axis to rotate
  8760. * @param result the resulting transformnode
  8761. * @returns this TransformNode.
  8762. */
  8763. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8764. /**
  8765. * Sets this transform node rotation to the given local axis.
  8766. * @param localAxis the axis in local space
  8767. * @param yawCor optional yaw (y-axis) correction in radians
  8768. * @param pitchCor optional pitch (x-axis) correction in radians
  8769. * @param rollCor optional roll (z-axis) correction in radians
  8770. * @returns this TransformNode
  8771. */
  8772. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8773. /**
  8774. * Sets a new pivot point to the current node
  8775. * @param point defines the new pivot point to use
  8776. * @param space defines if the point is in world or local space (local by default)
  8777. * @returns the current TransformNode
  8778. */
  8779. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8780. /**
  8781. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8782. * @returns the pivot point
  8783. */
  8784. getPivotPoint(): Vector3;
  8785. /**
  8786. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8787. * @param result the vector3 to store the result
  8788. * @returns this TransformNode.
  8789. */
  8790. getPivotPointToRef(result: Vector3): TransformNode;
  8791. /**
  8792. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8793. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8794. */
  8795. getAbsolutePivotPoint(): Vector3;
  8796. /**
  8797. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8798. * @param result vector3 to store the result
  8799. * @returns this TransformNode.
  8800. */
  8801. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8802. /**
  8803. * Defines the passed node as the parent of the current node.
  8804. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8805. * @see https://doc.babylonjs.com/how_to/parenting
  8806. * @param node the node ot set as the parent
  8807. * @returns this TransformNode.
  8808. */
  8809. setParent(node: Nullable<Node>): TransformNode;
  8810. private _nonUniformScaling;
  8811. /**
  8812. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8813. */
  8814. readonly nonUniformScaling: boolean;
  8815. /** @hidden */
  8816. _updateNonUniformScalingState(value: boolean): boolean;
  8817. /**
  8818. * Attach the current TransformNode to another TransformNode associated with a bone
  8819. * @param bone Bone affecting the TransformNode
  8820. * @param affectedTransformNode TransformNode associated with the bone
  8821. * @returns this object
  8822. */
  8823. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8824. /**
  8825. * Detach the transform node if its associated with a bone
  8826. * @returns this object
  8827. */
  8828. detachFromBone(): TransformNode;
  8829. private static _rotationAxisCache;
  8830. /**
  8831. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8832. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8833. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8834. * The passed axis is also normalized.
  8835. * @param axis the axis to rotate around
  8836. * @param amount the amount to rotate in radians
  8837. * @param space Space to rotate in (Default: local)
  8838. * @returns the TransformNode.
  8839. */
  8840. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8841. /**
  8842. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8843. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8844. * The passed axis is also normalized. .
  8845. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8846. * @param point the point to rotate around
  8847. * @param axis the axis to rotate around
  8848. * @param amount the amount to rotate in radians
  8849. * @returns the TransformNode
  8850. */
  8851. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8852. /**
  8853. * Translates the mesh along the axis vector for the passed distance in the given space.
  8854. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8855. * @param axis the axis to translate in
  8856. * @param distance the distance to translate
  8857. * @param space Space to rotate in (Default: local)
  8858. * @returns the TransformNode.
  8859. */
  8860. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8861. /**
  8862. * Adds a rotation step to the mesh current rotation.
  8863. * x, y, z are Euler angles expressed in radians.
  8864. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8865. * This means this rotation is made in the mesh local space only.
  8866. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8867. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8868. * ```javascript
  8869. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8870. * ```
  8871. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8872. * 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.
  8873. * @param x Rotation to add
  8874. * @param y Rotation to add
  8875. * @param z Rotation to add
  8876. * @returns the TransformNode.
  8877. */
  8878. addRotation(x: number, y: number, z: number): TransformNode;
  8879. /**
  8880. * @hidden
  8881. */
  8882. protected _getEffectiveParent(): Nullable<Node>;
  8883. /**
  8884. * Computes the world matrix of the node
  8885. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8886. * @returns the world matrix
  8887. */
  8888. computeWorldMatrix(force?: boolean): Matrix;
  8889. protected _afterComputeWorldMatrix(): void;
  8890. /**
  8891. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8892. * @param func callback function to add
  8893. *
  8894. * @returns the TransformNode.
  8895. */
  8896. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8897. /**
  8898. * Removes a registered callback function.
  8899. * @param func callback function to remove
  8900. * @returns the TransformNode.
  8901. */
  8902. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8903. /**
  8904. * Gets the position of the current mesh in camera space
  8905. * @param camera defines the camera to use
  8906. * @returns a position
  8907. */
  8908. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8909. /**
  8910. * Returns the distance from the mesh to the active camera
  8911. * @param camera defines the camera to use
  8912. * @returns the distance
  8913. */
  8914. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8915. /**
  8916. * Clone the current transform node
  8917. * @param name Name of the new clone
  8918. * @param newParent New parent for the clone
  8919. * @param doNotCloneChildren Do not clone children hierarchy
  8920. * @returns the new transform node
  8921. */
  8922. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8923. /**
  8924. * Serializes the objects information.
  8925. * @param currentSerializationObject defines the object to serialize in
  8926. * @returns the serialized object
  8927. */
  8928. serialize(currentSerializationObject?: any): any;
  8929. /**
  8930. * Returns a new TransformNode object parsed from the source provided.
  8931. * @param parsedTransformNode is the source.
  8932. * @param scene the scne the object belongs to
  8933. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8934. * @returns a new TransformNode object parsed from the source provided.
  8935. */
  8936. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8937. /**
  8938. * Get all child-transformNodes of this node
  8939. * @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
  8940. * @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
  8941. * @returns an array of TransformNode
  8942. */
  8943. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8944. /**
  8945. * Releases resources associated with this transform node.
  8946. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8947. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8948. */
  8949. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8950. /**
  8951. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  8952. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  8953. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  8954. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  8955. * @returns the current mesh
  8956. */
  8957. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  8958. }
  8959. }
  8960. declare module "babylonjs/Animations/animationPropertiesOverride" {
  8961. /**
  8962. * Class used to override all child animations of a given target
  8963. */
  8964. export class AnimationPropertiesOverride {
  8965. /**
  8966. * Gets or sets a value indicating if animation blending must be used
  8967. */
  8968. enableBlending: boolean;
  8969. /**
  8970. * Gets or sets the blending speed to use when enableBlending is true
  8971. */
  8972. blendingSpeed: number;
  8973. /**
  8974. * Gets or sets the default loop mode to use
  8975. */
  8976. loopMode: number;
  8977. }
  8978. }
  8979. declare module "babylonjs/Bones/bone" {
  8980. import { Skeleton } from "babylonjs/Bones/skeleton";
  8981. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8982. import { Nullable } from "babylonjs/types";
  8983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8984. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8985. import { Node } from "babylonjs/node";
  8986. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8987. /**
  8988. * Class used to store bone information
  8989. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8990. */
  8991. export class Bone extends Node {
  8992. /**
  8993. * defines the bone name
  8994. */
  8995. name: string;
  8996. private static _tmpVecs;
  8997. private static _tmpQuat;
  8998. private static _tmpMats;
  8999. /**
  9000. * Gets the list of child bones
  9001. */
  9002. children: Bone[];
  9003. /** Gets the animations associated with this bone */
  9004. animations: import("babylonjs/Animations/animation").Animation[];
  9005. /**
  9006. * Gets or sets bone length
  9007. */
  9008. length: number;
  9009. /**
  9010. * @hidden Internal only
  9011. * Set this value to map this bone to a different index in the transform matrices
  9012. * Set this value to -1 to exclude the bone from the transform matrices
  9013. */
  9014. _index: Nullable<number>;
  9015. private _skeleton;
  9016. private _localMatrix;
  9017. private _restPose;
  9018. private _baseMatrix;
  9019. private _absoluteTransform;
  9020. private _invertedAbsoluteTransform;
  9021. private _parent;
  9022. private _scalingDeterminant;
  9023. private _worldTransform;
  9024. private _localScaling;
  9025. private _localRotation;
  9026. private _localPosition;
  9027. private _needToDecompose;
  9028. private _needToCompose;
  9029. /** @hidden */
  9030. _linkedTransformNode: Nullable<TransformNode>;
  9031. /** @hidden */
  9032. _waitingTransformNodeId: Nullable<string>;
  9033. /** @hidden */
  9034. /** @hidden */
  9035. _matrix: Matrix;
  9036. /**
  9037. * Create a new bone
  9038. * @param name defines the bone name
  9039. * @param skeleton defines the parent skeleton
  9040. * @param parentBone defines the parent (can be null if the bone is the root)
  9041. * @param localMatrix defines the local matrix
  9042. * @param restPose defines the rest pose matrix
  9043. * @param baseMatrix defines the base matrix
  9044. * @param index defines index of the bone in the hiearchy
  9045. */
  9046. constructor(
  9047. /**
  9048. * defines the bone name
  9049. */
  9050. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  9051. /**
  9052. * Gets the current object class name.
  9053. * @return the class name
  9054. */
  9055. getClassName(): string;
  9056. /**
  9057. * Gets the parent skeleton
  9058. * @returns a skeleton
  9059. */
  9060. getSkeleton(): Skeleton;
  9061. /**
  9062. * Gets parent bone
  9063. * @returns a bone or null if the bone is the root of the bone hierarchy
  9064. */
  9065. getParent(): Nullable<Bone>;
  9066. /**
  9067. * Returns an array containing the root bones
  9068. * @returns an array containing the root bones
  9069. */
  9070. getChildren(): Array<Bone>;
  9071. /**
  9072. * Sets the parent bone
  9073. * @param parent defines the parent (can be null if the bone is the root)
  9074. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9075. */
  9076. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  9077. /**
  9078. * Gets the local matrix
  9079. * @returns a matrix
  9080. */
  9081. getLocalMatrix(): Matrix;
  9082. /**
  9083. * Gets the base matrix (initial matrix which remains unchanged)
  9084. * @returns a matrix
  9085. */
  9086. getBaseMatrix(): Matrix;
  9087. /**
  9088. * Gets the rest pose matrix
  9089. * @returns a matrix
  9090. */
  9091. getRestPose(): Matrix;
  9092. /**
  9093. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9094. */
  9095. getWorldMatrix(): Matrix;
  9096. /**
  9097. * Sets the local matrix to rest pose matrix
  9098. */
  9099. returnToRest(): void;
  9100. /**
  9101. * Gets the inverse of the absolute transform matrix.
  9102. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9103. * @returns a matrix
  9104. */
  9105. getInvertedAbsoluteTransform(): Matrix;
  9106. /**
  9107. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9108. * @returns a matrix
  9109. */
  9110. getAbsoluteTransform(): Matrix;
  9111. /**
  9112. * Links with the given transform node.
  9113. * The local matrix of this bone is copied from the transform node every frame.
  9114. * @param transformNode defines the transform node to link to
  9115. */
  9116. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9117. /** Gets or sets current position (in local space) */
  9118. position: Vector3;
  9119. /** Gets or sets current rotation (in local space) */
  9120. rotation: Vector3;
  9121. /** Gets or sets current rotation quaternion (in local space) */
  9122. rotationQuaternion: Quaternion;
  9123. /** Gets or sets current scaling (in local space) */
  9124. scaling: Vector3;
  9125. /**
  9126. * Gets the animation properties override
  9127. */
  9128. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9129. private _decompose;
  9130. private _compose;
  9131. /**
  9132. * Update the base and local matrices
  9133. * @param matrix defines the new base or local matrix
  9134. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9135. * @param updateLocalMatrix defines if the local matrix should be updated
  9136. */
  9137. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9138. /** @hidden */
  9139. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9140. /**
  9141. * Flag the bone as dirty (Forcing it to update everything)
  9142. */
  9143. markAsDirty(): void;
  9144. /** @hidden */
  9145. _markAsDirtyAndCompose(): void;
  9146. private _markAsDirtyAndDecompose;
  9147. /**
  9148. * Translate the bone in local or world space
  9149. * @param vec The amount to translate the bone
  9150. * @param space The space that the translation is in
  9151. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9152. */
  9153. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9154. /**
  9155. * Set the postion of the bone in local or world space
  9156. * @param position The position to set the bone
  9157. * @param space The space that the position is in
  9158. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9159. */
  9160. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9161. /**
  9162. * Set the absolute position of the bone (world space)
  9163. * @param position The position to set the bone
  9164. * @param mesh The mesh that this bone is attached to
  9165. */
  9166. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9167. /**
  9168. * Scale the bone on the x, y and z axes (in local space)
  9169. * @param x The amount to scale the bone on the x axis
  9170. * @param y The amount to scale the bone on the y axis
  9171. * @param z The amount to scale the bone on the z axis
  9172. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9173. */
  9174. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9175. /**
  9176. * Set the bone scaling in local space
  9177. * @param scale defines the scaling vector
  9178. */
  9179. setScale(scale: Vector3): void;
  9180. /**
  9181. * Gets the current scaling in local space
  9182. * @returns the current scaling vector
  9183. */
  9184. getScale(): Vector3;
  9185. /**
  9186. * Gets the current scaling in local space and stores it in a target vector
  9187. * @param result defines the target vector
  9188. */
  9189. getScaleToRef(result: Vector3): void;
  9190. /**
  9191. * Set the yaw, pitch, and roll of the bone in local or world space
  9192. * @param yaw The rotation of the bone on the y axis
  9193. * @param pitch The rotation of the bone on the x axis
  9194. * @param roll The rotation of the bone on the z axis
  9195. * @param space The space that the axes of rotation are in
  9196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9197. */
  9198. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9199. /**
  9200. * Add a rotation to the bone on an axis in local or world space
  9201. * @param axis The axis to rotate the bone on
  9202. * @param amount The amount to rotate the bone
  9203. * @param space The space that the axis is in
  9204. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9205. */
  9206. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9207. /**
  9208. * Set the rotation of the bone to a particular axis angle in local or world space
  9209. * @param axis The axis to rotate the bone on
  9210. * @param angle The angle that the bone should be rotated to
  9211. * @param space The space that the axis is in
  9212. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9213. */
  9214. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9215. /**
  9216. * Set the euler rotation of the bone in local of world space
  9217. * @param rotation The euler rotation that the bone should be set to
  9218. * @param space The space that the rotation is in
  9219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9220. */
  9221. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9222. /**
  9223. * Set the quaternion rotation of the bone in local of world space
  9224. * @param quat The quaternion rotation that the bone should be set to
  9225. * @param space The space that the rotation is in
  9226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9227. */
  9228. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9229. /**
  9230. * Set the rotation matrix of the bone in local of world space
  9231. * @param rotMat The rotation matrix that the bone should be set to
  9232. * @param space The space that the rotation is in
  9233. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9234. */
  9235. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9236. private _rotateWithMatrix;
  9237. private _getNegativeRotationToRef;
  9238. /**
  9239. * Get the position of the bone in local or world space
  9240. * @param space The space that the returned position is in
  9241. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9242. * @returns The position of the bone
  9243. */
  9244. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9245. /**
  9246. * Copy the position of the bone to a vector3 in local or world space
  9247. * @param space The space that the returned position is in
  9248. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9249. * @param result The vector3 to copy the position to
  9250. */
  9251. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9252. /**
  9253. * Get the absolute position of the bone (world space)
  9254. * @param mesh The mesh that this bone is attached to
  9255. * @returns The absolute position of the bone
  9256. */
  9257. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9258. /**
  9259. * Copy the absolute position of the bone (world space) to the result param
  9260. * @param mesh The mesh that this bone is attached to
  9261. * @param result The vector3 to copy the absolute position to
  9262. */
  9263. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9264. /**
  9265. * Compute the absolute transforms of this bone and its children
  9266. */
  9267. computeAbsoluteTransforms(): void;
  9268. /**
  9269. * Get the world direction from an axis that is in the local space of the bone
  9270. * @param localAxis The local direction that is used to compute the world direction
  9271. * @param mesh The mesh that this bone is attached to
  9272. * @returns The world direction
  9273. */
  9274. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9275. /**
  9276. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9277. * @param localAxis The local direction that is used to compute the world direction
  9278. * @param mesh The mesh that this bone is attached to
  9279. * @param result The vector3 that the world direction will be copied to
  9280. */
  9281. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9282. /**
  9283. * Get the euler rotation of the bone in local or world space
  9284. * @param space The space that the rotation should be in
  9285. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9286. * @returns The euler rotation
  9287. */
  9288. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9289. /**
  9290. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9291. * @param space The space that the rotation should be in
  9292. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9293. * @param result The vector3 that the rotation should be copied to
  9294. */
  9295. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9296. /**
  9297. * Get the quaternion rotation of the bone in either local or world space
  9298. * @param space The space that the rotation should be in
  9299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9300. * @returns The quaternion rotation
  9301. */
  9302. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9303. /**
  9304. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9305. * @param space The space that the rotation should be in
  9306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9307. * @param result The quaternion that the rotation should be copied to
  9308. */
  9309. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9310. /**
  9311. * Get the rotation matrix of the bone in local or world space
  9312. * @param space The space that the rotation should be in
  9313. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9314. * @returns The rotation matrix
  9315. */
  9316. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9317. /**
  9318. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9319. * @param space The space that the rotation should be in
  9320. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9321. * @param result The quaternion that the rotation should be copied to
  9322. */
  9323. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9324. /**
  9325. * Get the world position of a point that is in the local space of the bone
  9326. * @param position The local position
  9327. * @param mesh The mesh that this bone is attached to
  9328. * @returns The world position
  9329. */
  9330. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9331. /**
  9332. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9333. * @param position The local position
  9334. * @param mesh The mesh that this bone is attached to
  9335. * @param result The vector3 that the world position should be copied to
  9336. */
  9337. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9338. /**
  9339. * Get the local position of a point that is in world space
  9340. * @param position The world position
  9341. * @param mesh The mesh that this bone is attached to
  9342. * @returns The local position
  9343. */
  9344. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9345. /**
  9346. * Get the local position of a point that is in world space and copy it to the result param
  9347. * @param position The world position
  9348. * @param mesh The mesh that this bone is attached to
  9349. * @param result The vector3 that the local position should be copied to
  9350. */
  9351. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9352. }
  9353. }
  9354. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  9355. import { Nullable } from "babylonjs/types";
  9356. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  9357. import { Scene } from "babylonjs/scene";
  9358. module "babylonjs/Engines/engine" {
  9359. interface Engine {
  9360. /**
  9361. * Creates a raw texture
  9362. * @param data defines the data to store in the texture
  9363. * @param width defines the width of the texture
  9364. * @param height defines the height of the texture
  9365. * @param format defines the format of the data
  9366. * @param generateMipMaps defines if the engine should generate the mip levels
  9367. * @param invertY defines if data must be stored with Y axis inverted
  9368. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  9369. * @param compression defines the compression used (null by default)
  9370. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9371. * @returns the raw texture inside an InternalTexture
  9372. */
  9373. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  9374. /**
  9375. * Update a raw texture
  9376. * @param texture defines the texture to update
  9377. * @param data defines the data to store in the texture
  9378. * @param format defines the format of the data
  9379. * @param invertY defines if data must be stored with Y axis inverted
  9380. */
  9381. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9382. /**
  9383. * Update a raw texture
  9384. * @param texture defines the texture to update
  9385. * @param data defines the data to store in the texture
  9386. * @param format defines the format of the data
  9387. * @param invertY defines if data must be stored with Y axis inverted
  9388. * @param compression defines the compression used (null by default)
  9389. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9390. */
  9391. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  9392. /**
  9393. * Creates a new raw cube texture
  9394. * @param data defines the array of data to use to create each face
  9395. * @param size defines the size of the textures
  9396. * @param format defines the format of the data
  9397. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9398. * @param generateMipMaps defines if the engine should generate the mip levels
  9399. * @param invertY defines if data must be stored with Y axis inverted
  9400. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9401. * @param compression defines the compression used (null by default)
  9402. * @returns the cube texture as an InternalTexture
  9403. */
  9404. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  9405. /**
  9406. * Update a raw cube texture
  9407. * @param texture defines the texture to udpdate
  9408. * @param data defines the data to store
  9409. * @param format defines the data format
  9410. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9411. * @param invertY defines if data must be stored with Y axis inverted
  9412. */
  9413. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  9414. /**
  9415. * Update a raw cube texture
  9416. * @param texture defines the texture to udpdate
  9417. * @param data defines the data to store
  9418. * @param format defines the data format
  9419. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9420. * @param invertY defines if data must be stored with Y axis inverted
  9421. * @param compression defines the compression used (null by default)
  9422. */
  9423. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  9424. /**
  9425. * Update a raw cube texture
  9426. * @param texture defines the texture to udpdate
  9427. * @param data defines the data to store
  9428. * @param format defines the data format
  9429. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9430. * @param invertY defines if data must be stored with Y axis inverted
  9431. * @param compression defines the compression used (null by default)
  9432. * @param level defines which level of the texture to update
  9433. */
  9434. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  9435. /**
  9436. * Creates a new raw cube texture from a specified url
  9437. * @param url defines the url where the data is located
  9438. * @param scene defines the current scene
  9439. * @param size defines the size of the textures
  9440. * @param format defines the format of the data
  9441. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9442. * @param noMipmap defines if the engine should avoid generating the mip levels
  9443. * @param callback defines a callback used to extract texture data from loaded data
  9444. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9445. * @param onLoad defines a callback called when texture is loaded
  9446. * @param onError defines a callback called if there is an error
  9447. * @returns the cube texture as an InternalTexture
  9448. */
  9449. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  9450. /**
  9451. * Creates a new raw cube texture from a specified url
  9452. * @param url defines the url where the data is located
  9453. * @param scene defines the current scene
  9454. * @param size defines the size of the textures
  9455. * @param format defines the format of the data
  9456. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9457. * @param noMipmap defines if the engine should avoid generating the mip levels
  9458. * @param callback defines a callback used to extract texture data from loaded data
  9459. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9460. * @param onLoad defines a callback called when texture is loaded
  9461. * @param onError defines a callback called if there is an error
  9462. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9463. * @param invertY defines if data must be stored with Y axis inverted
  9464. * @returns the cube texture as an InternalTexture
  9465. */
  9466. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  9467. /**
  9468. * Creates a new raw 3D texture
  9469. * @param data defines the data used to create the texture
  9470. * @param width defines the width of the texture
  9471. * @param height defines the height of the texture
  9472. * @param depth defines the depth of the texture
  9473. * @param format defines the format of the texture
  9474. * @param generateMipMaps defines if the engine must generate mip levels
  9475. * @param invertY defines if data must be stored with Y axis inverted
  9476. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9477. * @param compression defines the compressed used (can be null)
  9478. * @param textureType defines the compressed used (can be null)
  9479. * @returns a new raw 3D texture (stored in an InternalTexture)
  9480. */
  9481. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  9482. /**
  9483. * Update a raw 3D texture
  9484. * @param texture defines the texture to update
  9485. * @param data defines the data to store
  9486. * @param format defines the data format
  9487. * @param invertY defines if data must be stored with Y axis inverted
  9488. */
  9489. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9490. /**
  9491. * Update a raw 3D texture
  9492. * @param texture defines the texture to update
  9493. * @param data defines the data to store
  9494. * @param format defines the data format
  9495. * @param invertY defines if data must be stored with Y axis inverted
  9496. * @param compression defines the used compression (can be null)
  9497. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9498. */
  9499. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  9500. }
  9501. }
  9502. }
  9503. declare module "babylonjs/Materials/Textures/rawTexture" {
  9504. import { Scene } from "babylonjs/scene";
  9505. import { Texture } from "babylonjs/Materials/Textures/texture";
  9506. import "babylonjs/Engines/Extensions/engine.rawTexture";
  9507. /**
  9508. * Raw texture can help creating a texture directly from an array of data.
  9509. * This can be super useful if you either get the data from an uncompressed source or
  9510. * if you wish to create your texture pixel by pixel.
  9511. */
  9512. export class RawTexture extends Texture {
  9513. /**
  9514. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9515. */
  9516. format: number;
  9517. private _engine;
  9518. /**
  9519. * Instantiates a new RawTexture.
  9520. * Raw texture can help creating a texture directly from an array of data.
  9521. * This can be super useful if you either get the data from an uncompressed source or
  9522. * if you wish to create your texture pixel by pixel.
  9523. * @param data define the array of data to use to create the texture
  9524. * @param width define the width of the texture
  9525. * @param height define the height of the texture
  9526. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9527. * @param scene define the scene the texture belongs to
  9528. * @param generateMipMaps define whether mip maps should be generated or not
  9529. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9530. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9531. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9532. */
  9533. constructor(data: ArrayBufferView, width: number, height: number,
  9534. /**
  9535. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9536. */
  9537. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9538. /**
  9539. * Updates the texture underlying data.
  9540. * @param data Define the new data of the texture
  9541. */
  9542. update(data: ArrayBufferView): void;
  9543. /**
  9544. * Creates a luminance texture from some data.
  9545. * @param data Define the texture data
  9546. * @param width Define the width of the texture
  9547. * @param height Define the height of the texture
  9548. * @param scene Define the scene the texture belongs to
  9549. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9550. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9551. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9552. * @returns the luminance texture
  9553. */
  9554. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9555. /**
  9556. * Creates a luminance alpha texture from some data.
  9557. * @param data Define the texture data
  9558. * @param width Define the width of the texture
  9559. * @param height Define the height of the texture
  9560. * @param scene Define the scene the texture belongs to
  9561. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9562. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9563. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9564. * @returns the luminance alpha texture
  9565. */
  9566. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9567. /**
  9568. * Creates an alpha texture from some data.
  9569. * @param data Define the texture data
  9570. * @param width Define the width of the texture
  9571. * @param height Define the height of the texture
  9572. * @param scene Define the scene the texture belongs to
  9573. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9574. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9575. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9576. * @returns the alpha texture
  9577. */
  9578. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9579. /**
  9580. * Creates a RGB texture from some data.
  9581. * @param data Define the texture data
  9582. * @param width Define the width of the texture
  9583. * @param height Define the height of the texture
  9584. * @param scene Define the scene the texture belongs to
  9585. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9586. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9587. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9588. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9589. * @returns the RGB alpha texture
  9590. */
  9591. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9592. /**
  9593. * Creates a RGBA texture from some data.
  9594. * @param data Define the texture data
  9595. * @param width Define the width of the texture
  9596. * @param height Define the height of the texture
  9597. * @param scene Define the scene the texture belongs to
  9598. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9599. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9600. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9601. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9602. * @returns the RGBA texture
  9603. */
  9604. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9605. /**
  9606. * Creates a R texture from some data.
  9607. * @param data Define the texture data
  9608. * @param width Define the width of the texture
  9609. * @param height Define the height of the texture
  9610. * @param scene Define the scene the texture belongs to
  9611. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9612. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9613. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9614. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9615. * @returns the R texture
  9616. */
  9617. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9618. }
  9619. }
  9620. declare module "babylonjs/Animations/runtimeAnimation" {
  9621. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  9622. import { Animatable } from "babylonjs/Animations/animatable";
  9623. import { Scene } from "babylonjs/scene";
  9624. /**
  9625. * Defines a runtime animation
  9626. */
  9627. export class RuntimeAnimation {
  9628. private _events;
  9629. /**
  9630. * The current frame of the runtime animation
  9631. */
  9632. private _currentFrame;
  9633. /**
  9634. * The animation used by the runtime animation
  9635. */
  9636. private _animation;
  9637. /**
  9638. * The target of the runtime animation
  9639. */
  9640. private _target;
  9641. /**
  9642. * The initiating animatable
  9643. */
  9644. private _host;
  9645. /**
  9646. * The original value of the runtime animation
  9647. */
  9648. private _originalValue;
  9649. /**
  9650. * The original blend value of the runtime animation
  9651. */
  9652. private _originalBlendValue;
  9653. /**
  9654. * The offsets cache of the runtime animation
  9655. */
  9656. private _offsetsCache;
  9657. /**
  9658. * The high limits cache of the runtime animation
  9659. */
  9660. private _highLimitsCache;
  9661. /**
  9662. * Specifies if the runtime animation has been stopped
  9663. */
  9664. private _stopped;
  9665. /**
  9666. * The blending factor of the runtime animation
  9667. */
  9668. private _blendingFactor;
  9669. /**
  9670. * The BabylonJS scene
  9671. */
  9672. private _scene;
  9673. /**
  9674. * The current value of the runtime animation
  9675. */
  9676. private _currentValue;
  9677. /** @hidden */
  9678. _animationState: _IAnimationState;
  9679. /**
  9680. * The active target of the runtime animation
  9681. */
  9682. private _activeTargets;
  9683. private _currentActiveTarget;
  9684. private _directTarget;
  9685. /**
  9686. * The target path of the runtime animation
  9687. */
  9688. private _targetPath;
  9689. /**
  9690. * The weight of the runtime animation
  9691. */
  9692. private _weight;
  9693. /**
  9694. * The ratio offset of the runtime animation
  9695. */
  9696. private _ratioOffset;
  9697. /**
  9698. * The previous delay of the runtime animation
  9699. */
  9700. private _previousDelay;
  9701. /**
  9702. * The previous ratio of the runtime animation
  9703. */
  9704. private _previousRatio;
  9705. private _enableBlending;
  9706. private _keys;
  9707. private _minFrame;
  9708. private _maxFrame;
  9709. private _minValue;
  9710. private _maxValue;
  9711. private _targetIsArray;
  9712. /**
  9713. * Gets the current frame of the runtime animation
  9714. */
  9715. readonly currentFrame: number;
  9716. /**
  9717. * Gets the weight of the runtime animation
  9718. */
  9719. readonly weight: number;
  9720. /**
  9721. * Gets the current value of the runtime animation
  9722. */
  9723. readonly currentValue: any;
  9724. /**
  9725. * Gets the target path of the runtime animation
  9726. */
  9727. readonly targetPath: string;
  9728. /**
  9729. * Gets the actual target of the runtime animation
  9730. */
  9731. readonly target: any;
  9732. /** @hidden */
  9733. _onLoop: () => void;
  9734. /**
  9735. * Create a new RuntimeAnimation object
  9736. * @param target defines the target of the animation
  9737. * @param animation defines the source animation object
  9738. * @param scene defines the hosting scene
  9739. * @param host defines the initiating Animatable
  9740. */
  9741. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  9742. private _preparePath;
  9743. /**
  9744. * Gets the animation from the runtime animation
  9745. */
  9746. readonly animation: Animation;
  9747. /**
  9748. * Resets the runtime animation to the beginning
  9749. * @param restoreOriginal defines whether to restore the target property to the original value
  9750. */
  9751. reset(restoreOriginal?: boolean): void;
  9752. /**
  9753. * Specifies if the runtime animation is stopped
  9754. * @returns Boolean specifying if the runtime animation is stopped
  9755. */
  9756. isStopped(): boolean;
  9757. /**
  9758. * Disposes of the runtime animation
  9759. */
  9760. dispose(): void;
  9761. /**
  9762. * Apply the interpolated value to the target
  9763. * @param currentValue defines the value computed by the animation
  9764. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  9765. */
  9766. setValue(currentValue: any, weight: number): void;
  9767. private _getOriginalValues;
  9768. private _setValue;
  9769. /**
  9770. * Gets the loop pmode of the runtime animation
  9771. * @returns Loop Mode
  9772. */
  9773. private _getCorrectLoopMode;
  9774. /**
  9775. * Move the current animation to a given frame
  9776. * @param frame defines the frame to move to
  9777. */
  9778. goToFrame(frame: number): void;
  9779. /**
  9780. * @hidden Internal use only
  9781. */
  9782. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  9783. /**
  9784. * Execute the current animation
  9785. * @param delay defines the delay to add to the current frame
  9786. * @param from defines the lower bound of the animation range
  9787. * @param to defines the upper bound of the animation range
  9788. * @param loop defines if the current animation must loop
  9789. * @param speedRatio defines the current speed ratio
  9790. * @param weight defines the weight of the animation (default is -1 so no weight)
  9791. * @param onLoop optional callback called when animation loops
  9792. * @returns a boolean indicating if the animation is running
  9793. */
  9794. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  9795. }
  9796. }
  9797. declare module "babylonjs/Animations/animatable" {
  9798. import { Animation } from "babylonjs/Animations/animation";
  9799. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  9800. import { Nullable } from "babylonjs/types";
  9801. import { Observable } from "babylonjs/Misc/observable";
  9802. import { Scene } from "babylonjs/scene";
  9803. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  9804. import { Node } from "babylonjs/node";
  9805. /**
  9806. * Class used to store an actual running animation
  9807. */
  9808. export class Animatable {
  9809. /** defines the target object */
  9810. target: any;
  9811. /** defines the starting frame number (default is 0) */
  9812. fromFrame: number;
  9813. /** defines the ending frame number (default is 100) */
  9814. toFrame: number;
  9815. /** defines if the animation must loop (default is false) */
  9816. loopAnimation: boolean;
  9817. /** defines a callback to call when animation ends if it is not looping */
  9818. onAnimationEnd?: (() => void) | null | undefined;
  9819. /** defines a callback to call when animation loops */
  9820. onAnimationLoop?: (() => void) | null | undefined;
  9821. private _localDelayOffset;
  9822. private _pausedDelay;
  9823. private _runtimeAnimations;
  9824. private _paused;
  9825. private _scene;
  9826. private _speedRatio;
  9827. private _weight;
  9828. private _syncRoot;
  9829. /**
  9830. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  9831. * This will only apply for non looping animation (default is true)
  9832. */
  9833. disposeOnEnd: boolean;
  9834. /**
  9835. * Gets a boolean indicating if the animation has started
  9836. */
  9837. animationStarted: boolean;
  9838. /**
  9839. * Observer raised when the animation ends
  9840. */
  9841. onAnimationEndObservable: Observable<Animatable>;
  9842. /**
  9843. * Observer raised when the animation loops
  9844. */
  9845. onAnimationLoopObservable: Observable<Animatable>;
  9846. /**
  9847. * Gets the root Animatable used to synchronize and normalize animations
  9848. */
  9849. readonly syncRoot: Nullable<Animatable>;
  9850. /**
  9851. * Gets the current frame of the first RuntimeAnimation
  9852. * Used to synchronize Animatables
  9853. */
  9854. readonly masterFrame: number;
  9855. /**
  9856. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  9857. */
  9858. weight: number;
  9859. /**
  9860. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  9861. */
  9862. speedRatio: number;
  9863. /**
  9864. * Creates a new Animatable
  9865. * @param scene defines the hosting scene
  9866. * @param target defines the target object
  9867. * @param fromFrame defines the starting frame number (default is 0)
  9868. * @param toFrame defines the ending frame number (default is 100)
  9869. * @param loopAnimation defines if the animation must loop (default is false)
  9870. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  9871. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  9872. * @param animations defines a group of animation to add to the new Animatable
  9873. * @param onAnimationLoop defines a callback to call when animation loops
  9874. */
  9875. constructor(scene: Scene,
  9876. /** defines the target object */
  9877. target: any,
  9878. /** defines the starting frame number (default is 0) */
  9879. fromFrame?: number,
  9880. /** defines the ending frame number (default is 100) */
  9881. toFrame?: number,
  9882. /** defines if the animation must loop (default is false) */
  9883. loopAnimation?: boolean, speedRatio?: number,
  9884. /** defines a callback to call when animation ends if it is not looping */
  9885. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  9886. /** defines a callback to call when animation loops */
  9887. onAnimationLoop?: (() => void) | null | undefined);
  9888. /**
  9889. * Synchronize and normalize current Animatable with a source Animatable
  9890. * This is useful when using animation weights and when animations are not of the same length
  9891. * @param root defines the root Animatable to synchronize with
  9892. * @returns the current Animatable
  9893. */
  9894. syncWith(root: Animatable): Animatable;
  9895. /**
  9896. * Gets the list of runtime animations
  9897. * @returns an array of RuntimeAnimation
  9898. */
  9899. getAnimations(): RuntimeAnimation[];
  9900. /**
  9901. * Adds more animations to the current animatable
  9902. * @param target defines the target of the animations
  9903. * @param animations defines the new animations to add
  9904. */
  9905. appendAnimations(target: any, animations: Animation[]): void;
  9906. /**
  9907. * Gets the source animation for a specific property
  9908. * @param property defines the propertyu to look for
  9909. * @returns null or the source animation for the given property
  9910. */
  9911. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  9912. /**
  9913. * Gets the runtime animation for a specific property
  9914. * @param property defines the propertyu to look for
  9915. * @returns null or the runtime animation for the given property
  9916. */
  9917. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  9918. /**
  9919. * Resets the animatable to its original state
  9920. */
  9921. reset(): void;
  9922. /**
  9923. * Allows the animatable to blend with current running animations
  9924. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9925. * @param blendingSpeed defines the blending speed to use
  9926. */
  9927. enableBlending(blendingSpeed: number): void;
  9928. /**
  9929. * Disable animation blending
  9930. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9931. */
  9932. disableBlending(): void;
  9933. /**
  9934. * Jump directly to a given frame
  9935. * @param frame defines the frame to jump to
  9936. */
  9937. goToFrame(frame: number): void;
  9938. /**
  9939. * Pause the animation
  9940. */
  9941. pause(): void;
  9942. /**
  9943. * Restart the animation
  9944. */
  9945. restart(): void;
  9946. private _raiseOnAnimationEnd;
  9947. /**
  9948. * Stop and delete the current animation
  9949. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  9950. * @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)
  9951. */
  9952. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  9953. /**
  9954. * Wait asynchronously for the animation to end
  9955. * @returns a promise which will be fullfilled when the animation ends
  9956. */
  9957. waitAsync(): Promise<Animatable>;
  9958. /** @hidden */
  9959. _animate(delay: number): boolean;
  9960. }
  9961. module "babylonjs/scene" {
  9962. interface Scene {
  9963. /** @hidden */
  9964. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  9965. /** @hidden */
  9966. _processLateAnimationBindingsForMatrices(holder: {
  9967. totalWeight: number;
  9968. animations: RuntimeAnimation[];
  9969. originalValue: Matrix;
  9970. }): any;
  9971. /** @hidden */
  9972. _processLateAnimationBindingsForQuaternions(holder: {
  9973. totalWeight: number;
  9974. animations: RuntimeAnimation[];
  9975. originalValue: Quaternion;
  9976. }, refQuaternion: Quaternion): Quaternion;
  9977. /** @hidden */
  9978. _processLateAnimationBindings(): void;
  9979. /**
  9980. * Will start the animation sequence of a given target
  9981. * @param target defines the target
  9982. * @param from defines from which frame should animation start
  9983. * @param to defines until which frame should animation run.
  9984. * @param weight defines the weight to apply to the animation (1.0 by default)
  9985. * @param loop defines if the animation loops
  9986. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9987. * @param onAnimationEnd defines the function to be executed when the animation ends
  9988. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9989. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9990. * @param onAnimationLoop defines the callback to call when an animation loops
  9991. * @returns the animatable object created for this animation
  9992. */
  9993. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9994. /**
  9995. * Will start the animation sequence of a given target
  9996. * @param target defines the target
  9997. * @param from defines from which frame should animation start
  9998. * @param to defines until which frame should animation run.
  9999. * @param loop defines if the animation loops
  10000. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  10001. * @param onAnimationEnd defines the function to be executed when the animation ends
  10002. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  10003. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  10004. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  10005. * @param onAnimationLoop defines the callback to call when an animation loops
  10006. * @returns the animatable object created for this animation
  10007. */
  10008. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  10009. /**
  10010. * Will start the animation sequence of a given target and its hierarchy
  10011. * @param target defines the target
  10012. * @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.
  10013. * @param from defines from which frame should animation start
  10014. * @param to defines until which frame should animation run.
  10015. * @param loop defines if the animation loops
  10016. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  10017. * @param onAnimationEnd defines the function to be executed when the animation ends
  10018. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  10019. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  10020. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  10021. * @param onAnimationLoop defines the callback to call when an animation loops
  10022. * @returns the list of created animatables
  10023. */
  10024. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  10025. /**
  10026. * Begin a new animation on a given node
  10027. * @param target defines the target where the animation will take place
  10028. * @param animations defines the list of animations to start
  10029. * @param from defines the initial value
  10030. * @param to defines the final value
  10031. * @param loop defines if you want animation to loop (off by default)
  10032. * @param speedRatio defines the speed ratio to apply to all animations
  10033. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10034. * @param onAnimationLoop defines the callback to call when an animation loops
  10035. * @returns the list of created animatables
  10036. */
  10037. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  10038. /**
  10039. * Begin a new animation on a given node and its hierarchy
  10040. * @param target defines the root node where the animation will take place
  10041. * @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.
  10042. * @param animations defines the list of animations to start
  10043. * @param from defines the initial value
  10044. * @param to defines the final value
  10045. * @param loop defines if you want animation to loop (off by default)
  10046. * @param speedRatio defines the speed ratio to apply to all animations
  10047. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10048. * @param onAnimationLoop defines the callback to call when an animation loops
  10049. * @returns the list of animatables created for all nodes
  10050. */
  10051. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  10052. /**
  10053. * Gets the animatable associated with a specific target
  10054. * @param target defines the target of the animatable
  10055. * @returns the required animatable if found
  10056. */
  10057. getAnimatableByTarget(target: any): Nullable<Animatable>;
  10058. /**
  10059. * Gets all animatables associated with a given target
  10060. * @param target defines the target to look animatables for
  10061. * @returns an array of Animatables
  10062. */
  10063. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  10064. /**
  10065. * Stops and removes all animations that have been applied to the scene
  10066. */
  10067. stopAllAnimations(): void;
  10068. }
  10069. }
  10070. module "babylonjs/Bones/bone" {
  10071. interface Bone {
  10072. /**
  10073. * Copy an animation range from another bone
  10074. * @param source defines the source bone
  10075. * @param rangeName defines the range name to copy
  10076. * @param frameOffset defines the frame offset
  10077. * @param rescaleAsRequired defines if rescaling must be applied if required
  10078. * @param skelDimensionsRatio defines the scaling ratio
  10079. * @returns true if operation was successful
  10080. */
  10081. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  10082. }
  10083. }
  10084. }
  10085. declare module "babylonjs/Bones/skeleton" {
  10086. import { Bone } from "babylonjs/Bones/bone";
  10087. import { IAnimatable } from "babylonjs/Misc/tools";
  10088. import { Observable } from "babylonjs/Misc/observable";
  10089. import { Vector3, Matrix } from "babylonjs/Maths/math";
  10090. import { Scene } from "babylonjs/scene";
  10091. import { Nullable } from "babylonjs/types";
  10092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10093. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  10094. import { Animatable } from "babylonjs/Animations/animatable";
  10095. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10096. import { Animation } from "babylonjs/Animations/animation";
  10097. import { AnimationRange } from "babylonjs/Animations/animationRange";
  10098. import { IInspectable } from "babylonjs/Misc/iInspectable";
  10099. /**
  10100. * Class used to handle skinning animations
  10101. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  10102. */
  10103. export class Skeleton implements IAnimatable {
  10104. /** defines the skeleton name */
  10105. name: string;
  10106. /** defines the skeleton Id */
  10107. id: string;
  10108. /**
  10109. * Defines the list of child bones
  10110. */
  10111. bones: Bone[];
  10112. /**
  10113. * Defines an estimate of the dimension of the skeleton at rest
  10114. */
  10115. dimensionsAtRest: Vector3;
  10116. /**
  10117. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  10118. */
  10119. needInitialSkinMatrix: boolean;
  10120. /**
  10121. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  10122. */
  10123. overrideMesh: Nullable<AbstractMesh>;
  10124. /**
  10125. * Gets the list of animations attached to this skeleton
  10126. */
  10127. animations: Array<Animation>;
  10128. private _scene;
  10129. private _isDirty;
  10130. private _transformMatrices;
  10131. private _transformMatrixTexture;
  10132. private _meshesWithPoseMatrix;
  10133. private _animatables;
  10134. private _identity;
  10135. private _synchronizedWithMesh;
  10136. private _ranges;
  10137. private _lastAbsoluteTransformsUpdateId;
  10138. private _canUseTextureForBones;
  10139. private _uniqueId;
  10140. /** @hidden */
  10141. _numBonesWithLinkedTransformNode: number;
  10142. /** @hidden */
  10143. _hasWaitingData: Nullable<boolean>;
  10144. /**
  10145. * Specifies if the skeleton should be serialized
  10146. */
  10147. doNotSerialize: boolean;
  10148. private _useTextureToStoreBoneMatrices;
  10149. /**
  10150. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  10151. * Please note that this option is not available if the hardware does not support it
  10152. */
  10153. useTextureToStoreBoneMatrices: boolean;
  10154. private _animationPropertiesOverride;
  10155. /**
  10156. * Gets or sets the animation properties override
  10157. */
  10158. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10159. /**
  10160. * List of inspectable custom properties (used by the Inspector)
  10161. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  10162. */
  10163. inspectableCustomProperties: IInspectable[];
  10164. /**
  10165. * An observable triggered before computing the skeleton's matrices
  10166. */
  10167. onBeforeComputeObservable: Observable<Skeleton>;
  10168. /**
  10169. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  10170. */
  10171. readonly isUsingTextureForMatrices: boolean;
  10172. /**
  10173. * Gets the unique ID of this skeleton
  10174. */
  10175. readonly uniqueId: number;
  10176. /**
  10177. * Creates a new skeleton
  10178. * @param name defines the skeleton name
  10179. * @param id defines the skeleton Id
  10180. * @param scene defines the hosting scene
  10181. */
  10182. constructor(
  10183. /** defines the skeleton name */
  10184. name: string,
  10185. /** defines the skeleton Id */
  10186. id: string, scene: Scene);
  10187. /**
  10188. * Gets the current object class name.
  10189. * @return the class name
  10190. */
  10191. getClassName(): string;
  10192. /**
  10193. * Returns an array containing the root bones
  10194. * @returns an array containing the root bones
  10195. */
  10196. getChildren(): Array<Bone>;
  10197. /**
  10198. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  10199. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10200. * @returns a Float32Array containing matrices data
  10201. */
  10202. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  10203. /**
  10204. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  10205. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10206. * @returns a raw texture containing the data
  10207. */
  10208. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  10209. /**
  10210. * Gets the current hosting scene
  10211. * @returns a scene object
  10212. */
  10213. getScene(): Scene;
  10214. /**
  10215. * Gets a string representing the current skeleton data
  10216. * @param fullDetails defines a boolean indicating if we want a verbose version
  10217. * @returns a string representing the current skeleton data
  10218. */
  10219. toString(fullDetails?: boolean): string;
  10220. /**
  10221. * Get bone's index searching by name
  10222. * @param name defines bone's name to search for
  10223. * @return the indice of the bone. Returns -1 if not found
  10224. */
  10225. getBoneIndexByName(name: string): number;
  10226. /**
  10227. * Creater a new animation range
  10228. * @param name defines the name of the range
  10229. * @param from defines the start key
  10230. * @param to defines the end key
  10231. */
  10232. createAnimationRange(name: string, from: number, to: number): void;
  10233. /**
  10234. * Delete a specific animation range
  10235. * @param name defines the name of the range
  10236. * @param deleteFrames defines if frames must be removed as well
  10237. */
  10238. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  10239. /**
  10240. * Gets a specific animation range
  10241. * @param name defines the name of the range to look for
  10242. * @returns the requested animation range or null if not found
  10243. */
  10244. getAnimationRange(name: string): Nullable<AnimationRange>;
  10245. /**
  10246. * Gets the list of all animation ranges defined on this skeleton
  10247. * @returns an array
  10248. */
  10249. getAnimationRanges(): Nullable<AnimationRange>[];
  10250. /**
  10251. * Copy animation range from a source skeleton.
  10252. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  10253. * @param source defines the source skeleton
  10254. * @param name defines the name of the range to copy
  10255. * @param rescaleAsRequired defines if rescaling must be applied if required
  10256. * @returns true if operation was successful
  10257. */
  10258. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  10259. /**
  10260. * Forces the skeleton to go to rest pose
  10261. */
  10262. returnToRest(): void;
  10263. private _getHighestAnimationFrame;
  10264. /**
  10265. * Begin a specific animation range
  10266. * @param name defines the name of the range to start
  10267. * @param loop defines if looping must be turned on (false by default)
  10268. * @param speedRatio defines the speed ratio to apply (1 by default)
  10269. * @param onAnimationEnd defines a callback which will be called when animation will end
  10270. * @returns a new animatable
  10271. */
  10272. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  10273. /** @hidden */
  10274. _markAsDirty(): void;
  10275. /** @hidden */
  10276. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10277. /** @hidden */
  10278. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10279. private _computeTransformMatrices;
  10280. /**
  10281. * Build all resources required to render a skeleton
  10282. */
  10283. prepare(): void;
  10284. /**
  10285. * Gets the list of animatables currently running for this skeleton
  10286. * @returns an array of animatables
  10287. */
  10288. getAnimatables(): IAnimatable[];
  10289. /**
  10290. * Clone the current skeleton
  10291. * @param name defines the name of the new skeleton
  10292. * @param id defines the id of the new skeleton
  10293. * @returns the new skeleton
  10294. */
  10295. clone(name: string, id: string): Skeleton;
  10296. /**
  10297. * Enable animation blending for this skeleton
  10298. * @param blendingSpeed defines the blending speed to apply
  10299. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  10300. */
  10301. enableBlending(blendingSpeed?: number): void;
  10302. /**
  10303. * Releases all resources associated with the current skeleton
  10304. */
  10305. dispose(): void;
  10306. /**
  10307. * Serialize the skeleton in a JSON object
  10308. * @returns a JSON object
  10309. */
  10310. serialize(): any;
  10311. /**
  10312. * Creates a new skeleton from serialized data
  10313. * @param parsedSkeleton defines the serialized data
  10314. * @param scene defines the hosting scene
  10315. * @returns a new skeleton
  10316. */
  10317. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  10318. /**
  10319. * Compute all node absolute transforms
  10320. * @param forceUpdate defines if computation must be done even if cache is up to date
  10321. */
  10322. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  10323. /**
  10324. * Gets the root pose matrix
  10325. * @returns a matrix
  10326. */
  10327. getPoseMatrix(): Nullable<Matrix>;
  10328. /**
  10329. * Sorts bones per internal index
  10330. */
  10331. sortBones(): void;
  10332. private _sortBones;
  10333. }
  10334. }
  10335. declare module "babylonjs/Morph/morphTarget" {
  10336. import { IAnimatable } from "babylonjs/Misc/tools";
  10337. import { Observable } from "babylonjs/Misc/observable";
  10338. import { Nullable, FloatArray } from "babylonjs/types";
  10339. import { Scene } from "babylonjs/scene";
  10340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10341. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10342. /**
  10343. * Defines a target to use with MorphTargetManager
  10344. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10345. */
  10346. export class MorphTarget implements IAnimatable {
  10347. /** defines the name of the target */
  10348. name: string;
  10349. /**
  10350. * Gets or sets the list of animations
  10351. */
  10352. animations: import("babylonjs/Animations/animation").Animation[];
  10353. private _scene;
  10354. private _positions;
  10355. private _normals;
  10356. private _tangents;
  10357. private _uvs;
  10358. private _influence;
  10359. /**
  10360. * Observable raised when the influence changes
  10361. */
  10362. onInfluenceChanged: Observable<boolean>;
  10363. /** @hidden */
  10364. _onDataLayoutChanged: Observable<void>;
  10365. /**
  10366. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  10367. */
  10368. influence: number;
  10369. /**
  10370. * Gets or sets the id of the morph Target
  10371. */
  10372. id: string;
  10373. private _animationPropertiesOverride;
  10374. /**
  10375. * Gets or sets the animation properties override
  10376. */
  10377. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10378. /**
  10379. * Creates a new MorphTarget
  10380. * @param name defines the name of the target
  10381. * @param influence defines the influence to use
  10382. * @param scene defines the scene the morphtarget belongs to
  10383. */
  10384. constructor(
  10385. /** defines the name of the target */
  10386. name: string, influence?: number, scene?: Nullable<Scene>);
  10387. /**
  10388. * Gets a boolean defining if the target contains position data
  10389. */
  10390. readonly hasPositions: boolean;
  10391. /**
  10392. * Gets a boolean defining if the target contains normal data
  10393. */
  10394. readonly hasNormals: boolean;
  10395. /**
  10396. * Gets a boolean defining if the target contains tangent data
  10397. */
  10398. readonly hasTangents: boolean;
  10399. /**
  10400. * Gets a boolean defining if the target contains texture coordinates data
  10401. */
  10402. readonly hasUVs: boolean;
  10403. /**
  10404. * Affects position data to this target
  10405. * @param data defines the position data to use
  10406. */
  10407. setPositions(data: Nullable<FloatArray>): void;
  10408. /**
  10409. * Gets the position data stored in this target
  10410. * @returns a FloatArray containing the position data (or null if not present)
  10411. */
  10412. getPositions(): Nullable<FloatArray>;
  10413. /**
  10414. * Affects normal data to this target
  10415. * @param data defines the normal data to use
  10416. */
  10417. setNormals(data: Nullable<FloatArray>): void;
  10418. /**
  10419. * Gets the normal data stored in this target
  10420. * @returns a FloatArray containing the normal data (or null if not present)
  10421. */
  10422. getNormals(): Nullable<FloatArray>;
  10423. /**
  10424. * Affects tangent data to this target
  10425. * @param data defines the tangent data to use
  10426. */
  10427. setTangents(data: Nullable<FloatArray>): void;
  10428. /**
  10429. * Gets the tangent data stored in this target
  10430. * @returns a FloatArray containing the tangent data (or null if not present)
  10431. */
  10432. getTangents(): Nullable<FloatArray>;
  10433. /**
  10434. * Affects texture coordinates data to this target
  10435. * @param data defines the texture coordinates data to use
  10436. */
  10437. setUVs(data: Nullable<FloatArray>): void;
  10438. /**
  10439. * Gets the texture coordinates data stored in this target
  10440. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  10441. */
  10442. getUVs(): Nullable<FloatArray>;
  10443. /**
  10444. * Serializes the current target into a Serialization object
  10445. * @returns the serialized object
  10446. */
  10447. serialize(): any;
  10448. /**
  10449. * Returns the string "MorphTarget"
  10450. * @returns "MorphTarget"
  10451. */
  10452. getClassName(): string;
  10453. /**
  10454. * Creates a new target from serialized data
  10455. * @param serializationObject defines the serialized data to use
  10456. * @returns a new MorphTarget
  10457. */
  10458. static Parse(serializationObject: any): MorphTarget;
  10459. /**
  10460. * Creates a MorphTarget from mesh data
  10461. * @param mesh defines the source mesh
  10462. * @param name defines the name to use for the new target
  10463. * @param influence defines the influence to attach to the target
  10464. * @returns a new MorphTarget
  10465. */
  10466. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10467. }
  10468. }
  10469. declare module "babylonjs/Morph/morphTargetManager" {
  10470. import { Nullable } from "babylonjs/types";
  10471. import { Scene } from "babylonjs/scene";
  10472. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  10473. /**
  10474. * This class is used to deform meshes using morphing between different targets
  10475. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10476. */
  10477. export class MorphTargetManager {
  10478. private _targets;
  10479. private _targetInfluenceChangedObservers;
  10480. private _targetDataLayoutChangedObservers;
  10481. private _activeTargets;
  10482. private _scene;
  10483. private _influences;
  10484. private _supportsNormals;
  10485. private _supportsTangents;
  10486. private _supportsUVs;
  10487. private _vertexCount;
  10488. private _uniqueId;
  10489. private _tempInfluences;
  10490. /**
  10491. * Gets or sets a boolean indicating if normals must be morphed
  10492. */
  10493. enableNormalMorphing: boolean;
  10494. /**
  10495. * Gets or sets a boolean indicating if tangents must be morphed
  10496. */
  10497. enableTangentMorphing: boolean;
  10498. /**
  10499. * Gets or sets a boolean indicating if UV must be morphed
  10500. */
  10501. enableUVMorphing: boolean;
  10502. /**
  10503. * Creates a new MorphTargetManager
  10504. * @param scene defines the current scene
  10505. */
  10506. constructor(scene?: Nullable<Scene>);
  10507. /**
  10508. * Gets the unique ID of this manager
  10509. */
  10510. readonly uniqueId: number;
  10511. /**
  10512. * Gets the number of vertices handled by this manager
  10513. */
  10514. readonly vertexCount: number;
  10515. /**
  10516. * Gets a boolean indicating if this manager supports morphing of normals
  10517. */
  10518. readonly supportsNormals: boolean;
  10519. /**
  10520. * Gets a boolean indicating if this manager supports morphing of tangents
  10521. */
  10522. readonly supportsTangents: boolean;
  10523. /**
  10524. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  10525. */
  10526. readonly supportsUVs: boolean;
  10527. /**
  10528. * Gets the number of targets stored in this manager
  10529. */
  10530. readonly numTargets: number;
  10531. /**
  10532. * Gets the number of influencers (ie. the number of targets with influences > 0)
  10533. */
  10534. readonly numInfluencers: number;
  10535. /**
  10536. * Gets the list of influences (one per target)
  10537. */
  10538. readonly influences: Float32Array;
  10539. /**
  10540. * Gets the active target at specified index. An active target is a target with an influence > 0
  10541. * @param index defines the index to check
  10542. * @returns the requested target
  10543. */
  10544. getActiveTarget(index: number): MorphTarget;
  10545. /**
  10546. * Gets the target at specified index
  10547. * @param index defines the index to check
  10548. * @returns the requested target
  10549. */
  10550. getTarget(index: number): MorphTarget;
  10551. /**
  10552. * Add a new target to this manager
  10553. * @param target defines the target to add
  10554. */
  10555. addTarget(target: MorphTarget): void;
  10556. /**
  10557. * Removes a target from the manager
  10558. * @param target defines the target to remove
  10559. */
  10560. removeTarget(target: MorphTarget): void;
  10561. /**
  10562. * Serializes the current manager into a Serialization object
  10563. * @returns the serialized object
  10564. */
  10565. serialize(): any;
  10566. private _syncActiveTargets;
  10567. /**
  10568. * Syncrhonize the targets with all the meshes using this morph target manager
  10569. */
  10570. synchronize(): void;
  10571. /**
  10572. * Creates a new MorphTargetManager from serialized data
  10573. * @param serializationObject defines the serialized data
  10574. * @param scene defines the hosting scene
  10575. * @returns the new MorphTargetManager
  10576. */
  10577. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10578. }
  10579. }
  10580. declare module "babylonjs/sceneComponent" {
  10581. import { Scene } from "babylonjs/scene";
  10582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10583. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10584. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10585. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10586. import { Nullable } from "babylonjs/types";
  10587. import { Camera } from "babylonjs/Cameras/camera";
  10588. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10589. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10590. import { AbstractScene } from "babylonjs/abstractScene";
  10591. /**
  10592. * Groups all the scene component constants in one place to ease maintenance.
  10593. * @hidden
  10594. */
  10595. export class SceneComponentConstants {
  10596. static readonly NAME_EFFECTLAYER: string;
  10597. static readonly NAME_LAYER: string;
  10598. static readonly NAME_LENSFLARESYSTEM: string;
  10599. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10600. static readonly NAME_PARTICLESYSTEM: string;
  10601. static readonly NAME_GAMEPAD: string;
  10602. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10603. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10604. static readonly NAME_DEPTHRENDERER: string;
  10605. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10606. static readonly NAME_SPRITE: string;
  10607. static readonly NAME_OUTLINERENDERER: string;
  10608. static readonly NAME_PROCEDURALTEXTURE: string;
  10609. static readonly NAME_SHADOWGENERATOR: string;
  10610. static readonly NAME_OCTREE: string;
  10611. static readonly NAME_PHYSICSENGINE: string;
  10612. static readonly NAME_AUDIO: string;
  10613. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10614. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10615. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10616. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10617. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10618. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10619. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10620. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10621. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10622. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10623. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10624. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10625. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10626. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10627. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10628. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10629. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10630. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10631. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10632. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10633. static readonly STEP_AFTERRENDER_AUDIO: number;
  10634. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10635. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10636. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10637. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10638. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10639. static readonly STEP_POINTERMOVE_SPRITE: number;
  10640. static readonly STEP_POINTERDOWN_SPRITE: number;
  10641. static readonly STEP_POINTERUP_SPRITE: number;
  10642. }
  10643. /**
  10644. * This represents a scene component.
  10645. *
  10646. * This is used to decouple the dependency the scene is having on the different workloads like
  10647. * layers, post processes...
  10648. */
  10649. export interface ISceneComponent {
  10650. /**
  10651. * The name of the component. Each component must have a unique name.
  10652. */
  10653. name: string;
  10654. /**
  10655. * The scene the component belongs to.
  10656. */
  10657. scene: Scene;
  10658. /**
  10659. * Register the component to one instance of a scene.
  10660. */
  10661. register(): void;
  10662. /**
  10663. * Rebuilds the elements related to this component in case of
  10664. * context lost for instance.
  10665. */
  10666. rebuild(): void;
  10667. /**
  10668. * Disposes the component and the associated ressources.
  10669. */
  10670. dispose(): void;
  10671. }
  10672. /**
  10673. * This represents a SERIALIZABLE scene component.
  10674. *
  10675. * This extends Scene Component to add Serialization methods on top.
  10676. */
  10677. export interface ISceneSerializableComponent extends ISceneComponent {
  10678. /**
  10679. * Adds all the elements from the container to the scene
  10680. * @param container the container holding the elements
  10681. */
  10682. addFromContainer(container: AbstractScene): void;
  10683. /**
  10684. * Removes all the elements in the container from the scene
  10685. * @param container contains the elements to remove
  10686. * @param dispose if the removed element should be disposed (default: false)
  10687. */
  10688. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10689. /**
  10690. * Serializes the component data to the specified json object
  10691. * @param serializationObject The object to serialize to
  10692. */
  10693. serialize(serializationObject: any): void;
  10694. }
  10695. /**
  10696. * Strong typing of a Mesh related stage step action
  10697. */
  10698. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10699. /**
  10700. * Strong typing of a Evaluate Sub Mesh related stage step action
  10701. */
  10702. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10703. /**
  10704. * Strong typing of a Active Mesh related stage step action
  10705. */
  10706. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10707. /**
  10708. * Strong typing of a Camera related stage step action
  10709. */
  10710. export type CameraStageAction = (camera: Camera) => void;
  10711. /**
  10712. * Strong typing of a Camera Frame buffer related stage step action
  10713. */
  10714. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10715. /**
  10716. * Strong typing of a Render Target related stage step action
  10717. */
  10718. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10719. /**
  10720. * Strong typing of a RenderingGroup related stage step action
  10721. */
  10722. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10723. /**
  10724. * Strong typing of a Mesh Render related stage step action
  10725. */
  10726. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10727. /**
  10728. * Strong typing of a simple stage step action
  10729. */
  10730. export type SimpleStageAction = () => void;
  10731. /**
  10732. * Strong typing of a render target action.
  10733. */
  10734. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10735. /**
  10736. * Strong typing of a pointer move action.
  10737. */
  10738. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10739. /**
  10740. * Strong typing of a pointer up/down action.
  10741. */
  10742. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10743. /**
  10744. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  10745. * @hidden
  10746. */
  10747. export class Stage<T extends Function> extends Array<{
  10748. index: number;
  10749. component: ISceneComponent;
  10750. action: T;
  10751. }> {
  10752. /**
  10753. * Hide ctor from the rest of the world.
  10754. * @param items The items to add.
  10755. */
  10756. private constructor();
  10757. /**
  10758. * Creates a new Stage.
  10759. * @returns A new instance of a Stage
  10760. */
  10761. static Create<T extends Function>(): Stage<T>;
  10762. /**
  10763. * Registers a step in an ordered way in the targeted stage.
  10764. * @param index Defines the position to register the step in
  10765. * @param component Defines the component attached to the step
  10766. * @param action Defines the action to launch during the step
  10767. */
  10768. registerStep(index: number, component: ISceneComponent, action: T): void;
  10769. /**
  10770. * Clears all the steps from the stage.
  10771. */
  10772. clear(): void;
  10773. }
  10774. }
  10775. declare module "babylonjs/Meshes/meshLODLevel" {
  10776. import { Mesh } from "babylonjs/Meshes/mesh";
  10777. import { Nullable } from "babylonjs/types";
  10778. /**
  10779. * Class used to represent a specific level of detail of a mesh
  10780. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  10781. */
  10782. export class MeshLODLevel {
  10783. /** Defines the distance where this level should star being displayed */
  10784. distance: number;
  10785. /** Defines the mesh to use to render this level */
  10786. mesh: Nullable<Mesh>;
  10787. /**
  10788. * Creates a new LOD level
  10789. * @param distance defines the distance where this level should star being displayed
  10790. * @param mesh defines the mesh to use to render this level
  10791. */
  10792. constructor(
  10793. /** Defines the distance where this level should star being displayed */
  10794. distance: number,
  10795. /** Defines the mesh to use to render this level */
  10796. mesh: Nullable<Mesh>);
  10797. }
  10798. }
  10799. declare module "babylonjs/Lights/shadowLight" {
  10800. import { Camera } from "babylonjs/Cameras/camera";
  10801. import { Scene } from "babylonjs/scene";
  10802. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  10803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10804. import { Light } from "babylonjs/Lights/light";
  10805. /**
  10806. * Interface describing all the common properties and methods a shadow light needs to implement.
  10807. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10808. * as well as binding the different shadow properties to the effects.
  10809. */
  10810. export interface IShadowLight extends Light {
  10811. /**
  10812. * The light id in the scene (used in scene.findLighById for instance)
  10813. */
  10814. id: string;
  10815. /**
  10816. * The position the shdow will be casted from.
  10817. */
  10818. position: Vector3;
  10819. /**
  10820. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10821. */
  10822. direction: Vector3;
  10823. /**
  10824. * The transformed position. Position of the light in world space taking parenting in account.
  10825. */
  10826. transformedPosition: Vector3;
  10827. /**
  10828. * The transformed direction. Direction of the light in world space taking parenting in account.
  10829. */
  10830. transformedDirection: Vector3;
  10831. /**
  10832. * The friendly name of the light in the scene.
  10833. */
  10834. name: string;
  10835. /**
  10836. * Defines the shadow projection clipping minimum z value.
  10837. */
  10838. shadowMinZ: number;
  10839. /**
  10840. * Defines the shadow projection clipping maximum z value.
  10841. */
  10842. shadowMaxZ: number;
  10843. /**
  10844. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10845. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10846. */
  10847. computeTransformedInformation(): boolean;
  10848. /**
  10849. * Gets the scene the light belongs to.
  10850. * @returns The scene
  10851. */
  10852. getScene(): Scene;
  10853. /**
  10854. * Callback defining a custom Projection Matrix Builder.
  10855. * This can be used to override the default projection matrix computation.
  10856. */
  10857. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10858. /**
  10859. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10860. * @param matrix The materix to updated with the projection information
  10861. * @param viewMatrix The transform matrix of the light
  10862. * @param renderList The list of mesh to render in the map
  10863. * @returns The current light
  10864. */
  10865. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10866. /**
  10867. * Gets the current depth scale used in ESM.
  10868. * @returns The scale
  10869. */
  10870. getDepthScale(): number;
  10871. /**
  10872. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10873. * @returns true if a cube texture needs to be use
  10874. */
  10875. needCube(): boolean;
  10876. /**
  10877. * Detects if the projection matrix requires to be recomputed this frame.
  10878. * @returns true if it requires to be recomputed otherwise, false.
  10879. */
  10880. needProjectionMatrixCompute(): boolean;
  10881. /**
  10882. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10883. */
  10884. forceProjectionMatrixCompute(): void;
  10885. /**
  10886. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10887. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10888. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10889. */
  10890. getShadowDirection(faceIndex?: number): Vector3;
  10891. /**
  10892. * Gets the minZ used for shadow according to both the scene and the light.
  10893. * @param activeCamera The camera we are returning the min for
  10894. * @returns the depth min z
  10895. */
  10896. getDepthMinZ(activeCamera: Camera): number;
  10897. /**
  10898. * Gets the maxZ used for shadow according to both the scene and the light.
  10899. * @param activeCamera The camera we are returning the max for
  10900. * @returns the depth max z
  10901. */
  10902. getDepthMaxZ(activeCamera: Camera): number;
  10903. }
  10904. /**
  10905. * Base implementation IShadowLight
  10906. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10907. */
  10908. export abstract class ShadowLight extends Light implements IShadowLight {
  10909. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10910. protected _position: Vector3;
  10911. protected _setPosition(value: Vector3): void;
  10912. /**
  10913. * Sets the position the shadow will be casted from. Also use as the light position for both
  10914. * point and spot lights.
  10915. */
  10916. /**
  10917. * Sets the position the shadow will be casted from. Also use as the light position for both
  10918. * point and spot lights.
  10919. */
  10920. position: Vector3;
  10921. protected _direction: Vector3;
  10922. protected _setDirection(value: Vector3): void;
  10923. /**
  10924. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10925. * Also use as the light direction on spot and directional lights.
  10926. */
  10927. /**
  10928. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10929. * Also use as the light direction on spot and directional lights.
  10930. */
  10931. direction: Vector3;
  10932. private _shadowMinZ;
  10933. /**
  10934. * Gets the shadow projection clipping minimum z value.
  10935. */
  10936. /**
  10937. * Sets the shadow projection clipping minimum z value.
  10938. */
  10939. shadowMinZ: number;
  10940. private _shadowMaxZ;
  10941. /**
  10942. * Sets the shadow projection clipping maximum z value.
  10943. */
  10944. /**
  10945. * Gets the shadow projection clipping maximum z value.
  10946. */
  10947. shadowMaxZ: number;
  10948. /**
  10949. * Callback defining a custom Projection Matrix Builder.
  10950. * This can be used to override the default projection matrix computation.
  10951. */
  10952. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10953. /**
  10954. * The transformed position. Position of the light in world space taking parenting in account.
  10955. */
  10956. transformedPosition: Vector3;
  10957. /**
  10958. * The transformed direction. Direction of the light in world space taking parenting in account.
  10959. */
  10960. transformedDirection: Vector3;
  10961. private _needProjectionMatrixCompute;
  10962. /**
  10963. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10964. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10965. */
  10966. computeTransformedInformation(): boolean;
  10967. /**
  10968. * Return the depth scale used for the shadow map.
  10969. * @returns the depth scale.
  10970. */
  10971. getDepthScale(): number;
  10972. /**
  10973. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10974. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10975. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10976. */
  10977. getShadowDirection(faceIndex?: number): Vector3;
  10978. /**
  10979. * Returns the ShadowLight absolute position in the World.
  10980. * @returns the position vector in world space
  10981. */
  10982. getAbsolutePosition(): Vector3;
  10983. /**
  10984. * Sets the ShadowLight direction toward the passed target.
  10985. * @param target The point to target in local space
  10986. * @returns the updated ShadowLight direction
  10987. */
  10988. setDirectionToTarget(target: Vector3): Vector3;
  10989. /**
  10990. * Returns the light rotation in euler definition.
  10991. * @returns the x y z rotation in local space.
  10992. */
  10993. getRotation(): Vector3;
  10994. /**
  10995. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10996. * @returns true if a cube texture needs to be use
  10997. */
  10998. needCube(): boolean;
  10999. /**
  11000. * Detects if the projection matrix requires to be recomputed this frame.
  11001. * @returns true if it requires to be recomputed otherwise, false.
  11002. */
  11003. needProjectionMatrixCompute(): boolean;
  11004. /**
  11005. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11006. */
  11007. forceProjectionMatrixCompute(): void;
  11008. /** @hidden */
  11009. _initCache(): void;
  11010. /** @hidden */
  11011. _isSynchronized(): boolean;
  11012. /**
  11013. * Computes the world matrix of the node
  11014. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  11015. * @returns the world matrix
  11016. */
  11017. computeWorldMatrix(force?: boolean): Matrix;
  11018. /**
  11019. * Gets the minZ used for shadow according to both the scene and the light.
  11020. * @param activeCamera The camera we are returning the min for
  11021. * @returns the depth min z
  11022. */
  11023. getDepthMinZ(activeCamera: Camera): number;
  11024. /**
  11025. * Gets the maxZ used for shadow according to both the scene and the light.
  11026. * @param activeCamera The camera we are returning the max for
  11027. * @returns the depth max z
  11028. */
  11029. getDepthMaxZ(activeCamera: Camera): number;
  11030. /**
  11031. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11032. * @param matrix The materix to updated with the projection information
  11033. * @param viewMatrix The transform matrix of the light
  11034. * @param renderList The list of mesh to render in the map
  11035. * @returns The current light
  11036. */
  11037. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11038. }
  11039. }
  11040. declare module "babylonjs/Materials/materialHelper" {
  11041. import { Nullable } from "babylonjs/types";
  11042. import { Scene } from "babylonjs/scene";
  11043. import { Engine } from "babylonjs/Engines/engine";
  11044. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11045. import { Light } from "babylonjs/Lights/light";
  11046. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11047. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  11048. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11049. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11050. /**
  11051. * "Static Class" containing the most commonly used helper while dealing with material for
  11052. * rendering purpose.
  11053. *
  11054. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  11055. *
  11056. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  11057. */
  11058. export class MaterialHelper {
  11059. /**
  11060. * Bind the current view position to an effect.
  11061. * @param effect The effect to be bound
  11062. * @param scene The scene the eyes position is used from
  11063. */
  11064. static BindEyePosition(effect: Effect, scene: Scene): void;
  11065. /**
  11066. * Helps preparing the defines values about the UVs in used in the effect.
  11067. * UVs are shared as much as we can accross channels in the shaders.
  11068. * @param texture The texture we are preparing the UVs for
  11069. * @param defines The defines to update
  11070. * @param key The channel key "diffuse", "specular"... used in the shader
  11071. */
  11072. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  11073. /**
  11074. * Binds a texture matrix value to its corrsponding uniform
  11075. * @param texture The texture to bind the matrix for
  11076. * @param uniformBuffer The uniform buffer receivin the data
  11077. * @param key The channel key "diffuse", "specular"... used in the shader
  11078. */
  11079. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  11080. /**
  11081. * Gets the current status of the fog (should it be enabled?)
  11082. * @param mesh defines the mesh to evaluate for fog support
  11083. * @param scene defines the hosting scene
  11084. * @returns true if fog must be enabled
  11085. */
  11086. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  11087. /**
  11088. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  11089. * @param mesh defines the current mesh
  11090. * @param scene defines the current scene
  11091. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  11092. * @param pointsCloud defines if point cloud rendering has to be turned on
  11093. * @param fogEnabled defines if fog has to be turned on
  11094. * @param alphaTest defines if alpha testing has to be turned on
  11095. * @param defines defines the current list of defines
  11096. */
  11097. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  11098. /**
  11099. * Helper used to prepare the list of defines associated with frame values for shader compilation
  11100. * @param scene defines the current scene
  11101. * @param engine defines the current engine
  11102. * @param defines specifies the list of active defines
  11103. * @param useInstances defines if instances have to be turned on
  11104. * @param useClipPlane defines if clip plane have to be turned on
  11105. */
  11106. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  11107. /**
  11108. * Prepares the defines for bones
  11109. * @param mesh The mesh containing the geometry data we will draw
  11110. * @param defines The defines to update
  11111. */
  11112. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  11113. /**
  11114. * Prepares the defines for morph targets
  11115. * @param mesh The mesh containing the geometry data we will draw
  11116. * @param defines The defines to update
  11117. */
  11118. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  11119. /**
  11120. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  11121. * @param mesh The mesh containing the geometry data we will draw
  11122. * @param defines The defines to update
  11123. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  11124. * @param useBones Precise whether bones should be used or not (override mesh info)
  11125. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  11126. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  11127. * @returns false if defines are considered not dirty and have not been checked
  11128. */
  11129. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  11130. /**
  11131. * Prepares the defines related to multiview
  11132. * @param scene The scene we are intending to draw
  11133. * @param defines The defines to update
  11134. */
  11135. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  11136. /**
  11137. * Prepares the defines related to the light information passed in parameter
  11138. * @param scene The scene we are intending to draw
  11139. * @param mesh The mesh the effect is compiling for
  11140. * @param light The light the effect is compiling for
  11141. * @param lightIndex The index of the light
  11142. * @param defines The defines to update
  11143. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  11144. * @param state Defines the current state regarding what is needed (normals, etc...)
  11145. */
  11146. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  11147. needNormals: boolean;
  11148. needRebuild: boolean;
  11149. shadowEnabled: boolean;
  11150. specularEnabled: boolean;
  11151. lightmapMode: boolean;
  11152. }): void;
  11153. /**
  11154. * Prepares the defines related to the light information passed in parameter
  11155. * @param scene The scene we are intending to draw
  11156. * @param mesh The mesh the effect is compiling for
  11157. * @param defines The defines to update
  11158. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  11159. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  11160. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  11161. * @returns true if normals will be required for the rest of the effect
  11162. */
  11163. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  11164. /**
  11165. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  11166. * @param lightIndex defines the light index
  11167. * @param uniformsList The uniform list
  11168. * @param samplersList The sampler list
  11169. * @param projectedLightTexture defines if projected texture must be used
  11170. * @param uniformBuffersList defines an optional list of uniform buffers
  11171. */
  11172. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  11173. /**
  11174. * Prepares the uniforms and samplers list to be used in the effect
  11175. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  11176. * @param samplersList The sampler list
  11177. * @param defines The defines helping in the list generation
  11178. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  11179. */
  11180. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  11181. /**
  11182. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  11183. * @param defines The defines to update while falling back
  11184. * @param fallbacks The authorized effect fallbacks
  11185. * @param maxSimultaneousLights The maximum number of lights allowed
  11186. * @param rank the current rank of the Effect
  11187. * @returns The newly affected rank
  11188. */
  11189. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  11190. private static _TmpMorphInfluencers;
  11191. /**
  11192. * Prepares the list of attributes required for morph targets according to the effect defines.
  11193. * @param attribs The current list of supported attribs
  11194. * @param mesh The mesh to prepare the morph targets attributes for
  11195. * @param influencers The number of influencers
  11196. */
  11197. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  11198. /**
  11199. * Prepares the list of attributes required for morph targets according to the effect defines.
  11200. * @param attribs The current list of supported attribs
  11201. * @param mesh The mesh to prepare the morph targets attributes for
  11202. * @param defines The current Defines of the effect
  11203. */
  11204. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  11205. /**
  11206. * Prepares the list of attributes required for bones according to the effect defines.
  11207. * @param attribs The current list of supported attribs
  11208. * @param mesh The mesh to prepare the bones attributes for
  11209. * @param defines The current Defines of the effect
  11210. * @param fallbacks The current efffect fallback strategy
  11211. */
  11212. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  11213. /**
  11214. * Check and prepare the list of attributes required for instances according to the effect defines.
  11215. * @param attribs The current list of supported attribs
  11216. * @param defines The current MaterialDefines of the effect
  11217. */
  11218. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  11219. /**
  11220. * Add the list of attributes required for instances to the attribs array.
  11221. * @param attribs The current list of supported attribs
  11222. */
  11223. static PushAttributesForInstances(attribs: string[]): void;
  11224. /**
  11225. * Binds the light shadow information to the effect for the given mesh.
  11226. * @param light The light containing the generator
  11227. * @param scene The scene the lights belongs to
  11228. * @param mesh The mesh we are binding the information to render
  11229. * @param lightIndex The light index in the effect used to render the mesh
  11230. * @param effect The effect we are binding the data to
  11231. */
  11232. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  11233. /**
  11234. * Binds the light information to the effect.
  11235. * @param light The light containing the generator
  11236. * @param effect The effect we are binding the data to
  11237. * @param lightIndex The light index in the effect used to render
  11238. */
  11239. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  11240. /**
  11241. * Binds the lights information from the scene to the effect for the given mesh.
  11242. * @param light Light to bind
  11243. * @param lightIndex Light index
  11244. * @param scene The scene where the light belongs to
  11245. * @param mesh The mesh we are binding the information to render
  11246. * @param effect The effect we are binding the data to
  11247. * @param useSpecular Defines if specular is supported
  11248. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11249. */
  11250. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  11251. /**
  11252. * Binds the lights information from the scene to the effect for the given mesh.
  11253. * @param scene The scene the lights belongs to
  11254. * @param mesh The mesh we are binding the information to render
  11255. * @param effect The effect we are binding the data to
  11256. * @param defines The generated defines for the effect
  11257. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  11258. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11259. */
  11260. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  11261. private static _tempFogColor;
  11262. /**
  11263. * Binds the fog information from the scene to the effect for the given mesh.
  11264. * @param scene The scene the lights belongs to
  11265. * @param mesh The mesh we are binding the information to render
  11266. * @param effect The effect we are binding the data to
  11267. * @param linearSpace Defines if the fog effect is applied in linear space
  11268. */
  11269. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  11270. /**
  11271. * Binds the bones information from the mesh to the effect.
  11272. * @param mesh The mesh we are binding the information to render
  11273. * @param effect The effect we are binding the data to
  11274. */
  11275. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  11276. /**
  11277. * Binds the morph targets information from the mesh to the effect.
  11278. * @param abstractMesh The mesh we are binding the information to render
  11279. * @param effect The effect we are binding the data to
  11280. */
  11281. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  11282. /**
  11283. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  11284. * @param defines The generated defines used in the effect
  11285. * @param effect The effect we are binding the data to
  11286. * @param scene The scene we are willing to render with logarithmic scale for
  11287. */
  11288. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  11289. /**
  11290. * Binds the clip plane information from the scene to the effect.
  11291. * @param scene The scene the clip plane information are extracted from
  11292. * @param effect The effect we are binding the data to
  11293. */
  11294. static BindClipPlane(effect: Effect, scene: Scene): void;
  11295. }
  11296. }
  11297. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  11298. /** @hidden */
  11299. export var packingFunctions: {
  11300. name: string;
  11301. shader: string;
  11302. };
  11303. }
  11304. declare module "babylonjs/Shaders/shadowMap.fragment" {
  11305. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  11306. /** @hidden */
  11307. export var shadowMapPixelShader: {
  11308. name: string;
  11309. shader: string;
  11310. };
  11311. }
  11312. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  11313. /** @hidden */
  11314. export var bonesDeclaration: {
  11315. name: string;
  11316. shader: string;
  11317. };
  11318. }
  11319. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  11320. /** @hidden */
  11321. export var morphTargetsVertexGlobalDeclaration: {
  11322. name: string;
  11323. shader: string;
  11324. };
  11325. }
  11326. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  11327. /** @hidden */
  11328. export var morphTargetsVertexDeclaration: {
  11329. name: string;
  11330. shader: string;
  11331. };
  11332. }
  11333. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  11334. /** @hidden */
  11335. export var instancesDeclaration: {
  11336. name: string;
  11337. shader: string;
  11338. };
  11339. }
  11340. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  11341. /** @hidden */
  11342. export var helperFunctions: {
  11343. name: string;
  11344. shader: string;
  11345. };
  11346. }
  11347. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  11348. /** @hidden */
  11349. export var morphTargetsVertex: {
  11350. name: string;
  11351. shader: string;
  11352. };
  11353. }
  11354. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  11355. /** @hidden */
  11356. export var instancesVertex: {
  11357. name: string;
  11358. shader: string;
  11359. };
  11360. }
  11361. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  11362. /** @hidden */
  11363. export var bonesVertex: {
  11364. name: string;
  11365. shader: string;
  11366. };
  11367. }
  11368. declare module "babylonjs/Shaders/shadowMap.vertex" {
  11369. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  11370. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  11371. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  11372. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  11373. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11374. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  11375. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  11376. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  11377. /** @hidden */
  11378. export var shadowMapVertexShader: {
  11379. name: string;
  11380. shader: string;
  11381. };
  11382. }
  11383. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  11384. /** @hidden */
  11385. export var depthBoxBlurPixelShader: {
  11386. name: string;
  11387. shader: string;
  11388. };
  11389. }
  11390. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  11391. import { Nullable } from "babylonjs/types";
  11392. import { Scene } from "babylonjs/scene";
  11393. import { Matrix } from "babylonjs/Maths/math";
  11394. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11396. import { Mesh } from "babylonjs/Meshes/mesh";
  11397. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  11398. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11399. import { Effect } from "babylonjs/Materials/effect";
  11400. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11401. import "babylonjs/Shaders/shadowMap.fragment";
  11402. import "babylonjs/Shaders/shadowMap.vertex";
  11403. import "babylonjs/Shaders/depthBoxBlur.fragment";
  11404. import { Observable } from "babylonjs/Misc/observable";
  11405. /**
  11406. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11407. */
  11408. export interface ICustomShaderOptions {
  11409. /**
  11410. * Gets or sets the custom shader name to use
  11411. */
  11412. shaderName: string;
  11413. /**
  11414. * The list of attribute names used in the shader
  11415. */
  11416. attributes?: string[];
  11417. /**
  11418. * The list of unifrom names used in the shader
  11419. */
  11420. uniforms?: string[];
  11421. /**
  11422. * The list of sampler names used in the shader
  11423. */
  11424. samplers?: string[];
  11425. /**
  11426. * The list of defines used in the shader
  11427. */
  11428. defines?: string[];
  11429. }
  11430. /**
  11431. * Interface to implement to create a shadow generator compatible with BJS.
  11432. */
  11433. export interface IShadowGenerator {
  11434. /**
  11435. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11436. * @returns The render target texture if present otherwise, null
  11437. */
  11438. getShadowMap(): Nullable<RenderTargetTexture>;
  11439. /**
  11440. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11441. * @returns The render target texture if the shadow map is present otherwise, null
  11442. */
  11443. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11444. /**
  11445. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11446. * @param subMesh The submesh we want to render in the shadow map
  11447. * @param useInstances Defines wether will draw in the map using instances
  11448. * @returns true if ready otherwise, false
  11449. */
  11450. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11451. /**
  11452. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11453. * @param defines Defines of the material we want to update
  11454. * @param lightIndex Index of the light in the enabled light list of the material
  11455. */
  11456. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11457. /**
  11458. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11459. * defined in the generator but impacting the effect).
  11460. * It implies the unifroms available on the materials are the standard BJS ones.
  11461. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11462. * @param effect The effect we are binfing the information for
  11463. */
  11464. bindShadowLight(lightIndex: string, effect: Effect): void;
  11465. /**
  11466. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11467. * (eq to shadow prjection matrix * light transform matrix)
  11468. * @returns The transform matrix used to create the shadow map
  11469. */
  11470. getTransformMatrix(): Matrix;
  11471. /**
  11472. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11473. * Cube and 2D textures for instance.
  11474. */
  11475. recreateShadowMap(): void;
  11476. /**
  11477. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11478. * @param onCompiled Callback triggered at the and of the effects compilation
  11479. * @param options Sets of optional options forcing the compilation with different modes
  11480. */
  11481. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11482. useInstances: boolean;
  11483. }>): void;
  11484. /**
  11485. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11486. * @param options Sets of optional options forcing the compilation with different modes
  11487. * @returns A promise that resolves when the compilation completes
  11488. */
  11489. forceCompilationAsync(options?: Partial<{
  11490. useInstances: boolean;
  11491. }>): Promise<void>;
  11492. /**
  11493. * Serializes the shadow generator setup to a json object.
  11494. * @returns The serialized JSON object
  11495. */
  11496. serialize(): any;
  11497. /**
  11498. * Disposes the Shadow map and related Textures and effects.
  11499. */
  11500. dispose(): void;
  11501. }
  11502. /**
  11503. * Default implementation IShadowGenerator.
  11504. * This is the main object responsible of generating shadows in the framework.
  11505. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11506. */
  11507. export class ShadowGenerator implements IShadowGenerator {
  11508. /**
  11509. * Shadow generator mode None: no filtering applied.
  11510. */
  11511. static readonly FILTER_NONE: number;
  11512. /**
  11513. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11514. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11515. */
  11516. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11517. /**
  11518. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11519. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11520. */
  11521. static readonly FILTER_POISSONSAMPLING: number;
  11522. /**
  11523. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11524. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11525. */
  11526. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11527. /**
  11528. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11529. * edge artifacts on steep falloff.
  11530. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11531. */
  11532. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11533. /**
  11534. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11535. * edge artifacts on steep falloff.
  11536. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11537. */
  11538. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11539. /**
  11540. * Shadow generator mode PCF: Percentage Closer Filtering
  11541. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11542. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11543. */
  11544. static readonly FILTER_PCF: number;
  11545. /**
  11546. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11547. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11548. * Contact Hardening
  11549. */
  11550. static readonly FILTER_PCSS: number;
  11551. /**
  11552. * Reserved for PCF and PCSS
  11553. * Highest Quality.
  11554. *
  11555. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11556. *
  11557. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11558. */
  11559. static readonly QUALITY_HIGH: number;
  11560. /**
  11561. * Reserved for PCF and PCSS
  11562. * Good tradeoff for quality/perf cross devices
  11563. *
  11564. * Execute PCF on a 3*3 kernel.
  11565. *
  11566. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11567. */
  11568. static readonly QUALITY_MEDIUM: number;
  11569. /**
  11570. * Reserved for PCF and PCSS
  11571. * The lowest quality but the fastest.
  11572. *
  11573. * Execute PCF on a 1*1 kernel.
  11574. *
  11575. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11576. */
  11577. static readonly QUALITY_LOW: number;
  11578. /** Gets or sets the custom shader name to use */
  11579. customShaderOptions: ICustomShaderOptions;
  11580. /**
  11581. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11582. */
  11583. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11584. /**
  11585. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11586. */
  11587. onAfterShadowMapRenderObservable: Observable<Effect>;
  11588. /**
  11589. * Observable triggered before a mesh is rendered in the shadow map.
  11590. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11591. */
  11592. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11593. /**
  11594. * Observable triggered after a mesh is rendered in the shadow map.
  11595. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11596. */
  11597. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11598. private _bias;
  11599. /**
  11600. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11601. */
  11602. /**
  11603. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11604. */
  11605. bias: number;
  11606. private _normalBias;
  11607. /**
  11608. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11609. */
  11610. /**
  11611. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11612. */
  11613. normalBias: number;
  11614. private _blurBoxOffset;
  11615. /**
  11616. * Gets the blur box offset: offset applied during the blur pass.
  11617. * Only useful if useKernelBlur = false
  11618. */
  11619. /**
  11620. * Sets the blur box offset: offset applied during the blur pass.
  11621. * Only useful if useKernelBlur = false
  11622. */
  11623. blurBoxOffset: number;
  11624. private _blurScale;
  11625. /**
  11626. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11627. * 2 means half of the size.
  11628. */
  11629. /**
  11630. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11631. * 2 means half of the size.
  11632. */
  11633. blurScale: number;
  11634. private _blurKernel;
  11635. /**
  11636. * Gets the blur kernel: kernel size of the blur pass.
  11637. * Only useful if useKernelBlur = true
  11638. */
  11639. /**
  11640. * Sets the blur kernel: kernel size of the blur pass.
  11641. * Only useful if useKernelBlur = true
  11642. */
  11643. blurKernel: number;
  11644. private _useKernelBlur;
  11645. /**
  11646. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11647. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11648. */
  11649. /**
  11650. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11651. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11652. */
  11653. useKernelBlur: boolean;
  11654. private _depthScale;
  11655. /**
  11656. * Gets the depth scale used in ESM mode.
  11657. */
  11658. /**
  11659. * Sets the depth scale used in ESM mode.
  11660. * This can override the scale stored on the light.
  11661. */
  11662. depthScale: number;
  11663. private _filter;
  11664. /**
  11665. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11666. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11667. */
  11668. /**
  11669. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11670. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11671. */
  11672. filter: number;
  11673. /**
  11674. * Gets if the current filter is set to Poisson Sampling.
  11675. */
  11676. /**
  11677. * Sets the current filter to Poisson Sampling.
  11678. */
  11679. usePoissonSampling: boolean;
  11680. /**
  11681. * Gets if the current filter is set to ESM.
  11682. */
  11683. /**
  11684. * Sets the current filter is to ESM.
  11685. */
  11686. useExponentialShadowMap: boolean;
  11687. /**
  11688. * Gets if the current filter is set to filtered ESM.
  11689. */
  11690. /**
  11691. * Gets if the current filter is set to filtered ESM.
  11692. */
  11693. useBlurExponentialShadowMap: boolean;
  11694. /**
  11695. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11696. * exponential to prevent steep falloff artifacts).
  11697. */
  11698. /**
  11699. * Sets the current filter to "close ESM" (using the inverse of the
  11700. * exponential to prevent steep falloff artifacts).
  11701. */
  11702. useCloseExponentialShadowMap: boolean;
  11703. /**
  11704. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11705. * exponential to prevent steep falloff artifacts).
  11706. */
  11707. /**
  11708. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11709. * exponential to prevent steep falloff artifacts).
  11710. */
  11711. useBlurCloseExponentialShadowMap: boolean;
  11712. /**
  11713. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11714. */
  11715. /**
  11716. * Sets the current filter to "PCF" (percentage closer filtering).
  11717. */
  11718. usePercentageCloserFiltering: boolean;
  11719. private _filteringQuality;
  11720. /**
  11721. * Gets the PCF or PCSS Quality.
  11722. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11723. */
  11724. /**
  11725. * Sets the PCF or PCSS Quality.
  11726. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11727. */
  11728. filteringQuality: number;
  11729. /**
  11730. * Gets if the current filter is set to "PCSS" (contact hardening).
  11731. */
  11732. /**
  11733. * Sets the current filter to "PCSS" (contact hardening).
  11734. */
  11735. useContactHardeningShadow: boolean;
  11736. private _contactHardeningLightSizeUVRatio;
  11737. /**
  11738. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11739. * Using a ratio helps keeping shape stability independently of the map size.
  11740. *
  11741. * It does not account for the light projection as it was having too much
  11742. * instability during the light setup or during light position changes.
  11743. *
  11744. * Only valid if useContactHardeningShadow is true.
  11745. */
  11746. /**
  11747. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11748. * Using a ratio helps keeping shape stability independently of the map size.
  11749. *
  11750. * It does not account for the light projection as it was having too much
  11751. * instability during the light setup or during light position changes.
  11752. *
  11753. * Only valid if useContactHardeningShadow is true.
  11754. */
  11755. contactHardeningLightSizeUVRatio: number;
  11756. private _darkness;
  11757. /** Gets or sets the actual darkness of a shadow */
  11758. darkness: number;
  11759. /**
  11760. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11761. * 0 means strongest and 1 would means no shadow.
  11762. * @returns the darkness.
  11763. */
  11764. getDarkness(): number;
  11765. /**
  11766. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11767. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11768. * @returns the shadow generator allowing fluent coding.
  11769. */
  11770. setDarkness(darkness: number): ShadowGenerator;
  11771. private _transparencyShadow;
  11772. /** Gets or sets the ability to have transparent shadow */
  11773. transparencyShadow: boolean;
  11774. /**
  11775. * Sets the ability to have transparent shadow (boolean).
  11776. * @param transparent True if transparent else False
  11777. * @returns the shadow generator allowing fluent coding
  11778. */
  11779. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11780. private _shadowMap;
  11781. private _shadowMap2;
  11782. /**
  11783. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11784. * @returns The render target texture if present otherwise, null
  11785. */
  11786. getShadowMap(): Nullable<RenderTargetTexture>;
  11787. /**
  11788. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11789. * @returns The render target texture if the shadow map is present otherwise, null
  11790. */
  11791. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11792. /**
  11793. * Gets the class name of that object
  11794. * @returns "ShadowGenerator"
  11795. */
  11796. getClassName(): string;
  11797. /**
  11798. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11799. * @param mesh Mesh to add
  11800. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11801. * @returns the Shadow Generator itself
  11802. */
  11803. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11804. /**
  11805. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11806. * @param mesh Mesh to remove
  11807. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11808. * @returns the Shadow Generator itself
  11809. */
  11810. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11811. /**
  11812. * Controls the extent to which the shadows fade out at the edge of the frustum
  11813. * Used only by directionals and spots
  11814. */
  11815. frustumEdgeFalloff: number;
  11816. private _light;
  11817. /**
  11818. * Returns the associated light object.
  11819. * @returns the light generating the shadow
  11820. */
  11821. getLight(): IShadowLight;
  11822. /**
  11823. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11824. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11825. * It might on the other hand introduce peter panning.
  11826. */
  11827. forceBackFacesOnly: boolean;
  11828. private _scene;
  11829. private _lightDirection;
  11830. private _effect;
  11831. private _viewMatrix;
  11832. private _projectionMatrix;
  11833. private _transformMatrix;
  11834. private _cachedPosition;
  11835. private _cachedDirection;
  11836. private _cachedDefines;
  11837. private _currentRenderID;
  11838. private _boxBlurPostprocess;
  11839. private _kernelBlurXPostprocess;
  11840. private _kernelBlurYPostprocess;
  11841. private _blurPostProcesses;
  11842. private _mapSize;
  11843. private _currentFaceIndex;
  11844. private _currentFaceIndexCache;
  11845. private _textureType;
  11846. private _defaultTextureMatrix;
  11847. /** @hidden */
  11848. static _SceneComponentInitialization: (scene: Scene) => void;
  11849. /**
  11850. * Creates a ShadowGenerator object.
  11851. * A ShadowGenerator is the required tool to use the shadows.
  11852. * Each light casting shadows needs to use its own ShadowGenerator.
  11853. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11854. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11855. * @param light The light object generating the shadows.
  11856. * @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.
  11857. */
  11858. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11859. private _initializeGenerator;
  11860. private _initializeShadowMap;
  11861. private _initializeBlurRTTAndPostProcesses;
  11862. private _renderForShadowMap;
  11863. private _renderSubMeshForShadowMap;
  11864. private _applyFilterValues;
  11865. /**
  11866. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11867. * @param onCompiled Callback triggered at the and of the effects compilation
  11868. * @param options Sets of optional options forcing the compilation with different modes
  11869. */
  11870. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11871. useInstances: boolean;
  11872. }>): void;
  11873. /**
  11874. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11875. * @param options Sets of optional options forcing the compilation with different modes
  11876. * @returns A promise that resolves when the compilation completes
  11877. */
  11878. forceCompilationAsync(options?: Partial<{
  11879. useInstances: boolean;
  11880. }>): Promise<void>;
  11881. /**
  11882. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11883. * @param subMesh The submesh we want to render in the shadow map
  11884. * @param useInstances Defines wether will draw in the map using instances
  11885. * @returns true if ready otherwise, false
  11886. */
  11887. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11888. /**
  11889. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11890. * @param defines Defines of the material we want to update
  11891. * @param lightIndex Index of the light in the enabled light list of the material
  11892. */
  11893. prepareDefines(defines: any, lightIndex: number): void;
  11894. /**
  11895. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11896. * defined in the generator but impacting the effect).
  11897. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11898. * @param effect The effect we are binfing the information for
  11899. */
  11900. bindShadowLight(lightIndex: string, effect: Effect): void;
  11901. /**
  11902. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11903. * (eq to shadow prjection matrix * light transform matrix)
  11904. * @returns The transform matrix used to create the shadow map
  11905. */
  11906. getTransformMatrix(): Matrix;
  11907. /**
  11908. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11909. * Cube and 2D textures for instance.
  11910. */
  11911. recreateShadowMap(): void;
  11912. private _disposeBlurPostProcesses;
  11913. private _disposeRTTandPostProcesses;
  11914. /**
  11915. * Disposes the ShadowGenerator.
  11916. * Returns nothing.
  11917. */
  11918. dispose(): void;
  11919. /**
  11920. * Serializes the shadow generator setup to a json object.
  11921. * @returns The serialized JSON object
  11922. */
  11923. serialize(): any;
  11924. /**
  11925. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11926. * @param parsedShadowGenerator The JSON object to parse
  11927. * @param scene The scene to create the shadow map for
  11928. * @returns The parsed shadow generator
  11929. */
  11930. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11931. }
  11932. }
  11933. declare module "babylonjs/Lights/light" {
  11934. import { Nullable } from "babylonjs/types";
  11935. import { Scene } from "babylonjs/scene";
  11936. import { Vector3, Color3 } from "babylonjs/Maths/math";
  11937. import { Node } from "babylonjs/node";
  11938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11939. import { Effect } from "babylonjs/Materials/effect";
  11940. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11941. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  11942. /**
  11943. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11944. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11945. * 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.
  11946. */
  11947. export abstract class Light extends Node {
  11948. /**
  11949. * Falloff Default: light is falling off following the material specification:
  11950. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11951. */
  11952. static readonly FALLOFF_DEFAULT: number;
  11953. /**
  11954. * Falloff Physical: light is falling off following the inverse squared distance law.
  11955. */
  11956. static readonly FALLOFF_PHYSICAL: number;
  11957. /**
  11958. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11959. * to enhance interoperability with other engines.
  11960. */
  11961. static readonly FALLOFF_GLTF: number;
  11962. /**
  11963. * Falloff Standard: light is falling off like in the standard material
  11964. * to enhance interoperability with other materials.
  11965. */
  11966. static readonly FALLOFF_STANDARD: number;
  11967. /**
  11968. * If every light affecting the material is in this lightmapMode,
  11969. * material.lightmapTexture adds or multiplies
  11970. * (depends on material.useLightmapAsShadowmap)
  11971. * after every other light calculations.
  11972. */
  11973. static readonly LIGHTMAP_DEFAULT: number;
  11974. /**
  11975. * material.lightmapTexture as only diffuse lighting from this light
  11976. * adds only specular lighting from this light
  11977. * adds dynamic shadows
  11978. */
  11979. static readonly LIGHTMAP_SPECULAR: number;
  11980. /**
  11981. * material.lightmapTexture as only lighting
  11982. * no light calculation from this light
  11983. * only adds dynamic shadows from this light
  11984. */
  11985. static readonly LIGHTMAP_SHADOWSONLY: number;
  11986. /**
  11987. * Each light type uses the default quantity according to its type:
  11988. * point/spot lights use luminous intensity
  11989. * directional lights use illuminance
  11990. */
  11991. static readonly INTENSITYMODE_AUTOMATIC: number;
  11992. /**
  11993. * lumen (lm)
  11994. */
  11995. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11996. /**
  11997. * candela (lm/sr)
  11998. */
  11999. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  12000. /**
  12001. * lux (lm/m^2)
  12002. */
  12003. static readonly INTENSITYMODE_ILLUMINANCE: number;
  12004. /**
  12005. * nit (cd/m^2)
  12006. */
  12007. static readonly INTENSITYMODE_LUMINANCE: number;
  12008. /**
  12009. * Light type const id of the point light.
  12010. */
  12011. static readonly LIGHTTYPEID_POINTLIGHT: number;
  12012. /**
  12013. * Light type const id of the directional light.
  12014. */
  12015. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  12016. /**
  12017. * Light type const id of the spot light.
  12018. */
  12019. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  12020. /**
  12021. * Light type const id of the hemispheric light.
  12022. */
  12023. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  12024. /**
  12025. * Diffuse gives the basic color to an object.
  12026. */
  12027. diffuse: Color3;
  12028. /**
  12029. * Specular produces a highlight color on an object.
  12030. * Note: This is note affecting PBR materials.
  12031. */
  12032. specular: Color3;
  12033. /**
  12034. * Defines the falloff type for this light. This lets overrriding how punctual light are
  12035. * falling off base on range or angle.
  12036. * This can be set to any values in Light.FALLOFF_x.
  12037. *
  12038. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  12039. * other types of materials.
  12040. */
  12041. falloffType: number;
  12042. /**
  12043. * Strength of the light.
  12044. * Note: By default it is define in the framework own unit.
  12045. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  12046. */
  12047. intensity: number;
  12048. private _range;
  12049. protected _inverseSquaredRange: number;
  12050. /**
  12051. * Defines how far from the source the light is impacting in scene units.
  12052. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12053. */
  12054. /**
  12055. * Defines how far from the source the light is impacting in scene units.
  12056. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12057. */
  12058. range: number;
  12059. /**
  12060. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  12061. * of light.
  12062. */
  12063. private _photometricScale;
  12064. private _intensityMode;
  12065. /**
  12066. * Gets the photometric scale used to interpret the intensity.
  12067. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12068. */
  12069. /**
  12070. * Sets the photometric scale used to interpret the intensity.
  12071. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12072. */
  12073. intensityMode: number;
  12074. private _radius;
  12075. /**
  12076. * Gets the light radius used by PBR Materials to simulate soft area lights.
  12077. */
  12078. /**
  12079. * sets the light radius used by PBR Materials to simulate soft area lights.
  12080. */
  12081. radius: number;
  12082. private _renderPriority;
  12083. /**
  12084. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  12085. * exceeding the number allowed of the materials.
  12086. */
  12087. renderPriority: number;
  12088. private _shadowEnabled;
  12089. /**
  12090. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12091. * the current shadow generator.
  12092. */
  12093. /**
  12094. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12095. * the current shadow generator.
  12096. */
  12097. shadowEnabled: boolean;
  12098. private _includedOnlyMeshes;
  12099. /**
  12100. * Gets the only meshes impacted by this light.
  12101. */
  12102. /**
  12103. * Sets the only meshes impacted by this light.
  12104. */
  12105. includedOnlyMeshes: AbstractMesh[];
  12106. private _excludedMeshes;
  12107. /**
  12108. * Gets the meshes not impacted by this light.
  12109. */
  12110. /**
  12111. * Sets the meshes not impacted by this light.
  12112. */
  12113. excludedMeshes: AbstractMesh[];
  12114. private _excludeWithLayerMask;
  12115. /**
  12116. * Gets the layer id use to find what meshes are not impacted by the light.
  12117. * Inactive if 0
  12118. */
  12119. /**
  12120. * Sets the layer id use to find what meshes are not impacted by the light.
  12121. * Inactive if 0
  12122. */
  12123. excludeWithLayerMask: number;
  12124. private _includeOnlyWithLayerMask;
  12125. /**
  12126. * Gets the layer id use to find what meshes are impacted by the light.
  12127. * Inactive if 0
  12128. */
  12129. /**
  12130. * Sets the layer id use to find what meshes are impacted by the light.
  12131. * Inactive if 0
  12132. */
  12133. includeOnlyWithLayerMask: number;
  12134. private _lightmapMode;
  12135. /**
  12136. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12137. */
  12138. /**
  12139. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12140. */
  12141. lightmapMode: number;
  12142. /**
  12143. * Shadow generator associted to the light.
  12144. * @hidden Internal use only.
  12145. */
  12146. _shadowGenerator: Nullable<IShadowGenerator>;
  12147. /**
  12148. * @hidden Internal use only.
  12149. */
  12150. _excludedMeshesIds: string[];
  12151. /**
  12152. * @hidden Internal use only.
  12153. */
  12154. _includedOnlyMeshesIds: string[];
  12155. /**
  12156. * The current light unifom buffer.
  12157. * @hidden Internal use only.
  12158. */
  12159. _uniformBuffer: UniformBuffer;
  12160. /**
  12161. * Creates a Light object in the scene.
  12162. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12163. * @param name The firendly name of the light
  12164. * @param scene The scene the light belongs too
  12165. */
  12166. constructor(name: string, scene: Scene);
  12167. protected abstract _buildUniformLayout(): void;
  12168. /**
  12169. * Sets the passed Effect "effect" with the Light information.
  12170. * @param effect The effect to update
  12171. * @param lightIndex The index of the light in the effect to update
  12172. * @returns The light
  12173. */
  12174. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12175. /**
  12176. * Returns the string "Light".
  12177. * @returns the class name
  12178. */
  12179. getClassName(): string;
  12180. /** @hidden */
  12181. readonly _isLight: boolean;
  12182. /**
  12183. * Converts the light information to a readable string for debug purpose.
  12184. * @param fullDetails Supports for multiple levels of logging within scene loading
  12185. * @returns the human readable light info
  12186. */
  12187. toString(fullDetails?: boolean): string;
  12188. /** @hidden */
  12189. protected _syncParentEnabledState(): void;
  12190. /**
  12191. * Set the enabled state of this node.
  12192. * @param value - the new enabled state
  12193. */
  12194. setEnabled(value: boolean): void;
  12195. /**
  12196. * Returns the Light associated shadow generator if any.
  12197. * @return the associated shadow generator.
  12198. */
  12199. getShadowGenerator(): Nullable<IShadowGenerator>;
  12200. /**
  12201. * Returns a Vector3, the absolute light position in the World.
  12202. * @returns the world space position of the light
  12203. */
  12204. getAbsolutePosition(): Vector3;
  12205. /**
  12206. * Specifies if the light will affect the passed mesh.
  12207. * @param mesh The mesh to test against the light
  12208. * @return true the mesh is affected otherwise, false.
  12209. */
  12210. canAffectMesh(mesh: AbstractMesh): boolean;
  12211. /**
  12212. * Sort function to order lights for rendering.
  12213. * @param a First Light object to compare to second.
  12214. * @param b Second Light object to compare first.
  12215. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12216. */
  12217. static CompareLightsPriority(a: Light, b: Light): number;
  12218. /**
  12219. * Releases resources associated with this node.
  12220. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12221. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12222. */
  12223. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12224. /**
  12225. * Returns the light type ID (integer).
  12226. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12227. */
  12228. getTypeID(): number;
  12229. /**
  12230. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12231. * @returns the scaled intensity in intensity mode unit
  12232. */
  12233. getScaledIntensity(): number;
  12234. /**
  12235. * Returns a new Light object, named "name", from the current one.
  12236. * @param name The name of the cloned light
  12237. * @returns the new created light
  12238. */
  12239. clone(name: string): Nullable<Light>;
  12240. /**
  12241. * Serializes the current light into a Serialization object.
  12242. * @returns the serialized object.
  12243. */
  12244. serialize(): any;
  12245. /**
  12246. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12247. * This new light is named "name" and added to the passed scene.
  12248. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12249. * @param name The friendly name of the light
  12250. * @param scene The scene the new light will belong to
  12251. * @returns the constructor function
  12252. */
  12253. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12254. /**
  12255. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12256. * @param parsedLight The JSON representation of the light
  12257. * @param scene The scene to create the parsed light in
  12258. * @returns the created light after parsing
  12259. */
  12260. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12261. private _hookArrayForExcluded;
  12262. private _hookArrayForIncludedOnly;
  12263. private _resyncMeshes;
  12264. /**
  12265. * Forces the meshes to update their light related information in their rendering used effects
  12266. * @hidden Internal Use Only
  12267. */
  12268. _markMeshesAsLightDirty(): void;
  12269. /**
  12270. * Recomputes the cached photometric scale if needed.
  12271. */
  12272. private _computePhotometricScale;
  12273. /**
  12274. * Returns the Photometric Scale according to the light type and intensity mode.
  12275. */
  12276. private _getPhotometricScale;
  12277. /**
  12278. * Reorder the light in the scene according to their defined priority.
  12279. * @hidden Internal Use Only
  12280. */
  12281. _reorderLightsInScene(): void;
  12282. /**
  12283. * Prepares the list of defines specific to the light type.
  12284. * @param defines the list of defines
  12285. * @param lightIndex defines the index of the light for the effect
  12286. */
  12287. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12288. }
  12289. }
  12290. declare module "babylonjs/Meshes/instancedMesh" {
  12291. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  12292. import { Vector3, Matrix } from "babylonjs/Maths/math";
  12293. import { Camera } from "babylonjs/Cameras/camera";
  12294. import { Node } from "babylonjs/node";
  12295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12296. import { Mesh } from "babylonjs/Meshes/mesh";
  12297. import { Material } from "babylonjs/Materials/material";
  12298. import { Skeleton } from "babylonjs/Bones/skeleton";
  12299. import { Light } from "babylonjs/Lights/light";
  12300. /**
  12301. * Creates an instance based on a source mesh.
  12302. */
  12303. export class InstancedMesh extends AbstractMesh {
  12304. private _sourceMesh;
  12305. private _currentLOD;
  12306. /** @hidden */
  12307. _indexInSourceMeshInstanceArray: number;
  12308. constructor(name: string, source: Mesh);
  12309. /**
  12310. * Returns the string "InstancedMesh".
  12311. */
  12312. getClassName(): string;
  12313. /** Gets the list of lights affecting that mesh */
  12314. readonly lightSources: Light[];
  12315. _resyncLightSources(): void;
  12316. _resyncLighSource(light: Light): void;
  12317. _removeLightSource(light: Light): void;
  12318. /**
  12319. * If the source mesh receives shadows
  12320. */
  12321. readonly receiveShadows: boolean;
  12322. /**
  12323. * The material of the source mesh
  12324. */
  12325. readonly material: Nullable<Material>;
  12326. /**
  12327. * Visibility of the source mesh
  12328. */
  12329. readonly visibility: number;
  12330. /**
  12331. * Skeleton of the source mesh
  12332. */
  12333. readonly skeleton: Nullable<Skeleton>;
  12334. /**
  12335. * Rendering ground id of the source mesh
  12336. */
  12337. renderingGroupId: number;
  12338. /**
  12339. * Returns the total number of vertices (integer).
  12340. */
  12341. getTotalVertices(): number;
  12342. /**
  12343. * Returns a positive integer : the total number of indices in this mesh geometry.
  12344. * @returns the numner of indices or zero if the mesh has no geometry.
  12345. */
  12346. getTotalIndices(): number;
  12347. /**
  12348. * The source mesh of the instance
  12349. */
  12350. readonly sourceMesh: Mesh;
  12351. /**
  12352. * Is this node ready to be used/rendered
  12353. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  12354. * @return {boolean} is it ready
  12355. */
  12356. isReady(completeCheck?: boolean): boolean;
  12357. /**
  12358. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  12359. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  12360. * @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.
  12361. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  12362. */
  12363. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  12364. /**
  12365. * Sets the vertex data of the mesh geometry for the requested `kind`.
  12366. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  12367. * The `data` are either a numeric array either a Float32Array.
  12368. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  12369. * 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).
  12370. * Note that a new underlying VertexBuffer object is created each call.
  12371. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12372. *
  12373. * Possible `kind` values :
  12374. * - VertexBuffer.PositionKind
  12375. * - VertexBuffer.UVKind
  12376. * - VertexBuffer.UV2Kind
  12377. * - VertexBuffer.UV3Kind
  12378. * - VertexBuffer.UV4Kind
  12379. * - VertexBuffer.UV5Kind
  12380. * - VertexBuffer.UV6Kind
  12381. * - VertexBuffer.ColorKind
  12382. * - VertexBuffer.MatricesIndicesKind
  12383. * - VertexBuffer.MatricesIndicesExtraKind
  12384. * - VertexBuffer.MatricesWeightsKind
  12385. * - VertexBuffer.MatricesWeightsExtraKind
  12386. *
  12387. * Returns the Mesh.
  12388. */
  12389. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12390. /**
  12391. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12392. * If the mesh has no geometry, it is simply returned as it is.
  12393. * The `data` are either a numeric array either a Float32Array.
  12394. * No new underlying VertexBuffer object is created.
  12395. * 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.
  12396. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12397. *
  12398. * Possible `kind` values :
  12399. * - VertexBuffer.PositionKind
  12400. * - VertexBuffer.UVKind
  12401. * - VertexBuffer.UV2Kind
  12402. * - VertexBuffer.UV3Kind
  12403. * - VertexBuffer.UV4Kind
  12404. * - VertexBuffer.UV5Kind
  12405. * - VertexBuffer.UV6Kind
  12406. * - VertexBuffer.ColorKind
  12407. * - VertexBuffer.MatricesIndicesKind
  12408. * - VertexBuffer.MatricesIndicesExtraKind
  12409. * - VertexBuffer.MatricesWeightsKind
  12410. * - VertexBuffer.MatricesWeightsExtraKind
  12411. *
  12412. * Returns the Mesh.
  12413. */
  12414. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12415. /**
  12416. * Sets the mesh indices.
  12417. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12418. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12419. * This method creates a new index buffer each call.
  12420. * Returns the Mesh.
  12421. */
  12422. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12423. /**
  12424. * Boolean : True if the mesh owns the requested kind of data.
  12425. */
  12426. isVerticesDataPresent(kind: string): boolean;
  12427. /**
  12428. * Returns an array of indices (IndicesArray).
  12429. */
  12430. getIndices(): Nullable<IndicesArray>;
  12431. readonly _positions: Nullable<Vector3[]>;
  12432. /**
  12433. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12434. * This means the mesh underlying bounding box and sphere are recomputed.
  12435. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12436. * @returns the current mesh
  12437. */
  12438. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12439. /** @hidden */
  12440. _preActivate(): InstancedMesh;
  12441. /** @hidden */
  12442. _activate(renderId: number, intermediateRendering: boolean): boolean;
  12443. /** @hidden */
  12444. _postActivate(): void;
  12445. getWorldMatrix(): Matrix;
  12446. readonly isAnInstance: boolean;
  12447. /**
  12448. * Returns the current associated LOD AbstractMesh.
  12449. */
  12450. getLOD(camera: Camera): AbstractMesh;
  12451. /** @hidden */
  12452. _syncSubMeshes(): InstancedMesh;
  12453. /** @hidden */
  12454. _generatePointsArray(): boolean;
  12455. /**
  12456. * Creates a new InstancedMesh from the current mesh.
  12457. * - name (string) : the cloned mesh name
  12458. * - newParent (optional Node) : the optional Node to parent the clone to.
  12459. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12460. *
  12461. * Returns the clone.
  12462. */
  12463. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12464. /**
  12465. * Disposes the InstancedMesh.
  12466. * Returns nothing.
  12467. */
  12468. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12469. }
  12470. }
  12471. declare module "babylonjs/Materials/shaderMaterial" {
  12472. import { Scene } from "babylonjs/scene";
  12473. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  12474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12475. import { Mesh } from "babylonjs/Meshes/mesh";
  12476. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  12477. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12478. import { Texture } from "babylonjs/Materials/Textures/texture";
  12479. import { Material } from "babylonjs/Materials/material";
  12480. /**
  12481. * Defines the options associated with the creation of a shader material.
  12482. */
  12483. export interface IShaderMaterialOptions {
  12484. /**
  12485. * Does the material work in alpha blend mode
  12486. */
  12487. needAlphaBlending: boolean;
  12488. /**
  12489. * Does the material work in alpha test mode
  12490. */
  12491. needAlphaTesting: boolean;
  12492. /**
  12493. * The list of attribute names used in the shader
  12494. */
  12495. attributes: string[];
  12496. /**
  12497. * The list of unifrom names used in the shader
  12498. */
  12499. uniforms: string[];
  12500. /**
  12501. * The list of UBO names used in the shader
  12502. */
  12503. uniformBuffers: string[];
  12504. /**
  12505. * The list of sampler names used in the shader
  12506. */
  12507. samplers: string[];
  12508. /**
  12509. * The list of defines used in the shader
  12510. */
  12511. defines: string[];
  12512. }
  12513. /**
  12514. * 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.
  12515. *
  12516. * This returned material effects how the mesh will look based on the code in the shaders.
  12517. *
  12518. * @see http://doc.babylonjs.com/how_to/shader_material
  12519. */
  12520. export class ShaderMaterial extends Material {
  12521. private _shaderPath;
  12522. private _options;
  12523. private _textures;
  12524. private _textureArrays;
  12525. private _floats;
  12526. private _ints;
  12527. private _floatsArrays;
  12528. private _colors3;
  12529. private _colors3Arrays;
  12530. private _colors4;
  12531. private _colors4Arrays;
  12532. private _vectors2;
  12533. private _vectors3;
  12534. private _vectors4;
  12535. private _matrices;
  12536. private _matrices3x3;
  12537. private _matrices2x2;
  12538. private _vectors2Arrays;
  12539. private _vectors3Arrays;
  12540. private _vectors4Arrays;
  12541. private _cachedWorldViewMatrix;
  12542. private _cachedWorldViewProjectionMatrix;
  12543. private _renderId;
  12544. /**
  12545. * Instantiate a new shader material.
  12546. * 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.
  12547. * This returned material effects how the mesh will look based on the code in the shaders.
  12548. * @see http://doc.babylonjs.com/how_to/shader_material
  12549. * @param name Define the name of the material in the scene
  12550. * @param scene Define the scene the material belongs to
  12551. * @param shaderPath Defines the route to the shader code in one of three ways:
  12552. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12553. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12554. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12555. * @param options Define the options used to create the shader
  12556. */
  12557. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12558. /**
  12559. * Gets the options used to compile the shader.
  12560. * They can be modified to trigger a new compilation
  12561. */
  12562. readonly options: IShaderMaterialOptions;
  12563. /**
  12564. * Gets the current class name of the material e.g. "ShaderMaterial"
  12565. * Mainly use in serialization.
  12566. * @returns the class name
  12567. */
  12568. getClassName(): string;
  12569. /**
  12570. * Specifies if the material will require alpha blending
  12571. * @returns a boolean specifying if alpha blending is needed
  12572. */
  12573. needAlphaBlending(): boolean;
  12574. /**
  12575. * Specifies if this material should be rendered in alpha test mode
  12576. * @returns a boolean specifying if an alpha test is needed.
  12577. */
  12578. needAlphaTesting(): boolean;
  12579. private _checkUniform;
  12580. /**
  12581. * Set a texture in the shader.
  12582. * @param name Define the name of the uniform samplers as defined in the shader
  12583. * @param texture Define the texture to bind to this sampler
  12584. * @return the material itself allowing "fluent" like uniform updates
  12585. */
  12586. setTexture(name: string, texture: Texture): ShaderMaterial;
  12587. /**
  12588. * Set a texture array in the shader.
  12589. * @param name Define the name of the uniform sampler array as defined in the shader
  12590. * @param textures Define the list of textures to bind to this sampler
  12591. * @return the material itself allowing "fluent" like uniform updates
  12592. */
  12593. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12594. /**
  12595. * Set a float in the shader.
  12596. * @param name Define the name of the uniform as defined in the shader
  12597. * @param value Define the value to give to the uniform
  12598. * @return the material itself allowing "fluent" like uniform updates
  12599. */
  12600. setFloat(name: string, value: number): ShaderMaterial;
  12601. /**
  12602. * Set a int in the shader.
  12603. * @param name Define the name of the uniform as defined in the shader
  12604. * @param value Define the value to give to the uniform
  12605. * @return the material itself allowing "fluent" like uniform updates
  12606. */
  12607. setInt(name: string, value: number): ShaderMaterial;
  12608. /**
  12609. * Set an array of floats in the shader.
  12610. * @param name Define the name of the uniform as defined in the shader
  12611. * @param value Define the value to give to the uniform
  12612. * @return the material itself allowing "fluent" like uniform updates
  12613. */
  12614. setFloats(name: string, value: number[]): ShaderMaterial;
  12615. /**
  12616. * Set a vec3 in the shader from a Color3.
  12617. * @param name Define the name of the uniform as defined in the shader
  12618. * @param value Define the value to give to the uniform
  12619. * @return the material itself allowing "fluent" like uniform updates
  12620. */
  12621. setColor3(name: string, value: Color3): ShaderMaterial;
  12622. /**
  12623. * Set a vec3 array in the shader from a Color3 array.
  12624. * @param name Define the name of the uniform as defined in the shader
  12625. * @param value Define the value to give to the uniform
  12626. * @return the material itself allowing "fluent" like uniform updates
  12627. */
  12628. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12629. /**
  12630. * Set a vec4 in the shader from a Color4.
  12631. * @param name Define the name of the uniform as defined in the shader
  12632. * @param value Define the value to give to the uniform
  12633. * @return the material itself allowing "fluent" like uniform updates
  12634. */
  12635. setColor4(name: string, value: Color4): ShaderMaterial;
  12636. /**
  12637. * Set a vec4 array in the shader from a Color4 array.
  12638. * @param name Define the name of the uniform as defined in the shader
  12639. * @param value Define the value to give to the uniform
  12640. * @return the material itself allowing "fluent" like uniform updates
  12641. */
  12642. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  12643. /**
  12644. * Set a vec2 in the shader from a Vector2.
  12645. * @param name Define the name of the uniform as defined in the shader
  12646. * @param value Define the value to give to the uniform
  12647. * @return the material itself allowing "fluent" like uniform updates
  12648. */
  12649. setVector2(name: string, value: Vector2): ShaderMaterial;
  12650. /**
  12651. * Set a vec3 in the shader from a Vector3.
  12652. * @param name Define the name of the uniform as defined in the shader
  12653. * @param value Define the value to give to the uniform
  12654. * @return the material itself allowing "fluent" like uniform updates
  12655. */
  12656. setVector3(name: string, value: Vector3): ShaderMaterial;
  12657. /**
  12658. * Set a vec4 in the shader from a Vector4.
  12659. * @param name Define the name of the uniform as defined in the shader
  12660. * @param value Define the value to give to the uniform
  12661. * @return the material itself allowing "fluent" like uniform updates
  12662. */
  12663. setVector4(name: string, value: Vector4): ShaderMaterial;
  12664. /**
  12665. * Set a mat4 in the shader from a Matrix.
  12666. * @param name Define the name of the uniform as defined in the shader
  12667. * @param value Define the value to give to the uniform
  12668. * @return the material itself allowing "fluent" like uniform updates
  12669. */
  12670. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12671. /**
  12672. * Set a mat3 in the shader from a Float32Array.
  12673. * @param name Define the name of the uniform as defined in the shader
  12674. * @param value Define the value to give to the uniform
  12675. * @return the material itself allowing "fluent" like uniform updates
  12676. */
  12677. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12678. /**
  12679. * Set a mat2 in the shader from a Float32Array.
  12680. * @param name Define the name of the uniform as defined in the shader
  12681. * @param value Define the value to give to the uniform
  12682. * @return the material itself allowing "fluent" like uniform updates
  12683. */
  12684. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12685. /**
  12686. * Set a vec2 array in the shader from a number array.
  12687. * @param name Define the name of the uniform as defined in the shader
  12688. * @param value Define the value to give to the uniform
  12689. * @return the material itself allowing "fluent" like uniform updates
  12690. */
  12691. setArray2(name: string, value: number[]): ShaderMaterial;
  12692. /**
  12693. * Set a vec3 array in the shader from a number array.
  12694. * @param name Define the name of the uniform as defined in the shader
  12695. * @param value Define the value to give to the uniform
  12696. * @return the material itself allowing "fluent" like uniform updates
  12697. */
  12698. setArray3(name: string, value: number[]): ShaderMaterial;
  12699. /**
  12700. * Set a vec4 array in the shader from a number array.
  12701. * @param name Define the name of the uniform as defined in the shader
  12702. * @param value Define the value to give to the uniform
  12703. * @return the material itself allowing "fluent" like uniform updates
  12704. */
  12705. setArray4(name: string, value: number[]): ShaderMaterial;
  12706. private _checkCache;
  12707. /**
  12708. * Specifies that the submesh is ready to be used
  12709. * @param mesh defines the mesh to check
  12710. * @param subMesh defines which submesh to check
  12711. * @param useInstances specifies that instances should be used
  12712. * @returns a boolean indicating that the submesh is ready or not
  12713. */
  12714. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12715. /**
  12716. * Checks if the material is ready to render the requested mesh
  12717. * @param mesh Define the mesh to render
  12718. * @param useInstances Define whether or not the material is used with instances
  12719. * @returns true if ready, otherwise false
  12720. */
  12721. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12722. /**
  12723. * Binds the world matrix to the material
  12724. * @param world defines the world transformation matrix
  12725. */
  12726. bindOnlyWorldMatrix(world: Matrix): void;
  12727. /**
  12728. * Binds the material to the mesh
  12729. * @param world defines the world transformation matrix
  12730. * @param mesh defines the mesh to bind the material to
  12731. */
  12732. bind(world: Matrix, mesh?: Mesh): void;
  12733. /**
  12734. * Gets the active textures from the material
  12735. * @returns an array of textures
  12736. */
  12737. getActiveTextures(): BaseTexture[];
  12738. /**
  12739. * Specifies if the material uses a texture
  12740. * @param texture defines the texture to check against the material
  12741. * @returns a boolean specifying if the material uses the texture
  12742. */
  12743. hasTexture(texture: BaseTexture): boolean;
  12744. /**
  12745. * Makes a duplicate of the material, and gives it a new name
  12746. * @param name defines the new name for the duplicated material
  12747. * @returns the cloned material
  12748. */
  12749. clone(name: string): ShaderMaterial;
  12750. /**
  12751. * Disposes the material
  12752. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12753. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12754. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12755. */
  12756. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12757. /**
  12758. * Serializes this material in a JSON representation
  12759. * @returns the serialized material object
  12760. */
  12761. serialize(): any;
  12762. /**
  12763. * Creates a shader material from parsed shader material data
  12764. * @param source defines the JSON represnetation of the material
  12765. * @param scene defines the hosting scene
  12766. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12767. * @returns a new material
  12768. */
  12769. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12770. }
  12771. }
  12772. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  12773. /** @hidden */
  12774. export var clipPlaneFragmentDeclaration: {
  12775. name: string;
  12776. shader: string;
  12777. };
  12778. }
  12779. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  12780. /** @hidden */
  12781. export var clipPlaneFragment: {
  12782. name: string;
  12783. shader: string;
  12784. };
  12785. }
  12786. declare module "babylonjs/Shaders/color.fragment" {
  12787. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12788. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12789. /** @hidden */
  12790. export var colorPixelShader: {
  12791. name: string;
  12792. shader: string;
  12793. };
  12794. }
  12795. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  12796. /** @hidden */
  12797. export var clipPlaneVertexDeclaration: {
  12798. name: string;
  12799. shader: string;
  12800. };
  12801. }
  12802. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  12803. /** @hidden */
  12804. export var clipPlaneVertex: {
  12805. name: string;
  12806. shader: string;
  12807. };
  12808. }
  12809. declare module "babylonjs/Shaders/color.vertex" {
  12810. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  12811. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12812. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  12813. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  12814. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  12815. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12816. /** @hidden */
  12817. export var colorVertexShader: {
  12818. name: string;
  12819. shader: string;
  12820. };
  12821. }
  12822. declare module "babylonjs/Meshes/linesMesh" {
  12823. import { Nullable } from "babylonjs/types";
  12824. import { Scene } from "babylonjs/scene";
  12825. import { Color3 } from "babylonjs/Maths/math";
  12826. import { Node } from "babylonjs/node";
  12827. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12828. import { Mesh } from "babylonjs/Meshes/mesh";
  12829. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  12830. import { Effect } from "babylonjs/Materials/effect";
  12831. import { Material } from "babylonjs/Materials/material";
  12832. import "babylonjs/Shaders/color.fragment";
  12833. import "babylonjs/Shaders/color.vertex";
  12834. /**
  12835. * Line mesh
  12836. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12837. */
  12838. export class LinesMesh extends Mesh {
  12839. /**
  12840. * If vertex color should be applied to the mesh
  12841. */
  12842. readonly useVertexColor?: boolean | undefined;
  12843. /**
  12844. * If vertex alpha should be applied to the mesh
  12845. */
  12846. readonly useVertexAlpha?: boolean | undefined;
  12847. /**
  12848. * Color of the line (Default: White)
  12849. */
  12850. color: Color3;
  12851. /**
  12852. * Alpha of the line (Default: 1)
  12853. */
  12854. alpha: number;
  12855. /**
  12856. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12857. * This margin is expressed in world space coordinates, so its value may vary.
  12858. * Default value is 0.1
  12859. */
  12860. intersectionThreshold: number;
  12861. private _colorShader;
  12862. private color4;
  12863. /**
  12864. * Creates a new LinesMesh
  12865. * @param name defines the name
  12866. * @param scene defines the hosting scene
  12867. * @param parent defines the parent mesh if any
  12868. * @param source defines the optional source LinesMesh used to clone data from
  12869. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12870. * When false, achieved by calling a clone(), also passing False.
  12871. * This will make creation of children, recursive.
  12872. * @param useVertexColor defines if this LinesMesh supports vertex color
  12873. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12874. */
  12875. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12876. /**
  12877. * If vertex color should be applied to the mesh
  12878. */
  12879. useVertexColor?: boolean | undefined,
  12880. /**
  12881. * If vertex alpha should be applied to the mesh
  12882. */
  12883. useVertexAlpha?: boolean | undefined);
  12884. private _addClipPlaneDefine;
  12885. private _removeClipPlaneDefine;
  12886. isReady(): boolean;
  12887. /**
  12888. * Returns the string "LineMesh"
  12889. */
  12890. getClassName(): string;
  12891. /**
  12892. * @hidden
  12893. */
  12894. /**
  12895. * @hidden
  12896. */
  12897. material: Material;
  12898. /**
  12899. * @hidden
  12900. */
  12901. readonly checkCollisions: boolean;
  12902. /** @hidden */
  12903. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12904. /** @hidden */
  12905. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12906. /**
  12907. * Disposes of the line mesh
  12908. * @param doNotRecurse If children should be disposed
  12909. */
  12910. dispose(doNotRecurse?: boolean): void;
  12911. /**
  12912. * Returns a new LineMesh object cloned from the current one.
  12913. */
  12914. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12915. /**
  12916. * Creates a new InstancedLinesMesh object from the mesh model.
  12917. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12918. * @param name defines the name of the new instance
  12919. * @returns a new InstancedLinesMesh
  12920. */
  12921. createInstance(name: string): InstancedLinesMesh;
  12922. }
  12923. /**
  12924. * Creates an instance based on a source LinesMesh
  12925. */
  12926. export class InstancedLinesMesh extends InstancedMesh {
  12927. /**
  12928. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12929. * This margin is expressed in world space coordinates, so its value may vary.
  12930. * Initilized with the intersectionThreshold value of the source LinesMesh
  12931. */
  12932. intersectionThreshold: number;
  12933. constructor(name: string, source: LinesMesh);
  12934. /**
  12935. * Returns the string "InstancedLinesMesh".
  12936. */
  12937. getClassName(): string;
  12938. }
  12939. }
  12940. declare module "babylonjs/Meshes/groundMesh" {
  12941. import { Scene } from "babylonjs/scene";
  12942. import { Vector3 } from "babylonjs/Maths/math";
  12943. import { Mesh } from "babylonjs/Meshes/mesh";
  12944. /**
  12945. * Mesh representing the gorund
  12946. */
  12947. export class GroundMesh extends Mesh {
  12948. /** If octree should be generated */
  12949. generateOctree: boolean;
  12950. private _heightQuads;
  12951. /** @hidden */
  12952. _subdivisionsX: number;
  12953. /** @hidden */
  12954. _subdivisionsY: number;
  12955. /** @hidden */
  12956. _width: number;
  12957. /** @hidden */
  12958. _height: number;
  12959. /** @hidden */
  12960. _minX: number;
  12961. /** @hidden */
  12962. _maxX: number;
  12963. /** @hidden */
  12964. _minZ: number;
  12965. /** @hidden */
  12966. _maxZ: number;
  12967. constructor(name: string, scene: Scene);
  12968. /**
  12969. * "GroundMesh"
  12970. * @returns "GroundMesh"
  12971. */
  12972. getClassName(): string;
  12973. /**
  12974. * The minimum of x and y subdivisions
  12975. */
  12976. readonly subdivisions: number;
  12977. /**
  12978. * X subdivisions
  12979. */
  12980. readonly subdivisionsX: number;
  12981. /**
  12982. * Y subdivisions
  12983. */
  12984. readonly subdivisionsY: number;
  12985. /**
  12986. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12987. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12988. * @param chunksCount the number of subdivisions for x and y
  12989. * @param octreeBlocksSize (Default: 32)
  12990. */
  12991. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12992. /**
  12993. * Returns a height (y) value in the Worl system :
  12994. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12995. * @param x x coordinate
  12996. * @param z z coordinate
  12997. * @returns the ground y position if (x, z) are outside the ground surface.
  12998. */
  12999. getHeightAtCoordinates(x: number, z: number): number;
  13000. /**
  13001. * Returns a normalized vector (Vector3) orthogonal to the ground
  13002. * at the ground coordinates (x, z) expressed in the World system.
  13003. * @param x x coordinate
  13004. * @param z z coordinate
  13005. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  13006. */
  13007. getNormalAtCoordinates(x: number, z: number): Vector3;
  13008. /**
  13009. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  13010. * at the ground coordinates (x, z) expressed in the World system.
  13011. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  13012. * @param x x coordinate
  13013. * @param z z coordinate
  13014. * @param ref vector to store the result
  13015. * @returns the GroundMesh.
  13016. */
  13017. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  13018. /**
  13019. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  13020. * if the ground has been updated.
  13021. * This can be used in the render loop.
  13022. * @returns the GroundMesh.
  13023. */
  13024. updateCoordinateHeights(): GroundMesh;
  13025. private _getFacetAt;
  13026. private _initHeightQuads;
  13027. private _computeHeightQuads;
  13028. /**
  13029. * Serializes this ground mesh
  13030. * @param serializationObject object to write serialization to
  13031. */
  13032. serialize(serializationObject: any): void;
  13033. /**
  13034. * Parses a serialized ground mesh
  13035. * @param parsedMesh the serialized mesh
  13036. * @param scene the scene to create the ground mesh in
  13037. * @returns the created ground mesh
  13038. */
  13039. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  13040. }
  13041. }
  13042. declare module "babylonjs/Physics/physicsJoint" {
  13043. import { Vector3 } from "babylonjs/Maths/math";
  13044. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  13045. /**
  13046. * Interface for Physics-Joint data
  13047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13048. */
  13049. export interface PhysicsJointData {
  13050. /**
  13051. * The main pivot of the joint
  13052. */
  13053. mainPivot?: Vector3;
  13054. /**
  13055. * The connected pivot of the joint
  13056. */
  13057. connectedPivot?: Vector3;
  13058. /**
  13059. * The main axis of the joint
  13060. */
  13061. mainAxis?: Vector3;
  13062. /**
  13063. * The connected axis of the joint
  13064. */
  13065. connectedAxis?: Vector3;
  13066. /**
  13067. * The collision of the joint
  13068. */
  13069. collision?: boolean;
  13070. /**
  13071. * Native Oimo/Cannon/Energy data
  13072. */
  13073. nativeParams?: any;
  13074. }
  13075. /**
  13076. * This is a holder class for the physics joint created by the physics plugin
  13077. * It holds a set of functions to control the underlying joint
  13078. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13079. */
  13080. export class PhysicsJoint {
  13081. /**
  13082. * The type of the physics joint
  13083. */
  13084. type: number;
  13085. /**
  13086. * The data for the physics joint
  13087. */
  13088. jointData: PhysicsJointData;
  13089. private _physicsJoint;
  13090. protected _physicsPlugin: IPhysicsEnginePlugin;
  13091. /**
  13092. * Initializes the physics joint
  13093. * @param type The type of the physics joint
  13094. * @param jointData The data for the physics joint
  13095. */
  13096. constructor(
  13097. /**
  13098. * The type of the physics joint
  13099. */
  13100. type: number,
  13101. /**
  13102. * The data for the physics joint
  13103. */
  13104. jointData: PhysicsJointData);
  13105. /**
  13106. * Gets the physics joint
  13107. */
  13108. /**
  13109. * Sets the physics joint
  13110. */
  13111. physicsJoint: any;
  13112. /**
  13113. * Sets the physics plugin
  13114. */
  13115. physicsPlugin: IPhysicsEnginePlugin;
  13116. /**
  13117. * Execute a function that is physics-plugin specific.
  13118. * @param {Function} func the function that will be executed.
  13119. * It accepts two parameters: the physics world and the physics joint
  13120. */
  13121. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  13122. /**
  13123. * Distance-Joint type
  13124. */
  13125. static DistanceJoint: number;
  13126. /**
  13127. * Hinge-Joint type
  13128. */
  13129. static HingeJoint: number;
  13130. /**
  13131. * Ball-and-Socket joint type
  13132. */
  13133. static BallAndSocketJoint: number;
  13134. /**
  13135. * Wheel-Joint type
  13136. */
  13137. static WheelJoint: number;
  13138. /**
  13139. * Slider-Joint type
  13140. */
  13141. static SliderJoint: number;
  13142. /**
  13143. * Prismatic-Joint type
  13144. */
  13145. static PrismaticJoint: number;
  13146. /**
  13147. * Universal-Joint type
  13148. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  13149. */
  13150. static UniversalJoint: number;
  13151. /**
  13152. * Hinge-Joint 2 type
  13153. */
  13154. static Hinge2Joint: number;
  13155. /**
  13156. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  13157. */
  13158. static PointToPointJoint: number;
  13159. /**
  13160. * Spring-Joint type
  13161. */
  13162. static SpringJoint: number;
  13163. /**
  13164. * Lock-Joint type
  13165. */
  13166. static LockJoint: number;
  13167. }
  13168. /**
  13169. * A class representing a physics distance joint
  13170. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13171. */
  13172. export class DistanceJoint extends PhysicsJoint {
  13173. /**
  13174. *
  13175. * @param jointData The data for the Distance-Joint
  13176. */
  13177. constructor(jointData: DistanceJointData);
  13178. /**
  13179. * Update the predefined distance.
  13180. * @param maxDistance The maximum preferred distance
  13181. * @param minDistance The minimum preferred distance
  13182. */
  13183. updateDistance(maxDistance: number, minDistance?: number): void;
  13184. }
  13185. /**
  13186. * Represents a Motor-Enabled Joint
  13187. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13188. */
  13189. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  13190. /**
  13191. * Initializes the Motor-Enabled Joint
  13192. * @param type The type of the joint
  13193. * @param jointData The physica joint data for the joint
  13194. */
  13195. constructor(type: number, jointData: PhysicsJointData);
  13196. /**
  13197. * Set the motor values.
  13198. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13199. * @param force the force to apply
  13200. * @param maxForce max force for this motor.
  13201. */
  13202. setMotor(force?: number, maxForce?: number): void;
  13203. /**
  13204. * Set the motor's limits.
  13205. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13206. * @param upperLimit The upper limit of the motor
  13207. * @param lowerLimit The lower limit of the motor
  13208. */
  13209. setLimit(upperLimit: number, lowerLimit?: number): void;
  13210. }
  13211. /**
  13212. * This class represents a single physics Hinge-Joint
  13213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13214. */
  13215. export class HingeJoint extends MotorEnabledJoint {
  13216. /**
  13217. * Initializes the Hinge-Joint
  13218. * @param jointData The joint data for the Hinge-Joint
  13219. */
  13220. constructor(jointData: PhysicsJointData);
  13221. /**
  13222. * Set the motor values.
  13223. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13224. * @param {number} force the force to apply
  13225. * @param {number} maxForce max force for this motor.
  13226. */
  13227. setMotor(force?: number, maxForce?: number): void;
  13228. /**
  13229. * Set the motor's limits.
  13230. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13231. * @param upperLimit The upper limit of the motor
  13232. * @param lowerLimit The lower limit of the motor
  13233. */
  13234. setLimit(upperLimit: number, lowerLimit?: number): void;
  13235. }
  13236. /**
  13237. * This class represents a dual hinge physics joint (same as wheel joint)
  13238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13239. */
  13240. export class Hinge2Joint extends MotorEnabledJoint {
  13241. /**
  13242. * Initializes the Hinge2-Joint
  13243. * @param jointData The joint data for the Hinge2-Joint
  13244. */
  13245. constructor(jointData: PhysicsJointData);
  13246. /**
  13247. * Set the motor values.
  13248. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13249. * @param {number} targetSpeed the speed the motor is to reach
  13250. * @param {number} maxForce max force for this motor.
  13251. * @param {motorIndex} the motor's index, 0 or 1.
  13252. */
  13253. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  13254. /**
  13255. * Set the motor limits.
  13256. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13257. * @param {number} upperLimit the upper limit
  13258. * @param {number} lowerLimit lower limit
  13259. * @param {motorIndex} the motor's index, 0 or 1.
  13260. */
  13261. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13262. }
  13263. /**
  13264. * Interface for a motor enabled joint
  13265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13266. */
  13267. export interface IMotorEnabledJoint {
  13268. /**
  13269. * Physics joint
  13270. */
  13271. physicsJoint: any;
  13272. /**
  13273. * Sets the motor of the motor-enabled joint
  13274. * @param force The force of the motor
  13275. * @param maxForce The maximum force of the motor
  13276. * @param motorIndex The index of the motor
  13277. */
  13278. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  13279. /**
  13280. * Sets the limit of the motor
  13281. * @param upperLimit The upper limit of the motor
  13282. * @param lowerLimit The lower limit of the motor
  13283. * @param motorIndex The index of the motor
  13284. */
  13285. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13286. }
  13287. /**
  13288. * Joint data for a Distance-Joint
  13289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13290. */
  13291. export interface DistanceJointData extends PhysicsJointData {
  13292. /**
  13293. * Max distance the 2 joint objects can be apart
  13294. */
  13295. maxDistance: number;
  13296. }
  13297. /**
  13298. * Joint data from a spring joint
  13299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13300. */
  13301. export interface SpringJointData extends PhysicsJointData {
  13302. /**
  13303. * Length of the spring
  13304. */
  13305. length: number;
  13306. /**
  13307. * Stiffness of the spring
  13308. */
  13309. stiffness: number;
  13310. /**
  13311. * Damping of the spring
  13312. */
  13313. damping: number;
  13314. /** this callback will be called when applying the force to the impostors. */
  13315. forceApplicationCallback: () => void;
  13316. }
  13317. }
  13318. declare module "babylonjs/Physics/physicsRaycastResult" {
  13319. import { Vector3 } from "babylonjs/Maths/math";
  13320. /**
  13321. * Holds the data for the raycast result
  13322. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13323. */
  13324. export class PhysicsRaycastResult {
  13325. private _hasHit;
  13326. private _hitDistance;
  13327. private _hitNormalWorld;
  13328. private _hitPointWorld;
  13329. private _rayFromWorld;
  13330. private _rayToWorld;
  13331. /**
  13332. * Gets if there was a hit
  13333. */
  13334. readonly hasHit: boolean;
  13335. /**
  13336. * Gets the distance from the hit
  13337. */
  13338. readonly hitDistance: number;
  13339. /**
  13340. * Gets the hit normal/direction in the world
  13341. */
  13342. readonly hitNormalWorld: Vector3;
  13343. /**
  13344. * Gets the hit point in the world
  13345. */
  13346. readonly hitPointWorld: Vector3;
  13347. /**
  13348. * Gets the ray "start point" of the ray in the world
  13349. */
  13350. readonly rayFromWorld: Vector3;
  13351. /**
  13352. * Gets the ray "end point" of the ray in the world
  13353. */
  13354. readonly rayToWorld: Vector3;
  13355. /**
  13356. * Sets the hit data (normal & point in world space)
  13357. * @param hitNormalWorld defines the normal in world space
  13358. * @param hitPointWorld defines the point in world space
  13359. */
  13360. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  13361. /**
  13362. * Sets the distance from the start point to the hit point
  13363. * @param distance
  13364. */
  13365. setHitDistance(distance: number): void;
  13366. /**
  13367. * Calculates the distance manually
  13368. */
  13369. calculateHitDistance(): void;
  13370. /**
  13371. * Resets all the values to default
  13372. * @param from The from point on world space
  13373. * @param to The to point on world space
  13374. */
  13375. reset(from?: Vector3, to?: Vector3): void;
  13376. }
  13377. /**
  13378. * Interface for the size containing width and height
  13379. */
  13380. interface IXYZ {
  13381. /**
  13382. * X
  13383. */
  13384. x: number;
  13385. /**
  13386. * Y
  13387. */
  13388. y: number;
  13389. /**
  13390. * Z
  13391. */
  13392. z: number;
  13393. }
  13394. }
  13395. declare module "babylonjs/Physics/IPhysicsEngine" {
  13396. import { Nullable } from "babylonjs/types";
  13397. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  13398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13399. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  13400. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  13401. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  13402. /**
  13403. * Interface used to describe a physics joint
  13404. */
  13405. export interface PhysicsImpostorJoint {
  13406. /** Defines the main impostor to which the joint is linked */
  13407. mainImpostor: PhysicsImpostor;
  13408. /** Defines the impostor that is connected to the main impostor using this joint */
  13409. connectedImpostor: PhysicsImpostor;
  13410. /** Defines the joint itself */
  13411. joint: PhysicsJoint;
  13412. }
  13413. /** @hidden */
  13414. export interface IPhysicsEnginePlugin {
  13415. world: any;
  13416. name: string;
  13417. setGravity(gravity: Vector3): void;
  13418. setTimeStep(timeStep: number): void;
  13419. getTimeStep(): number;
  13420. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13421. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13422. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13423. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13424. removePhysicsBody(impostor: PhysicsImpostor): void;
  13425. generateJoint(joint: PhysicsImpostorJoint): void;
  13426. removeJoint(joint: PhysicsImpostorJoint): void;
  13427. isSupported(): boolean;
  13428. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13429. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13430. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13431. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13432. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13433. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13434. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13435. getBodyMass(impostor: PhysicsImpostor): number;
  13436. getBodyFriction(impostor: PhysicsImpostor): number;
  13437. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  13438. getBodyRestitution(impostor: PhysicsImpostor): number;
  13439. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  13440. getBodyPressure?(impostor: PhysicsImpostor): number;
  13441. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  13442. getBodyStiffness?(impostor: PhysicsImpostor): number;
  13443. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  13444. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  13445. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  13446. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  13447. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  13448. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13449. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13450. sleepBody(impostor: PhysicsImpostor): void;
  13451. wakeUpBody(impostor: PhysicsImpostor): void;
  13452. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13453. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13454. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13455. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13456. getRadius(impostor: PhysicsImpostor): number;
  13457. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13458. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13459. dispose(): void;
  13460. }
  13461. /**
  13462. * Interface used to define a physics engine
  13463. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13464. */
  13465. export interface IPhysicsEngine {
  13466. /**
  13467. * Gets the gravity vector used by the simulation
  13468. */
  13469. gravity: Vector3;
  13470. /**
  13471. * Sets the gravity vector used by the simulation
  13472. * @param gravity defines the gravity vector to use
  13473. */
  13474. setGravity(gravity: Vector3): void;
  13475. /**
  13476. * Set the time step of the physics engine.
  13477. * Default is 1/60.
  13478. * To slow it down, enter 1/600 for example.
  13479. * To speed it up, 1/30
  13480. * @param newTimeStep the new timestep to apply to this world.
  13481. */
  13482. setTimeStep(newTimeStep: number): void;
  13483. /**
  13484. * Get the time step of the physics engine.
  13485. * @returns the current time step
  13486. */
  13487. getTimeStep(): number;
  13488. /**
  13489. * Release all resources
  13490. */
  13491. dispose(): void;
  13492. /**
  13493. * Gets the name of the current physics plugin
  13494. * @returns the name of the plugin
  13495. */
  13496. getPhysicsPluginName(): string;
  13497. /**
  13498. * Adding a new impostor for the impostor tracking.
  13499. * This will be done by the impostor itself.
  13500. * @param impostor the impostor to add
  13501. */
  13502. addImpostor(impostor: PhysicsImpostor): void;
  13503. /**
  13504. * Remove an impostor from the engine.
  13505. * This impostor and its mesh will not longer be updated by the physics engine.
  13506. * @param impostor the impostor to remove
  13507. */
  13508. removeImpostor(impostor: PhysicsImpostor): void;
  13509. /**
  13510. * Add a joint to the physics engine
  13511. * @param mainImpostor defines the main impostor to which the joint is added.
  13512. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13513. * @param joint defines the joint that will connect both impostors.
  13514. */
  13515. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13516. /**
  13517. * Removes a joint from the simulation
  13518. * @param mainImpostor defines the impostor used with the joint
  13519. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13520. * @param joint defines the joint to remove
  13521. */
  13522. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13523. /**
  13524. * Gets the current plugin used to run the simulation
  13525. * @returns current plugin
  13526. */
  13527. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13528. /**
  13529. * Gets the list of physic impostors
  13530. * @returns an array of PhysicsImpostor
  13531. */
  13532. getImpostors(): Array<PhysicsImpostor>;
  13533. /**
  13534. * Gets the impostor for a physics enabled object
  13535. * @param object defines the object impersonated by the impostor
  13536. * @returns the PhysicsImpostor or null if not found
  13537. */
  13538. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13539. /**
  13540. * Gets the impostor for a physics body object
  13541. * @param body defines physics body used by the impostor
  13542. * @returns the PhysicsImpostor or null if not found
  13543. */
  13544. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13545. /**
  13546. * Does a raycast in the physics world
  13547. * @param from when should the ray start?
  13548. * @param to when should the ray end?
  13549. * @returns PhysicsRaycastResult
  13550. */
  13551. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13552. /**
  13553. * Called by the scene. No need to call it.
  13554. * @param delta defines the timespam between frames
  13555. */
  13556. _step(delta: number): void;
  13557. }
  13558. }
  13559. declare module "babylonjs/Physics/physicsImpostor" {
  13560. import { Nullable, IndicesArray } from "babylonjs/types";
  13561. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  13562. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13564. import { Scene } from "babylonjs/scene";
  13565. import { Bone } from "babylonjs/Bones/bone";
  13566. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  13567. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  13568. /**
  13569. * The interface for the physics imposter parameters
  13570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13571. */
  13572. export interface PhysicsImpostorParameters {
  13573. /**
  13574. * The mass of the physics imposter
  13575. */
  13576. mass: number;
  13577. /**
  13578. * The friction of the physics imposter
  13579. */
  13580. friction?: number;
  13581. /**
  13582. * The coefficient of restitution of the physics imposter
  13583. */
  13584. restitution?: number;
  13585. /**
  13586. * The native options of the physics imposter
  13587. */
  13588. nativeOptions?: any;
  13589. /**
  13590. * Specifies if the parent should be ignored
  13591. */
  13592. ignoreParent?: boolean;
  13593. /**
  13594. * Specifies if bi-directional transformations should be disabled
  13595. */
  13596. disableBidirectionalTransformation?: boolean;
  13597. /**
  13598. * The pressure inside the physics imposter, soft object only
  13599. */
  13600. pressure?: number;
  13601. /**
  13602. * The stiffness the physics imposter, soft object only
  13603. */
  13604. stiffness?: number;
  13605. /**
  13606. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13607. */
  13608. velocityIterations?: number;
  13609. /**
  13610. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13611. */
  13612. positionIterations?: number;
  13613. /**
  13614. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13615. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13616. * Add to fix multiple points
  13617. */
  13618. fixedPoints?: number;
  13619. /**
  13620. * The collision margin around a soft object
  13621. */
  13622. margin?: number;
  13623. /**
  13624. * The collision margin around a soft object
  13625. */
  13626. damping?: number;
  13627. /**
  13628. * The path for a rope based on an extrusion
  13629. */
  13630. path?: any;
  13631. /**
  13632. * The shape of an extrusion used for a rope based on an extrusion
  13633. */
  13634. shape?: any;
  13635. }
  13636. /**
  13637. * Interface for a physics-enabled object
  13638. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13639. */
  13640. export interface IPhysicsEnabledObject {
  13641. /**
  13642. * The position of the physics-enabled object
  13643. */
  13644. position: Vector3;
  13645. /**
  13646. * The rotation of the physics-enabled object
  13647. */
  13648. rotationQuaternion: Nullable<Quaternion>;
  13649. /**
  13650. * The scale of the physics-enabled object
  13651. */
  13652. scaling: Vector3;
  13653. /**
  13654. * The rotation of the physics-enabled object
  13655. */
  13656. rotation?: Vector3;
  13657. /**
  13658. * The parent of the physics-enabled object
  13659. */
  13660. parent?: any;
  13661. /**
  13662. * The bounding info of the physics-enabled object
  13663. * @returns The bounding info of the physics-enabled object
  13664. */
  13665. getBoundingInfo(): BoundingInfo;
  13666. /**
  13667. * Computes the world matrix
  13668. * @param force Specifies if the world matrix should be computed by force
  13669. * @returns A world matrix
  13670. */
  13671. computeWorldMatrix(force: boolean): Matrix;
  13672. /**
  13673. * Gets the world matrix
  13674. * @returns A world matrix
  13675. */
  13676. getWorldMatrix?(): Matrix;
  13677. /**
  13678. * Gets the child meshes
  13679. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13680. * @returns An array of abstract meshes
  13681. */
  13682. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13683. /**
  13684. * Gets the vertex data
  13685. * @param kind The type of vertex data
  13686. * @returns A nullable array of numbers, or a float32 array
  13687. */
  13688. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13689. /**
  13690. * Gets the indices from the mesh
  13691. * @returns A nullable array of index arrays
  13692. */
  13693. getIndices?(): Nullable<IndicesArray>;
  13694. /**
  13695. * Gets the scene from the mesh
  13696. * @returns the indices array or null
  13697. */
  13698. getScene?(): Scene;
  13699. /**
  13700. * Gets the absolute position from the mesh
  13701. * @returns the absolute position
  13702. */
  13703. getAbsolutePosition(): Vector3;
  13704. /**
  13705. * Gets the absolute pivot point from the mesh
  13706. * @returns the absolute pivot point
  13707. */
  13708. getAbsolutePivotPoint(): Vector3;
  13709. /**
  13710. * Rotates the mesh
  13711. * @param axis The axis of rotation
  13712. * @param amount The amount of rotation
  13713. * @param space The space of the rotation
  13714. * @returns The rotation transform node
  13715. */
  13716. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13717. /**
  13718. * Translates the mesh
  13719. * @param axis The axis of translation
  13720. * @param distance The distance of translation
  13721. * @param space The space of the translation
  13722. * @returns The transform node
  13723. */
  13724. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13725. /**
  13726. * Sets the absolute position of the mesh
  13727. * @param absolutePosition The absolute position of the mesh
  13728. * @returns The transform node
  13729. */
  13730. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13731. /**
  13732. * Gets the class name of the mesh
  13733. * @returns The class name
  13734. */
  13735. getClassName(): string;
  13736. }
  13737. /**
  13738. * Represents a physics imposter
  13739. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13740. */
  13741. export class PhysicsImpostor {
  13742. /**
  13743. * The physics-enabled object used as the physics imposter
  13744. */
  13745. object: IPhysicsEnabledObject;
  13746. /**
  13747. * The type of the physics imposter
  13748. */
  13749. type: number;
  13750. private _options;
  13751. private _scene?;
  13752. /**
  13753. * The default object size of the imposter
  13754. */
  13755. static DEFAULT_OBJECT_SIZE: Vector3;
  13756. /**
  13757. * The identity quaternion of the imposter
  13758. */
  13759. static IDENTITY_QUATERNION: Quaternion;
  13760. /** @hidden */
  13761. _pluginData: any;
  13762. private _physicsEngine;
  13763. private _physicsBody;
  13764. private _bodyUpdateRequired;
  13765. private _onBeforePhysicsStepCallbacks;
  13766. private _onAfterPhysicsStepCallbacks;
  13767. /** @hidden */
  13768. _onPhysicsCollideCallbacks: Array<{
  13769. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13770. otherImpostors: Array<PhysicsImpostor>;
  13771. }>;
  13772. private _deltaPosition;
  13773. private _deltaRotation;
  13774. private _deltaRotationConjugated;
  13775. /** @hidden */
  13776. _isFromLine: boolean;
  13777. private _parent;
  13778. private _isDisposed;
  13779. private static _tmpVecs;
  13780. private static _tmpQuat;
  13781. /**
  13782. * Specifies if the physics imposter is disposed
  13783. */
  13784. readonly isDisposed: boolean;
  13785. /**
  13786. * Gets the mass of the physics imposter
  13787. */
  13788. mass: number;
  13789. /**
  13790. * Gets the coefficient of friction
  13791. */
  13792. /**
  13793. * Sets the coefficient of friction
  13794. */
  13795. friction: number;
  13796. /**
  13797. * Gets the coefficient of restitution
  13798. */
  13799. /**
  13800. * Sets the coefficient of restitution
  13801. */
  13802. restitution: number;
  13803. /**
  13804. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13805. */
  13806. /**
  13807. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13808. */
  13809. pressure: number;
  13810. /**
  13811. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13812. */
  13813. /**
  13814. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13815. */
  13816. stiffness: number;
  13817. /**
  13818. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13819. */
  13820. /**
  13821. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13822. */
  13823. velocityIterations: number;
  13824. /**
  13825. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13826. */
  13827. /**
  13828. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13829. */
  13830. positionIterations: number;
  13831. /**
  13832. * The unique id of the physics imposter
  13833. * set by the physics engine when adding this impostor to the array
  13834. */
  13835. uniqueId: number;
  13836. /**
  13837. * @hidden
  13838. */
  13839. soft: boolean;
  13840. /**
  13841. * @hidden
  13842. */
  13843. segments: number;
  13844. private _joints;
  13845. /**
  13846. * Initializes the physics imposter
  13847. * @param object The physics-enabled object used as the physics imposter
  13848. * @param type The type of the physics imposter
  13849. * @param _options The options for the physics imposter
  13850. * @param _scene The Babylon scene
  13851. */
  13852. constructor(
  13853. /**
  13854. * The physics-enabled object used as the physics imposter
  13855. */
  13856. object: IPhysicsEnabledObject,
  13857. /**
  13858. * The type of the physics imposter
  13859. */
  13860. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13861. /**
  13862. * This function will completly initialize this impostor.
  13863. * It will create a new body - but only if this mesh has no parent.
  13864. * If it has, this impostor will not be used other than to define the impostor
  13865. * of the child mesh.
  13866. * @hidden
  13867. */
  13868. _init(): void;
  13869. private _getPhysicsParent;
  13870. /**
  13871. * Should a new body be generated.
  13872. * @returns boolean specifying if body initialization is required
  13873. */
  13874. isBodyInitRequired(): boolean;
  13875. /**
  13876. * Sets the updated scaling
  13877. * @param updated Specifies if the scaling is updated
  13878. */
  13879. setScalingUpdated(): void;
  13880. /**
  13881. * Force a regeneration of this or the parent's impostor's body.
  13882. * Use under cautious - This will remove all joints already implemented.
  13883. */
  13884. forceUpdate(): void;
  13885. /**
  13886. * Gets the body that holds this impostor. Either its own, or its parent.
  13887. */
  13888. /**
  13889. * Set the physics body. Used mainly by the physics engine/plugin
  13890. */
  13891. physicsBody: any;
  13892. /**
  13893. * Get the parent of the physics imposter
  13894. * @returns Physics imposter or null
  13895. */
  13896. /**
  13897. * Sets the parent of the physics imposter
  13898. */
  13899. parent: Nullable<PhysicsImpostor>;
  13900. /**
  13901. * Resets the update flags
  13902. */
  13903. resetUpdateFlags(): void;
  13904. /**
  13905. * Gets the object extend size
  13906. * @returns the object extend size
  13907. */
  13908. getObjectExtendSize(): Vector3;
  13909. /**
  13910. * Gets the object center
  13911. * @returns The object center
  13912. */
  13913. getObjectCenter(): Vector3;
  13914. /**
  13915. * Get a specific parametes from the options parameter
  13916. * @param paramName The object parameter name
  13917. * @returns The object parameter
  13918. */
  13919. getParam(paramName: string): any;
  13920. /**
  13921. * Sets a specific parameter in the options given to the physics plugin
  13922. * @param paramName The parameter name
  13923. * @param value The value of the parameter
  13924. */
  13925. setParam(paramName: string, value: number): void;
  13926. /**
  13927. * Specifically change the body's mass option. Won't recreate the physics body object
  13928. * @param mass The mass of the physics imposter
  13929. */
  13930. setMass(mass: number): void;
  13931. /**
  13932. * Gets the linear velocity
  13933. * @returns linear velocity or null
  13934. */
  13935. getLinearVelocity(): Nullable<Vector3>;
  13936. /**
  13937. * Sets the linear velocity
  13938. * @param velocity linear velocity or null
  13939. */
  13940. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13941. /**
  13942. * Gets the angular velocity
  13943. * @returns angular velocity or null
  13944. */
  13945. getAngularVelocity(): Nullable<Vector3>;
  13946. /**
  13947. * Sets the angular velocity
  13948. * @param velocity The velocity or null
  13949. */
  13950. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13951. /**
  13952. * Execute a function with the physics plugin native code
  13953. * Provide a function the will have two variables - the world object and the physics body object
  13954. * @param func The function to execute with the physics plugin native code
  13955. */
  13956. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13957. /**
  13958. * Register a function that will be executed before the physics world is stepping forward
  13959. * @param func The function to execute before the physics world is stepped forward
  13960. */
  13961. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13962. /**
  13963. * Unregister a function that will be executed before the physics world is stepping forward
  13964. * @param func The function to execute before the physics world is stepped forward
  13965. */
  13966. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13967. /**
  13968. * Register a function that will be executed after the physics step
  13969. * @param func The function to execute after physics step
  13970. */
  13971. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13972. /**
  13973. * Unregisters a function that will be executed after the physics step
  13974. * @param func The function to execute after physics step
  13975. */
  13976. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13977. /**
  13978. * register a function that will be executed when this impostor collides against a different body
  13979. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13980. * @param func Callback that is executed on collision
  13981. */
  13982. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13983. /**
  13984. * Unregisters the physics imposter on contact
  13985. * @param collideAgainst The physics object to collide against
  13986. * @param func Callback to execute on collision
  13987. */
  13988. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13989. private _tmpQuat;
  13990. private _tmpQuat2;
  13991. /**
  13992. * Get the parent rotation
  13993. * @returns The parent rotation
  13994. */
  13995. getParentsRotation(): Quaternion;
  13996. /**
  13997. * this function is executed by the physics engine.
  13998. */
  13999. beforeStep: () => void;
  14000. /**
  14001. * this function is executed by the physics engine
  14002. */
  14003. afterStep: () => void;
  14004. /**
  14005. * Legacy collision detection event support
  14006. */
  14007. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  14008. /**
  14009. * event and body object due to cannon's event-based architecture.
  14010. */
  14011. onCollide: (e: {
  14012. body: any;
  14013. }) => void;
  14014. /**
  14015. * Apply a force
  14016. * @param force The force to apply
  14017. * @param contactPoint The contact point for the force
  14018. * @returns The physics imposter
  14019. */
  14020. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  14021. /**
  14022. * Apply an impulse
  14023. * @param force The impulse force
  14024. * @param contactPoint The contact point for the impulse force
  14025. * @returns The physics imposter
  14026. */
  14027. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  14028. /**
  14029. * A help function to create a joint
  14030. * @param otherImpostor A physics imposter used to create a joint
  14031. * @param jointType The type of joint
  14032. * @param jointData The data for the joint
  14033. * @returns The physics imposter
  14034. */
  14035. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  14036. /**
  14037. * Add a joint to this impostor with a different impostor
  14038. * @param otherImpostor A physics imposter used to add a joint
  14039. * @param joint The joint to add
  14040. * @returns The physics imposter
  14041. */
  14042. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  14043. /**
  14044. * Add an anchor to a cloth impostor
  14045. * @param otherImpostor rigid impostor to anchor to
  14046. * @param width ratio across width from 0 to 1
  14047. * @param height ratio up height from 0 to 1
  14048. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  14049. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  14050. * @returns impostor the soft imposter
  14051. */
  14052. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  14053. /**
  14054. * Add a hook to a rope impostor
  14055. * @param otherImpostor rigid impostor to anchor to
  14056. * @param length ratio across rope from 0 to 1
  14057. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  14058. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  14059. * @returns impostor the rope imposter
  14060. */
  14061. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  14062. /**
  14063. * Will keep this body still, in a sleep mode.
  14064. * @returns the physics imposter
  14065. */
  14066. sleep(): PhysicsImpostor;
  14067. /**
  14068. * Wake the body up.
  14069. * @returns The physics imposter
  14070. */
  14071. wakeUp(): PhysicsImpostor;
  14072. /**
  14073. * Clones the physics imposter
  14074. * @param newObject The physics imposter clones to this physics-enabled object
  14075. * @returns A nullable physics imposter
  14076. */
  14077. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  14078. /**
  14079. * Disposes the physics imposter
  14080. */
  14081. dispose(): void;
  14082. /**
  14083. * Sets the delta position
  14084. * @param position The delta position amount
  14085. */
  14086. setDeltaPosition(position: Vector3): void;
  14087. /**
  14088. * Sets the delta rotation
  14089. * @param rotation The delta rotation amount
  14090. */
  14091. setDeltaRotation(rotation: Quaternion): void;
  14092. /**
  14093. * Gets the box size of the physics imposter and stores the result in the input parameter
  14094. * @param result Stores the box size
  14095. * @returns The physics imposter
  14096. */
  14097. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  14098. /**
  14099. * Gets the radius of the physics imposter
  14100. * @returns Radius of the physics imposter
  14101. */
  14102. getRadius(): number;
  14103. /**
  14104. * Sync a bone with this impostor
  14105. * @param bone The bone to sync to the impostor.
  14106. * @param boneMesh The mesh that the bone is influencing.
  14107. * @param jointPivot The pivot of the joint / bone in local space.
  14108. * @param distToJoint Optional distance from the impostor to the joint.
  14109. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14110. */
  14111. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  14112. /**
  14113. * Sync impostor to a bone
  14114. * @param bone The bone that the impostor will be synced to.
  14115. * @param boneMesh The mesh that the bone is influencing.
  14116. * @param jointPivot The pivot of the joint / bone in local space.
  14117. * @param distToJoint Optional distance from the impostor to the joint.
  14118. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14119. * @param boneAxis Optional vector3 axis the bone is aligned with
  14120. */
  14121. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  14122. /**
  14123. * No-Imposter type
  14124. */
  14125. static NoImpostor: number;
  14126. /**
  14127. * Sphere-Imposter type
  14128. */
  14129. static SphereImpostor: number;
  14130. /**
  14131. * Box-Imposter type
  14132. */
  14133. static BoxImpostor: number;
  14134. /**
  14135. * Plane-Imposter type
  14136. */
  14137. static PlaneImpostor: number;
  14138. /**
  14139. * Mesh-imposter type
  14140. */
  14141. static MeshImpostor: number;
  14142. /**
  14143. * Capsule-Impostor type (Ammo.js plugin only)
  14144. */
  14145. static CapsuleImpostor: number;
  14146. /**
  14147. * Cylinder-Imposter type
  14148. */
  14149. static CylinderImpostor: number;
  14150. /**
  14151. * Particle-Imposter type
  14152. */
  14153. static ParticleImpostor: number;
  14154. /**
  14155. * Heightmap-Imposter type
  14156. */
  14157. static HeightmapImpostor: number;
  14158. /**
  14159. * ConvexHull-Impostor type (Ammo.js plugin only)
  14160. */
  14161. static ConvexHullImpostor: number;
  14162. /**
  14163. * Rope-Imposter type
  14164. */
  14165. static RopeImpostor: number;
  14166. /**
  14167. * Cloth-Imposter type
  14168. */
  14169. static ClothImpostor: number;
  14170. /**
  14171. * Softbody-Imposter type
  14172. */
  14173. static SoftbodyImpostor: number;
  14174. }
  14175. }
  14176. declare module "babylonjs/Meshes/mesh" {
  14177. import { Observable } from "babylonjs/Misc/observable";
  14178. import { IAnimatable } from "babylonjs/Misc/tools";
  14179. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  14180. import { Camera } from "babylonjs/Cameras/camera";
  14181. import { Scene } from "babylonjs/scene";
  14182. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  14183. import { Engine } from "babylonjs/Engines/engine";
  14184. import { Node } from "babylonjs/node";
  14185. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  14186. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  14187. import { Buffer } from "babylonjs/Meshes/buffer";
  14188. import { Geometry } from "babylonjs/Meshes/geometry";
  14189. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14190. import { SubMesh } from "babylonjs/Meshes/subMesh";
  14191. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  14192. import { Effect } from "babylonjs/Materials/effect";
  14193. import { Material } from "babylonjs/Materials/material";
  14194. import { Skeleton } from "babylonjs/Bones/skeleton";
  14195. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  14196. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  14197. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  14198. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  14199. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  14200. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  14201. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  14202. /**
  14203. * @hidden
  14204. **/
  14205. export class _CreationDataStorage {
  14206. closePath?: boolean;
  14207. closeArray?: boolean;
  14208. idx: number[];
  14209. dashSize: number;
  14210. gapSize: number;
  14211. path3D: Path3D;
  14212. pathArray: Vector3[][];
  14213. arc: number;
  14214. radius: number;
  14215. cap: number;
  14216. tessellation: number;
  14217. }
  14218. /**
  14219. * @hidden
  14220. **/
  14221. class _InstanceDataStorage {
  14222. visibleInstances: any;
  14223. batchCache: _InstancesBatch;
  14224. instancesBufferSize: number;
  14225. instancesBuffer: Nullable<Buffer>;
  14226. instancesData: Float32Array;
  14227. overridenInstanceCount: number;
  14228. isFrozen: boolean;
  14229. previousBatch: Nullable<_InstancesBatch>;
  14230. hardwareInstancedRendering: boolean;
  14231. sideOrientation: number;
  14232. }
  14233. /**
  14234. * @hidden
  14235. **/
  14236. export class _InstancesBatch {
  14237. mustReturn: boolean;
  14238. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  14239. renderSelf: boolean[];
  14240. hardwareInstancedRendering: boolean[];
  14241. }
  14242. /**
  14243. * Class used to represent renderable models
  14244. */
  14245. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  14246. /**
  14247. * Mesh side orientation : usually the external or front surface
  14248. */
  14249. static readonly FRONTSIDE: number;
  14250. /**
  14251. * Mesh side orientation : usually the internal or back surface
  14252. */
  14253. static readonly BACKSIDE: number;
  14254. /**
  14255. * Mesh side orientation : both internal and external or front and back surfaces
  14256. */
  14257. static readonly DOUBLESIDE: number;
  14258. /**
  14259. * Mesh side orientation : by default, `FRONTSIDE`
  14260. */
  14261. static readonly DEFAULTSIDE: number;
  14262. /**
  14263. * Mesh cap setting : no cap
  14264. */
  14265. static readonly NO_CAP: number;
  14266. /**
  14267. * Mesh cap setting : one cap at the beginning of the mesh
  14268. */
  14269. static readonly CAP_START: number;
  14270. /**
  14271. * Mesh cap setting : one cap at the end of the mesh
  14272. */
  14273. static readonly CAP_END: number;
  14274. /**
  14275. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  14276. */
  14277. static readonly CAP_ALL: number;
  14278. /**
  14279. * Mesh pattern setting : no flip or rotate
  14280. */
  14281. static readonly NO_FLIP: number;
  14282. /**
  14283. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  14284. */
  14285. static readonly FLIP_TILE: number;
  14286. /**
  14287. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  14288. */
  14289. static readonly ROTATE_TILE: number;
  14290. /**
  14291. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  14292. */
  14293. static readonly FLIP_ROW: number;
  14294. /**
  14295. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  14296. */
  14297. static readonly ROTATE_ROW: number;
  14298. /**
  14299. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  14300. */
  14301. static readonly FLIP_N_ROTATE_TILE: number;
  14302. /**
  14303. * Mesh pattern setting : rotate pattern and rotate
  14304. */
  14305. static readonly FLIP_N_ROTATE_ROW: number;
  14306. /**
  14307. * Mesh tile positioning : part tiles same on left/right or top/bottom
  14308. */
  14309. static readonly CENTER: number;
  14310. /**
  14311. * Mesh tile positioning : part tiles on left
  14312. */
  14313. static readonly LEFT: number;
  14314. /**
  14315. * Mesh tile positioning : part tiles on right
  14316. */
  14317. static readonly RIGHT: number;
  14318. /**
  14319. * Mesh tile positioning : part tiles on top
  14320. */
  14321. static readonly TOP: number;
  14322. /**
  14323. * Mesh tile positioning : part tiles on bottom
  14324. */
  14325. static readonly BOTTOM: number;
  14326. /**
  14327. * Gets the default side orientation.
  14328. * @param orientation the orientation to value to attempt to get
  14329. * @returns the default orientation
  14330. * @hidden
  14331. */
  14332. static _GetDefaultSideOrientation(orientation?: number): number;
  14333. private _internalMeshDataInfo;
  14334. /**
  14335. * An event triggered before rendering the mesh
  14336. */
  14337. readonly onBeforeRenderObservable: Observable<Mesh>;
  14338. /**
  14339. * An event triggered before binding the mesh
  14340. */
  14341. readonly onBeforeBindObservable: Observable<Mesh>;
  14342. /**
  14343. * An event triggered after rendering the mesh
  14344. */
  14345. readonly onAfterRenderObservable: Observable<Mesh>;
  14346. /**
  14347. * An event triggered before drawing the mesh
  14348. */
  14349. readonly onBeforeDrawObservable: Observable<Mesh>;
  14350. private _onBeforeDrawObserver;
  14351. /**
  14352. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  14353. */
  14354. onBeforeDraw: () => void;
  14355. /**
  14356. * Gets the delay loading state of the mesh (when delay loading is turned on)
  14357. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  14358. */
  14359. delayLoadState: number;
  14360. /**
  14361. * Gets the list of instances created from this mesh
  14362. * it is not supposed to be modified manually.
  14363. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  14364. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14365. */
  14366. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  14367. /**
  14368. * Gets the file containing delay loading data for this mesh
  14369. */
  14370. delayLoadingFile: string;
  14371. /** @hidden */
  14372. _binaryInfo: any;
  14373. /**
  14374. * User defined function used to change how LOD level selection is done
  14375. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  14376. */
  14377. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  14378. /**
  14379. * Gets or sets the morph target manager
  14380. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  14381. */
  14382. morphTargetManager: Nullable<MorphTargetManager>;
  14383. /** @hidden */
  14384. _creationDataStorage: Nullable<_CreationDataStorage>;
  14385. /** @hidden */
  14386. _geometry: Nullable<Geometry>;
  14387. /** @hidden */
  14388. _delayInfo: Array<string>;
  14389. /** @hidden */
  14390. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  14391. /** @hidden */
  14392. _instanceDataStorage: _InstanceDataStorage;
  14393. private _effectiveMaterial;
  14394. /** @hidden */
  14395. _shouldGenerateFlatShading: boolean;
  14396. /** @hidden */
  14397. _originalBuilderSideOrientation: number;
  14398. /**
  14399. * Use this property to change the original side orientation defined at construction time
  14400. */
  14401. overrideMaterialSideOrientation: Nullable<number>;
  14402. /**
  14403. * Gets the source mesh (the one used to clone this one from)
  14404. */
  14405. readonly source: Nullable<Mesh>;
  14406. /**
  14407. * Gets or sets a boolean indicating that this mesh does not use index buffer
  14408. */
  14409. isUnIndexed: boolean;
  14410. /**
  14411. * @constructor
  14412. * @param name The value used by scene.getMeshByName() to do a lookup.
  14413. * @param scene The scene to add this mesh to.
  14414. * @param parent The parent of this mesh, if it has one
  14415. * @param source An optional Mesh from which geometry is shared, cloned.
  14416. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  14417. * When false, achieved by calling a clone(), also passing False.
  14418. * This will make creation of children, recursive.
  14419. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  14420. */
  14421. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  14422. /**
  14423. * Gets the class name
  14424. * @returns the string "Mesh".
  14425. */
  14426. getClassName(): string;
  14427. /** @hidden */
  14428. readonly _isMesh: boolean;
  14429. /**
  14430. * Returns a description of this mesh
  14431. * @param fullDetails define if full details about this mesh must be used
  14432. * @returns a descriptive string representing this mesh
  14433. */
  14434. toString(fullDetails?: boolean): string;
  14435. /** @hidden */
  14436. _unBindEffect(): void;
  14437. /**
  14438. * Gets a boolean indicating if this mesh has LOD
  14439. */
  14440. readonly hasLODLevels: boolean;
  14441. /**
  14442. * Gets the list of MeshLODLevel associated with the current mesh
  14443. * @returns an array of MeshLODLevel
  14444. */
  14445. getLODLevels(): MeshLODLevel[];
  14446. private _sortLODLevels;
  14447. /**
  14448. * Add a mesh as LOD level triggered at the given distance.
  14449. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14450. * @param distance The distance from the center of the object to show this level
  14451. * @param mesh The mesh to be added as LOD level (can be null)
  14452. * @return This mesh (for chaining)
  14453. */
  14454. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  14455. /**
  14456. * Returns the LOD level mesh at the passed distance or null if not found.
  14457. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14458. * @param distance The distance from the center of the object to show this level
  14459. * @returns a Mesh or `null`
  14460. */
  14461. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  14462. /**
  14463. * Remove a mesh from the LOD array
  14464. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14465. * @param mesh defines the mesh to be removed
  14466. * @return This mesh (for chaining)
  14467. */
  14468. removeLODLevel(mesh: Mesh): Mesh;
  14469. /**
  14470. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  14471. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14472. * @param camera defines the camera to use to compute distance
  14473. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  14474. * @return This mesh (for chaining)
  14475. */
  14476. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  14477. /**
  14478. * Gets the mesh internal Geometry object
  14479. */
  14480. readonly geometry: Nullable<Geometry>;
  14481. /**
  14482. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14483. * @returns the total number of vertices
  14484. */
  14485. getTotalVertices(): number;
  14486. /**
  14487. * Returns the content of an associated vertex buffer
  14488. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14489. * - VertexBuffer.PositionKind
  14490. * - VertexBuffer.UVKind
  14491. * - VertexBuffer.UV2Kind
  14492. * - VertexBuffer.UV3Kind
  14493. * - VertexBuffer.UV4Kind
  14494. * - VertexBuffer.UV5Kind
  14495. * - VertexBuffer.UV6Kind
  14496. * - VertexBuffer.ColorKind
  14497. * - VertexBuffer.MatricesIndicesKind
  14498. * - VertexBuffer.MatricesIndicesExtraKind
  14499. * - VertexBuffer.MatricesWeightsKind
  14500. * - VertexBuffer.MatricesWeightsExtraKind
  14501. * @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
  14502. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14503. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14504. */
  14505. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14506. /**
  14507. * Returns the mesh VertexBuffer object from the requested `kind`
  14508. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14509. * - VertexBuffer.PositionKind
  14510. * - VertexBuffer.NormalKind
  14511. * - VertexBuffer.UVKind
  14512. * - VertexBuffer.UV2Kind
  14513. * - VertexBuffer.UV3Kind
  14514. * - VertexBuffer.UV4Kind
  14515. * - VertexBuffer.UV5Kind
  14516. * - VertexBuffer.UV6Kind
  14517. * - VertexBuffer.ColorKind
  14518. * - VertexBuffer.MatricesIndicesKind
  14519. * - VertexBuffer.MatricesIndicesExtraKind
  14520. * - VertexBuffer.MatricesWeightsKind
  14521. * - VertexBuffer.MatricesWeightsExtraKind
  14522. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14523. */
  14524. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14525. /**
  14526. * Tests if a specific vertex buffer is associated with this mesh
  14527. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14528. * - VertexBuffer.PositionKind
  14529. * - VertexBuffer.NormalKind
  14530. * - VertexBuffer.UVKind
  14531. * - VertexBuffer.UV2Kind
  14532. * - VertexBuffer.UV3Kind
  14533. * - VertexBuffer.UV4Kind
  14534. * - VertexBuffer.UV5Kind
  14535. * - VertexBuffer.UV6Kind
  14536. * - VertexBuffer.ColorKind
  14537. * - VertexBuffer.MatricesIndicesKind
  14538. * - VertexBuffer.MatricesIndicesExtraKind
  14539. * - VertexBuffer.MatricesWeightsKind
  14540. * - VertexBuffer.MatricesWeightsExtraKind
  14541. * @returns a boolean
  14542. */
  14543. isVerticesDataPresent(kind: string): boolean;
  14544. /**
  14545. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14546. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14547. * - VertexBuffer.PositionKind
  14548. * - VertexBuffer.UVKind
  14549. * - VertexBuffer.UV2Kind
  14550. * - VertexBuffer.UV3Kind
  14551. * - VertexBuffer.UV4Kind
  14552. * - VertexBuffer.UV5Kind
  14553. * - VertexBuffer.UV6Kind
  14554. * - VertexBuffer.ColorKind
  14555. * - VertexBuffer.MatricesIndicesKind
  14556. * - VertexBuffer.MatricesIndicesExtraKind
  14557. * - VertexBuffer.MatricesWeightsKind
  14558. * - VertexBuffer.MatricesWeightsExtraKind
  14559. * @returns a boolean
  14560. */
  14561. isVertexBufferUpdatable(kind: string): boolean;
  14562. /**
  14563. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14564. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14565. * - VertexBuffer.PositionKind
  14566. * - VertexBuffer.NormalKind
  14567. * - VertexBuffer.UVKind
  14568. * - VertexBuffer.UV2Kind
  14569. * - VertexBuffer.UV3Kind
  14570. * - VertexBuffer.UV4Kind
  14571. * - VertexBuffer.UV5Kind
  14572. * - VertexBuffer.UV6Kind
  14573. * - VertexBuffer.ColorKind
  14574. * - VertexBuffer.MatricesIndicesKind
  14575. * - VertexBuffer.MatricesIndicesExtraKind
  14576. * - VertexBuffer.MatricesWeightsKind
  14577. * - VertexBuffer.MatricesWeightsExtraKind
  14578. * @returns an array of strings
  14579. */
  14580. getVerticesDataKinds(): string[];
  14581. /**
  14582. * Returns a positive integer : the total number of indices in this mesh geometry.
  14583. * @returns the numner of indices or zero if the mesh has no geometry.
  14584. */
  14585. getTotalIndices(): number;
  14586. /**
  14587. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14588. * @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.
  14589. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14590. * @returns the indices array or an empty array if the mesh has no geometry
  14591. */
  14592. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14593. readonly isBlocked: boolean;
  14594. /**
  14595. * Determine if the current mesh is ready to be rendered
  14596. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14597. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14598. * @returns true if all associated assets are ready (material, textures, shaders)
  14599. */
  14600. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14601. /**
  14602. * 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.
  14603. */
  14604. readonly areNormalsFrozen: boolean;
  14605. /**
  14606. * 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.
  14607. * @returns the current mesh
  14608. */
  14609. freezeNormals(): Mesh;
  14610. /**
  14611. * 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
  14612. * @returns the current mesh
  14613. */
  14614. unfreezeNormals(): Mesh;
  14615. /**
  14616. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14617. */
  14618. overridenInstanceCount: number;
  14619. /** @hidden */
  14620. _preActivate(): Mesh;
  14621. /** @hidden */
  14622. _preActivateForIntermediateRendering(renderId: number): Mesh;
  14623. /** @hidden */
  14624. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14625. /**
  14626. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14627. * This means the mesh underlying bounding box and sphere are recomputed.
  14628. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14629. * @returns the current mesh
  14630. */
  14631. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14632. /** @hidden */
  14633. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14634. /**
  14635. * This function will subdivide the mesh into multiple submeshes
  14636. * @param count defines the expected number of submeshes
  14637. */
  14638. subdivide(count: number): void;
  14639. /**
  14640. * Copy a FloatArray into a specific associated vertex buffer
  14641. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14642. * - VertexBuffer.PositionKind
  14643. * - VertexBuffer.UVKind
  14644. * - VertexBuffer.UV2Kind
  14645. * - VertexBuffer.UV3Kind
  14646. * - VertexBuffer.UV4Kind
  14647. * - VertexBuffer.UV5Kind
  14648. * - VertexBuffer.UV6Kind
  14649. * - VertexBuffer.ColorKind
  14650. * - VertexBuffer.MatricesIndicesKind
  14651. * - VertexBuffer.MatricesIndicesExtraKind
  14652. * - VertexBuffer.MatricesWeightsKind
  14653. * - VertexBuffer.MatricesWeightsExtraKind
  14654. * @param data defines the data source
  14655. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14656. * @param stride defines the data stride size (can be null)
  14657. * @returns the current mesh
  14658. */
  14659. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14660. /**
  14661. * Flags an associated vertex buffer as updatable
  14662. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14663. * - VertexBuffer.PositionKind
  14664. * - VertexBuffer.UVKind
  14665. * - VertexBuffer.UV2Kind
  14666. * - VertexBuffer.UV3Kind
  14667. * - VertexBuffer.UV4Kind
  14668. * - VertexBuffer.UV5Kind
  14669. * - VertexBuffer.UV6Kind
  14670. * - VertexBuffer.ColorKind
  14671. * - VertexBuffer.MatricesIndicesKind
  14672. * - VertexBuffer.MatricesIndicesExtraKind
  14673. * - VertexBuffer.MatricesWeightsKind
  14674. * - VertexBuffer.MatricesWeightsExtraKind
  14675. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14676. */
  14677. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14678. /**
  14679. * Sets the mesh global Vertex Buffer
  14680. * @param buffer defines the buffer to use
  14681. * @returns the current mesh
  14682. */
  14683. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14684. /**
  14685. * Update a specific associated vertex buffer
  14686. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14687. * - VertexBuffer.PositionKind
  14688. * - VertexBuffer.UVKind
  14689. * - VertexBuffer.UV2Kind
  14690. * - VertexBuffer.UV3Kind
  14691. * - VertexBuffer.UV4Kind
  14692. * - VertexBuffer.UV5Kind
  14693. * - VertexBuffer.UV6Kind
  14694. * - VertexBuffer.ColorKind
  14695. * - VertexBuffer.MatricesIndicesKind
  14696. * - VertexBuffer.MatricesIndicesExtraKind
  14697. * - VertexBuffer.MatricesWeightsKind
  14698. * - VertexBuffer.MatricesWeightsExtraKind
  14699. * @param data defines the data source
  14700. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14701. * @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)
  14702. * @returns the current mesh
  14703. */
  14704. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14705. /**
  14706. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14707. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14708. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14709. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14710. * @returns the current mesh
  14711. */
  14712. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14713. /**
  14714. * Creates a un-shared specific occurence of the geometry for the mesh.
  14715. * @returns the current mesh
  14716. */
  14717. makeGeometryUnique(): Mesh;
  14718. /**
  14719. * Set the index buffer of this mesh
  14720. * @param indices defines the source data
  14721. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14722. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14723. * @returns the current mesh
  14724. */
  14725. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14726. /**
  14727. * Update the current index buffer
  14728. * @param indices defines the source data
  14729. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14730. * @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)
  14731. * @returns the current mesh
  14732. */
  14733. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14734. /**
  14735. * Invert the geometry to move from a right handed system to a left handed one.
  14736. * @returns the current mesh
  14737. */
  14738. toLeftHanded(): Mesh;
  14739. /** @hidden */
  14740. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14741. /** @hidden */
  14742. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14743. /**
  14744. * Registers for this mesh a javascript function called just before the rendering process
  14745. * @param func defines the function to call before rendering this mesh
  14746. * @returns the current mesh
  14747. */
  14748. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14749. /**
  14750. * Disposes a previously registered javascript function called before the rendering
  14751. * @param func defines the function to remove
  14752. * @returns the current mesh
  14753. */
  14754. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14755. /**
  14756. * Registers for this mesh a javascript function called just after the rendering is complete
  14757. * @param func defines the function to call after rendering this mesh
  14758. * @returns the current mesh
  14759. */
  14760. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14761. /**
  14762. * Disposes a previously registered javascript function called after the rendering.
  14763. * @param func defines the function to remove
  14764. * @returns the current mesh
  14765. */
  14766. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14767. /** @hidden */
  14768. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14769. /** @hidden */
  14770. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14771. /** @hidden */
  14772. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14773. /** @hidden */
  14774. _rebuild(): void;
  14775. /** @hidden */
  14776. _freeze(): void;
  14777. /** @hidden */
  14778. _unFreeze(): void;
  14779. /**
  14780. * 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
  14781. * @param subMesh defines the subMesh to render
  14782. * @param enableAlphaMode defines if alpha mode can be changed
  14783. * @returns the current mesh
  14784. */
  14785. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14786. private _onBeforeDraw;
  14787. /**
  14788. * Renormalize the mesh and patch it up if there are no weights
  14789. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14790. * However in the case of zero weights then we set just a single influence to 1.
  14791. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14792. */
  14793. cleanMatrixWeights(): void;
  14794. private normalizeSkinFourWeights;
  14795. private normalizeSkinWeightsAndExtra;
  14796. /**
  14797. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14798. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14799. * the user know there was an issue with importing the mesh
  14800. * @returns a validation object with skinned, valid and report string
  14801. */
  14802. validateSkinning(): {
  14803. skinned: boolean;
  14804. valid: boolean;
  14805. report: string;
  14806. };
  14807. /** @hidden */
  14808. _checkDelayState(): Mesh;
  14809. private _queueLoad;
  14810. /**
  14811. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14812. * A mesh is in the frustum if its bounding box intersects the frustum
  14813. * @param frustumPlanes defines the frustum to test
  14814. * @returns true if the mesh is in the frustum planes
  14815. */
  14816. isInFrustum(frustumPlanes: Plane[]): boolean;
  14817. /**
  14818. * Sets the mesh material by the material or multiMaterial `id` property
  14819. * @param id is a string identifying the material or the multiMaterial
  14820. * @returns the current mesh
  14821. */
  14822. setMaterialByID(id: string): Mesh;
  14823. /**
  14824. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14825. * @returns an array of IAnimatable
  14826. */
  14827. getAnimatables(): IAnimatable[];
  14828. /**
  14829. * Modifies the mesh geometry according to the passed transformation matrix.
  14830. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14831. * The mesh normals are modified using the same transformation.
  14832. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14833. * @param transform defines the transform matrix to use
  14834. * @see http://doc.babylonjs.com/resources/baking_transformations
  14835. * @returns the current mesh
  14836. */
  14837. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14838. /**
  14839. * Modifies the mesh geometry according to its own current World Matrix.
  14840. * The mesh World Matrix is then reset.
  14841. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14842. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14843. * @see http://doc.babylonjs.com/resources/baking_transformations
  14844. * @returns the current mesh
  14845. */
  14846. bakeCurrentTransformIntoVertices(): Mesh;
  14847. /** @hidden */
  14848. readonly _positions: Nullable<Vector3[]>;
  14849. /** @hidden */
  14850. _resetPointsArrayCache(): Mesh;
  14851. /** @hidden */
  14852. _generatePointsArray(): boolean;
  14853. /**
  14854. * Returns a new Mesh object generated from the current mesh properties.
  14855. * This method must not get confused with createInstance()
  14856. * @param name is a string, the name given to the new mesh
  14857. * @param newParent can be any Node object (default `null`)
  14858. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14859. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14860. * @returns a new mesh
  14861. */
  14862. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14863. /**
  14864. * Releases resources associated with this mesh.
  14865. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14866. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14867. */
  14868. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14869. /**
  14870. * Modifies the mesh geometry according to a displacement map.
  14871. * 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.
  14872. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14873. * @param url is a string, the URL from the image file is to be downloaded.
  14874. * @param minHeight is the lower limit of the displacement.
  14875. * @param maxHeight is the upper limit of the displacement.
  14876. * @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.
  14877. * @param uvOffset is an optional vector2 used to offset UV.
  14878. * @param uvScale is an optional vector2 used to scale UV.
  14879. * @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.
  14880. * @returns the Mesh.
  14881. */
  14882. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14883. /**
  14884. * Modifies the mesh geometry according to a displacementMap buffer.
  14885. * 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.
  14886. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14887. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14888. * @param heightMapWidth is the width of the buffer image.
  14889. * @param heightMapHeight is the height of the buffer image.
  14890. * @param minHeight is the lower limit of the displacement.
  14891. * @param maxHeight is the upper limit of the displacement.
  14892. * @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.
  14893. * @param uvOffset is an optional vector2 used to offset UV.
  14894. * @param uvScale is an optional vector2 used to scale UV.
  14895. * @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.
  14896. * @returns the Mesh.
  14897. */
  14898. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14899. /**
  14900. * Modify the mesh to get a flat shading rendering.
  14901. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14902. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14903. * @returns current mesh
  14904. */
  14905. convertToFlatShadedMesh(): Mesh;
  14906. /**
  14907. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14908. * In other words, more vertices, no more indices and a single bigger VBO.
  14909. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14910. * @returns current mesh
  14911. */
  14912. convertToUnIndexedMesh(): Mesh;
  14913. /**
  14914. * Inverses facet orientations.
  14915. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14916. * @param flipNormals will also inverts the normals
  14917. * @returns current mesh
  14918. */
  14919. flipFaces(flipNormals?: boolean): Mesh;
  14920. /**
  14921. * Increase the number of facets and hence vertices in a mesh
  14922. * Vertex normals are interpolated from existing vertex normals
  14923. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14924. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14925. */
  14926. increaseVertices(numberPerEdge: number): void;
  14927. /**
  14928. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14929. * This will undo any application of covertToFlatShadedMesh
  14930. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14931. */
  14932. forceSharedVertices(): void;
  14933. /** @hidden */
  14934. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14935. /** @hidden */
  14936. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14937. /**
  14938. * Creates a new InstancedMesh object from the mesh model.
  14939. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14940. * @param name defines the name of the new instance
  14941. * @returns a new InstancedMesh
  14942. */
  14943. createInstance(name: string): InstancedMesh;
  14944. /**
  14945. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14946. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14947. * @returns the current mesh
  14948. */
  14949. synchronizeInstances(): Mesh;
  14950. /**
  14951. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14952. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14953. * This should be used together with the simplification to avoid disappearing triangles.
  14954. * @param successCallback an optional success callback to be called after the optimization finished.
  14955. * @returns the current mesh
  14956. */
  14957. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14958. /**
  14959. * Serialize current mesh
  14960. * @param serializationObject defines the object which will receive the serialization data
  14961. */
  14962. serialize(serializationObject: any): void;
  14963. /** @hidden */
  14964. _syncGeometryWithMorphTargetManager(): void;
  14965. /** @hidden */
  14966. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14967. /**
  14968. * Returns a new Mesh object parsed from the source provided.
  14969. * @param parsedMesh is the source
  14970. * @param scene defines the hosting scene
  14971. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14972. * @returns a new Mesh
  14973. */
  14974. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14975. /**
  14976. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14977. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14978. * @param name defines the name of the mesh to create
  14979. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14980. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14981. * @param closePath creates a seam between the first and the last points of each path of the path array
  14982. * @param offset is taken in account only if the `pathArray` is containing a single path
  14983. * @param scene defines the hosting scene
  14984. * @param updatable defines if the mesh must be flagged as updatable
  14985. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14986. * @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)
  14987. * @returns a new Mesh
  14988. */
  14989. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14990. /**
  14991. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14992. * @param name defines the name of the mesh to create
  14993. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14994. * @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
  14995. * @param scene defines the hosting scene
  14996. * @param updatable defines if the mesh must be flagged as updatable
  14997. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14998. * @returns a new Mesh
  14999. */
  15000. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  15001. /**
  15002. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  15003. * @param name defines the name of the mesh to create
  15004. * @param size sets the size (float) of each box side (default 1)
  15005. * @param scene defines the hosting scene
  15006. * @param updatable defines if the mesh must be flagged as updatable
  15007. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15008. * @returns a new Mesh
  15009. */
  15010. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  15011. /**
  15012. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  15013. * @param name defines the name of the mesh to create
  15014. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  15015. * @param diameter sets the diameter size (float) of the sphere (default 1)
  15016. * @param scene defines the hosting scene
  15017. * @param updatable defines if the mesh must be flagged as updatable
  15018. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15019. * @returns a new Mesh
  15020. */
  15021. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15022. /**
  15023. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  15024. * @param name defines the name of the mesh to create
  15025. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  15026. * @param diameter sets the diameter size (float) of the sphere (default 1)
  15027. * @param scene defines the hosting scene
  15028. * @returns a new Mesh
  15029. */
  15030. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  15031. /**
  15032. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  15033. * @param name defines the name of the mesh to create
  15034. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  15035. * @param diameterTop set the top cap diameter (floats, default 1)
  15036. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  15037. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  15038. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  15039. * @param scene defines the hosting scene
  15040. * @param updatable defines if the mesh must be flagged as updatable
  15041. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15042. * @returns a new Mesh
  15043. */
  15044. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  15045. /**
  15046. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  15047. * @param name defines the name of the mesh to create
  15048. * @param diameter sets the diameter size (float) of the torus (default 1)
  15049. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  15050. * @param tessellation sets the number of torus sides (postive integer, default 16)
  15051. * @param scene defines the hosting scene
  15052. * @param updatable defines if the mesh must be flagged as updatable
  15053. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15054. * @returns a new Mesh
  15055. */
  15056. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15057. /**
  15058. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  15059. * @param name defines the name of the mesh to create
  15060. * @param radius sets the global radius size (float) of the torus knot (default 2)
  15061. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  15062. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  15063. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  15064. * @param p the number of windings on X axis (positive integers, default 2)
  15065. * @param q the number of windings on Y axis (positive integers, default 3)
  15066. * @param scene defines the hosting scene
  15067. * @param updatable defines if the mesh must be flagged as updatable
  15068. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15069. * @returns a new Mesh
  15070. */
  15071. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15072. /**
  15073. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  15074. * @param name defines the name of the mesh to create
  15075. * @param points is an array successive Vector3
  15076. * @param scene defines the hosting scene
  15077. * @param updatable defines if the mesh must be flagged as updatable
  15078. * @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).
  15079. * @returns a new Mesh
  15080. */
  15081. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  15082. /**
  15083. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  15084. * @param name defines the name of the mesh to create
  15085. * @param points is an array successive Vector3
  15086. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  15087. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  15088. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  15089. * @param scene defines the hosting scene
  15090. * @param updatable defines if the mesh must be flagged as updatable
  15091. * @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)
  15092. * @returns a new Mesh
  15093. */
  15094. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  15095. /**
  15096. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  15097. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  15098. * 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.
  15099. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15100. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15101. * Remember you can only change the shape positions, not their number when updating a polygon.
  15102. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  15103. * @param name defines the name of the mesh to create
  15104. * @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
  15105. * @param scene defines the hosting scene
  15106. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  15107. * @param updatable defines if the mesh must be flagged as updatable
  15108. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15109. * @param earcutInjection can be used to inject your own earcut reference
  15110. * @returns a new Mesh
  15111. */
  15112. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15113. /**
  15114. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  15115. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  15116. * @param name defines the name of the mesh to create
  15117. * @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
  15118. * @param depth defines the height of extrusion
  15119. * @param scene defines the hosting scene
  15120. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  15121. * @param updatable defines if the mesh must be flagged as updatable
  15122. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15123. * @param earcutInjection can be used to inject your own earcut reference
  15124. * @returns a new Mesh
  15125. */
  15126. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15127. /**
  15128. * Creates an extruded shape mesh.
  15129. * 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
  15130. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15131. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15132. * @param name defines the name of the mesh to create
  15133. * @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
  15134. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15135. * @param scale is the value to scale the shape
  15136. * @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
  15137. * @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
  15138. * @param scene defines the hosting scene
  15139. * @param updatable defines if the mesh must be flagged as updatable
  15140. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15141. * @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)
  15142. * @returns a new Mesh
  15143. */
  15144. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15145. /**
  15146. * Creates an custom extruded shape mesh.
  15147. * The custom extrusion is a parametric shape.
  15148. * It has no predefined shape. Its final shape will depend on the input parameters.
  15149. * Please consider using the same method from the MeshBuilder class instead
  15150. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15151. * @param name defines the name of the mesh to create
  15152. * @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
  15153. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15154. * @param scaleFunction is a custom Javascript function called on each path point
  15155. * @param rotationFunction is a custom Javascript function called on each path point
  15156. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  15157. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  15158. * @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
  15159. * @param scene defines the hosting scene
  15160. * @param updatable defines if the mesh must be flagged as updatable
  15161. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15162. * @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)
  15163. * @returns a new Mesh
  15164. */
  15165. 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;
  15166. /**
  15167. * Creates lathe mesh.
  15168. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  15169. * Please consider using the same method from the MeshBuilder class instead
  15170. * @param name defines the name of the mesh to create
  15171. * @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
  15172. * @param radius is the radius value of the lathe
  15173. * @param tessellation is the side number of the lathe.
  15174. * @param scene defines the hosting scene
  15175. * @param updatable defines if the mesh must be flagged as updatable
  15176. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15177. * @returns a new Mesh
  15178. */
  15179. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15180. /**
  15181. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  15182. * @param name defines the name of the mesh to create
  15183. * @param size sets the size (float) of both sides of the plane at once (default 1)
  15184. * @param scene defines the hosting scene
  15185. * @param updatable defines if the mesh must be flagged as updatable
  15186. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15187. * @returns a new Mesh
  15188. */
  15189. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15190. /**
  15191. * Creates a ground mesh.
  15192. * Please consider using the same method from the MeshBuilder class instead
  15193. * @param name defines the name of the mesh to create
  15194. * @param width set the width of the ground
  15195. * @param height set the height of the ground
  15196. * @param subdivisions sets the number of subdivisions per side
  15197. * @param scene defines the hosting scene
  15198. * @param updatable defines if the mesh must be flagged as updatable
  15199. * @returns a new Mesh
  15200. */
  15201. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  15202. /**
  15203. * Creates a tiled ground mesh.
  15204. * Please consider using the same method from the MeshBuilder class instead
  15205. * @param name defines the name of the mesh to create
  15206. * @param xmin set the ground minimum X coordinate
  15207. * @param zmin set the ground minimum Y coordinate
  15208. * @param xmax set the ground maximum X coordinate
  15209. * @param zmax set the ground maximum Z coordinate
  15210. * @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
  15211. * @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
  15212. * @param scene defines the hosting scene
  15213. * @param updatable defines if the mesh must be flagged as updatable
  15214. * @returns a new Mesh
  15215. */
  15216. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  15217. w: number;
  15218. h: number;
  15219. }, precision: {
  15220. w: number;
  15221. h: number;
  15222. }, scene: Scene, updatable?: boolean): Mesh;
  15223. /**
  15224. * Creates a ground mesh from a height map.
  15225. * Please consider using the same method from the MeshBuilder class instead
  15226. * @see http://doc.babylonjs.com/babylon101/height_map
  15227. * @param name defines the name of the mesh to create
  15228. * @param url sets the URL of the height map image resource
  15229. * @param width set the ground width size
  15230. * @param height set the ground height size
  15231. * @param subdivisions sets the number of subdivision per side
  15232. * @param minHeight is the minimum altitude on the ground
  15233. * @param maxHeight is the maximum altitude on the ground
  15234. * @param scene defines the hosting scene
  15235. * @param updatable defines if the mesh must be flagged as updatable
  15236. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  15237. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  15238. * @returns a new Mesh
  15239. */
  15240. 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;
  15241. /**
  15242. * Creates a tube mesh.
  15243. * The tube is a parametric shape.
  15244. * It has no predefined shape. Its final shape will depend on the input parameters.
  15245. * Please consider using the same method from the MeshBuilder class instead
  15246. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15247. * @param name defines the name of the mesh to create
  15248. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  15249. * @param radius sets the tube radius size
  15250. * @param tessellation is the number of sides on the tubular surface
  15251. * @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
  15252. * @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
  15253. * @param scene defines the hosting scene
  15254. * @param updatable defines if the mesh must be flagged as updatable
  15255. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15256. * @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)
  15257. * @returns a new Mesh
  15258. */
  15259. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  15260. (i: number, distance: number): number;
  15261. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15262. /**
  15263. * Creates a polyhedron mesh.
  15264. * Please consider using the same method from the MeshBuilder class instead.
  15265. * * 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
  15266. * * The parameter `size` (positive float, default 1) sets the polygon size
  15267. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  15268. * * 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`
  15269. * * 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
  15270. * * 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)`)
  15271. * * 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
  15272. * * 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
  15273. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15274. * * 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
  15275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15276. * @param name defines the name of the mesh to create
  15277. * @param options defines the options used to create the mesh
  15278. * @param scene defines the hosting scene
  15279. * @returns a new Mesh
  15280. */
  15281. static CreatePolyhedron(name: string, options: {
  15282. type?: number;
  15283. size?: number;
  15284. sizeX?: number;
  15285. sizeY?: number;
  15286. sizeZ?: number;
  15287. custom?: any;
  15288. faceUV?: Vector4[];
  15289. faceColors?: Color4[];
  15290. updatable?: boolean;
  15291. sideOrientation?: number;
  15292. }, scene: Scene): Mesh;
  15293. /**
  15294. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  15295. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  15296. * * 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`)
  15297. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  15298. * * 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
  15299. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15300. * * 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
  15301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15302. * @param name defines the name of the mesh
  15303. * @param options defines the options used to create the mesh
  15304. * @param scene defines the hosting scene
  15305. * @returns a new Mesh
  15306. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  15307. */
  15308. static CreateIcoSphere(name: string, options: {
  15309. radius?: number;
  15310. flat?: boolean;
  15311. subdivisions?: number;
  15312. sideOrientation?: number;
  15313. updatable?: boolean;
  15314. }, scene: Scene): Mesh;
  15315. /**
  15316. * Creates a decal mesh.
  15317. * Please consider using the same method from the MeshBuilder class instead.
  15318. * A decal is a mesh usually applied as a model onto the surface of another mesh
  15319. * @param name defines the name of the mesh
  15320. * @param sourceMesh defines the mesh receiving the decal
  15321. * @param position sets the position of the decal in world coordinates
  15322. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  15323. * @param size sets the decal scaling
  15324. * @param angle sets the angle to rotate the decal
  15325. * @returns a new Mesh
  15326. */
  15327. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15328. /**
  15329. * Prepare internal position array for software CPU skinning
  15330. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  15331. */
  15332. setPositionsForCPUSkinning(): Float32Array;
  15333. /**
  15334. * Prepare internal normal array for software CPU skinning
  15335. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15336. */
  15337. setNormalsForCPUSkinning(): Float32Array;
  15338. /**
  15339. * Updates the vertex buffer by applying transformation from the bones
  15340. * @param skeleton defines the skeleton to apply to current mesh
  15341. * @returns the current mesh
  15342. */
  15343. applySkeleton(skeleton: Skeleton): Mesh;
  15344. /**
  15345. * 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
  15346. * @param meshes defines the list of meshes to scan
  15347. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  15348. */
  15349. static MinMax(meshes: AbstractMesh[]): {
  15350. min: Vector3;
  15351. max: Vector3;
  15352. };
  15353. /**
  15354. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  15355. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  15356. * @returns a vector3
  15357. */
  15358. static Center(meshesOrMinMaxVector: {
  15359. min: Vector3;
  15360. max: Vector3;
  15361. } | AbstractMesh[]): Vector3;
  15362. /**
  15363. * Merge the array of meshes into a single mesh for performance reasons.
  15364. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  15365. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  15366. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  15367. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  15368. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  15369. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  15370. * @returns a new mesh
  15371. */
  15372. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  15373. /** @hidden */
  15374. addInstance(instance: InstancedMesh): void;
  15375. /** @hidden */
  15376. removeInstance(instance: InstancedMesh): void;
  15377. }
  15378. }
  15379. declare module "babylonjs/Actions/action" {
  15380. import { Observable } from "babylonjs/Misc/observable";
  15381. import { Condition } from "babylonjs/Actions/condition";
  15382. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  15383. import { ActionManager } from "babylonjs/Actions/actionManager";
  15384. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15385. /**
  15386. * Interface used to define Action
  15387. */
  15388. export interface IAction {
  15389. /**
  15390. * Trigger for the action
  15391. */
  15392. trigger: number;
  15393. /** Options of the trigger */
  15394. triggerOptions: any;
  15395. /**
  15396. * Gets the trigger parameters
  15397. * @returns the trigger parameters
  15398. */
  15399. getTriggerParameter(): any;
  15400. /**
  15401. * Internal only - executes current action event
  15402. * @hidden
  15403. */
  15404. _executeCurrent(evt?: ActionEvent): void;
  15405. /**
  15406. * Serialize placeholder for child classes
  15407. * @param parent of child
  15408. * @returns the serialized object
  15409. */
  15410. serialize(parent: any): any;
  15411. /**
  15412. * Internal only
  15413. * @hidden
  15414. */
  15415. _prepare(): void;
  15416. /**
  15417. * Internal only - manager for action
  15418. * @hidden
  15419. */
  15420. _actionManager: AbstractActionManager;
  15421. /**
  15422. * Adds action to chain of actions, may be a DoNothingAction
  15423. * @param action defines the next action to execute
  15424. * @returns The action passed in
  15425. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15426. */
  15427. then(action: IAction): IAction;
  15428. }
  15429. /**
  15430. * The action to be carried out following a trigger
  15431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  15432. */
  15433. export class Action implements IAction {
  15434. /** the trigger, with or without parameters, for the action */
  15435. triggerOptions: any;
  15436. /**
  15437. * Trigger for the action
  15438. */
  15439. trigger: number;
  15440. /**
  15441. * Internal only - manager for action
  15442. * @hidden
  15443. */
  15444. _actionManager: ActionManager;
  15445. private _nextActiveAction;
  15446. private _child;
  15447. private _condition?;
  15448. private _triggerParameter;
  15449. /**
  15450. * An event triggered prior to action being executed.
  15451. */
  15452. onBeforeExecuteObservable: Observable<Action>;
  15453. /**
  15454. * Creates a new Action
  15455. * @param triggerOptions the trigger, with or without parameters, for the action
  15456. * @param condition an optional determinant of action
  15457. */
  15458. constructor(
  15459. /** the trigger, with or without parameters, for the action */
  15460. triggerOptions: any, condition?: Condition);
  15461. /**
  15462. * Internal only
  15463. * @hidden
  15464. */
  15465. _prepare(): void;
  15466. /**
  15467. * Gets the trigger parameters
  15468. * @returns the trigger parameters
  15469. */
  15470. getTriggerParameter(): any;
  15471. /**
  15472. * Internal only - executes current action event
  15473. * @hidden
  15474. */
  15475. _executeCurrent(evt?: ActionEvent): void;
  15476. /**
  15477. * Execute placeholder for child classes
  15478. * @param evt optional action event
  15479. */
  15480. execute(evt?: ActionEvent): void;
  15481. /**
  15482. * Skips to next active action
  15483. */
  15484. skipToNextActiveAction(): void;
  15485. /**
  15486. * Adds action to chain of actions, may be a DoNothingAction
  15487. * @param action defines the next action to execute
  15488. * @returns The action passed in
  15489. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15490. */
  15491. then(action: Action): Action;
  15492. /**
  15493. * Internal only
  15494. * @hidden
  15495. */
  15496. _getProperty(propertyPath: string): string;
  15497. /**
  15498. * Internal only
  15499. * @hidden
  15500. */
  15501. _getEffectiveTarget(target: any, propertyPath: string): any;
  15502. /**
  15503. * Serialize placeholder for child classes
  15504. * @param parent of child
  15505. * @returns the serialized object
  15506. */
  15507. serialize(parent: any): any;
  15508. /**
  15509. * Internal only called by serialize
  15510. * @hidden
  15511. */
  15512. protected _serialize(serializedAction: any, parent?: any): any;
  15513. /**
  15514. * Internal only
  15515. * @hidden
  15516. */
  15517. static _SerializeValueAsString: (value: any) => string;
  15518. /**
  15519. * Internal only
  15520. * @hidden
  15521. */
  15522. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  15523. name: string;
  15524. targetType: string;
  15525. value: string;
  15526. };
  15527. }
  15528. }
  15529. declare module "babylonjs/Actions/condition" {
  15530. import { ActionManager } from "babylonjs/Actions/actionManager";
  15531. /**
  15532. * A Condition applied to an Action
  15533. */
  15534. export class Condition {
  15535. /**
  15536. * Internal only - manager for action
  15537. * @hidden
  15538. */
  15539. _actionManager: ActionManager;
  15540. /**
  15541. * Internal only
  15542. * @hidden
  15543. */
  15544. _evaluationId: number;
  15545. /**
  15546. * Internal only
  15547. * @hidden
  15548. */
  15549. _currentResult: boolean;
  15550. /**
  15551. * Creates a new Condition
  15552. * @param actionManager the manager of the action the condition is applied to
  15553. */
  15554. constructor(actionManager: ActionManager);
  15555. /**
  15556. * Check if the current condition is valid
  15557. * @returns a boolean
  15558. */
  15559. isValid(): boolean;
  15560. /**
  15561. * Internal only
  15562. * @hidden
  15563. */
  15564. _getProperty(propertyPath: string): string;
  15565. /**
  15566. * Internal only
  15567. * @hidden
  15568. */
  15569. _getEffectiveTarget(target: any, propertyPath: string): any;
  15570. /**
  15571. * Serialize placeholder for child classes
  15572. * @returns the serialized object
  15573. */
  15574. serialize(): any;
  15575. /**
  15576. * Internal only
  15577. * @hidden
  15578. */
  15579. protected _serialize(serializedCondition: any): any;
  15580. }
  15581. /**
  15582. * Defines specific conditional operators as extensions of Condition
  15583. */
  15584. export class ValueCondition extends Condition {
  15585. /** path to specify the property of the target the conditional operator uses */
  15586. propertyPath: string;
  15587. /** the value compared by the conditional operator against the current value of the property */
  15588. value: any;
  15589. /** the conditional operator, default ValueCondition.IsEqual */
  15590. operator: number;
  15591. /**
  15592. * Internal only
  15593. * @hidden
  15594. */
  15595. private static _IsEqual;
  15596. /**
  15597. * Internal only
  15598. * @hidden
  15599. */
  15600. private static _IsDifferent;
  15601. /**
  15602. * Internal only
  15603. * @hidden
  15604. */
  15605. private static _IsGreater;
  15606. /**
  15607. * Internal only
  15608. * @hidden
  15609. */
  15610. private static _IsLesser;
  15611. /**
  15612. * returns the number for IsEqual
  15613. */
  15614. static readonly IsEqual: number;
  15615. /**
  15616. * Returns the number for IsDifferent
  15617. */
  15618. static readonly IsDifferent: number;
  15619. /**
  15620. * Returns the number for IsGreater
  15621. */
  15622. static readonly IsGreater: number;
  15623. /**
  15624. * Returns the number for IsLesser
  15625. */
  15626. static readonly IsLesser: number;
  15627. /**
  15628. * Internal only The action manager for the condition
  15629. * @hidden
  15630. */
  15631. _actionManager: ActionManager;
  15632. /**
  15633. * Internal only
  15634. * @hidden
  15635. */
  15636. private _target;
  15637. /**
  15638. * Internal only
  15639. * @hidden
  15640. */
  15641. private _effectiveTarget;
  15642. /**
  15643. * Internal only
  15644. * @hidden
  15645. */
  15646. private _property;
  15647. /**
  15648. * Creates a new ValueCondition
  15649. * @param actionManager manager for the action the condition applies to
  15650. * @param target for the action
  15651. * @param propertyPath path to specify the property of the target the conditional operator uses
  15652. * @param value the value compared by the conditional operator against the current value of the property
  15653. * @param operator the conditional operator, default ValueCondition.IsEqual
  15654. */
  15655. constructor(actionManager: ActionManager, target: any,
  15656. /** path to specify the property of the target the conditional operator uses */
  15657. propertyPath: string,
  15658. /** the value compared by the conditional operator against the current value of the property */
  15659. value: any,
  15660. /** the conditional operator, default ValueCondition.IsEqual */
  15661. operator?: number);
  15662. /**
  15663. * Compares the given value with the property value for the specified conditional operator
  15664. * @returns the result of the comparison
  15665. */
  15666. isValid(): boolean;
  15667. /**
  15668. * Serialize the ValueCondition into a JSON compatible object
  15669. * @returns serialization object
  15670. */
  15671. serialize(): any;
  15672. /**
  15673. * Gets the name of the conditional operator for the ValueCondition
  15674. * @param operator the conditional operator
  15675. * @returns the name
  15676. */
  15677. static GetOperatorName(operator: number): string;
  15678. }
  15679. /**
  15680. * Defines a predicate condition as an extension of Condition
  15681. */
  15682. export class PredicateCondition extends Condition {
  15683. /** defines the predicate function used to validate the condition */
  15684. predicate: () => boolean;
  15685. /**
  15686. * Internal only - manager for action
  15687. * @hidden
  15688. */
  15689. _actionManager: ActionManager;
  15690. /**
  15691. * Creates a new PredicateCondition
  15692. * @param actionManager manager for the action the condition applies to
  15693. * @param predicate defines the predicate function used to validate the condition
  15694. */
  15695. constructor(actionManager: ActionManager,
  15696. /** defines the predicate function used to validate the condition */
  15697. predicate: () => boolean);
  15698. /**
  15699. * @returns the validity of the predicate condition
  15700. */
  15701. isValid(): boolean;
  15702. }
  15703. /**
  15704. * Defines a state condition as an extension of Condition
  15705. */
  15706. export class StateCondition extends Condition {
  15707. /** Value to compare with target state */
  15708. value: string;
  15709. /**
  15710. * Internal only - manager for action
  15711. * @hidden
  15712. */
  15713. _actionManager: ActionManager;
  15714. /**
  15715. * Internal only
  15716. * @hidden
  15717. */
  15718. private _target;
  15719. /**
  15720. * Creates a new StateCondition
  15721. * @param actionManager manager for the action the condition applies to
  15722. * @param target of the condition
  15723. * @param value to compare with target state
  15724. */
  15725. constructor(actionManager: ActionManager, target: any,
  15726. /** Value to compare with target state */
  15727. value: string);
  15728. /**
  15729. * Gets a boolean indicating if the current condition is met
  15730. * @returns the validity of the state
  15731. */
  15732. isValid(): boolean;
  15733. /**
  15734. * Serialize the StateCondition into a JSON compatible object
  15735. * @returns serialization object
  15736. */
  15737. serialize(): any;
  15738. }
  15739. }
  15740. declare module "babylonjs/Actions/directActions" {
  15741. import { Action } from "babylonjs/Actions/action";
  15742. import { Condition } from "babylonjs/Actions/condition";
  15743. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15744. /**
  15745. * This defines an action responsible to toggle a boolean once triggered.
  15746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15747. */
  15748. export class SwitchBooleanAction extends Action {
  15749. /**
  15750. * The path to the boolean property in the target object
  15751. */
  15752. propertyPath: string;
  15753. private _target;
  15754. private _effectiveTarget;
  15755. private _property;
  15756. /**
  15757. * Instantiate the action
  15758. * @param triggerOptions defines the trigger options
  15759. * @param target defines the object containing the boolean
  15760. * @param propertyPath defines the path to the boolean property in the target object
  15761. * @param condition defines the trigger related conditions
  15762. */
  15763. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15764. /** @hidden */
  15765. _prepare(): void;
  15766. /**
  15767. * Execute the action toggle the boolean value.
  15768. */
  15769. execute(): void;
  15770. /**
  15771. * Serializes the actions and its related information.
  15772. * @param parent defines the object to serialize in
  15773. * @returns the serialized object
  15774. */
  15775. serialize(parent: any): any;
  15776. }
  15777. /**
  15778. * This defines an action responsible to set a the state field of the target
  15779. * to a desired value once triggered.
  15780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15781. */
  15782. export class SetStateAction extends Action {
  15783. /**
  15784. * The value to store in the state field.
  15785. */
  15786. value: string;
  15787. private _target;
  15788. /**
  15789. * Instantiate the action
  15790. * @param triggerOptions defines the trigger options
  15791. * @param target defines the object containing the state property
  15792. * @param value defines the value to store in the state field
  15793. * @param condition defines the trigger related conditions
  15794. */
  15795. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15796. /**
  15797. * Execute the action and store the value on the target state property.
  15798. */
  15799. execute(): void;
  15800. /**
  15801. * Serializes the actions and its related information.
  15802. * @param parent defines the object to serialize in
  15803. * @returns the serialized object
  15804. */
  15805. serialize(parent: any): any;
  15806. }
  15807. /**
  15808. * This defines an action responsible to set a property of the target
  15809. * to a desired value once triggered.
  15810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15811. */
  15812. export class SetValueAction extends Action {
  15813. /**
  15814. * The path of the property to set in the target.
  15815. */
  15816. propertyPath: string;
  15817. /**
  15818. * The value to set in the property
  15819. */
  15820. value: any;
  15821. private _target;
  15822. private _effectiveTarget;
  15823. private _property;
  15824. /**
  15825. * Instantiate the action
  15826. * @param triggerOptions defines the trigger options
  15827. * @param target defines the object containing the property
  15828. * @param propertyPath defines the path of the property to set in the target
  15829. * @param value defines the value to set in the property
  15830. * @param condition defines the trigger related conditions
  15831. */
  15832. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15833. /** @hidden */
  15834. _prepare(): void;
  15835. /**
  15836. * Execute the action and set the targetted property to the desired value.
  15837. */
  15838. execute(): void;
  15839. /**
  15840. * Serializes the actions and its related information.
  15841. * @param parent defines the object to serialize in
  15842. * @returns the serialized object
  15843. */
  15844. serialize(parent: any): any;
  15845. }
  15846. /**
  15847. * This defines an action responsible to increment the target value
  15848. * to a desired value once triggered.
  15849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15850. */
  15851. export class IncrementValueAction extends Action {
  15852. /**
  15853. * The path of the property to increment in the target.
  15854. */
  15855. propertyPath: string;
  15856. /**
  15857. * The value we should increment the property by.
  15858. */
  15859. value: any;
  15860. private _target;
  15861. private _effectiveTarget;
  15862. private _property;
  15863. /**
  15864. * Instantiate the action
  15865. * @param triggerOptions defines the trigger options
  15866. * @param target defines the object containing the property
  15867. * @param propertyPath defines the path of the property to increment in the target
  15868. * @param value defines the value value we should increment the property by
  15869. * @param condition defines the trigger related conditions
  15870. */
  15871. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15872. /** @hidden */
  15873. _prepare(): void;
  15874. /**
  15875. * Execute the action and increment the target of the value amount.
  15876. */
  15877. execute(): void;
  15878. /**
  15879. * Serializes the actions and its related information.
  15880. * @param parent defines the object to serialize in
  15881. * @returns the serialized object
  15882. */
  15883. serialize(parent: any): any;
  15884. }
  15885. /**
  15886. * This defines an action responsible to start an animation once triggered.
  15887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15888. */
  15889. export class PlayAnimationAction extends Action {
  15890. /**
  15891. * Where the animation should start (animation frame)
  15892. */
  15893. from: number;
  15894. /**
  15895. * Where the animation should stop (animation frame)
  15896. */
  15897. to: number;
  15898. /**
  15899. * Define if the animation should loop or stop after the first play.
  15900. */
  15901. loop?: boolean;
  15902. private _target;
  15903. /**
  15904. * Instantiate the action
  15905. * @param triggerOptions defines the trigger options
  15906. * @param target defines the target animation or animation name
  15907. * @param from defines from where the animation should start (animation frame)
  15908. * @param end defines where the animation should stop (animation frame)
  15909. * @param loop defines if the animation should loop or stop after the first play
  15910. * @param condition defines the trigger related conditions
  15911. */
  15912. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15913. /** @hidden */
  15914. _prepare(): void;
  15915. /**
  15916. * Execute the action and play the animation.
  15917. */
  15918. execute(): void;
  15919. /**
  15920. * Serializes the actions and its related information.
  15921. * @param parent defines the object to serialize in
  15922. * @returns the serialized object
  15923. */
  15924. serialize(parent: any): any;
  15925. }
  15926. /**
  15927. * This defines an action responsible to stop an animation once triggered.
  15928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15929. */
  15930. export class StopAnimationAction extends Action {
  15931. private _target;
  15932. /**
  15933. * Instantiate the action
  15934. * @param triggerOptions defines the trigger options
  15935. * @param target defines the target animation or animation name
  15936. * @param condition defines the trigger related conditions
  15937. */
  15938. constructor(triggerOptions: any, target: any, condition?: Condition);
  15939. /** @hidden */
  15940. _prepare(): void;
  15941. /**
  15942. * Execute the action and stop the animation.
  15943. */
  15944. execute(): void;
  15945. /**
  15946. * Serializes the actions and its related information.
  15947. * @param parent defines the object to serialize in
  15948. * @returns the serialized object
  15949. */
  15950. serialize(parent: any): any;
  15951. }
  15952. /**
  15953. * This defines an action responsible that does nothing once triggered.
  15954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15955. */
  15956. export class DoNothingAction extends Action {
  15957. /**
  15958. * Instantiate the action
  15959. * @param triggerOptions defines the trigger options
  15960. * @param condition defines the trigger related conditions
  15961. */
  15962. constructor(triggerOptions?: any, condition?: Condition);
  15963. /**
  15964. * Execute the action and do nothing.
  15965. */
  15966. execute(): void;
  15967. /**
  15968. * Serializes the actions and its related information.
  15969. * @param parent defines the object to serialize in
  15970. * @returns the serialized object
  15971. */
  15972. serialize(parent: any): any;
  15973. }
  15974. /**
  15975. * This defines an action responsible to trigger several actions once triggered.
  15976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15977. */
  15978. export class CombineAction extends Action {
  15979. /**
  15980. * The list of aggregated animations to run.
  15981. */
  15982. children: Action[];
  15983. /**
  15984. * Instantiate the action
  15985. * @param triggerOptions defines the trigger options
  15986. * @param children defines the list of aggregated animations to run
  15987. * @param condition defines the trigger related conditions
  15988. */
  15989. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15990. /** @hidden */
  15991. _prepare(): void;
  15992. /**
  15993. * Execute the action and executes all the aggregated actions.
  15994. */
  15995. execute(evt: ActionEvent): void;
  15996. /**
  15997. * Serializes the actions and its related information.
  15998. * @param parent defines the object to serialize in
  15999. * @returns the serialized object
  16000. */
  16001. serialize(parent: any): any;
  16002. }
  16003. /**
  16004. * This defines an action responsible to run code (external event) once triggered.
  16005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  16006. */
  16007. export class ExecuteCodeAction extends Action {
  16008. /**
  16009. * The callback function to run.
  16010. */
  16011. func: (evt: ActionEvent) => void;
  16012. /**
  16013. * Instantiate the action
  16014. * @param triggerOptions defines the trigger options
  16015. * @param func defines the callback function to run
  16016. * @param condition defines the trigger related conditions
  16017. */
  16018. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  16019. /**
  16020. * Execute the action and run the attached code.
  16021. */
  16022. execute(evt: ActionEvent): void;
  16023. }
  16024. /**
  16025. * This defines an action responsible to set the parent property of the target once triggered.
  16026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  16027. */
  16028. export class SetParentAction extends Action {
  16029. private _parent;
  16030. private _target;
  16031. /**
  16032. * Instantiate the action
  16033. * @param triggerOptions defines the trigger options
  16034. * @param target defines the target containing the parent property
  16035. * @param parent defines from where the animation should start (animation frame)
  16036. * @param condition defines the trigger related conditions
  16037. */
  16038. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  16039. /** @hidden */
  16040. _prepare(): void;
  16041. /**
  16042. * Execute the action and set the parent property.
  16043. */
  16044. execute(): void;
  16045. /**
  16046. * Serializes the actions and its related information.
  16047. * @param parent defines the object to serialize in
  16048. * @returns the serialized object
  16049. */
  16050. serialize(parent: any): any;
  16051. }
  16052. }
  16053. declare module "babylonjs/Actions/actionManager" {
  16054. import { Nullable } from "babylonjs/types";
  16055. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16056. import { Scene } from "babylonjs/scene";
  16057. import { IAction } from "babylonjs/Actions/action";
  16058. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  16059. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  16060. /**
  16061. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  16062. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  16063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  16064. */
  16065. export class ActionManager extends AbstractActionManager {
  16066. /**
  16067. * Nothing
  16068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16069. */
  16070. static readonly NothingTrigger: number;
  16071. /**
  16072. * On pick
  16073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16074. */
  16075. static readonly OnPickTrigger: number;
  16076. /**
  16077. * On left pick
  16078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16079. */
  16080. static readonly OnLeftPickTrigger: number;
  16081. /**
  16082. * On right pick
  16083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16084. */
  16085. static readonly OnRightPickTrigger: number;
  16086. /**
  16087. * On center pick
  16088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16089. */
  16090. static readonly OnCenterPickTrigger: number;
  16091. /**
  16092. * On pick down
  16093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16094. */
  16095. static readonly OnPickDownTrigger: number;
  16096. /**
  16097. * On double pick
  16098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16099. */
  16100. static readonly OnDoublePickTrigger: number;
  16101. /**
  16102. * On pick up
  16103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16104. */
  16105. static readonly OnPickUpTrigger: number;
  16106. /**
  16107. * On pick out.
  16108. * This trigger will only be raised if you also declared a OnPickDown
  16109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16110. */
  16111. static readonly OnPickOutTrigger: number;
  16112. /**
  16113. * On long press
  16114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16115. */
  16116. static readonly OnLongPressTrigger: number;
  16117. /**
  16118. * On pointer over
  16119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16120. */
  16121. static readonly OnPointerOverTrigger: number;
  16122. /**
  16123. * On pointer out
  16124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16125. */
  16126. static readonly OnPointerOutTrigger: number;
  16127. /**
  16128. * On every frame
  16129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16130. */
  16131. static readonly OnEveryFrameTrigger: number;
  16132. /**
  16133. * On intersection enter
  16134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16135. */
  16136. static readonly OnIntersectionEnterTrigger: number;
  16137. /**
  16138. * On intersection exit
  16139. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16140. */
  16141. static readonly OnIntersectionExitTrigger: number;
  16142. /**
  16143. * On key down
  16144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16145. */
  16146. static readonly OnKeyDownTrigger: number;
  16147. /**
  16148. * On key up
  16149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16150. */
  16151. static readonly OnKeyUpTrigger: number;
  16152. private _scene;
  16153. /**
  16154. * Creates a new action manager
  16155. * @param scene defines the hosting scene
  16156. */
  16157. constructor(scene: Scene);
  16158. /**
  16159. * Releases all associated resources
  16160. */
  16161. dispose(): void;
  16162. /**
  16163. * Gets hosting scene
  16164. * @returns the hosting scene
  16165. */
  16166. getScene(): Scene;
  16167. /**
  16168. * Does this action manager handles actions of any of the given triggers
  16169. * @param triggers defines the triggers to be tested
  16170. * @return a boolean indicating whether one (or more) of the triggers is handled
  16171. */
  16172. hasSpecificTriggers(triggers: number[]): boolean;
  16173. /**
  16174. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  16175. * speed.
  16176. * @param triggerA defines the trigger to be tested
  16177. * @param triggerB defines the trigger to be tested
  16178. * @return a boolean indicating whether one (or more) of the triggers is handled
  16179. */
  16180. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  16181. /**
  16182. * Does this action manager handles actions of a given trigger
  16183. * @param trigger defines the trigger to be tested
  16184. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  16185. * @return whether the trigger is handled
  16186. */
  16187. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  16188. /**
  16189. * Does this action manager has pointer triggers
  16190. */
  16191. readonly hasPointerTriggers: boolean;
  16192. /**
  16193. * Does this action manager has pick triggers
  16194. */
  16195. readonly hasPickTriggers: boolean;
  16196. /**
  16197. * Registers an action to this action manager
  16198. * @param action defines the action to be registered
  16199. * @return the action amended (prepared) after registration
  16200. */
  16201. registerAction(action: IAction): Nullable<IAction>;
  16202. /**
  16203. * Unregisters an action to this action manager
  16204. * @param action defines the action to be unregistered
  16205. * @return a boolean indicating whether the action has been unregistered
  16206. */
  16207. unregisterAction(action: IAction): Boolean;
  16208. /**
  16209. * Process a specific trigger
  16210. * @param trigger defines the trigger to process
  16211. * @param evt defines the event details to be processed
  16212. */
  16213. processTrigger(trigger: number, evt?: IActionEvent): void;
  16214. /** @hidden */
  16215. _getEffectiveTarget(target: any, propertyPath: string): any;
  16216. /** @hidden */
  16217. _getProperty(propertyPath: string): string;
  16218. /**
  16219. * Serialize this manager to a JSON object
  16220. * @param name defines the property name to store this manager
  16221. * @returns a JSON representation of this manager
  16222. */
  16223. serialize(name: string): any;
  16224. /**
  16225. * Creates a new ActionManager from a JSON data
  16226. * @param parsedActions defines the JSON data to read from
  16227. * @param object defines the hosting mesh
  16228. * @param scene defines the hosting scene
  16229. */
  16230. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  16231. /**
  16232. * Get a trigger name by index
  16233. * @param trigger defines the trigger index
  16234. * @returns a trigger name
  16235. */
  16236. static GetTriggerName(trigger: number): string;
  16237. }
  16238. }
  16239. declare module "babylonjs/Culling/ray" {
  16240. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  16241. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  16242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16243. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16244. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  16245. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  16246. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  16247. /**
  16248. * Class representing a ray with position and direction
  16249. */
  16250. export class Ray {
  16251. /** origin point */
  16252. origin: Vector3;
  16253. /** direction */
  16254. direction: Vector3;
  16255. /** length of the ray */
  16256. length: number;
  16257. private static readonly TmpVector3;
  16258. private _tmpRay;
  16259. /**
  16260. * Creates a new ray
  16261. * @param origin origin point
  16262. * @param direction direction
  16263. * @param length length of the ray
  16264. */
  16265. constructor(
  16266. /** origin point */
  16267. origin: Vector3,
  16268. /** direction */
  16269. direction: Vector3,
  16270. /** length of the ray */
  16271. length?: number);
  16272. /**
  16273. * Checks if the ray intersects a box
  16274. * @param minimum bound of the box
  16275. * @param maximum bound of the box
  16276. * @param intersectionTreshold extra extend to be added to the box in all direction
  16277. * @returns if the box was hit
  16278. */
  16279. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  16280. /**
  16281. * Checks if the ray intersects a box
  16282. * @param box the bounding box to check
  16283. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  16284. * @returns if the box was hit
  16285. */
  16286. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  16287. /**
  16288. * If the ray hits a sphere
  16289. * @param sphere the bounding sphere to check
  16290. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  16291. * @returns true if it hits the sphere
  16292. */
  16293. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  16294. /**
  16295. * If the ray hits a triange
  16296. * @param vertex0 triangle vertex
  16297. * @param vertex1 triangle vertex
  16298. * @param vertex2 triangle vertex
  16299. * @returns intersection information if hit
  16300. */
  16301. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  16302. /**
  16303. * Checks if ray intersects a plane
  16304. * @param plane the plane to check
  16305. * @returns the distance away it was hit
  16306. */
  16307. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  16308. /**
  16309. * Calculate the intercept of a ray on a given axis
  16310. * @param axis to check 'x' | 'y' | 'z'
  16311. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  16312. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  16313. */
  16314. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  16315. /**
  16316. * Checks if ray intersects a mesh
  16317. * @param mesh the mesh to check
  16318. * @param fastCheck if only the bounding box should checked
  16319. * @returns picking info of the intersecton
  16320. */
  16321. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  16322. /**
  16323. * Checks if ray intersects a mesh
  16324. * @param meshes the meshes to check
  16325. * @param fastCheck if only the bounding box should checked
  16326. * @param results array to store result in
  16327. * @returns Array of picking infos
  16328. */
  16329. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  16330. private _comparePickingInfo;
  16331. private static smallnum;
  16332. private static rayl;
  16333. /**
  16334. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  16335. * @param sega the first point of the segment to test the intersection against
  16336. * @param segb the second point of the segment to test the intersection against
  16337. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  16338. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  16339. */
  16340. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  16341. /**
  16342. * Update the ray from viewport position
  16343. * @param x position
  16344. * @param y y position
  16345. * @param viewportWidth viewport width
  16346. * @param viewportHeight viewport height
  16347. * @param world world matrix
  16348. * @param view view matrix
  16349. * @param projection projection matrix
  16350. * @returns this ray updated
  16351. */
  16352. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16353. /**
  16354. * Creates a ray with origin and direction of 0,0,0
  16355. * @returns the new ray
  16356. */
  16357. static Zero(): Ray;
  16358. /**
  16359. * Creates a new ray from screen space and viewport
  16360. * @param x position
  16361. * @param y y position
  16362. * @param viewportWidth viewport width
  16363. * @param viewportHeight viewport height
  16364. * @param world world matrix
  16365. * @param view view matrix
  16366. * @param projection projection matrix
  16367. * @returns new ray
  16368. */
  16369. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16370. /**
  16371. * 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
  16372. * transformed to the given world matrix.
  16373. * @param origin The origin point
  16374. * @param end The end point
  16375. * @param world a matrix to transform the ray to. Default is the identity matrix.
  16376. * @returns the new ray
  16377. */
  16378. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  16379. /**
  16380. * Transforms a ray by a matrix
  16381. * @param ray ray to transform
  16382. * @param matrix matrix to apply
  16383. * @returns the resulting new ray
  16384. */
  16385. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  16386. /**
  16387. * Transforms a ray by a matrix
  16388. * @param ray ray to transform
  16389. * @param matrix matrix to apply
  16390. * @param result ray to store result in
  16391. */
  16392. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  16393. /**
  16394. * Unproject a ray from screen space to object space
  16395. * @param sourceX defines the screen space x coordinate to use
  16396. * @param sourceY defines the screen space y coordinate to use
  16397. * @param viewportWidth defines the current width of the viewport
  16398. * @param viewportHeight defines the current height of the viewport
  16399. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16400. * @param view defines the view matrix to use
  16401. * @param projection defines the projection matrix to use
  16402. */
  16403. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  16404. }
  16405. /**
  16406. * Type used to define predicate used to select faces when a mesh intersection is detected
  16407. */
  16408. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  16409. module "babylonjs/scene" {
  16410. interface Scene {
  16411. /** @hidden */
  16412. _tempPickingRay: Nullable<Ray>;
  16413. /** @hidden */
  16414. _cachedRayForTransform: Ray;
  16415. /** @hidden */
  16416. _pickWithRayInverseMatrix: Matrix;
  16417. /** @hidden */
  16418. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  16419. /** @hidden */
  16420. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  16421. }
  16422. }
  16423. }
  16424. declare module "babylonjs/Sprites/spriteSceneComponent" {
  16425. import { Nullable } from "babylonjs/types";
  16426. import { Observable } from "babylonjs/Misc/observable";
  16427. import { Scene } from "babylonjs/scene";
  16428. import { Sprite } from "babylonjs/Sprites/sprite";
  16429. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16430. import { Ray } from "babylonjs/Culling/ray";
  16431. import { Camera } from "babylonjs/Cameras/camera";
  16432. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16433. import { ISceneComponent } from "babylonjs/sceneComponent";
  16434. module "babylonjs/scene" {
  16435. interface Scene {
  16436. /** @hidden */
  16437. _pointerOverSprite: Nullable<Sprite>;
  16438. /** @hidden */
  16439. _pickedDownSprite: Nullable<Sprite>;
  16440. /** @hidden */
  16441. _tempSpritePickingRay: Nullable<Ray>;
  16442. /**
  16443. * All of the sprite managers added to this scene
  16444. * @see http://doc.babylonjs.com/babylon101/sprites
  16445. */
  16446. spriteManagers: Array<ISpriteManager>;
  16447. /**
  16448. * An event triggered when sprites rendering is about to start
  16449. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16450. */
  16451. onBeforeSpritesRenderingObservable: Observable<Scene>;
  16452. /**
  16453. * An event triggered when sprites rendering is done
  16454. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16455. */
  16456. onAfterSpritesRenderingObservable: Observable<Scene>;
  16457. /** @hidden */
  16458. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16459. /** Launch a ray to try to pick a sprite in the scene
  16460. * @param x position on screen
  16461. * @param y position on screen
  16462. * @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
  16463. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16464. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  16465. * @returns a PickingInfo
  16466. */
  16467. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16468. /** Use the given ray to pick a sprite in the scene
  16469. * @param ray The ray (in world space) to use to pick meshes
  16470. * @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
  16471. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16472. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  16473. * @returns a PickingInfo
  16474. */
  16475. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16476. /**
  16477. * Force the sprite under the pointer
  16478. * @param sprite defines the sprite to use
  16479. */
  16480. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  16481. /**
  16482. * Gets the sprite under the pointer
  16483. * @returns a Sprite or null if no sprite is under the pointer
  16484. */
  16485. getPointerOverSprite(): Nullable<Sprite>;
  16486. }
  16487. }
  16488. /**
  16489. * Defines the sprite scene component responsible to manage sprites
  16490. * in a given scene.
  16491. */
  16492. export class SpriteSceneComponent implements ISceneComponent {
  16493. /**
  16494. * The component name helpfull to identify the component in the list of scene components.
  16495. */
  16496. readonly name: string;
  16497. /**
  16498. * The scene the component belongs to.
  16499. */
  16500. scene: Scene;
  16501. /** @hidden */
  16502. private _spritePredicate;
  16503. /**
  16504. * Creates a new instance of the component for the given scene
  16505. * @param scene Defines the scene to register the component in
  16506. */
  16507. constructor(scene: Scene);
  16508. /**
  16509. * Registers the component in a given scene
  16510. */
  16511. register(): void;
  16512. /**
  16513. * Rebuilds the elements related to this component in case of
  16514. * context lost for instance.
  16515. */
  16516. rebuild(): void;
  16517. /**
  16518. * Disposes the component and the associated ressources.
  16519. */
  16520. dispose(): void;
  16521. private _pickSpriteButKeepRay;
  16522. private _pointerMove;
  16523. private _pointerDown;
  16524. private _pointerUp;
  16525. }
  16526. }
  16527. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  16528. /** @hidden */
  16529. export var fogFragmentDeclaration: {
  16530. name: string;
  16531. shader: string;
  16532. };
  16533. }
  16534. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  16535. /** @hidden */
  16536. export var fogFragment: {
  16537. name: string;
  16538. shader: string;
  16539. };
  16540. }
  16541. declare module "babylonjs/Shaders/sprites.fragment" {
  16542. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  16543. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  16544. /** @hidden */
  16545. export var spritesPixelShader: {
  16546. name: string;
  16547. shader: string;
  16548. };
  16549. }
  16550. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  16551. /** @hidden */
  16552. export var fogVertexDeclaration: {
  16553. name: string;
  16554. shader: string;
  16555. };
  16556. }
  16557. declare module "babylonjs/Shaders/sprites.vertex" {
  16558. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  16559. /** @hidden */
  16560. export var spritesVertexShader: {
  16561. name: string;
  16562. shader: string;
  16563. };
  16564. }
  16565. declare module "babylonjs/Sprites/spriteManager" {
  16566. import { IDisposable, Scene } from "babylonjs/scene";
  16567. import { Nullable } from "babylonjs/types";
  16568. import { Observable } from "babylonjs/Misc/observable";
  16569. import { Sprite } from "babylonjs/Sprites/sprite";
  16570. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16571. import { Camera } from "babylonjs/Cameras/camera";
  16572. import { Texture } from "babylonjs/Materials/Textures/texture";
  16573. import "babylonjs/Shaders/sprites.fragment";
  16574. import "babylonjs/Shaders/sprites.vertex";
  16575. import { Ray } from "babylonjs/Culling/ray";
  16576. /**
  16577. * Defines the minimum interface to fullfil in order to be a sprite manager.
  16578. */
  16579. export interface ISpriteManager extends IDisposable {
  16580. /**
  16581. * Restricts the camera to viewing objects with the same layerMask.
  16582. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  16583. */
  16584. layerMask: number;
  16585. /**
  16586. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  16587. */
  16588. isPickable: boolean;
  16589. /**
  16590. * Specifies the rendering group id for this mesh (0 by default)
  16591. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  16592. */
  16593. renderingGroupId: number;
  16594. /**
  16595. * Defines the list of sprites managed by the manager.
  16596. */
  16597. sprites: Array<Sprite>;
  16598. /**
  16599. * Tests the intersection of a sprite with a specific ray.
  16600. * @param ray The ray we are sending to test the collision
  16601. * @param camera The camera space we are sending rays in
  16602. * @param predicate A predicate allowing excluding sprites from the list of object to test
  16603. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  16604. * @returns picking info or null.
  16605. */
  16606. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16607. /**
  16608. * Renders the list of sprites on screen.
  16609. */
  16610. render(): void;
  16611. }
  16612. /**
  16613. * Class used to manage multiple sprites on the same spritesheet
  16614. * @see http://doc.babylonjs.com/babylon101/sprites
  16615. */
  16616. export class SpriteManager implements ISpriteManager {
  16617. /** defines the manager's name */
  16618. name: string;
  16619. /** Gets the list of sprites */
  16620. sprites: Sprite[];
  16621. /** Gets or sets the rendering group id (0 by default) */
  16622. renderingGroupId: number;
  16623. /** Gets or sets camera layer mask */
  16624. layerMask: number;
  16625. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16626. fogEnabled: boolean;
  16627. /** Gets or sets a boolean indicating if the sprites are pickable */
  16628. isPickable: boolean;
  16629. /** Defines the default width of a cell in the spritesheet */
  16630. cellWidth: number;
  16631. /** Defines the default height of a cell in the spritesheet */
  16632. cellHeight: number;
  16633. /**
  16634. * An event triggered when the manager is disposed.
  16635. */
  16636. onDisposeObservable: Observable<SpriteManager>;
  16637. private _onDisposeObserver;
  16638. /**
  16639. * Callback called when the manager is disposed
  16640. */
  16641. onDispose: () => void;
  16642. private _capacity;
  16643. private _spriteTexture;
  16644. private _epsilon;
  16645. private _scene;
  16646. private _vertexData;
  16647. private _buffer;
  16648. private _vertexBuffers;
  16649. private _indexBuffer;
  16650. private _effectBase;
  16651. private _effectFog;
  16652. /**
  16653. * Gets or sets the spritesheet texture
  16654. */
  16655. texture: Texture;
  16656. /**
  16657. * Creates a new sprite manager
  16658. * @param name defines the manager's name
  16659. * @param imgUrl defines the sprite sheet url
  16660. * @param capacity defines the maximum allowed number of sprites
  16661. * @param cellSize defines the size of a sprite cell
  16662. * @param scene defines the hosting scene
  16663. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16664. * @param samplingMode defines the smapling mode to use with spritesheet
  16665. */
  16666. constructor(
  16667. /** defines the manager's name */
  16668. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16669. private _appendSpriteVertex;
  16670. /**
  16671. * Intersects the sprites with a ray
  16672. * @param ray defines the ray to intersect with
  16673. * @param camera defines the current active camera
  16674. * @param predicate defines a predicate used to select candidate sprites
  16675. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16676. * @returns null if no hit or a PickingInfo
  16677. */
  16678. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16679. /**
  16680. * Render all child sprites
  16681. */
  16682. render(): void;
  16683. /**
  16684. * Release associated resources
  16685. */
  16686. dispose(): void;
  16687. }
  16688. }
  16689. declare module "babylonjs/Sprites/sprite" {
  16690. import { Vector3, Color4 } from "babylonjs/Maths/math";
  16691. import { Nullable } from "babylonjs/types";
  16692. import { ActionManager } from "babylonjs/Actions/actionManager";
  16693. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16694. /**
  16695. * Class used to represent a sprite
  16696. * @see http://doc.babylonjs.com/babylon101/sprites
  16697. */
  16698. export class Sprite {
  16699. /** defines the name */
  16700. name: string;
  16701. /** Gets or sets the current world position */
  16702. position: Vector3;
  16703. /** Gets or sets the main color */
  16704. color: Color4;
  16705. /** Gets or sets the width */
  16706. width: number;
  16707. /** Gets or sets the height */
  16708. height: number;
  16709. /** Gets or sets rotation angle */
  16710. angle: number;
  16711. /** Gets or sets the cell index in the sprite sheet */
  16712. cellIndex: number;
  16713. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16714. invertU: number;
  16715. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16716. invertV: number;
  16717. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16718. disposeWhenFinishedAnimating: boolean;
  16719. /** Gets the list of attached animations */
  16720. animations: Animation[];
  16721. /** Gets or sets a boolean indicating if the sprite can be picked */
  16722. isPickable: boolean;
  16723. /**
  16724. * Gets or sets the associated action manager
  16725. */
  16726. actionManager: Nullable<ActionManager>;
  16727. private _animationStarted;
  16728. private _loopAnimation;
  16729. private _fromIndex;
  16730. private _toIndex;
  16731. private _delay;
  16732. private _direction;
  16733. private _manager;
  16734. private _time;
  16735. private _onAnimationEnd;
  16736. /**
  16737. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16738. */
  16739. isVisible: boolean;
  16740. /**
  16741. * Gets or sets the sprite size
  16742. */
  16743. size: number;
  16744. /**
  16745. * Creates a new Sprite
  16746. * @param name defines the name
  16747. * @param manager defines the manager
  16748. */
  16749. constructor(
  16750. /** defines the name */
  16751. name: string, manager: ISpriteManager);
  16752. /**
  16753. * Starts an animation
  16754. * @param from defines the initial key
  16755. * @param to defines the end key
  16756. * @param loop defines if the animation must loop
  16757. * @param delay defines the start delay (in ms)
  16758. * @param onAnimationEnd defines a callback to call when animation ends
  16759. */
  16760. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16761. /** Stops current animation (if any) */
  16762. stopAnimation(): void;
  16763. /** @hidden */
  16764. _animate(deltaTime: number): void;
  16765. /** Release associated resources */
  16766. dispose(): void;
  16767. }
  16768. }
  16769. declare module "babylonjs/Collisions/pickingInfo" {
  16770. import { Nullable } from "babylonjs/types";
  16771. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  16772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16773. import { Sprite } from "babylonjs/Sprites/sprite";
  16774. import { Ray } from "babylonjs/Culling/ray";
  16775. /**
  16776. * Information about the result of picking within a scene
  16777. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16778. */
  16779. export class PickingInfo {
  16780. /** @hidden */
  16781. _pickingUnavailable: boolean;
  16782. /**
  16783. * If the pick collided with an object
  16784. */
  16785. hit: boolean;
  16786. /**
  16787. * Distance away where the pick collided
  16788. */
  16789. distance: number;
  16790. /**
  16791. * The location of pick collision
  16792. */
  16793. pickedPoint: Nullable<Vector3>;
  16794. /**
  16795. * The mesh corresponding the the pick collision
  16796. */
  16797. pickedMesh: Nullable<AbstractMesh>;
  16798. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16799. bu: number;
  16800. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16801. bv: number;
  16802. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16803. faceId: number;
  16804. /** Id of the the submesh that was picked */
  16805. subMeshId: number;
  16806. /** If a sprite was picked, this will be the sprite the pick collided with */
  16807. pickedSprite: Nullable<Sprite>;
  16808. /**
  16809. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16810. */
  16811. originMesh: Nullable<AbstractMesh>;
  16812. /**
  16813. * The ray that was used to perform the picking.
  16814. */
  16815. ray: Nullable<Ray>;
  16816. /**
  16817. * Gets the normal correspodning to the face the pick collided with
  16818. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16819. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16820. * @returns The normal correspodning to the face the pick collided with
  16821. */
  16822. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16823. /**
  16824. * Gets the texture coordinates of where the pick occured
  16825. * @returns the vector containing the coordnates of the texture
  16826. */
  16827. getTextureCoordinates(): Nullable<Vector2>;
  16828. }
  16829. }
  16830. declare module "babylonjs/Events/pointerEvents" {
  16831. import { Nullable } from "babylonjs/types";
  16832. import { Vector2 } from "babylonjs/Maths/math";
  16833. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16834. import { Ray } from "babylonjs/Culling/ray";
  16835. /**
  16836. * Gather the list of pointer event types as constants.
  16837. */
  16838. export class PointerEventTypes {
  16839. /**
  16840. * 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.
  16841. */
  16842. static readonly POINTERDOWN: number;
  16843. /**
  16844. * The pointerup event is fired when a pointer is no longer active.
  16845. */
  16846. static readonly POINTERUP: number;
  16847. /**
  16848. * The pointermove event is fired when a pointer changes coordinates.
  16849. */
  16850. static readonly POINTERMOVE: number;
  16851. /**
  16852. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16853. */
  16854. static readonly POINTERWHEEL: number;
  16855. /**
  16856. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16857. */
  16858. static readonly POINTERPICK: number;
  16859. /**
  16860. * The pointertap event is fired when a the object has been touched and released without drag.
  16861. */
  16862. static readonly POINTERTAP: number;
  16863. /**
  16864. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16865. */
  16866. static readonly POINTERDOUBLETAP: number;
  16867. }
  16868. /**
  16869. * Base class of pointer info types.
  16870. */
  16871. export class PointerInfoBase {
  16872. /**
  16873. * Defines the type of event (PointerEventTypes)
  16874. */
  16875. type: number;
  16876. /**
  16877. * Defines the related dom event
  16878. */
  16879. event: PointerEvent | MouseWheelEvent;
  16880. /**
  16881. * Instantiates the base class of pointers info.
  16882. * @param type Defines the type of event (PointerEventTypes)
  16883. * @param event Defines the related dom event
  16884. */
  16885. constructor(
  16886. /**
  16887. * Defines the type of event (PointerEventTypes)
  16888. */
  16889. type: number,
  16890. /**
  16891. * Defines the related dom event
  16892. */
  16893. event: PointerEvent | MouseWheelEvent);
  16894. }
  16895. /**
  16896. * This class is used to store pointer related info for the onPrePointerObservable event.
  16897. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16898. */
  16899. export class PointerInfoPre extends PointerInfoBase {
  16900. /**
  16901. * Ray from a pointer if availible (eg. 6dof controller)
  16902. */
  16903. ray: Nullable<Ray>;
  16904. /**
  16905. * Defines the local position of the pointer on the canvas.
  16906. */
  16907. localPosition: Vector2;
  16908. /**
  16909. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16910. */
  16911. skipOnPointerObservable: boolean;
  16912. /**
  16913. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16914. * @param type Defines the type of event (PointerEventTypes)
  16915. * @param event Defines the related dom event
  16916. * @param localX Defines the local x coordinates of the pointer when the event occured
  16917. * @param localY Defines the local y coordinates of the pointer when the event occured
  16918. */
  16919. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16920. }
  16921. /**
  16922. * This type contains all the data related to a pointer event in Babylon.js.
  16923. * 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.
  16924. */
  16925. export class PointerInfo extends PointerInfoBase {
  16926. /**
  16927. * Defines the picking info associated to the info (if any)\
  16928. */
  16929. pickInfo: Nullable<PickingInfo>;
  16930. /**
  16931. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16932. * @param type Defines the type of event (PointerEventTypes)
  16933. * @param event Defines the related dom event
  16934. * @param pickInfo Defines the picking info associated to the info (if any)\
  16935. */
  16936. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16937. /**
  16938. * Defines the picking info associated to the info (if any)\
  16939. */
  16940. pickInfo: Nullable<PickingInfo>);
  16941. }
  16942. /**
  16943. * Data relating to a touch event on the screen.
  16944. */
  16945. export interface PointerTouch {
  16946. /**
  16947. * X coordinate of touch.
  16948. */
  16949. x: number;
  16950. /**
  16951. * Y coordinate of touch.
  16952. */
  16953. y: number;
  16954. /**
  16955. * Id of touch. Unique for each finger.
  16956. */
  16957. pointerId: number;
  16958. /**
  16959. * Event type passed from DOM.
  16960. */
  16961. type: any;
  16962. }
  16963. }
  16964. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  16965. import { Observable } from "babylonjs/Misc/observable";
  16966. import { Nullable } from "babylonjs/types";
  16967. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  16968. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  16969. /**
  16970. * Manage the mouse inputs to control the movement of a free camera.
  16971. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16972. */
  16973. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16974. /**
  16975. * Define if touch is enabled in the mouse input
  16976. */
  16977. touchEnabled: boolean;
  16978. /**
  16979. * Defines the camera the input is attached to.
  16980. */
  16981. camera: FreeCamera;
  16982. /**
  16983. * Defines the buttons associated with the input to handle camera move.
  16984. */
  16985. buttons: number[];
  16986. /**
  16987. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16988. */
  16989. angularSensibility: number;
  16990. private _pointerInput;
  16991. private _onMouseMove;
  16992. private _observer;
  16993. private previousPosition;
  16994. /**
  16995. * Observable for when a pointer move event occurs containing the move offset
  16996. */
  16997. onPointerMovedObservable: Observable<{
  16998. offsetX: number;
  16999. offsetY: number;
  17000. }>;
  17001. /**
  17002. * @hidden
  17003. * If the camera should be rotated automatically based on pointer movement
  17004. */
  17005. _allowCameraRotation: boolean;
  17006. /**
  17007. * Manage the mouse inputs to control the movement of a free camera.
  17008. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  17009. * @param touchEnabled Defines if touch is enabled or not
  17010. */
  17011. constructor(
  17012. /**
  17013. * Define if touch is enabled in the mouse input
  17014. */
  17015. touchEnabled?: boolean);
  17016. /**
  17017. * Attach the input controls to a specific dom element to get the input from.
  17018. * @param element Defines the element the controls should be listened from
  17019. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17020. */
  17021. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17022. /**
  17023. * Called on JS contextmenu event.
  17024. * Override this method to provide functionality.
  17025. */
  17026. protected onContextMenu(evt: PointerEvent): void;
  17027. /**
  17028. * Detach the current controls from the specified dom element.
  17029. * @param element Defines the element to stop listening the inputs from
  17030. */
  17031. detachControl(element: Nullable<HTMLElement>): void;
  17032. /**
  17033. * Gets the class name of the current intput.
  17034. * @returns the class name
  17035. */
  17036. getClassName(): string;
  17037. /**
  17038. * Get the friendly name associated with the input class.
  17039. * @returns the input friendly name
  17040. */
  17041. getSimpleName(): string;
  17042. }
  17043. }
  17044. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  17045. import { Nullable } from "babylonjs/types";
  17046. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  17047. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17048. /**
  17049. * Manage the touch inputs to control the movement of a free camera.
  17050. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  17051. */
  17052. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  17053. /**
  17054. * Defines the camera the input is attached to.
  17055. */
  17056. camera: FreeCamera;
  17057. /**
  17058. * Defines the touch sensibility for rotation.
  17059. * The higher the faster.
  17060. */
  17061. touchAngularSensibility: number;
  17062. /**
  17063. * Defines the touch sensibility for move.
  17064. * The higher the faster.
  17065. */
  17066. touchMoveSensibility: number;
  17067. private _offsetX;
  17068. private _offsetY;
  17069. private _pointerPressed;
  17070. private _pointerInput;
  17071. private _observer;
  17072. private _onLostFocus;
  17073. /**
  17074. * Attach the input controls to a specific dom element to get the input from.
  17075. * @param element Defines the element the controls should be listened from
  17076. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17077. */
  17078. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17079. /**
  17080. * Detach the current controls from the specified dom element.
  17081. * @param element Defines the element to stop listening the inputs from
  17082. */
  17083. detachControl(element: Nullable<HTMLElement>): void;
  17084. /**
  17085. * Update the current camera state depending on the inputs that have been used this frame.
  17086. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  17087. */
  17088. checkInputs(): void;
  17089. /**
  17090. * Gets the class name of the current intput.
  17091. * @returns the class name
  17092. */
  17093. getClassName(): string;
  17094. /**
  17095. * Get the friendly name associated with the input class.
  17096. * @returns the input friendly name
  17097. */
  17098. getSimpleName(): string;
  17099. }
  17100. }
  17101. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  17102. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17103. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  17104. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  17105. import { Nullable } from "babylonjs/types";
  17106. /**
  17107. * Default Inputs manager for the FreeCamera.
  17108. * It groups all the default supported inputs for ease of use.
  17109. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  17110. */
  17111. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  17112. /**
  17113. * @hidden
  17114. */
  17115. _mouseInput: Nullable<FreeCameraMouseInput>;
  17116. /**
  17117. * Instantiates a new FreeCameraInputsManager.
  17118. * @param camera Defines the camera the inputs belong to
  17119. */
  17120. constructor(camera: FreeCamera);
  17121. /**
  17122. * Add keyboard input support to the input manager.
  17123. * @returns the current input manager
  17124. */
  17125. addKeyboard(): FreeCameraInputsManager;
  17126. /**
  17127. * Add mouse input support to the input manager.
  17128. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  17129. * @returns the current input manager
  17130. */
  17131. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  17132. /**
  17133. * Removes the mouse input support from the manager
  17134. * @returns the current input manager
  17135. */
  17136. removeMouse(): FreeCameraInputsManager;
  17137. /**
  17138. * Add touch input support to the input manager.
  17139. * @returns the current input manager
  17140. */
  17141. addTouch(): FreeCameraInputsManager;
  17142. /**
  17143. * Remove all attached input methods from a camera
  17144. */
  17145. clear(): void;
  17146. }
  17147. }
  17148. declare module "babylonjs/Cameras/freeCamera" {
  17149. import { Vector3 } from "babylonjs/Maths/math";
  17150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17151. import { Scene } from "babylonjs/scene";
  17152. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17153. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  17154. /**
  17155. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17156. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  17157. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17158. */
  17159. export class FreeCamera extends TargetCamera {
  17160. /**
  17161. * Define the collision ellipsoid of the camera.
  17162. * This is helpful to simulate a camera body like the player body around the camera
  17163. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  17164. */
  17165. ellipsoid: Vector3;
  17166. /**
  17167. * Define an offset for the position of the ellipsoid around the camera.
  17168. * This can be helpful to determine the center of the body near the gravity center of the body
  17169. * instead of its head.
  17170. */
  17171. ellipsoidOffset: Vector3;
  17172. /**
  17173. * Enable or disable collisions of the camera with the rest of the scene objects.
  17174. */
  17175. checkCollisions: boolean;
  17176. /**
  17177. * Enable or disable gravity on the camera.
  17178. */
  17179. applyGravity: boolean;
  17180. /**
  17181. * Define the input manager associated to the camera.
  17182. */
  17183. inputs: FreeCameraInputsManager;
  17184. /**
  17185. * Gets the input sensibility for a mouse input. (default is 2000.0)
  17186. * Higher values reduce sensitivity.
  17187. */
  17188. /**
  17189. * Sets the input sensibility for a mouse input. (default is 2000.0)
  17190. * Higher values reduce sensitivity.
  17191. */
  17192. angularSensibility: number;
  17193. /**
  17194. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  17195. */
  17196. keysUp: number[];
  17197. /**
  17198. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  17199. */
  17200. keysDown: number[];
  17201. /**
  17202. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  17203. */
  17204. keysLeft: number[];
  17205. /**
  17206. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  17207. */
  17208. keysRight: number[];
  17209. /**
  17210. * Event raised when the camera collide with a mesh in the scene.
  17211. */
  17212. onCollide: (collidedMesh: AbstractMesh) => void;
  17213. private _collider;
  17214. private _needMoveForGravity;
  17215. private _oldPosition;
  17216. private _diffPosition;
  17217. private _newPosition;
  17218. /** @hidden */
  17219. _localDirection: Vector3;
  17220. /** @hidden */
  17221. _transformedDirection: Vector3;
  17222. /**
  17223. * Instantiates a Free Camera.
  17224. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17225. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  17226. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17227. * @param name Define the name of the camera in the scene
  17228. * @param position Define the start position of the camera in the scene
  17229. * @param scene Define the scene the camera belongs to
  17230. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  17231. */
  17232. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  17233. /**
  17234. * Attached controls to the current camera.
  17235. * @param element Defines the element the controls should be listened from
  17236. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17237. */
  17238. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17239. /**
  17240. * Detach the current controls from the camera.
  17241. * The camera will stop reacting to inputs.
  17242. * @param element Defines the element to stop listening the inputs from
  17243. */
  17244. detachControl(element: HTMLElement): void;
  17245. private _collisionMask;
  17246. /**
  17247. * Define a collision mask to limit the list of object the camera can collide with
  17248. */
  17249. collisionMask: number;
  17250. /** @hidden */
  17251. _collideWithWorld(displacement: Vector3): void;
  17252. private _onCollisionPositionChange;
  17253. /** @hidden */
  17254. _checkInputs(): void;
  17255. /** @hidden */
  17256. _decideIfNeedsToMove(): boolean;
  17257. /** @hidden */
  17258. _updatePosition(): void;
  17259. /**
  17260. * Destroy the camera and release the current resources hold by it.
  17261. */
  17262. dispose(): void;
  17263. /**
  17264. * Gets the current object class name.
  17265. * @return the class name
  17266. */
  17267. getClassName(): string;
  17268. }
  17269. }
  17270. declare module "babylonjs/Gamepads/gamepad" {
  17271. import { Observable } from "babylonjs/Misc/observable";
  17272. /**
  17273. * Represents a gamepad control stick position
  17274. */
  17275. export class StickValues {
  17276. /**
  17277. * The x component of the control stick
  17278. */
  17279. x: number;
  17280. /**
  17281. * The y component of the control stick
  17282. */
  17283. y: number;
  17284. /**
  17285. * Initializes the gamepad x and y control stick values
  17286. * @param x The x component of the gamepad control stick value
  17287. * @param y The y component of the gamepad control stick value
  17288. */
  17289. constructor(
  17290. /**
  17291. * The x component of the control stick
  17292. */
  17293. x: number,
  17294. /**
  17295. * The y component of the control stick
  17296. */
  17297. y: number);
  17298. }
  17299. /**
  17300. * An interface which manages callbacks for gamepad button changes
  17301. */
  17302. export interface GamepadButtonChanges {
  17303. /**
  17304. * Called when a gamepad has been changed
  17305. */
  17306. changed: boolean;
  17307. /**
  17308. * Called when a gamepad press event has been triggered
  17309. */
  17310. pressChanged: boolean;
  17311. /**
  17312. * Called when a touch event has been triggered
  17313. */
  17314. touchChanged: boolean;
  17315. /**
  17316. * Called when a value has changed
  17317. */
  17318. valueChanged: boolean;
  17319. }
  17320. /**
  17321. * Represents a gamepad
  17322. */
  17323. export class Gamepad {
  17324. /**
  17325. * The id of the gamepad
  17326. */
  17327. id: string;
  17328. /**
  17329. * The index of the gamepad
  17330. */
  17331. index: number;
  17332. /**
  17333. * The browser gamepad
  17334. */
  17335. browserGamepad: any;
  17336. /**
  17337. * Specifies what type of gamepad this represents
  17338. */
  17339. type: number;
  17340. private _leftStick;
  17341. private _rightStick;
  17342. /** @hidden */
  17343. _isConnected: boolean;
  17344. private _leftStickAxisX;
  17345. private _leftStickAxisY;
  17346. private _rightStickAxisX;
  17347. private _rightStickAxisY;
  17348. /**
  17349. * Triggered when the left control stick has been changed
  17350. */
  17351. private _onleftstickchanged;
  17352. /**
  17353. * Triggered when the right control stick has been changed
  17354. */
  17355. private _onrightstickchanged;
  17356. /**
  17357. * Represents a gamepad controller
  17358. */
  17359. static GAMEPAD: number;
  17360. /**
  17361. * Represents a generic controller
  17362. */
  17363. static GENERIC: number;
  17364. /**
  17365. * Represents an XBox controller
  17366. */
  17367. static XBOX: number;
  17368. /**
  17369. * Represents a pose-enabled controller
  17370. */
  17371. static POSE_ENABLED: number;
  17372. /**
  17373. * Specifies whether the left control stick should be Y-inverted
  17374. */
  17375. protected _invertLeftStickY: boolean;
  17376. /**
  17377. * Specifies if the gamepad has been connected
  17378. */
  17379. readonly isConnected: boolean;
  17380. /**
  17381. * Initializes the gamepad
  17382. * @param id The id of the gamepad
  17383. * @param index The index of the gamepad
  17384. * @param browserGamepad The browser gamepad
  17385. * @param leftStickX The x component of the left joystick
  17386. * @param leftStickY The y component of the left joystick
  17387. * @param rightStickX The x component of the right joystick
  17388. * @param rightStickY The y component of the right joystick
  17389. */
  17390. constructor(
  17391. /**
  17392. * The id of the gamepad
  17393. */
  17394. id: string,
  17395. /**
  17396. * The index of the gamepad
  17397. */
  17398. index: number,
  17399. /**
  17400. * The browser gamepad
  17401. */
  17402. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  17403. /**
  17404. * Callback triggered when the left joystick has changed
  17405. * @param callback
  17406. */
  17407. onleftstickchanged(callback: (values: StickValues) => void): void;
  17408. /**
  17409. * Callback triggered when the right joystick has changed
  17410. * @param callback
  17411. */
  17412. onrightstickchanged(callback: (values: StickValues) => void): void;
  17413. /**
  17414. * Gets the left joystick
  17415. */
  17416. /**
  17417. * Sets the left joystick values
  17418. */
  17419. leftStick: StickValues;
  17420. /**
  17421. * Gets the right joystick
  17422. */
  17423. /**
  17424. * Sets the right joystick value
  17425. */
  17426. rightStick: StickValues;
  17427. /**
  17428. * Updates the gamepad joystick positions
  17429. */
  17430. update(): void;
  17431. /**
  17432. * Disposes the gamepad
  17433. */
  17434. dispose(): void;
  17435. }
  17436. /**
  17437. * Represents a generic gamepad
  17438. */
  17439. export class GenericPad extends Gamepad {
  17440. private _buttons;
  17441. private _onbuttondown;
  17442. private _onbuttonup;
  17443. /**
  17444. * Observable triggered when a button has been pressed
  17445. */
  17446. onButtonDownObservable: Observable<number>;
  17447. /**
  17448. * Observable triggered when a button has been released
  17449. */
  17450. onButtonUpObservable: Observable<number>;
  17451. /**
  17452. * Callback triggered when a button has been pressed
  17453. * @param callback Called when a button has been pressed
  17454. */
  17455. onbuttondown(callback: (buttonPressed: number) => void): void;
  17456. /**
  17457. * Callback triggered when a button has been released
  17458. * @param callback Called when a button has been released
  17459. */
  17460. onbuttonup(callback: (buttonReleased: number) => void): void;
  17461. /**
  17462. * Initializes the generic gamepad
  17463. * @param id The id of the generic gamepad
  17464. * @param index The index of the generic gamepad
  17465. * @param browserGamepad The browser gamepad
  17466. */
  17467. constructor(id: string, index: number, browserGamepad: any);
  17468. private _setButtonValue;
  17469. /**
  17470. * Updates the generic gamepad
  17471. */
  17472. update(): void;
  17473. /**
  17474. * Disposes the generic gamepad
  17475. */
  17476. dispose(): void;
  17477. }
  17478. }
  17479. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  17480. import { Observable } from "babylonjs/Misc/observable";
  17481. import { Nullable } from "babylonjs/types";
  17482. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  17483. import { TransformNode } from "babylonjs/Meshes/transformNode";
  17484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17485. import { Ray } from "babylonjs/Culling/ray";
  17486. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  17487. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  17488. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17489. /**
  17490. * Defines the types of pose enabled controllers that are supported
  17491. */
  17492. export enum PoseEnabledControllerType {
  17493. /**
  17494. * HTC Vive
  17495. */
  17496. VIVE = 0,
  17497. /**
  17498. * Oculus Rift
  17499. */
  17500. OCULUS = 1,
  17501. /**
  17502. * Windows mixed reality
  17503. */
  17504. WINDOWS = 2,
  17505. /**
  17506. * Samsung gear VR
  17507. */
  17508. GEAR_VR = 3,
  17509. /**
  17510. * Google Daydream
  17511. */
  17512. DAYDREAM = 4,
  17513. /**
  17514. * Generic
  17515. */
  17516. GENERIC = 5
  17517. }
  17518. /**
  17519. * Defines the MutableGamepadButton interface for the state of a gamepad button
  17520. */
  17521. export interface MutableGamepadButton {
  17522. /**
  17523. * Value of the button/trigger
  17524. */
  17525. value: number;
  17526. /**
  17527. * If the button/trigger is currently touched
  17528. */
  17529. touched: boolean;
  17530. /**
  17531. * If the button/trigger is currently pressed
  17532. */
  17533. pressed: boolean;
  17534. }
  17535. /**
  17536. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  17537. * @hidden
  17538. */
  17539. export interface ExtendedGamepadButton extends GamepadButton {
  17540. /**
  17541. * If the button/trigger is currently pressed
  17542. */
  17543. readonly pressed: boolean;
  17544. /**
  17545. * If the button/trigger is currently touched
  17546. */
  17547. readonly touched: boolean;
  17548. /**
  17549. * Value of the button/trigger
  17550. */
  17551. readonly value: number;
  17552. }
  17553. /** @hidden */
  17554. export interface _GamePadFactory {
  17555. /**
  17556. * Returns wether or not the current gamepad can be created for this type of controller.
  17557. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17558. * @returns true if it can be created, otherwise false
  17559. */
  17560. canCreate(gamepadInfo: any): boolean;
  17561. /**
  17562. * Creates a new instance of the Gamepad.
  17563. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17564. * @returns the new gamepad instance
  17565. */
  17566. create(gamepadInfo: any): Gamepad;
  17567. }
  17568. /**
  17569. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17570. */
  17571. export class PoseEnabledControllerHelper {
  17572. /** @hidden */
  17573. static _ControllerFactories: _GamePadFactory[];
  17574. /** @hidden */
  17575. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  17576. /**
  17577. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17578. * @param vrGamepad the gamepad to initialized
  17579. * @returns a vr controller of the type the gamepad identified as
  17580. */
  17581. static InitiateController(vrGamepad: any): Gamepad;
  17582. }
  17583. /**
  17584. * Defines the PoseEnabledController object that contains state of a vr capable controller
  17585. */
  17586. export class PoseEnabledController extends Gamepad implements PoseControlled {
  17587. /**
  17588. * If the controller is used in a webXR session
  17589. */
  17590. isXR: boolean;
  17591. private _deviceRoomPosition;
  17592. private _deviceRoomRotationQuaternion;
  17593. /**
  17594. * The device position in babylon space
  17595. */
  17596. devicePosition: Vector3;
  17597. /**
  17598. * The device rotation in babylon space
  17599. */
  17600. deviceRotationQuaternion: Quaternion;
  17601. /**
  17602. * The scale factor of the device in babylon space
  17603. */
  17604. deviceScaleFactor: number;
  17605. /**
  17606. * (Likely devicePosition should be used instead) The device position in its room space
  17607. */
  17608. position: Vector3;
  17609. /**
  17610. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  17611. */
  17612. rotationQuaternion: Quaternion;
  17613. /**
  17614. * The type of controller (Eg. Windows mixed reality)
  17615. */
  17616. controllerType: PoseEnabledControllerType;
  17617. protected _calculatedPosition: Vector3;
  17618. private _calculatedRotation;
  17619. /**
  17620. * The raw pose from the device
  17621. */
  17622. rawPose: DevicePose;
  17623. private _trackPosition;
  17624. private _maxRotationDistFromHeadset;
  17625. private _draggedRoomRotation;
  17626. /**
  17627. * @hidden
  17628. */
  17629. _disableTrackPosition(fixedPosition: Vector3): void;
  17630. /**
  17631. * Internal, the mesh attached to the controller
  17632. * @hidden
  17633. */
  17634. _mesh: Nullable<AbstractMesh>;
  17635. private _poseControlledCamera;
  17636. private _leftHandSystemQuaternion;
  17637. /**
  17638. * Internal, matrix used to convert room space to babylon space
  17639. * @hidden
  17640. */
  17641. _deviceToWorld: Matrix;
  17642. /**
  17643. * Node to be used when casting a ray from the controller
  17644. * @hidden
  17645. */
  17646. _pointingPoseNode: Nullable<TransformNode>;
  17647. /**
  17648. * Name of the child mesh that can be used to cast a ray from the controller
  17649. */
  17650. static readonly POINTING_POSE: string;
  17651. /**
  17652. * Creates a new PoseEnabledController from a gamepad
  17653. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  17654. */
  17655. constructor(browserGamepad: any);
  17656. private _workingMatrix;
  17657. /**
  17658. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  17659. */
  17660. update(): void;
  17661. /**
  17662. * Updates only the pose device and mesh without doing any button event checking
  17663. */
  17664. protected _updatePoseAndMesh(): void;
  17665. /**
  17666. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  17667. * @param poseData raw pose fromthe device
  17668. */
  17669. updateFromDevice(poseData: DevicePose): void;
  17670. /**
  17671. * @hidden
  17672. */
  17673. _meshAttachedObservable: Observable<AbstractMesh>;
  17674. /**
  17675. * Attaches a mesh to the controller
  17676. * @param mesh the mesh to be attached
  17677. */
  17678. attachToMesh(mesh: AbstractMesh): void;
  17679. /**
  17680. * Attaches the controllers mesh to a camera
  17681. * @param camera the camera the mesh should be attached to
  17682. */
  17683. attachToPoseControlledCamera(camera: TargetCamera): void;
  17684. /**
  17685. * Disposes of the controller
  17686. */
  17687. dispose(): void;
  17688. /**
  17689. * The mesh that is attached to the controller
  17690. */
  17691. readonly mesh: Nullable<AbstractMesh>;
  17692. /**
  17693. * Gets the ray of the controller in the direction the controller is pointing
  17694. * @param length the length the resulting ray should be
  17695. * @returns a ray in the direction the controller is pointing
  17696. */
  17697. getForwardRay(length?: number): Ray;
  17698. }
  17699. }
  17700. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  17701. import { Observable } from "babylonjs/Misc/observable";
  17702. import { Scene } from "babylonjs/scene";
  17703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17704. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  17705. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  17706. /**
  17707. * Defines the WebVRController object that represents controllers tracked in 3D space
  17708. */
  17709. export abstract class WebVRController extends PoseEnabledController {
  17710. /**
  17711. * Internal, the default controller model for the controller
  17712. */
  17713. protected _defaultModel: AbstractMesh;
  17714. /**
  17715. * Fired when the trigger state has changed
  17716. */
  17717. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17718. /**
  17719. * Fired when the main button state has changed
  17720. */
  17721. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17722. /**
  17723. * Fired when the secondary button state has changed
  17724. */
  17725. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17726. /**
  17727. * Fired when the pad state has changed
  17728. */
  17729. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17730. /**
  17731. * Fired when controllers stick values have changed
  17732. */
  17733. onPadValuesChangedObservable: Observable<StickValues>;
  17734. /**
  17735. * Array of button availible on the controller
  17736. */
  17737. protected _buttons: Array<MutableGamepadButton>;
  17738. private _onButtonStateChange;
  17739. /**
  17740. * Fired when a controller button's state has changed
  17741. * @param callback the callback containing the button that was modified
  17742. */
  17743. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17744. /**
  17745. * X and Y axis corresponding to the controllers joystick
  17746. */
  17747. pad: StickValues;
  17748. /**
  17749. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17750. */
  17751. hand: string;
  17752. /**
  17753. * The default controller model for the controller
  17754. */
  17755. readonly defaultModel: AbstractMesh;
  17756. /**
  17757. * Creates a new WebVRController from a gamepad
  17758. * @param vrGamepad the gamepad that the WebVRController should be created from
  17759. */
  17760. constructor(vrGamepad: any);
  17761. /**
  17762. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17763. */
  17764. update(): void;
  17765. /**
  17766. * Function to be called when a button is modified
  17767. */
  17768. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17769. /**
  17770. * Loads a mesh and attaches it to the controller
  17771. * @param scene the scene the mesh should be added to
  17772. * @param meshLoaded callback for when the mesh has been loaded
  17773. */
  17774. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17775. private _setButtonValue;
  17776. private _changes;
  17777. private _checkChanges;
  17778. /**
  17779. * Disposes of th webVRCOntroller
  17780. */
  17781. dispose(): void;
  17782. }
  17783. }
  17784. declare module "babylonjs/Lights/hemisphericLight" {
  17785. import { Nullable } from "babylonjs/types";
  17786. import { Scene } from "babylonjs/scene";
  17787. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  17788. import { Effect } from "babylonjs/Materials/effect";
  17789. import { Light } from "babylonjs/Lights/light";
  17790. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17791. /**
  17792. * The HemisphericLight simulates the ambient environment light,
  17793. * so the passed direction is the light reflection direction, not the incoming direction.
  17794. */
  17795. export class HemisphericLight extends Light {
  17796. /**
  17797. * The groundColor is the light in the opposite direction to the one specified during creation.
  17798. * 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.
  17799. */
  17800. groundColor: Color3;
  17801. /**
  17802. * The light reflection direction, not the incoming direction.
  17803. */
  17804. direction: Vector3;
  17805. /**
  17806. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17807. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17808. * The HemisphericLight can't cast shadows.
  17809. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17810. * @param name The friendly name of the light
  17811. * @param direction The direction of the light reflection
  17812. * @param scene The scene the light belongs to
  17813. */
  17814. constructor(name: string, direction: Vector3, scene: Scene);
  17815. protected _buildUniformLayout(): void;
  17816. /**
  17817. * Returns the string "HemisphericLight".
  17818. * @return The class name
  17819. */
  17820. getClassName(): string;
  17821. /**
  17822. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17823. * Returns the updated direction.
  17824. * @param target The target the direction should point to
  17825. * @return The computed direction
  17826. */
  17827. setDirectionToTarget(target: Vector3): Vector3;
  17828. /**
  17829. * Returns the shadow generator associated to the light.
  17830. * @returns Always null for hemispheric lights because it does not support shadows.
  17831. */
  17832. getShadowGenerator(): Nullable<IShadowGenerator>;
  17833. /**
  17834. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17835. * @param effect The effect to update
  17836. * @param lightIndex The index of the light in the effect to update
  17837. * @returns The hemispheric light
  17838. */
  17839. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17840. /**
  17841. * Computes the world matrix of the node
  17842. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17843. * @param useWasUpdatedFlag defines a reserved property
  17844. * @returns the world matrix
  17845. */
  17846. computeWorldMatrix(): Matrix;
  17847. /**
  17848. * Returns the integer 3.
  17849. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17850. */
  17851. getTypeID(): number;
  17852. /**
  17853. * Prepares the list of defines specific to the light type.
  17854. * @param defines the list of defines
  17855. * @param lightIndex defines the index of the light for the effect
  17856. */
  17857. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17858. }
  17859. }
  17860. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  17861. /** @hidden */
  17862. export var vrMultiviewToSingleviewPixelShader: {
  17863. name: string;
  17864. shader: string;
  17865. };
  17866. }
  17867. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  17868. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17869. import { Scene } from "babylonjs/scene";
  17870. /**
  17871. * Renders to multiple views with a single draw call
  17872. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17873. */
  17874. export class MultiviewRenderTarget extends RenderTargetTexture {
  17875. /**
  17876. * Creates a multiview render target
  17877. * @param scene scene used with the render target
  17878. * @param size the size of the render target (used for each view)
  17879. */
  17880. constructor(scene: Scene, size?: number | {
  17881. width: number;
  17882. height: number;
  17883. } | {
  17884. ratio: number;
  17885. });
  17886. /**
  17887. * @hidden
  17888. * @param faceIndex the face index, if its a cube texture
  17889. */
  17890. _bindFrameBuffer(faceIndex?: number): void;
  17891. /**
  17892. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17893. * @returns the view count
  17894. */
  17895. getViewCount(): number;
  17896. }
  17897. }
  17898. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  17899. import { Camera } from "babylonjs/Cameras/camera";
  17900. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17901. import { Nullable } from "babylonjs/types";
  17902. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17903. import { Matrix } from "babylonjs/Maths/math";
  17904. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17905. module "babylonjs/Engines/engine" {
  17906. interface Engine {
  17907. /**
  17908. * Creates a new multiview render target
  17909. * @param width defines the width of the texture
  17910. * @param height defines the height of the texture
  17911. * @returns the created multiview texture
  17912. */
  17913. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17914. /**
  17915. * Binds a multiview framebuffer to be drawn to
  17916. * @param multiviewTexture texture to bind
  17917. */
  17918. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17919. }
  17920. }
  17921. module "babylonjs/Cameras/camera" {
  17922. interface Camera {
  17923. /**
  17924. * @hidden
  17925. * 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)
  17926. */
  17927. _useMultiviewToSingleView: boolean;
  17928. /**
  17929. * @hidden
  17930. * 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)
  17931. */
  17932. _multiviewTexture: Nullable<RenderTargetTexture>;
  17933. /**
  17934. * @hidden
  17935. * ensures the multiview texture of the camera exists and has the specified width/height
  17936. * @param width height to set on the multiview texture
  17937. * @param height width to set on the multiview texture
  17938. */
  17939. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17940. }
  17941. }
  17942. module "babylonjs/scene" {
  17943. interface Scene {
  17944. /** @hidden */
  17945. _transformMatrixR: Matrix;
  17946. /** @hidden */
  17947. _multiviewSceneUbo: Nullable<UniformBuffer>;
  17948. /** @hidden */
  17949. _createMultiviewUbo(): void;
  17950. /** @hidden */
  17951. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17952. /** @hidden */
  17953. _renderMultiviewToSingleView(camera: Camera): void;
  17954. }
  17955. }
  17956. }
  17957. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  17958. import { Camera } from "babylonjs/Cameras/camera";
  17959. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17960. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  17961. import "babylonjs/Engines/Extensions/engine.multiview";
  17962. /**
  17963. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17964. * This will not be used for webXR as it supports displaying texture arrays directly
  17965. */
  17966. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17967. /**
  17968. * Initializes a VRMultiviewToSingleview
  17969. * @param name name of the post process
  17970. * @param camera camera to be applied to
  17971. * @param scaleFactor scaling factor to the size of the output texture
  17972. */
  17973. constructor(name: string, camera: Camera, scaleFactor: number);
  17974. }
  17975. }
  17976. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  17977. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  17978. import { Nullable } from "babylonjs/types";
  17979. import { Size } from "babylonjs/Maths/math";
  17980. import { Observable } from "babylonjs/Misc/observable";
  17981. module "babylonjs/Engines/engine" {
  17982. interface Engine {
  17983. /** @hidden */
  17984. _vrDisplay: any;
  17985. /** @hidden */
  17986. _vrSupported: boolean;
  17987. /** @hidden */
  17988. _oldSize: Size;
  17989. /** @hidden */
  17990. _oldHardwareScaleFactor: number;
  17991. /** @hidden */
  17992. _vrExclusivePointerMode: boolean;
  17993. /** @hidden */
  17994. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17995. /** @hidden */
  17996. _onVRDisplayPointerRestricted: () => void;
  17997. /** @hidden */
  17998. _onVRDisplayPointerUnrestricted: () => void;
  17999. /** @hidden */
  18000. _onVrDisplayConnect: Nullable<(display: any) => void>;
  18001. /** @hidden */
  18002. _onVrDisplayDisconnect: Nullable<() => void>;
  18003. /** @hidden */
  18004. _onVrDisplayPresentChange: Nullable<() => void>;
  18005. /**
  18006. * Observable signaled when VR display mode changes
  18007. */
  18008. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  18009. /**
  18010. * Observable signaled when VR request present is complete
  18011. */
  18012. onVRRequestPresentComplete: Observable<boolean>;
  18013. /**
  18014. * Observable signaled when VR request present starts
  18015. */
  18016. onVRRequestPresentStart: Observable<Engine>;
  18017. /**
  18018. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  18019. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  18020. */
  18021. isInVRExclusivePointerMode: boolean;
  18022. /**
  18023. * Gets a boolean indicating if a webVR device was detected
  18024. * @returns true if a webVR device was detected
  18025. */
  18026. isVRDevicePresent(): boolean;
  18027. /**
  18028. * Gets the current webVR device
  18029. * @returns the current webVR device (or null)
  18030. */
  18031. getVRDevice(): any;
  18032. /**
  18033. * Initializes a webVR display and starts listening to display change events
  18034. * The onVRDisplayChangedObservable will be notified upon these changes
  18035. * @returns A promise containing a VRDisplay and if vr is supported
  18036. */
  18037. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  18038. /** @hidden */
  18039. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  18040. /**
  18041. * Call this function to switch to webVR mode
  18042. * Will do nothing if webVR is not supported or if there is no webVR device
  18043. * @see http://doc.babylonjs.com/how_to/webvr_camera
  18044. */
  18045. enableVR(): void;
  18046. /** @hidden */
  18047. _onVRFullScreenTriggered(): void;
  18048. }
  18049. }
  18050. }
  18051. declare module "babylonjs/Cameras/VR/webVRCamera" {
  18052. import { Nullable } from "babylonjs/types";
  18053. import { Observable } from "babylonjs/Misc/observable";
  18054. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18055. import { Scene } from "babylonjs/scene";
  18056. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  18057. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  18058. import { Node } from "babylonjs/node";
  18059. import { Ray } from "babylonjs/Culling/ray";
  18060. import "babylonjs/Cameras/RigModes/webVRRigMode";
  18061. import "babylonjs/Engines/Extensions/engine.webVR";
  18062. /**
  18063. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  18064. * IMPORTANT!! The data is right-hand data.
  18065. * @export
  18066. * @interface DevicePose
  18067. */
  18068. export interface DevicePose {
  18069. /**
  18070. * The position of the device, values in array are [x,y,z].
  18071. */
  18072. readonly position: Nullable<Float32Array>;
  18073. /**
  18074. * The linearVelocity of the device, values in array are [x,y,z].
  18075. */
  18076. readonly linearVelocity: Nullable<Float32Array>;
  18077. /**
  18078. * The linearAcceleration of the device, values in array are [x,y,z].
  18079. */
  18080. readonly linearAcceleration: Nullable<Float32Array>;
  18081. /**
  18082. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  18083. */
  18084. readonly orientation: Nullable<Float32Array>;
  18085. /**
  18086. * The angularVelocity of the device, values in array are [x,y,z].
  18087. */
  18088. readonly angularVelocity: Nullable<Float32Array>;
  18089. /**
  18090. * The angularAcceleration of the device, values in array are [x,y,z].
  18091. */
  18092. readonly angularAcceleration: Nullable<Float32Array>;
  18093. }
  18094. /**
  18095. * Interface representing a pose controlled object in Babylon.
  18096. * A pose controlled object has both regular pose values as well as pose values
  18097. * from an external device such as a VR head mounted display
  18098. */
  18099. export interface PoseControlled {
  18100. /**
  18101. * The position of the object in babylon space.
  18102. */
  18103. position: Vector3;
  18104. /**
  18105. * The rotation quaternion of the object in babylon space.
  18106. */
  18107. rotationQuaternion: Quaternion;
  18108. /**
  18109. * The position of the device in babylon space.
  18110. */
  18111. devicePosition?: Vector3;
  18112. /**
  18113. * The rotation quaternion of the device in babylon space.
  18114. */
  18115. deviceRotationQuaternion: Quaternion;
  18116. /**
  18117. * The raw pose coming from the device.
  18118. */
  18119. rawPose: Nullable<DevicePose>;
  18120. /**
  18121. * The scale of the device to be used when translating from device space to babylon space.
  18122. */
  18123. deviceScaleFactor: number;
  18124. /**
  18125. * Updates the poseControlled values based on the input device pose.
  18126. * @param poseData the pose data to update the object with
  18127. */
  18128. updateFromDevice(poseData: DevicePose): void;
  18129. }
  18130. /**
  18131. * Set of options to customize the webVRCamera
  18132. */
  18133. export interface WebVROptions {
  18134. /**
  18135. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  18136. */
  18137. trackPosition?: boolean;
  18138. /**
  18139. * Sets the scale of the vrDevice in babylon space. (default: 1)
  18140. */
  18141. positionScale?: number;
  18142. /**
  18143. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  18144. */
  18145. displayName?: string;
  18146. /**
  18147. * Should the native controller meshes be initialized. (default: true)
  18148. */
  18149. controllerMeshes?: boolean;
  18150. /**
  18151. * Creating a default HemiLight only on controllers. (default: true)
  18152. */
  18153. defaultLightingOnControllers?: boolean;
  18154. /**
  18155. * If you don't want to use the default VR button of the helper. (default: false)
  18156. */
  18157. useCustomVRButton?: boolean;
  18158. /**
  18159. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  18160. */
  18161. customVRButton?: HTMLButtonElement;
  18162. /**
  18163. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  18164. */
  18165. rayLength?: number;
  18166. /**
  18167. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  18168. */
  18169. defaultHeight?: number;
  18170. /**
  18171. * If multiview should be used if availible (default: false)
  18172. */
  18173. useMultiview?: boolean;
  18174. }
  18175. /**
  18176. * This represents a WebVR camera.
  18177. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  18178. * @example http://doc.babylonjs.com/how_to/webvr_camera
  18179. */
  18180. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  18181. private webVROptions;
  18182. /**
  18183. * @hidden
  18184. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  18185. */
  18186. _vrDevice: any;
  18187. /**
  18188. * The rawPose of the vrDevice.
  18189. */
  18190. rawPose: Nullable<DevicePose>;
  18191. private _onVREnabled;
  18192. private _specsVersion;
  18193. private _attached;
  18194. private _frameData;
  18195. protected _descendants: Array<Node>;
  18196. private _deviceRoomPosition;
  18197. /** @hidden */
  18198. _deviceRoomRotationQuaternion: Quaternion;
  18199. private _standingMatrix;
  18200. /**
  18201. * Represents device position in babylon space.
  18202. */
  18203. devicePosition: Vector3;
  18204. /**
  18205. * Represents device rotation in babylon space.
  18206. */
  18207. deviceRotationQuaternion: Quaternion;
  18208. /**
  18209. * The scale of the device to be used when translating from device space to babylon space.
  18210. */
  18211. deviceScaleFactor: number;
  18212. private _deviceToWorld;
  18213. private _worldToDevice;
  18214. /**
  18215. * References to the webVR controllers for the vrDevice.
  18216. */
  18217. controllers: Array<WebVRController>;
  18218. /**
  18219. * Emits an event when a controller is attached.
  18220. */
  18221. onControllersAttachedObservable: Observable<WebVRController[]>;
  18222. /**
  18223. * Emits an event when a controller's mesh has been loaded;
  18224. */
  18225. onControllerMeshLoadedObservable: Observable<WebVRController>;
  18226. /**
  18227. * Emits an event when the HMD's pose has been updated.
  18228. */
  18229. onPoseUpdatedFromDeviceObservable: Observable<any>;
  18230. private _poseSet;
  18231. /**
  18232. * If the rig cameras be used as parent instead of this camera.
  18233. */
  18234. rigParenting: boolean;
  18235. private _lightOnControllers;
  18236. private _defaultHeight?;
  18237. /**
  18238. * Instantiates a WebVRFreeCamera.
  18239. * @param name The name of the WebVRFreeCamera
  18240. * @param position The starting anchor position for the camera
  18241. * @param scene The scene the camera belongs to
  18242. * @param webVROptions a set of customizable options for the webVRCamera
  18243. */
  18244. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  18245. /**
  18246. * Gets the device distance from the ground in meters.
  18247. * @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.
  18248. */
  18249. deviceDistanceToRoomGround(): number;
  18250. /**
  18251. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18252. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  18253. */
  18254. useStandingMatrix(callback?: (bool: boolean) => void): void;
  18255. /**
  18256. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18257. * @returns A promise with a boolean set to if the standing matrix is supported.
  18258. */
  18259. useStandingMatrixAsync(): Promise<boolean>;
  18260. /**
  18261. * Disposes the camera
  18262. */
  18263. dispose(): void;
  18264. /**
  18265. * Gets a vrController by name.
  18266. * @param name The name of the controller to retreive
  18267. * @returns the controller matching the name specified or null if not found
  18268. */
  18269. getControllerByName(name: string): Nullable<WebVRController>;
  18270. private _leftController;
  18271. /**
  18272. * The controller corresponding to the users left hand.
  18273. */
  18274. readonly leftController: Nullable<WebVRController>;
  18275. private _rightController;
  18276. /**
  18277. * The controller corresponding to the users right hand.
  18278. */
  18279. readonly rightController: Nullable<WebVRController>;
  18280. /**
  18281. * Casts a ray forward from the vrCamera's gaze.
  18282. * @param length Length of the ray (default: 100)
  18283. * @returns the ray corresponding to the gaze
  18284. */
  18285. getForwardRay(length?: number): Ray;
  18286. /**
  18287. * @hidden
  18288. * Updates the camera based on device's frame data
  18289. */
  18290. _checkInputs(): void;
  18291. /**
  18292. * Updates the poseControlled values based on the input device pose.
  18293. * @param poseData Pose coming from the device
  18294. */
  18295. updateFromDevice(poseData: DevicePose): void;
  18296. private _htmlElementAttached;
  18297. private _detachIfAttached;
  18298. /**
  18299. * WebVR's attach control will start broadcasting frames to the device.
  18300. * Note that in certain browsers (chrome for example) this function must be called
  18301. * within a user-interaction callback. Example:
  18302. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18303. *
  18304. * @param element html element to attach the vrDevice to
  18305. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18306. */
  18307. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18308. /**
  18309. * Detaches the camera from the html element and disables VR
  18310. *
  18311. * @param element html element to detach from
  18312. */
  18313. detachControl(element: HTMLElement): void;
  18314. /**
  18315. * @returns the name of this class
  18316. */
  18317. getClassName(): string;
  18318. /**
  18319. * Calls resetPose on the vrDisplay
  18320. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18321. */
  18322. resetToCurrentRotation(): void;
  18323. /**
  18324. * @hidden
  18325. * Updates the rig cameras (left and right eye)
  18326. */
  18327. _updateRigCameras(): void;
  18328. private _workingVector;
  18329. private _oneVector;
  18330. private _workingMatrix;
  18331. private updateCacheCalled;
  18332. private _correctPositionIfNotTrackPosition;
  18333. /**
  18334. * @hidden
  18335. * Updates the cached values of the camera
  18336. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18337. */
  18338. _updateCache(ignoreParentClass?: boolean): void;
  18339. /**
  18340. * @hidden
  18341. * Get current device position in babylon world
  18342. */
  18343. _computeDevicePosition(): void;
  18344. /**
  18345. * Updates the current device position and rotation in the babylon world
  18346. */
  18347. update(): void;
  18348. /**
  18349. * @hidden
  18350. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18351. * @returns an identity matrix
  18352. */
  18353. _getViewMatrix(): Matrix;
  18354. private _tmpMatrix;
  18355. /**
  18356. * This function is called by the two RIG cameras.
  18357. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18358. * @hidden
  18359. */
  18360. _getWebVRViewMatrix(): Matrix;
  18361. /** @hidden */
  18362. _getWebVRProjectionMatrix(): Matrix;
  18363. private _onGamepadConnectedObserver;
  18364. private _onGamepadDisconnectedObserver;
  18365. private _updateCacheWhenTrackingDisabledObserver;
  18366. /**
  18367. * Initializes the controllers and their meshes
  18368. */
  18369. initControllers(): void;
  18370. }
  18371. }
  18372. declare module "babylonjs/PostProcesses/postProcess" {
  18373. import { Nullable } from "babylonjs/types";
  18374. import { SmartArray } from "babylonjs/Misc/smartArray";
  18375. import { Observable } from "babylonjs/Misc/observable";
  18376. import { Color4, Vector2 } from "babylonjs/Maths/math";
  18377. import { Camera } from "babylonjs/Cameras/camera";
  18378. import { Effect } from "babylonjs/Materials/effect";
  18379. import "babylonjs/Shaders/postprocess.vertex";
  18380. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18381. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18382. import { Engine } from "babylonjs/Engines/engine";
  18383. /**
  18384. * Size options for a post process
  18385. */
  18386. export type PostProcessOptions = {
  18387. width: number;
  18388. height: number;
  18389. };
  18390. /**
  18391. * PostProcess can be used to apply a shader to a texture after it has been rendered
  18392. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18393. */
  18394. export class PostProcess {
  18395. /** Name of the PostProcess. */
  18396. name: string;
  18397. /**
  18398. * Gets or sets the unique id of the post process
  18399. */
  18400. uniqueId: number;
  18401. /**
  18402. * Width of the texture to apply the post process on
  18403. */
  18404. width: number;
  18405. /**
  18406. * Height of the texture to apply the post process on
  18407. */
  18408. height: number;
  18409. /**
  18410. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  18411. * @hidden
  18412. */
  18413. _outputTexture: Nullable<InternalTexture>;
  18414. /**
  18415. * Sampling mode used by the shader
  18416. * See https://doc.babylonjs.com/classes/3.1/texture
  18417. */
  18418. renderTargetSamplingMode: number;
  18419. /**
  18420. * Clear color to use when screen clearing
  18421. */
  18422. clearColor: Color4;
  18423. /**
  18424. * If the buffer needs to be cleared before applying the post process. (default: true)
  18425. * Should be set to false if shader will overwrite all previous pixels.
  18426. */
  18427. autoClear: boolean;
  18428. /**
  18429. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  18430. */
  18431. alphaMode: number;
  18432. /**
  18433. * Sets the setAlphaBlendConstants of the babylon engine
  18434. */
  18435. alphaConstants: Color4;
  18436. /**
  18437. * Animations to be used for the post processing
  18438. */
  18439. animations: import("babylonjs/Animations/animation").Animation[];
  18440. /**
  18441. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  18442. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  18443. */
  18444. enablePixelPerfectMode: boolean;
  18445. /**
  18446. * Force the postprocess to be applied without taking in account viewport
  18447. */
  18448. forceFullscreenViewport: boolean;
  18449. /**
  18450. * List of inspectable custom properties (used by the Inspector)
  18451. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18452. */
  18453. inspectableCustomProperties: IInspectable[];
  18454. /**
  18455. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  18456. *
  18457. * | Value | Type | Description |
  18458. * | ----- | ----------------------------------- | ----------- |
  18459. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  18460. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  18461. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  18462. *
  18463. */
  18464. scaleMode: number;
  18465. /**
  18466. * Force textures to be a power of two (default: false)
  18467. */
  18468. alwaysForcePOT: boolean;
  18469. private _samples;
  18470. /**
  18471. * Number of sample textures (default: 1)
  18472. */
  18473. samples: number;
  18474. /**
  18475. * Modify the scale of the post process to be the same as the viewport (default: false)
  18476. */
  18477. adaptScaleToCurrentViewport: boolean;
  18478. private _camera;
  18479. private _scene;
  18480. private _engine;
  18481. private _options;
  18482. private _reusable;
  18483. private _textureType;
  18484. /**
  18485. * Smart array of input and output textures for the post process.
  18486. * @hidden
  18487. */
  18488. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  18489. /**
  18490. * The index in _textures that corresponds to the output texture.
  18491. * @hidden
  18492. */
  18493. _currentRenderTextureInd: number;
  18494. private _effect;
  18495. private _samplers;
  18496. private _fragmentUrl;
  18497. private _vertexUrl;
  18498. private _parameters;
  18499. private _scaleRatio;
  18500. protected _indexParameters: any;
  18501. private _shareOutputWithPostProcess;
  18502. private _texelSize;
  18503. private _forcedOutputTexture;
  18504. /**
  18505. * Returns the fragment url or shader name used in the post process.
  18506. * @returns the fragment url or name in the shader store.
  18507. */
  18508. getEffectName(): string;
  18509. /**
  18510. * An event triggered when the postprocess is activated.
  18511. */
  18512. onActivateObservable: Observable<Camera>;
  18513. private _onActivateObserver;
  18514. /**
  18515. * A function that is added to the onActivateObservable
  18516. */
  18517. onActivate: Nullable<(camera: Camera) => void>;
  18518. /**
  18519. * An event triggered when the postprocess changes its size.
  18520. */
  18521. onSizeChangedObservable: Observable<PostProcess>;
  18522. private _onSizeChangedObserver;
  18523. /**
  18524. * A function that is added to the onSizeChangedObservable
  18525. */
  18526. onSizeChanged: (postProcess: PostProcess) => void;
  18527. /**
  18528. * An event triggered when the postprocess applies its effect.
  18529. */
  18530. onApplyObservable: Observable<Effect>;
  18531. private _onApplyObserver;
  18532. /**
  18533. * A function that is added to the onApplyObservable
  18534. */
  18535. onApply: (effect: Effect) => void;
  18536. /**
  18537. * An event triggered before rendering the postprocess
  18538. */
  18539. onBeforeRenderObservable: Observable<Effect>;
  18540. private _onBeforeRenderObserver;
  18541. /**
  18542. * A function that is added to the onBeforeRenderObservable
  18543. */
  18544. onBeforeRender: (effect: Effect) => void;
  18545. /**
  18546. * An event triggered after rendering the postprocess
  18547. */
  18548. onAfterRenderObservable: Observable<Effect>;
  18549. private _onAfterRenderObserver;
  18550. /**
  18551. * A function that is added to the onAfterRenderObservable
  18552. */
  18553. onAfterRender: (efect: Effect) => void;
  18554. /**
  18555. * 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
  18556. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  18557. */
  18558. inputTexture: InternalTexture;
  18559. /**
  18560. * Gets the camera which post process is applied to.
  18561. * @returns The camera the post process is applied to.
  18562. */
  18563. getCamera(): Camera;
  18564. /**
  18565. * Gets the texel size of the postprocess.
  18566. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  18567. */
  18568. readonly texelSize: Vector2;
  18569. /**
  18570. * Creates a new instance PostProcess
  18571. * @param name The name of the PostProcess.
  18572. * @param fragmentUrl The url of the fragment shader to be used.
  18573. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  18574. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  18575. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18576. * @param camera The camera to apply the render pass to.
  18577. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18578. * @param engine The engine which the post process will be applied. (default: current engine)
  18579. * @param reusable If the post process can be reused on the same frame. (default: false)
  18580. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  18581. * @param textureType Type of textures used when performing the post process. (default: 0)
  18582. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  18583. * @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
  18584. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  18585. */
  18586. constructor(
  18587. /** Name of the PostProcess. */
  18588. 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);
  18589. /**
  18590. * Gets a string idenfifying the name of the class
  18591. * @returns "PostProcess" string
  18592. */
  18593. getClassName(): string;
  18594. /**
  18595. * Gets the engine which this post process belongs to.
  18596. * @returns The engine the post process was enabled with.
  18597. */
  18598. getEngine(): Engine;
  18599. /**
  18600. * The effect that is created when initializing the post process.
  18601. * @returns The created effect corresponding the the postprocess.
  18602. */
  18603. getEffect(): Effect;
  18604. /**
  18605. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  18606. * @param postProcess The post process to share the output with.
  18607. * @returns This post process.
  18608. */
  18609. shareOutputWith(postProcess: PostProcess): PostProcess;
  18610. /**
  18611. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  18612. * This should be called if the post process that shares output with this post process is disabled/disposed.
  18613. */
  18614. useOwnOutput(): void;
  18615. /**
  18616. * Updates the effect with the current post process compile time values and recompiles the shader.
  18617. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18618. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18619. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18620. * @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
  18621. * @param onCompiled Called when the shader has been compiled.
  18622. * @param onError Called if there is an error when compiling a shader.
  18623. */
  18624. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18625. /**
  18626. * The post process is reusable if it can be used multiple times within one frame.
  18627. * @returns If the post process is reusable
  18628. */
  18629. isReusable(): boolean;
  18630. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  18631. markTextureDirty(): void;
  18632. /**
  18633. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  18634. * 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.
  18635. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  18636. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  18637. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  18638. * @returns The target texture that was bound to be written to.
  18639. */
  18640. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  18641. /**
  18642. * If the post process is supported.
  18643. */
  18644. readonly isSupported: boolean;
  18645. /**
  18646. * The aspect ratio of the output texture.
  18647. */
  18648. readonly aspectRatio: number;
  18649. /**
  18650. * Get a value indicating if the post-process is ready to be used
  18651. * @returns true if the post-process is ready (shader is compiled)
  18652. */
  18653. isReady(): boolean;
  18654. /**
  18655. * Binds all textures and uniforms to the shader, this will be run on every pass.
  18656. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  18657. */
  18658. apply(): Nullable<Effect>;
  18659. private _disposeTextures;
  18660. /**
  18661. * Disposes the post process.
  18662. * @param camera The camera to dispose the post process on.
  18663. */
  18664. dispose(camera?: Camera): void;
  18665. }
  18666. }
  18667. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  18668. /** @hidden */
  18669. export var kernelBlurVaryingDeclaration: {
  18670. name: string;
  18671. shader: string;
  18672. };
  18673. }
  18674. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  18675. /** @hidden */
  18676. export var kernelBlurFragment: {
  18677. name: string;
  18678. shader: string;
  18679. };
  18680. }
  18681. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  18682. /** @hidden */
  18683. export var kernelBlurFragment2: {
  18684. name: string;
  18685. shader: string;
  18686. };
  18687. }
  18688. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  18689. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18690. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  18691. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  18692. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  18693. /** @hidden */
  18694. export var kernelBlurPixelShader: {
  18695. name: string;
  18696. shader: string;
  18697. };
  18698. }
  18699. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  18700. /** @hidden */
  18701. export var kernelBlurVertex: {
  18702. name: string;
  18703. shader: string;
  18704. };
  18705. }
  18706. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  18707. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18708. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  18709. /** @hidden */
  18710. export var kernelBlurVertexShader: {
  18711. name: string;
  18712. shader: string;
  18713. };
  18714. }
  18715. declare module "babylonjs/PostProcesses/blurPostProcess" {
  18716. import { Vector2 } from "babylonjs/Maths/math";
  18717. import { Nullable } from "babylonjs/types";
  18718. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18719. import { Camera } from "babylonjs/Cameras/camera";
  18720. import { Effect } from "babylonjs/Materials/effect";
  18721. import { Engine } from "babylonjs/Engines/engine";
  18722. import "babylonjs/Shaders/kernelBlur.fragment";
  18723. import "babylonjs/Shaders/kernelBlur.vertex";
  18724. /**
  18725. * The Blur Post Process which blurs an image based on a kernel and direction.
  18726. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  18727. */
  18728. export class BlurPostProcess extends PostProcess {
  18729. /** The direction in which to blur the image. */
  18730. direction: Vector2;
  18731. private blockCompilation;
  18732. protected _kernel: number;
  18733. protected _idealKernel: number;
  18734. protected _packedFloat: boolean;
  18735. private _staticDefines;
  18736. /**
  18737. * Sets the length in pixels of the blur sample region
  18738. */
  18739. /**
  18740. * Gets the length in pixels of the blur sample region
  18741. */
  18742. kernel: number;
  18743. /**
  18744. * Sets wether or not the blur needs to unpack/repack floats
  18745. */
  18746. /**
  18747. * Gets wether or not the blur is unpacking/repacking floats
  18748. */
  18749. packedFloat: boolean;
  18750. /**
  18751. * Creates a new instance BlurPostProcess
  18752. * @param name The name of the effect.
  18753. * @param direction The direction in which to blur the image.
  18754. * @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.
  18755. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18756. * @param camera The camera to apply the render pass to.
  18757. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18758. * @param engine The engine which the post process will be applied. (default: current engine)
  18759. * @param reusable If the post process can be reused on the same frame. (default: false)
  18760. * @param textureType Type of textures used when performing the post process. (default: 0)
  18761. * @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)
  18762. */
  18763. constructor(name: string,
  18764. /** The direction in which to blur the image. */
  18765. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  18766. /**
  18767. * Updates the effect with the current post process compile time values and recompiles the shader.
  18768. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18769. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18770. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18771. * @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
  18772. * @param onCompiled Called when the shader has been compiled.
  18773. * @param onError Called if there is an error when compiling a shader.
  18774. */
  18775. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18776. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18777. /**
  18778. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18779. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18780. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18781. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18782. * The gaps between physical kernels are compensated for in the weighting of the samples
  18783. * @param idealKernel Ideal blur kernel.
  18784. * @return Nearest best kernel.
  18785. */
  18786. protected _nearestBestKernel(idealKernel: number): number;
  18787. /**
  18788. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18789. * @param x The point on the Gaussian distribution to sample.
  18790. * @return the value of the Gaussian function at x.
  18791. */
  18792. protected _gaussianWeight(x: number): number;
  18793. /**
  18794. * Generates a string that can be used as a floating point number in GLSL.
  18795. * @param x Value to print.
  18796. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18797. * @return GLSL float string.
  18798. */
  18799. protected _glslFloat(x: number, decimalFigures?: number): string;
  18800. }
  18801. }
  18802. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18803. import { Scene } from "babylonjs/scene";
  18804. import { Plane } from "babylonjs/Maths/math";
  18805. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18806. /**
  18807. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18808. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18809. * You can then easily use it as a reflectionTexture on a flat surface.
  18810. * In case the surface is not a plane, please consider relying on reflection probes.
  18811. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18812. */
  18813. export class MirrorTexture extends RenderTargetTexture {
  18814. private scene;
  18815. /**
  18816. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18817. * 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.
  18818. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18819. */
  18820. mirrorPlane: Plane;
  18821. /**
  18822. * Define the blur ratio used to blur the reflection if needed.
  18823. */
  18824. blurRatio: number;
  18825. /**
  18826. * Define the adaptive blur kernel used to blur the reflection if needed.
  18827. * This will autocompute the closest best match for the `blurKernel`
  18828. */
  18829. adaptiveBlurKernel: number;
  18830. /**
  18831. * Define the blur kernel used to blur the reflection if needed.
  18832. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18833. */
  18834. blurKernel: number;
  18835. /**
  18836. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18837. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18838. */
  18839. blurKernelX: number;
  18840. /**
  18841. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18842. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18843. */
  18844. blurKernelY: number;
  18845. private _autoComputeBlurKernel;
  18846. protected _onRatioRescale(): void;
  18847. private _updateGammaSpace;
  18848. private _imageProcessingConfigChangeObserver;
  18849. private _transformMatrix;
  18850. private _mirrorMatrix;
  18851. private _savedViewMatrix;
  18852. private _blurX;
  18853. private _blurY;
  18854. private _adaptiveBlurKernel;
  18855. private _blurKernelX;
  18856. private _blurKernelY;
  18857. private _blurRatio;
  18858. /**
  18859. * Instantiates a Mirror Texture.
  18860. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18861. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18862. * You can then easily use it as a reflectionTexture on a flat surface.
  18863. * In case the surface is not a plane, please consider relying on reflection probes.
  18864. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18865. * @param name
  18866. * @param size
  18867. * @param scene
  18868. * @param generateMipMaps
  18869. * @param type
  18870. * @param samplingMode
  18871. * @param generateDepthBuffer
  18872. */
  18873. constructor(name: string, size: number | {
  18874. width: number;
  18875. height: number;
  18876. } | {
  18877. ratio: number;
  18878. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18879. private _preparePostProcesses;
  18880. /**
  18881. * Clone the mirror texture.
  18882. * @returns the cloned texture
  18883. */
  18884. clone(): MirrorTexture;
  18885. /**
  18886. * Serialize the texture to a JSON representation you could use in Parse later on
  18887. * @returns the serialized JSON representation
  18888. */
  18889. serialize(): any;
  18890. /**
  18891. * Dispose the texture and release its associated resources.
  18892. */
  18893. dispose(): void;
  18894. }
  18895. }
  18896. declare module "babylonjs/Materials/Textures/texture" {
  18897. import { Observable } from "babylonjs/Misc/observable";
  18898. import { Nullable } from "babylonjs/types";
  18899. import { Scene } from "babylonjs/scene";
  18900. import { Matrix } from "babylonjs/Maths/math";
  18901. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18902. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18903. import { Engine } from "babylonjs/Engines/engine";
  18904. /**
  18905. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18906. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18907. */
  18908. export class Texture extends BaseTexture {
  18909. /** @hidden */
  18910. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18911. /** @hidden */
  18912. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18913. /** @hidden */
  18914. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18915. /** nearest is mag = nearest and min = nearest and mip = linear */
  18916. static readonly NEAREST_SAMPLINGMODE: number;
  18917. /** nearest is mag = nearest and min = nearest and mip = linear */
  18918. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18919. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18920. static readonly BILINEAR_SAMPLINGMODE: number;
  18921. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18922. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18923. /** Trilinear is mag = linear and min = linear and mip = linear */
  18924. static readonly TRILINEAR_SAMPLINGMODE: number;
  18925. /** Trilinear is mag = linear and min = linear and mip = linear */
  18926. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18927. /** mag = nearest and min = nearest and mip = nearest */
  18928. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18929. /** mag = nearest and min = linear and mip = nearest */
  18930. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18931. /** mag = nearest and min = linear and mip = linear */
  18932. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18933. /** mag = nearest and min = linear and mip = none */
  18934. static readonly NEAREST_LINEAR: number;
  18935. /** mag = nearest and min = nearest and mip = none */
  18936. static readonly NEAREST_NEAREST: number;
  18937. /** mag = linear and min = nearest and mip = nearest */
  18938. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18939. /** mag = linear and min = nearest and mip = linear */
  18940. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18941. /** mag = linear and min = linear and mip = none */
  18942. static readonly LINEAR_LINEAR: number;
  18943. /** mag = linear and min = nearest and mip = none */
  18944. static readonly LINEAR_NEAREST: number;
  18945. /** Explicit coordinates mode */
  18946. static readonly EXPLICIT_MODE: number;
  18947. /** Spherical coordinates mode */
  18948. static readonly SPHERICAL_MODE: number;
  18949. /** Planar coordinates mode */
  18950. static readonly PLANAR_MODE: number;
  18951. /** Cubic coordinates mode */
  18952. static readonly CUBIC_MODE: number;
  18953. /** Projection coordinates mode */
  18954. static readonly PROJECTION_MODE: number;
  18955. /** Inverse Cubic coordinates mode */
  18956. static readonly SKYBOX_MODE: number;
  18957. /** Inverse Cubic coordinates mode */
  18958. static readonly INVCUBIC_MODE: number;
  18959. /** Equirectangular coordinates mode */
  18960. static readonly EQUIRECTANGULAR_MODE: number;
  18961. /** Equirectangular Fixed coordinates mode */
  18962. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18963. /** Equirectangular Fixed Mirrored coordinates mode */
  18964. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18965. /** Texture is not repeating outside of 0..1 UVs */
  18966. static readonly CLAMP_ADDRESSMODE: number;
  18967. /** Texture is repeating outside of 0..1 UVs */
  18968. static readonly WRAP_ADDRESSMODE: number;
  18969. /** Texture is repeating and mirrored */
  18970. static readonly MIRROR_ADDRESSMODE: number;
  18971. /**
  18972. * 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
  18973. */
  18974. static UseSerializedUrlIfAny: boolean;
  18975. /**
  18976. * Define the url of the texture.
  18977. */
  18978. url: Nullable<string>;
  18979. /**
  18980. * Define an offset on the texture to offset the u coordinates of the UVs
  18981. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18982. */
  18983. uOffset: number;
  18984. /**
  18985. * Define an offset on the texture to offset the v coordinates of the UVs
  18986. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18987. */
  18988. vOffset: number;
  18989. /**
  18990. * Define an offset on the texture to scale the u coordinates of the UVs
  18991. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18992. */
  18993. uScale: number;
  18994. /**
  18995. * Define an offset on the texture to scale the v coordinates of the UVs
  18996. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18997. */
  18998. vScale: number;
  18999. /**
  19000. * Define an offset on the texture to rotate around the u coordinates of the UVs
  19001. * @see http://doc.babylonjs.com/how_to/more_materials
  19002. */
  19003. uAng: number;
  19004. /**
  19005. * Define an offset on the texture to rotate around the v coordinates of the UVs
  19006. * @see http://doc.babylonjs.com/how_to/more_materials
  19007. */
  19008. vAng: number;
  19009. /**
  19010. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  19011. * @see http://doc.babylonjs.com/how_to/more_materials
  19012. */
  19013. wAng: number;
  19014. /**
  19015. * Defines the center of rotation (U)
  19016. */
  19017. uRotationCenter: number;
  19018. /**
  19019. * Defines the center of rotation (V)
  19020. */
  19021. vRotationCenter: number;
  19022. /**
  19023. * Defines the center of rotation (W)
  19024. */
  19025. wRotationCenter: number;
  19026. /**
  19027. * Are mip maps generated for this texture or not.
  19028. */
  19029. readonly noMipmap: boolean;
  19030. /**
  19031. * List of inspectable custom properties (used by the Inspector)
  19032. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19033. */
  19034. inspectableCustomProperties: Nullable<IInspectable[]>;
  19035. private _noMipmap;
  19036. /** @hidden */
  19037. _invertY: boolean;
  19038. private _rowGenerationMatrix;
  19039. private _cachedTextureMatrix;
  19040. private _projectionModeMatrix;
  19041. private _t0;
  19042. private _t1;
  19043. private _t2;
  19044. private _cachedUOffset;
  19045. private _cachedVOffset;
  19046. private _cachedUScale;
  19047. private _cachedVScale;
  19048. private _cachedUAng;
  19049. private _cachedVAng;
  19050. private _cachedWAng;
  19051. private _cachedProjectionMatrixId;
  19052. private _cachedCoordinatesMode;
  19053. /** @hidden */
  19054. protected _initialSamplingMode: number;
  19055. /** @hidden */
  19056. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  19057. private _deleteBuffer;
  19058. protected _format: Nullable<number>;
  19059. private _delayedOnLoad;
  19060. private _delayedOnError;
  19061. /**
  19062. * Observable triggered once the texture has been loaded.
  19063. */
  19064. onLoadObservable: Observable<Texture>;
  19065. protected _isBlocking: boolean;
  19066. /**
  19067. * Is the texture preventing material to render while loading.
  19068. * If false, a default texture will be used instead of the loading one during the preparation step.
  19069. */
  19070. isBlocking: boolean;
  19071. /**
  19072. * Get the current sampling mode associated with the texture.
  19073. */
  19074. readonly samplingMode: number;
  19075. /**
  19076. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  19077. */
  19078. readonly invertY: boolean;
  19079. /**
  19080. * Instantiates a new texture.
  19081. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  19082. * @see http://doc.babylonjs.com/babylon101/materials#texture
  19083. * @param url define the url of the picture to load as a texture
  19084. * @param scene define the scene or engine the texture will belong to
  19085. * @param noMipmap define if the texture will require mip maps or not
  19086. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19087. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19088. * @param onLoad define a callback triggered when the texture has been loaded
  19089. * @param onError define a callback triggered when an error occurred during the loading session
  19090. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19091. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  19092. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19093. */
  19094. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  19095. /**
  19096. * Update the url (and optional buffer) of this texture if url was null during construction.
  19097. * @param url the url of the texture
  19098. * @param buffer the buffer of the texture (defaults to null)
  19099. * @param onLoad callback called when the texture is loaded (defaults to null)
  19100. */
  19101. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  19102. /**
  19103. * Finish the loading sequence of a texture flagged as delayed load.
  19104. * @hidden
  19105. */
  19106. delayLoad(): void;
  19107. private _prepareRowForTextureGeneration;
  19108. /**
  19109. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  19110. * @returns the transform matrix of the texture.
  19111. */
  19112. getTextureMatrix(): Matrix;
  19113. /**
  19114. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  19115. * @returns The reflection texture transform
  19116. */
  19117. getReflectionTextureMatrix(): Matrix;
  19118. /**
  19119. * Clones the texture.
  19120. * @returns the cloned texture
  19121. */
  19122. clone(): Texture;
  19123. /**
  19124. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19125. * @returns The JSON representation of the texture
  19126. */
  19127. serialize(): any;
  19128. /**
  19129. * Get the current class name of the texture useful for serialization or dynamic coding.
  19130. * @returns "Texture"
  19131. */
  19132. getClassName(): string;
  19133. /**
  19134. * Dispose the texture and release its associated resources.
  19135. */
  19136. dispose(): void;
  19137. /**
  19138. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  19139. * @param parsedTexture Define the JSON representation of the texture
  19140. * @param scene Define the scene the parsed texture should be instantiated in
  19141. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  19142. * @returns The parsed texture if successful
  19143. */
  19144. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  19145. /**
  19146. * Creates a texture from its base 64 representation.
  19147. * @param data Define the base64 payload without the data: prefix
  19148. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19149. * @param scene Define the scene the texture should belong to
  19150. * @param noMipmap Forces the texture to not create mip map information if true
  19151. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19152. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19153. * @param onLoad define a callback triggered when the texture has been loaded
  19154. * @param onError define a callback triggered when an error occurred during the loading session
  19155. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19156. * @returns the created texture
  19157. */
  19158. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  19159. /**
  19160. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  19161. * @param data Define the base64 payload without the data: prefix
  19162. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19163. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19164. * @param scene Define the scene the texture should belong to
  19165. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  19166. * @param noMipmap Forces the texture to not create mip map information if true
  19167. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19168. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19169. * @param onLoad define a callback triggered when the texture has been loaded
  19170. * @param onError define a callback triggered when an error occurred during the loading session
  19171. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19172. * @returns the created texture
  19173. */
  19174. 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;
  19175. }
  19176. }
  19177. declare module "babylonjs/PostProcesses/postProcessManager" {
  19178. import { Nullable } from "babylonjs/types";
  19179. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19180. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19181. import { Scene } from "babylonjs/scene";
  19182. /**
  19183. * PostProcessManager is used to manage one or more post processes or post process pipelines
  19184. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19185. */
  19186. export class PostProcessManager {
  19187. private _scene;
  19188. private _indexBuffer;
  19189. private _vertexBuffers;
  19190. /**
  19191. * Creates a new instance PostProcess
  19192. * @param scene The scene that the post process is associated with.
  19193. */
  19194. constructor(scene: Scene);
  19195. private _prepareBuffers;
  19196. private _buildIndexBuffer;
  19197. /**
  19198. * Rebuilds the vertex buffers of the manager.
  19199. * @hidden
  19200. */
  19201. _rebuild(): void;
  19202. /**
  19203. * Prepares a frame to be run through a post process.
  19204. * @param sourceTexture The input texture to the post procesess. (default: null)
  19205. * @param postProcesses An array of post processes to be run. (default: null)
  19206. * @returns True if the post processes were able to be run.
  19207. * @hidden
  19208. */
  19209. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  19210. /**
  19211. * Manually render a set of post processes to a texture.
  19212. * @param postProcesses An array of post processes to be run.
  19213. * @param targetTexture The target texture to render to.
  19214. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  19215. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  19216. * @param lodLevel defines which lod of the texture to render to
  19217. */
  19218. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  19219. /**
  19220. * Finalize the result of the output of the postprocesses.
  19221. * @param doNotPresent If true the result will not be displayed to the screen.
  19222. * @param targetTexture The target texture to render to.
  19223. * @param faceIndex The index of the face to bind the target texture to.
  19224. * @param postProcesses The array of post processes to render.
  19225. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  19226. * @hidden
  19227. */
  19228. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  19229. /**
  19230. * Disposes of the post process manager.
  19231. */
  19232. dispose(): void;
  19233. }
  19234. }
  19235. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  19236. import { Scene } from "babylonjs/scene";
  19237. import { ISceneComponent } from "babylonjs/sceneComponent";
  19238. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19239. module "babylonjs/abstractScene" {
  19240. interface AbstractScene {
  19241. /**
  19242. * The list of procedural textures added to the scene
  19243. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19244. */
  19245. proceduralTextures: Array<ProceduralTexture>;
  19246. }
  19247. }
  19248. /**
  19249. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  19250. * in a given scene.
  19251. */
  19252. export class ProceduralTextureSceneComponent implements ISceneComponent {
  19253. /**
  19254. * The component name helpfull to identify the component in the list of scene components.
  19255. */
  19256. readonly name: string;
  19257. /**
  19258. * The scene the component belongs to.
  19259. */
  19260. scene: Scene;
  19261. /**
  19262. * Creates a new instance of the component for the given scene
  19263. * @param scene Defines the scene to register the component in
  19264. */
  19265. constructor(scene: Scene);
  19266. /**
  19267. * Registers the component in a given scene
  19268. */
  19269. register(): void;
  19270. /**
  19271. * Rebuilds the elements related to this component in case of
  19272. * context lost for instance.
  19273. */
  19274. rebuild(): void;
  19275. /**
  19276. * Disposes the component and the associated ressources.
  19277. */
  19278. dispose(): void;
  19279. private _beforeClear;
  19280. }
  19281. }
  19282. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  19283. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19284. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  19285. module "babylonjs/Engines/engine" {
  19286. interface Engine {
  19287. /**
  19288. * Creates a new render target cube texture
  19289. * @param size defines the size of the texture
  19290. * @param options defines the options used to create the texture
  19291. * @returns a new render target cube texture stored in an InternalTexture
  19292. */
  19293. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  19294. }
  19295. }
  19296. }
  19297. declare module "babylonjs/Shaders/procedural.vertex" {
  19298. /** @hidden */
  19299. export var proceduralVertexShader: {
  19300. name: string;
  19301. shader: string;
  19302. };
  19303. }
  19304. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  19305. import { Observable } from "babylonjs/Misc/observable";
  19306. import { Nullable } from "babylonjs/types";
  19307. import { Scene } from "babylonjs/scene";
  19308. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  19309. import { Effect } from "babylonjs/Materials/effect";
  19310. import { Texture } from "babylonjs/Materials/Textures/texture";
  19311. import "babylonjs/Engines/Extensions/engine.renderTarget";
  19312. import "babylonjs/Shaders/procedural.vertex";
  19313. /**
  19314. * 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.
  19315. * This is the base class of any Procedural texture and contains most of the shareable code.
  19316. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19317. */
  19318. export class ProceduralTexture extends Texture {
  19319. isCube: boolean;
  19320. /**
  19321. * Define if the texture is enabled or not (disabled texture will not render)
  19322. */
  19323. isEnabled: boolean;
  19324. /**
  19325. * Define if the texture must be cleared before rendering (default is true)
  19326. */
  19327. autoClear: boolean;
  19328. /**
  19329. * Callback called when the texture is generated
  19330. */
  19331. onGenerated: () => void;
  19332. /**
  19333. * Event raised when the texture is generated
  19334. */
  19335. onGeneratedObservable: Observable<ProceduralTexture>;
  19336. /** @hidden */
  19337. _generateMipMaps: boolean;
  19338. /** @hidden **/
  19339. _effect: Effect;
  19340. /** @hidden */
  19341. _textures: {
  19342. [key: string]: Texture;
  19343. };
  19344. private _size;
  19345. private _currentRefreshId;
  19346. private _refreshRate;
  19347. private _vertexBuffers;
  19348. private _indexBuffer;
  19349. private _uniforms;
  19350. private _samplers;
  19351. private _fragment;
  19352. private _floats;
  19353. private _ints;
  19354. private _floatsArrays;
  19355. private _colors3;
  19356. private _colors4;
  19357. private _vectors2;
  19358. private _vectors3;
  19359. private _matrices;
  19360. private _fallbackTexture;
  19361. private _fallbackTextureUsed;
  19362. private _engine;
  19363. private _cachedDefines;
  19364. private _contentUpdateId;
  19365. private _contentData;
  19366. /**
  19367. * Instantiates a new procedural texture.
  19368. * 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.
  19369. * This is the base class of any Procedural texture and contains most of the shareable code.
  19370. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19371. * @param name Define the name of the texture
  19372. * @param size Define the size of the texture to create
  19373. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  19374. * @param scene Define the scene the texture belongs to
  19375. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  19376. * @param generateMipMaps Define if the texture should creates mip maps or not
  19377. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  19378. */
  19379. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  19380. /**
  19381. * The effect that is created when initializing the post process.
  19382. * @returns The created effect corresponding the the postprocess.
  19383. */
  19384. getEffect(): Effect;
  19385. /**
  19386. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  19387. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  19388. */
  19389. getContent(): Nullable<ArrayBufferView>;
  19390. private _createIndexBuffer;
  19391. /** @hidden */
  19392. _rebuild(): void;
  19393. /**
  19394. * Resets the texture in order to recreate its associated resources.
  19395. * This can be called in case of context loss
  19396. */
  19397. reset(): void;
  19398. protected _getDefines(): string;
  19399. /**
  19400. * Is the texture ready to be used ? (rendered at least once)
  19401. * @returns true if ready, otherwise, false.
  19402. */
  19403. isReady(): boolean;
  19404. /**
  19405. * Resets the refresh counter of the texture and start bak from scratch.
  19406. * Could be useful to regenerate the texture if it is setup to render only once.
  19407. */
  19408. resetRefreshCounter(): void;
  19409. /**
  19410. * Set the fragment shader to use in order to render the texture.
  19411. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  19412. */
  19413. setFragment(fragment: any): void;
  19414. /**
  19415. * Define the refresh rate of the texture or the rendering frequency.
  19416. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19417. */
  19418. refreshRate: number;
  19419. /** @hidden */
  19420. _shouldRender(): boolean;
  19421. /**
  19422. * Get the size the texture is rendering at.
  19423. * @returns the size (texture is always squared)
  19424. */
  19425. getRenderSize(): number;
  19426. /**
  19427. * Resize the texture to new value.
  19428. * @param size Define the new size the texture should have
  19429. * @param generateMipMaps Define whether the new texture should create mip maps
  19430. */
  19431. resize(size: number, generateMipMaps: boolean): void;
  19432. private _checkUniform;
  19433. /**
  19434. * Set a texture in the shader program used to render.
  19435. * @param name Define the name of the uniform samplers as defined in the shader
  19436. * @param texture Define the texture to bind to this sampler
  19437. * @return the texture itself allowing "fluent" like uniform updates
  19438. */
  19439. setTexture(name: string, texture: Texture): ProceduralTexture;
  19440. /**
  19441. * Set a float in the shader.
  19442. * @param name Define the name of the uniform as defined in the shader
  19443. * @param value Define the value to give to the uniform
  19444. * @return the texture itself allowing "fluent" like uniform updates
  19445. */
  19446. setFloat(name: string, value: number): ProceduralTexture;
  19447. /**
  19448. * Set a int in the shader.
  19449. * @param name Define the name of the uniform as defined in the shader
  19450. * @param value Define the value to give to the uniform
  19451. * @return the texture itself allowing "fluent" like uniform updates
  19452. */
  19453. setInt(name: string, value: number): ProceduralTexture;
  19454. /**
  19455. * Set an array of floats in the shader.
  19456. * @param name Define the name of the uniform as defined in the shader
  19457. * @param value Define the value to give to the uniform
  19458. * @return the texture itself allowing "fluent" like uniform updates
  19459. */
  19460. setFloats(name: string, value: number[]): ProceduralTexture;
  19461. /**
  19462. * Set a vec3 in the shader from a Color3.
  19463. * @param name Define the name of the uniform as defined in the shader
  19464. * @param value Define the value to give to the uniform
  19465. * @return the texture itself allowing "fluent" like uniform updates
  19466. */
  19467. setColor3(name: string, value: Color3): ProceduralTexture;
  19468. /**
  19469. * Set a vec4 in the shader from a Color4.
  19470. * @param name Define the name of the uniform as defined in the shader
  19471. * @param value Define the value to give to the uniform
  19472. * @return the texture itself allowing "fluent" like uniform updates
  19473. */
  19474. setColor4(name: string, value: Color4): ProceduralTexture;
  19475. /**
  19476. * Set a vec2 in the shader from a Vector2.
  19477. * @param name Define the name of the uniform as defined in the shader
  19478. * @param value Define the value to give to the uniform
  19479. * @return the texture itself allowing "fluent" like uniform updates
  19480. */
  19481. setVector2(name: string, value: Vector2): ProceduralTexture;
  19482. /**
  19483. * Set a vec3 in the shader from a Vector3.
  19484. * @param name Define the name of the uniform as defined in the shader
  19485. * @param value Define the value to give to the uniform
  19486. * @return the texture itself allowing "fluent" like uniform updates
  19487. */
  19488. setVector3(name: string, value: Vector3): ProceduralTexture;
  19489. /**
  19490. * Set a mat4 in the shader from a MAtrix.
  19491. * @param name Define the name of the uniform as defined in the shader
  19492. * @param value Define the value to give to the uniform
  19493. * @return the texture itself allowing "fluent" like uniform updates
  19494. */
  19495. setMatrix(name: string, value: Matrix): ProceduralTexture;
  19496. /**
  19497. * Render the texture to its associated render target.
  19498. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  19499. */
  19500. render(useCameraPostProcess?: boolean): void;
  19501. /**
  19502. * Clone the texture.
  19503. * @returns the cloned texture
  19504. */
  19505. clone(): ProceduralTexture;
  19506. /**
  19507. * Dispose the texture and release its asoociated resources.
  19508. */
  19509. dispose(): void;
  19510. }
  19511. }
  19512. declare module "babylonjs/Particles/baseParticleSystem" {
  19513. import { Nullable } from "babylonjs/types";
  19514. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  19515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19516. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19517. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19518. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19519. import { Scene } from "babylonjs/scene";
  19520. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  19521. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19522. import { Texture } from "babylonjs/Materials/Textures/texture";
  19523. import { Animation } from "babylonjs/Animations/animation";
  19524. /**
  19525. * This represents the base class for particle system in Babylon.
  19526. * 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.
  19527. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19528. * @example https://doc.babylonjs.com/babylon101/particles
  19529. */
  19530. export class BaseParticleSystem {
  19531. /**
  19532. * Source color is added to the destination color without alpha affecting the result
  19533. */
  19534. static BLENDMODE_ONEONE: number;
  19535. /**
  19536. * Blend current color and particle color using particle’s alpha
  19537. */
  19538. static BLENDMODE_STANDARD: number;
  19539. /**
  19540. * Add current color and particle color multiplied by particle’s alpha
  19541. */
  19542. static BLENDMODE_ADD: number;
  19543. /**
  19544. * Multiply current color with particle color
  19545. */
  19546. static BLENDMODE_MULTIPLY: number;
  19547. /**
  19548. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  19549. */
  19550. static BLENDMODE_MULTIPLYADD: number;
  19551. /**
  19552. * List of animations used by the particle system.
  19553. */
  19554. animations: Animation[];
  19555. /**
  19556. * The id of the Particle system.
  19557. */
  19558. id: string;
  19559. /**
  19560. * The friendly name of the Particle system.
  19561. */
  19562. name: string;
  19563. /**
  19564. * The rendering group used by the Particle system to chose when to render.
  19565. */
  19566. renderingGroupId: number;
  19567. /**
  19568. * The emitter represents the Mesh or position we are attaching the particle system to.
  19569. */
  19570. emitter: Nullable<AbstractMesh | Vector3>;
  19571. /**
  19572. * The maximum number of particles to emit per frame
  19573. */
  19574. emitRate: number;
  19575. /**
  19576. * If you want to launch only a few particles at once, that can be done, as well.
  19577. */
  19578. manualEmitCount: number;
  19579. /**
  19580. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19581. */
  19582. updateSpeed: number;
  19583. /**
  19584. * The amount of time the particle system is running (depends of the overall update speed).
  19585. */
  19586. targetStopDuration: number;
  19587. /**
  19588. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19589. */
  19590. disposeOnStop: boolean;
  19591. /**
  19592. * Minimum power of emitting particles.
  19593. */
  19594. minEmitPower: number;
  19595. /**
  19596. * Maximum power of emitting particles.
  19597. */
  19598. maxEmitPower: number;
  19599. /**
  19600. * Minimum life time of emitting particles.
  19601. */
  19602. minLifeTime: number;
  19603. /**
  19604. * Maximum life time of emitting particles.
  19605. */
  19606. maxLifeTime: number;
  19607. /**
  19608. * Minimum Size of emitting particles.
  19609. */
  19610. minSize: number;
  19611. /**
  19612. * Maximum Size of emitting particles.
  19613. */
  19614. maxSize: number;
  19615. /**
  19616. * Minimum scale of emitting particles on X axis.
  19617. */
  19618. minScaleX: number;
  19619. /**
  19620. * Maximum scale of emitting particles on X axis.
  19621. */
  19622. maxScaleX: number;
  19623. /**
  19624. * Minimum scale of emitting particles on Y axis.
  19625. */
  19626. minScaleY: number;
  19627. /**
  19628. * Maximum scale of emitting particles on Y axis.
  19629. */
  19630. maxScaleY: number;
  19631. /**
  19632. * Gets or sets the minimal initial rotation in radians.
  19633. */
  19634. minInitialRotation: number;
  19635. /**
  19636. * Gets or sets the maximal initial rotation in radians.
  19637. */
  19638. maxInitialRotation: number;
  19639. /**
  19640. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19641. */
  19642. minAngularSpeed: number;
  19643. /**
  19644. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19645. */
  19646. maxAngularSpeed: number;
  19647. /**
  19648. * The texture used to render each particle. (this can be a spritesheet)
  19649. */
  19650. particleTexture: Nullable<Texture>;
  19651. /**
  19652. * The layer mask we are rendering the particles through.
  19653. */
  19654. layerMask: number;
  19655. /**
  19656. * This can help using your own shader to render the particle system.
  19657. * The according effect will be created
  19658. */
  19659. customShader: any;
  19660. /**
  19661. * By default particle system starts as soon as they are created. This prevents the
  19662. * automatic start to happen and let you decide when to start emitting particles.
  19663. */
  19664. preventAutoStart: boolean;
  19665. private _noiseTexture;
  19666. /**
  19667. * Gets or sets a texture used to add random noise to particle positions
  19668. */
  19669. noiseTexture: Nullable<ProceduralTexture>;
  19670. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19671. noiseStrength: Vector3;
  19672. /**
  19673. * Callback triggered when the particle animation is ending.
  19674. */
  19675. onAnimationEnd: Nullable<() => void>;
  19676. /**
  19677. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19678. */
  19679. blendMode: number;
  19680. /**
  19681. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19682. * to override the particles.
  19683. */
  19684. forceDepthWrite: boolean;
  19685. /** 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 */
  19686. preWarmCycles: number;
  19687. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  19688. preWarmStepOffset: number;
  19689. /**
  19690. * 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)
  19691. */
  19692. spriteCellChangeSpeed: number;
  19693. /**
  19694. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19695. */
  19696. startSpriteCellID: number;
  19697. /**
  19698. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19699. */
  19700. endSpriteCellID: number;
  19701. /**
  19702. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19703. */
  19704. spriteCellWidth: number;
  19705. /**
  19706. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19707. */
  19708. spriteCellHeight: number;
  19709. /**
  19710. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19711. */
  19712. spriteRandomStartCell: boolean;
  19713. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19714. translationPivot: Vector2;
  19715. /** @hidden */
  19716. protected _isAnimationSheetEnabled: boolean;
  19717. /**
  19718. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19719. */
  19720. beginAnimationOnStart: boolean;
  19721. /**
  19722. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19723. */
  19724. beginAnimationFrom: number;
  19725. /**
  19726. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19727. */
  19728. beginAnimationTo: number;
  19729. /**
  19730. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19731. */
  19732. beginAnimationLoop: boolean;
  19733. /**
  19734. * Gets or sets a world offset applied to all particles
  19735. */
  19736. worldOffset: Vector3;
  19737. /**
  19738. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  19739. */
  19740. isAnimationSheetEnabled: boolean;
  19741. /**
  19742. * Get hosting scene
  19743. * @returns the scene
  19744. */
  19745. getScene(): Scene;
  19746. /**
  19747. * You can use gravity if you want to give an orientation to your particles.
  19748. */
  19749. gravity: Vector3;
  19750. protected _colorGradients: Nullable<Array<ColorGradient>>;
  19751. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  19752. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  19753. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  19754. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  19755. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  19756. protected _dragGradients: Nullable<Array<FactorGradient>>;
  19757. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  19758. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  19759. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  19760. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  19761. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  19762. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  19763. /**
  19764. * Defines the delay in milliseconds before starting the system (0 by default)
  19765. */
  19766. startDelay: number;
  19767. /**
  19768. * Gets the current list of drag gradients.
  19769. * You must use addDragGradient and removeDragGradient to udpate this list
  19770. * @returns the list of drag gradients
  19771. */
  19772. getDragGradients(): Nullable<Array<FactorGradient>>;
  19773. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19774. limitVelocityDamping: number;
  19775. /**
  19776. * Gets the current list of limit velocity gradients.
  19777. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19778. * @returns the list of limit velocity gradients
  19779. */
  19780. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19781. /**
  19782. * Gets the current list of color gradients.
  19783. * You must use addColorGradient and removeColorGradient to udpate this list
  19784. * @returns the list of color gradients
  19785. */
  19786. getColorGradients(): Nullable<Array<ColorGradient>>;
  19787. /**
  19788. * Gets the current list of size gradients.
  19789. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19790. * @returns the list of size gradients
  19791. */
  19792. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19793. /**
  19794. * Gets the current list of color remap gradients.
  19795. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19796. * @returns the list of color remap gradients
  19797. */
  19798. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19799. /**
  19800. * Gets the current list of alpha remap gradients.
  19801. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19802. * @returns the list of alpha remap gradients
  19803. */
  19804. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19805. /**
  19806. * Gets the current list of life time gradients.
  19807. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19808. * @returns the list of life time gradients
  19809. */
  19810. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19811. /**
  19812. * Gets the current list of angular speed gradients.
  19813. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19814. * @returns the list of angular speed gradients
  19815. */
  19816. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19817. /**
  19818. * Gets the current list of velocity gradients.
  19819. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19820. * @returns the list of velocity gradients
  19821. */
  19822. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19823. /**
  19824. * Gets the current list of start size gradients.
  19825. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19826. * @returns the list of start size gradients
  19827. */
  19828. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19829. /**
  19830. * Gets the current list of emit rate gradients.
  19831. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19832. * @returns the list of emit rate gradients
  19833. */
  19834. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19835. /**
  19836. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19837. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19838. */
  19839. direction1: Vector3;
  19840. /**
  19841. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19842. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19843. */
  19844. direction2: Vector3;
  19845. /**
  19846. * 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.
  19847. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19848. */
  19849. minEmitBox: Vector3;
  19850. /**
  19851. * 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.
  19852. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19853. */
  19854. maxEmitBox: Vector3;
  19855. /**
  19856. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19857. */
  19858. color1: Color4;
  19859. /**
  19860. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19861. */
  19862. color2: Color4;
  19863. /**
  19864. * Color the particle will have at the end of its lifetime
  19865. */
  19866. colorDead: Color4;
  19867. /**
  19868. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19869. */
  19870. textureMask: Color4;
  19871. /**
  19872. * The particle emitter type defines the emitter used by the particle system.
  19873. * It can be for example box, sphere, or cone...
  19874. */
  19875. particleEmitterType: IParticleEmitterType;
  19876. /** @hidden */
  19877. _isSubEmitter: boolean;
  19878. /**
  19879. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19880. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19881. */
  19882. billboardMode: number;
  19883. protected _isBillboardBased: boolean;
  19884. /**
  19885. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19886. */
  19887. isBillboardBased: boolean;
  19888. /**
  19889. * The scene the particle system belongs to.
  19890. */
  19891. protected _scene: Scene;
  19892. /**
  19893. * Local cache of defines for image processing.
  19894. */
  19895. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19896. /**
  19897. * Default configuration related to image processing available in the standard Material.
  19898. */
  19899. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19900. /**
  19901. * Gets the image processing configuration used either in this material.
  19902. */
  19903. /**
  19904. * Sets the Default image processing configuration used either in the this material.
  19905. *
  19906. * If sets to null, the scene one is in use.
  19907. */
  19908. imageProcessingConfiguration: ImageProcessingConfiguration;
  19909. /**
  19910. * Attaches a new image processing configuration to the Standard Material.
  19911. * @param configuration
  19912. */
  19913. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19914. /** @hidden */
  19915. protected _reset(): void;
  19916. /** @hidden */
  19917. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19918. /**
  19919. * Instantiates a particle system.
  19920. * 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.
  19921. * @param name The name of the particle system
  19922. */
  19923. constructor(name: string);
  19924. /**
  19925. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19926. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19927. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19928. * @returns the emitter
  19929. */
  19930. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19931. /**
  19932. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19933. * @param radius The radius of the hemisphere to emit from
  19934. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19935. * @returns the emitter
  19936. */
  19937. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19938. /**
  19939. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19940. * @param radius The radius of the sphere to emit from
  19941. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19942. * @returns the emitter
  19943. */
  19944. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19945. /**
  19946. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19947. * @param radius The radius of the sphere to emit from
  19948. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19949. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19950. * @returns the emitter
  19951. */
  19952. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19953. /**
  19954. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19955. * @param radius The radius of the emission cylinder
  19956. * @param height The height of the emission cylinder
  19957. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19958. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19959. * @returns the emitter
  19960. */
  19961. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19962. /**
  19963. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19964. * @param radius The radius of the cylinder to emit from
  19965. * @param height The height of the emission cylinder
  19966. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19967. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19968. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19969. * @returns the emitter
  19970. */
  19971. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19972. /**
  19973. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19974. * @param radius The radius of the cone to emit from
  19975. * @param angle The base angle of the cone
  19976. * @returns the emitter
  19977. */
  19978. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19979. /**
  19980. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19981. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19982. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19983. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19984. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19985. * @returns the emitter
  19986. */
  19987. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19988. }
  19989. }
  19990. declare module "babylonjs/Particles/subEmitter" {
  19991. import { Scene } from "babylonjs/scene";
  19992. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  19993. /**
  19994. * Type of sub emitter
  19995. */
  19996. export enum SubEmitterType {
  19997. /**
  19998. * Attached to the particle over it's lifetime
  19999. */
  20000. ATTACHED = 0,
  20001. /**
  20002. * Created when the particle dies
  20003. */
  20004. END = 1
  20005. }
  20006. /**
  20007. * Sub emitter class used to emit particles from an existing particle
  20008. */
  20009. export class SubEmitter {
  20010. /**
  20011. * the particle system to be used by the sub emitter
  20012. */
  20013. particleSystem: ParticleSystem;
  20014. /**
  20015. * Type of the submitter (Default: END)
  20016. */
  20017. type: SubEmitterType;
  20018. /**
  20019. * 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)
  20020. * Note: This only is supported when using an emitter of type Mesh
  20021. */
  20022. inheritDirection: boolean;
  20023. /**
  20024. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  20025. */
  20026. inheritedVelocityAmount: number;
  20027. /**
  20028. * Creates a sub emitter
  20029. * @param particleSystem the particle system to be used by the sub emitter
  20030. */
  20031. constructor(
  20032. /**
  20033. * the particle system to be used by the sub emitter
  20034. */
  20035. particleSystem: ParticleSystem);
  20036. /**
  20037. * Clones the sub emitter
  20038. * @returns the cloned sub emitter
  20039. */
  20040. clone(): SubEmitter;
  20041. /**
  20042. * Serialize current object to a JSON object
  20043. * @returns the serialized object
  20044. */
  20045. serialize(): any;
  20046. /** @hidden */
  20047. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  20048. /**
  20049. * Creates a new SubEmitter from a serialized JSON version
  20050. * @param serializationObject defines the JSON object to read from
  20051. * @param scene defines the hosting scene
  20052. * @param rootUrl defines the rootUrl for data loading
  20053. * @returns a new SubEmitter
  20054. */
  20055. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  20056. /** Release associated resources */
  20057. dispose(): void;
  20058. }
  20059. }
  20060. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  20061. /** @hidden */
  20062. export var imageProcessingDeclaration: {
  20063. name: string;
  20064. shader: string;
  20065. };
  20066. }
  20067. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  20068. /** @hidden */
  20069. export var imageProcessingFunctions: {
  20070. name: string;
  20071. shader: string;
  20072. };
  20073. }
  20074. declare module "babylonjs/Shaders/particles.fragment" {
  20075. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20076. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  20077. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  20078. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  20079. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20080. /** @hidden */
  20081. export var particlesPixelShader: {
  20082. name: string;
  20083. shader: string;
  20084. };
  20085. }
  20086. declare module "babylonjs/Shaders/particles.vertex" {
  20087. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20088. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20089. /** @hidden */
  20090. export var particlesVertexShader: {
  20091. name: string;
  20092. shader: string;
  20093. };
  20094. }
  20095. declare module "babylonjs/Particles/particleSystem" {
  20096. import { Nullable } from "babylonjs/types";
  20097. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  20098. import { Observable } from "babylonjs/Misc/observable";
  20099. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  20100. import { Effect } from "babylonjs/Materials/effect";
  20101. import { Scene, IDisposable } from "babylonjs/scene";
  20102. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20103. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  20104. import { Particle } from "babylonjs/Particles/particle";
  20105. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20106. import "babylonjs/Shaders/particles.fragment";
  20107. import "babylonjs/Shaders/particles.vertex";
  20108. /**
  20109. * This represents a particle system in Babylon.
  20110. * 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.
  20111. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  20112. * @example https://doc.babylonjs.com/babylon101/particles
  20113. */
  20114. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  20115. /**
  20116. * Billboard mode will only apply to Y axis
  20117. */
  20118. static readonly BILLBOARDMODE_Y: number;
  20119. /**
  20120. * Billboard mode will apply to all axes
  20121. */
  20122. static readonly BILLBOARDMODE_ALL: number;
  20123. /**
  20124. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  20125. */
  20126. static readonly BILLBOARDMODE_STRETCHED: number;
  20127. /**
  20128. * This function can be defined to provide custom update for active particles.
  20129. * This function will be called instead of regular update (age, position, color, etc.).
  20130. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  20131. */
  20132. updateFunction: (particles: Particle[]) => void;
  20133. private _emitterWorldMatrix;
  20134. /**
  20135. * This function can be defined to specify initial direction for every new particle.
  20136. * It by default use the emitterType defined function
  20137. */
  20138. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  20139. /**
  20140. * This function can be defined to specify initial position for every new particle.
  20141. * It by default use the emitterType defined function
  20142. */
  20143. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  20144. /**
  20145. * @hidden
  20146. */
  20147. _inheritedVelocityOffset: Vector3;
  20148. /**
  20149. * An event triggered when the system is disposed
  20150. */
  20151. onDisposeObservable: Observable<ParticleSystem>;
  20152. private _onDisposeObserver;
  20153. /**
  20154. * Sets a callback that will be triggered when the system is disposed
  20155. */
  20156. onDispose: () => void;
  20157. private _particles;
  20158. private _epsilon;
  20159. private _capacity;
  20160. private _stockParticles;
  20161. private _newPartsExcess;
  20162. private _vertexData;
  20163. private _vertexBuffer;
  20164. private _vertexBuffers;
  20165. private _spriteBuffer;
  20166. private _indexBuffer;
  20167. private _effect;
  20168. private _customEffect;
  20169. private _cachedDefines;
  20170. private _scaledColorStep;
  20171. private _colorDiff;
  20172. private _scaledDirection;
  20173. private _scaledGravity;
  20174. private _currentRenderId;
  20175. private _alive;
  20176. private _useInstancing;
  20177. private _started;
  20178. private _stopped;
  20179. private _actualFrame;
  20180. private _scaledUpdateSpeed;
  20181. private _vertexBufferSize;
  20182. /** @hidden */
  20183. _currentEmitRateGradient: Nullable<FactorGradient>;
  20184. /** @hidden */
  20185. _currentEmitRate1: number;
  20186. /** @hidden */
  20187. _currentEmitRate2: number;
  20188. /** @hidden */
  20189. _currentStartSizeGradient: Nullable<FactorGradient>;
  20190. /** @hidden */
  20191. _currentStartSize1: number;
  20192. /** @hidden */
  20193. _currentStartSize2: number;
  20194. private readonly _rawTextureWidth;
  20195. private _rampGradientsTexture;
  20196. private _useRampGradients;
  20197. /** Gets or sets a boolean indicating that ramp gradients must be used
  20198. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  20199. */
  20200. useRampGradients: boolean;
  20201. /**
  20202. * 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.
  20203. * 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: [])
  20204. */
  20205. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  20206. private _subEmitters;
  20207. /**
  20208. * @hidden
  20209. * If the particle systems emitter should be disposed when the particle system is disposed
  20210. */
  20211. _disposeEmitterOnDispose: boolean;
  20212. /**
  20213. * The current active Sub-systems, this property is used by the root particle system only.
  20214. */
  20215. activeSubSystems: Array<ParticleSystem>;
  20216. private _rootParticleSystem;
  20217. /**
  20218. * Gets the current list of active particles
  20219. */
  20220. readonly particles: Particle[];
  20221. /**
  20222. * Returns the string "ParticleSystem"
  20223. * @returns a string containing the class name
  20224. */
  20225. getClassName(): string;
  20226. /**
  20227. * Instantiates a particle system.
  20228. * 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.
  20229. * @param name The name of the particle system
  20230. * @param capacity The max number of particles alive at the same time
  20231. * @param scene The scene the particle system belongs to
  20232. * @param customEffect a custom effect used to change the way particles are rendered by default
  20233. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  20234. * @param epsilon Offset used to render the particles
  20235. */
  20236. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  20237. private _addFactorGradient;
  20238. private _removeFactorGradient;
  20239. /**
  20240. * Adds a new life time gradient
  20241. * @param gradient defines the gradient to use (between 0 and 1)
  20242. * @param factor defines the life time factor to affect to the specified gradient
  20243. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20244. * @returns the current particle system
  20245. */
  20246. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20247. /**
  20248. * Remove a specific life time gradient
  20249. * @param gradient defines the gradient to remove
  20250. * @returns the current particle system
  20251. */
  20252. removeLifeTimeGradient(gradient: number): IParticleSystem;
  20253. /**
  20254. * Adds a new size gradient
  20255. * @param gradient defines the gradient to use (between 0 and 1)
  20256. * @param factor defines the size factor to affect to the specified gradient
  20257. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20258. * @returns the current particle system
  20259. */
  20260. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20261. /**
  20262. * Remove a specific size gradient
  20263. * @param gradient defines the gradient to remove
  20264. * @returns the current particle system
  20265. */
  20266. removeSizeGradient(gradient: number): IParticleSystem;
  20267. /**
  20268. * Adds a new color remap gradient
  20269. * @param gradient defines the gradient to use (between 0 and 1)
  20270. * @param min defines the color remap minimal range
  20271. * @param max defines the color remap maximal range
  20272. * @returns the current particle system
  20273. */
  20274. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20275. /**
  20276. * Remove a specific color remap gradient
  20277. * @param gradient defines the gradient to remove
  20278. * @returns the current particle system
  20279. */
  20280. removeColorRemapGradient(gradient: number): IParticleSystem;
  20281. /**
  20282. * Adds a new alpha remap gradient
  20283. * @param gradient defines the gradient to use (between 0 and 1)
  20284. * @param min defines the alpha remap minimal range
  20285. * @param max defines the alpha remap maximal range
  20286. * @returns the current particle system
  20287. */
  20288. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20289. /**
  20290. * Remove a specific alpha remap gradient
  20291. * @param gradient defines the gradient to remove
  20292. * @returns the current particle system
  20293. */
  20294. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  20295. /**
  20296. * Adds a new angular speed gradient
  20297. * @param gradient defines the gradient to use (between 0 and 1)
  20298. * @param factor defines the angular speed to affect to the specified gradient
  20299. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20300. * @returns the current particle system
  20301. */
  20302. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20303. /**
  20304. * Remove a specific angular speed gradient
  20305. * @param gradient defines the gradient to remove
  20306. * @returns the current particle system
  20307. */
  20308. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  20309. /**
  20310. * Adds a new velocity gradient
  20311. * @param gradient defines the gradient to use (between 0 and 1)
  20312. * @param factor defines the velocity to affect to the specified gradient
  20313. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20314. * @returns the current particle system
  20315. */
  20316. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20317. /**
  20318. * Remove a specific velocity gradient
  20319. * @param gradient defines the gradient to remove
  20320. * @returns the current particle system
  20321. */
  20322. removeVelocityGradient(gradient: number): IParticleSystem;
  20323. /**
  20324. * Adds a new limit velocity gradient
  20325. * @param gradient defines the gradient to use (between 0 and 1)
  20326. * @param factor defines the limit velocity value to affect to the specified gradient
  20327. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20328. * @returns the current particle system
  20329. */
  20330. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20331. /**
  20332. * Remove a specific limit velocity gradient
  20333. * @param gradient defines the gradient to remove
  20334. * @returns the current particle system
  20335. */
  20336. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  20337. /**
  20338. * Adds a new drag gradient
  20339. * @param gradient defines the gradient to use (between 0 and 1)
  20340. * @param factor defines the drag value to affect to the specified gradient
  20341. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20342. * @returns the current particle system
  20343. */
  20344. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20345. /**
  20346. * Remove a specific drag gradient
  20347. * @param gradient defines the gradient to remove
  20348. * @returns the current particle system
  20349. */
  20350. removeDragGradient(gradient: number): IParticleSystem;
  20351. /**
  20352. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  20353. * @param gradient defines the gradient to use (between 0 and 1)
  20354. * @param factor defines the emit rate value to affect to the specified gradient
  20355. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20356. * @returns the current particle system
  20357. */
  20358. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20359. /**
  20360. * Remove a specific emit rate gradient
  20361. * @param gradient defines the gradient to remove
  20362. * @returns the current particle system
  20363. */
  20364. removeEmitRateGradient(gradient: number): IParticleSystem;
  20365. /**
  20366. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  20367. * @param gradient defines the gradient to use (between 0 and 1)
  20368. * @param factor defines the start size value to affect to the specified gradient
  20369. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20370. * @returns the current particle system
  20371. */
  20372. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20373. /**
  20374. * Remove a specific start size gradient
  20375. * @param gradient defines the gradient to remove
  20376. * @returns the current particle system
  20377. */
  20378. removeStartSizeGradient(gradient: number): IParticleSystem;
  20379. private _createRampGradientTexture;
  20380. /**
  20381. * Gets the current list of ramp gradients.
  20382. * You must use addRampGradient and removeRampGradient to udpate this list
  20383. * @returns the list of ramp gradients
  20384. */
  20385. getRampGradients(): Nullable<Array<Color3Gradient>>;
  20386. /**
  20387. * Adds a new ramp gradient used to remap particle colors
  20388. * @param gradient defines the gradient to use (between 0 and 1)
  20389. * @param color defines the color to affect to the specified gradient
  20390. * @returns the current particle system
  20391. */
  20392. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  20393. /**
  20394. * Remove a specific ramp gradient
  20395. * @param gradient defines the gradient to remove
  20396. * @returns the current particle system
  20397. */
  20398. removeRampGradient(gradient: number): ParticleSystem;
  20399. /**
  20400. * Adds a new color gradient
  20401. * @param gradient defines the gradient to use (between 0 and 1)
  20402. * @param color1 defines the color to affect to the specified gradient
  20403. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  20404. * @returns this particle system
  20405. */
  20406. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  20407. /**
  20408. * Remove a specific color gradient
  20409. * @param gradient defines the gradient to remove
  20410. * @returns this particle system
  20411. */
  20412. removeColorGradient(gradient: number): IParticleSystem;
  20413. private _fetchR;
  20414. protected _reset(): void;
  20415. private _resetEffect;
  20416. private _createVertexBuffers;
  20417. private _createIndexBuffer;
  20418. /**
  20419. * Gets the maximum number of particles active at the same time.
  20420. * @returns The max number of active particles.
  20421. */
  20422. getCapacity(): number;
  20423. /**
  20424. * Gets whether there are still active particles in the system.
  20425. * @returns True if it is alive, otherwise false.
  20426. */
  20427. isAlive(): boolean;
  20428. /**
  20429. * Gets if the system has been started. (Note: this will still be true after stop is called)
  20430. * @returns True if it has been started, otherwise false.
  20431. */
  20432. isStarted(): boolean;
  20433. private _prepareSubEmitterInternalArray;
  20434. /**
  20435. * Starts the particle system and begins to emit
  20436. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  20437. */
  20438. start(delay?: number): void;
  20439. /**
  20440. * Stops the particle system.
  20441. * @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.
  20442. */
  20443. stop(stopSubEmitters?: boolean): void;
  20444. /**
  20445. * Remove all active particles
  20446. */
  20447. reset(): void;
  20448. /**
  20449. * @hidden (for internal use only)
  20450. */
  20451. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  20452. /**
  20453. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  20454. * Its lifetime will start back at 0.
  20455. */
  20456. recycleParticle: (particle: Particle) => void;
  20457. private _stopSubEmitters;
  20458. private _createParticle;
  20459. private _removeFromRoot;
  20460. private _emitFromParticle;
  20461. private _update;
  20462. /** @hidden */
  20463. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  20464. /** @hidden */
  20465. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  20466. /** @hidden */
  20467. private _getEffect;
  20468. /**
  20469. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  20470. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  20471. */
  20472. animate(preWarmOnly?: boolean): void;
  20473. private _appendParticleVertices;
  20474. /**
  20475. * Rebuilds the particle system.
  20476. */
  20477. rebuild(): void;
  20478. /**
  20479. * Is this system ready to be used/rendered
  20480. * @return true if the system is ready
  20481. */
  20482. isReady(): boolean;
  20483. private _render;
  20484. /**
  20485. * Renders the particle system in its current state.
  20486. * @returns the current number of particles
  20487. */
  20488. render(): number;
  20489. /**
  20490. * Disposes the particle system and free the associated resources
  20491. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  20492. */
  20493. dispose(disposeTexture?: boolean): void;
  20494. /**
  20495. * Clones the particle system.
  20496. * @param name The name of the cloned object
  20497. * @param newEmitter The new emitter to use
  20498. * @returns the cloned particle system
  20499. */
  20500. clone(name: string, newEmitter: any): ParticleSystem;
  20501. /**
  20502. * Serializes the particle system to a JSON object.
  20503. * @returns the JSON object
  20504. */
  20505. serialize(): any;
  20506. /** @hidden */
  20507. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  20508. /** @hidden */
  20509. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  20510. /**
  20511. * Parses a JSON object to create a particle system.
  20512. * @param parsedParticleSystem The JSON object to parse
  20513. * @param scene The scene to create the particle system in
  20514. * @param rootUrl The root url to use to load external dependencies like texture
  20515. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  20516. * @returns the Parsed particle system
  20517. */
  20518. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  20519. }
  20520. }
  20521. declare module "babylonjs/Particles/particle" {
  20522. import { Nullable } from "babylonjs/types";
  20523. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  20524. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  20525. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20526. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  20527. /**
  20528. * A particle represents one of the element emitted by a particle system.
  20529. * This is mainly define by its coordinates, direction, velocity and age.
  20530. */
  20531. export class Particle {
  20532. /**
  20533. * The particle system the particle belongs to.
  20534. */
  20535. particleSystem: ParticleSystem;
  20536. private static _Count;
  20537. /**
  20538. * Unique ID of the particle
  20539. */
  20540. id: number;
  20541. /**
  20542. * The world position of the particle in the scene.
  20543. */
  20544. position: Vector3;
  20545. /**
  20546. * The world direction of the particle in the scene.
  20547. */
  20548. direction: Vector3;
  20549. /**
  20550. * The color of the particle.
  20551. */
  20552. color: Color4;
  20553. /**
  20554. * The color change of the particle per step.
  20555. */
  20556. colorStep: Color4;
  20557. /**
  20558. * Defines how long will the life of the particle be.
  20559. */
  20560. lifeTime: number;
  20561. /**
  20562. * The current age of the particle.
  20563. */
  20564. age: number;
  20565. /**
  20566. * The current size of the particle.
  20567. */
  20568. size: number;
  20569. /**
  20570. * The current scale of the particle.
  20571. */
  20572. scale: Vector2;
  20573. /**
  20574. * The current angle of the particle.
  20575. */
  20576. angle: number;
  20577. /**
  20578. * Defines how fast is the angle changing.
  20579. */
  20580. angularSpeed: number;
  20581. /**
  20582. * Defines the cell index used by the particle to be rendered from a sprite.
  20583. */
  20584. cellIndex: number;
  20585. /**
  20586. * The information required to support color remapping
  20587. */
  20588. remapData: Vector4;
  20589. /** @hidden */
  20590. _randomCellOffset?: number;
  20591. /** @hidden */
  20592. _initialDirection: Nullable<Vector3>;
  20593. /** @hidden */
  20594. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  20595. /** @hidden */
  20596. _initialStartSpriteCellID: number;
  20597. /** @hidden */
  20598. _initialEndSpriteCellID: number;
  20599. /** @hidden */
  20600. _currentColorGradient: Nullable<ColorGradient>;
  20601. /** @hidden */
  20602. _currentColor1: Color4;
  20603. /** @hidden */
  20604. _currentColor2: Color4;
  20605. /** @hidden */
  20606. _currentSizeGradient: Nullable<FactorGradient>;
  20607. /** @hidden */
  20608. _currentSize1: number;
  20609. /** @hidden */
  20610. _currentSize2: number;
  20611. /** @hidden */
  20612. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  20613. /** @hidden */
  20614. _currentAngularSpeed1: number;
  20615. /** @hidden */
  20616. _currentAngularSpeed2: number;
  20617. /** @hidden */
  20618. _currentVelocityGradient: Nullable<FactorGradient>;
  20619. /** @hidden */
  20620. _currentVelocity1: number;
  20621. /** @hidden */
  20622. _currentVelocity2: number;
  20623. /** @hidden */
  20624. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  20625. /** @hidden */
  20626. _currentLimitVelocity1: number;
  20627. /** @hidden */
  20628. _currentLimitVelocity2: number;
  20629. /** @hidden */
  20630. _currentDragGradient: Nullable<FactorGradient>;
  20631. /** @hidden */
  20632. _currentDrag1: number;
  20633. /** @hidden */
  20634. _currentDrag2: number;
  20635. /** @hidden */
  20636. _randomNoiseCoordinates1: Vector3;
  20637. /** @hidden */
  20638. _randomNoiseCoordinates2: Vector3;
  20639. /**
  20640. * Creates a new instance Particle
  20641. * @param particleSystem the particle system the particle belongs to
  20642. */
  20643. constructor(
  20644. /**
  20645. * The particle system the particle belongs to.
  20646. */
  20647. particleSystem: ParticleSystem);
  20648. private updateCellInfoFromSystem;
  20649. /**
  20650. * Defines how the sprite cell index is updated for the particle
  20651. */
  20652. updateCellIndex(): void;
  20653. /** @hidden */
  20654. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  20655. /** @hidden */
  20656. _inheritParticleInfoToSubEmitters(): void;
  20657. /** @hidden */
  20658. _reset(): void;
  20659. /**
  20660. * Copy the properties of particle to another one.
  20661. * @param other the particle to copy the information to.
  20662. */
  20663. copyTo(other: Particle): void;
  20664. }
  20665. }
  20666. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  20667. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20668. import { Effect } from "babylonjs/Materials/effect";
  20669. import { Particle } from "babylonjs/Particles/particle";
  20670. /**
  20671. * Particle emitter represents a volume emitting particles.
  20672. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  20673. */
  20674. export interface IParticleEmitterType {
  20675. /**
  20676. * Called by the particle System when the direction is computed for the created particle.
  20677. * @param worldMatrix is the world matrix of the particle system
  20678. * @param directionToUpdate is the direction vector to update with the result
  20679. * @param particle is the particle we are computed the direction for
  20680. */
  20681. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20682. /**
  20683. * Called by the particle System when the position is computed for the created particle.
  20684. * @param worldMatrix is the world matrix of the particle system
  20685. * @param positionToUpdate is the position vector to update with the result
  20686. * @param particle is the particle we are computed the position for
  20687. */
  20688. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20689. /**
  20690. * Clones the current emitter and returns a copy of it
  20691. * @returns the new emitter
  20692. */
  20693. clone(): IParticleEmitterType;
  20694. /**
  20695. * Called by the GPUParticleSystem to setup the update shader
  20696. * @param effect defines the update shader
  20697. */
  20698. applyToShader(effect: Effect): void;
  20699. /**
  20700. * Returns a string to use to update the GPU particles update shader
  20701. * @returns the effect defines string
  20702. */
  20703. getEffectDefines(): string;
  20704. /**
  20705. * Returns a string representing the class name
  20706. * @returns a string containing the class name
  20707. */
  20708. getClassName(): string;
  20709. /**
  20710. * Serializes the particle system to a JSON object.
  20711. * @returns the JSON object
  20712. */
  20713. serialize(): any;
  20714. /**
  20715. * Parse properties from a JSON object
  20716. * @param serializationObject defines the JSON object
  20717. */
  20718. parse(serializationObject: any): void;
  20719. }
  20720. }
  20721. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  20722. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20723. import { Effect } from "babylonjs/Materials/effect";
  20724. import { Particle } from "babylonjs/Particles/particle";
  20725. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20726. /**
  20727. * Particle emitter emitting particles from the inside of a box.
  20728. * It emits the particles randomly between 2 given directions.
  20729. */
  20730. export class BoxParticleEmitter implements IParticleEmitterType {
  20731. /**
  20732. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20733. */
  20734. direction1: Vector3;
  20735. /**
  20736. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20737. */
  20738. direction2: Vector3;
  20739. /**
  20740. * 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.
  20741. */
  20742. minEmitBox: Vector3;
  20743. /**
  20744. * 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.
  20745. */
  20746. maxEmitBox: Vector3;
  20747. /**
  20748. * Creates a new instance BoxParticleEmitter
  20749. */
  20750. constructor();
  20751. /**
  20752. * Called by the particle System when the direction is computed for the created particle.
  20753. * @param worldMatrix is the world matrix of the particle system
  20754. * @param directionToUpdate is the direction vector to update with the result
  20755. * @param particle is the particle we are computed the direction for
  20756. */
  20757. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20758. /**
  20759. * Called by the particle System when the position is computed for the created particle.
  20760. * @param worldMatrix is the world matrix of the particle system
  20761. * @param positionToUpdate is the position vector to update with the result
  20762. * @param particle is the particle we are computed the position for
  20763. */
  20764. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20765. /**
  20766. * Clones the current emitter and returns a copy of it
  20767. * @returns the new emitter
  20768. */
  20769. clone(): BoxParticleEmitter;
  20770. /**
  20771. * Called by the GPUParticleSystem to setup the update shader
  20772. * @param effect defines the update shader
  20773. */
  20774. applyToShader(effect: Effect): void;
  20775. /**
  20776. * Returns a string to use to update the GPU particles update shader
  20777. * @returns a string containng the defines string
  20778. */
  20779. getEffectDefines(): string;
  20780. /**
  20781. * Returns the string "BoxParticleEmitter"
  20782. * @returns a string containing the class name
  20783. */
  20784. getClassName(): string;
  20785. /**
  20786. * Serializes the particle system to a JSON object.
  20787. * @returns the JSON object
  20788. */
  20789. serialize(): any;
  20790. /**
  20791. * Parse properties from a JSON object
  20792. * @param serializationObject defines the JSON object
  20793. */
  20794. parse(serializationObject: any): void;
  20795. }
  20796. }
  20797. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  20798. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20799. import { Effect } from "babylonjs/Materials/effect";
  20800. import { Particle } from "babylonjs/Particles/particle";
  20801. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20802. /**
  20803. * Particle emitter emitting particles from the inside of a cone.
  20804. * It emits the particles alongside the cone volume from the base to the particle.
  20805. * The emission direction might be randomized.
  20806. */
  20807. export class ConeParticleEmitter implements IParticleEmitterType {
  20808. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20809. directionRandomizer: number;
  20810. private _radius;
  20811. private _angle;
  20812. private _height;
  20813. /**
  20814. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  20815. */
  20816. radiusRange: number;
  20817. /**
  20818. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  20819. */
  20820. heightRange: number;
  20821. /**
  20822. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  20823. */
  20824. emitFromSpawnPointOnly: boolean;
  20825. /**
  20826. * Gets or sets the radius of the emission cone
  20827. */
  20828. radius: number;
  20829. /**
  20830. * Gets or sets the angle of the emission cone
  20831. */
  20832. angle: number;
  20833. private _buildHeight;
  20834. /**
  20835. * Creates a new instance ConeParticleEmitter
  20836. * @param radius the radius of the emission cone (1 by default)
  20837. * @param angle the cone base angle (PI by default)
  20838. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  20839. */
  20840. constructor(radius?: number, angle?: number,
  20841. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20842. directionRandomizer?: number);
  20843. /**
  20844. * Called by the particle System when the direction is computed for the created particle.
  20845. * @param worldMatrix is the world matrix of the particle system
  20846. * @param directionToUpdate is the direction vector to update with the result
  20847. * @param particle is the particle we are computed the direction for
  20848. */
  20849. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20850. /**
  20851. * Called by the particle System when the position is computed for the created particle.
  20852. * @param worldMatrix is the world matrix of the particle system
  20853. * @param positionToUpdate is the position vector to update with the result
  20854. * @param particle is the particle we are computed the position for
  20855. */
  20856. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20857. /**
  20858. * Clones the current emitter and returns a copy of it
  20859. * @returns the new emitter
  20860. */
  20861. clone(): ConeParticleEmitter;
  20862. /**
  20863. * Called by the GPUParticleSystem to setup the update shader
  20864. * @param effect defines the update shader
  20865. */
  20866. applyToShader(effect: Effect): void;
  20867. /**
  20868. * Returns a string to use to update the GPU particles update shader
  20869. * @returns a string containng the defines string
  20870. */
  20871. getEffectDefines(): string;
  20872. /**
  20873. * Returns the string "ConeParticleEmitter"
  20874. * @returns a string containing the class name
  20875. */
  20876. getClassName(): string;
  20877. /**
  20878. * Serializes the particle system to a JSON object.
  20879. * @returns the JSON object
  20880. */
  20881. serialize(): any;
  20882. /**
  20883. * Parse properties from a JSON object
  20884. * @param serializationObject defines the JSON object
  20885. */
  20886. parse(serializationObject: any): void;
  20887. }
  20888. }
  20889. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  20890. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20891. import { Effect } from "babylonjs/Materials/effect";
  20892. import { Particle } from "babylonjs/Particles/particle";
  20893. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20894. /**
  20895. * Particle emitter emitting particles from the inside of a cylinder.
  20896. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  20897. */
  20898. export class CylinderParticleEmitter implements IParticleEmitterType {
  20899. /**
  20900. * The radius of the emission cylinder.
  20901. */
  20902. radius: number;
  20903. /**
  20904. * The height of the emission cylinder.
  20905. */
  20906. height: number;
  20907. /**
  20908. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20909. */
  20910. radiusRange: number;
  20911. /**
  20912. * How much to randomize the particle direction [0-1].
  20913. */
  20914. directionRandomizer: number;
  20915. /**
  20916. * Creates a new instance CylinderParticleEmitter
  20917. * @param radius the radius of the emission cylinder (1 by default)
  20918. * @param height the height of the emission cylinder (1 by default)
  20919. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20920. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20921. */
  20922. constructor(
  20923. /**
  20924. * The radius of the emission cylinder.
  20925. */
  20926. radius?: number,
  20927. /**
  20928. * The height of the emission cylinder.
  20929. */
  20930. height?: number,
  20931. /**
  20932. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20933. */
  20934. radiusRange?: number,
  20935. /**
  20936. * How much to randomize the particle direction [0-1].
  20937. */
  20938. directionRandomizer?: number);
  20939. /**
  20940. * Called by the particle System when the direction is computed for the created particle.
  20941. * @param worldMatrix is the world matrix of the particle system
  20942. * @param directionToUpdate is the direction vector to update with the result
  20943. * @param particle is the particle we are computed the direction for
  20944. */
  20945. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20946. /**
  20947. * Called by the particle System when the position is computed for the created particle.
  20948. * @param worldMatrix is the world matrix of the particle system
  20949. * @param positionToUpdate is the position vector to update with the result
  20950. * @param particle is the particle we are computed the position for
  20951. */
  20952. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20953. /**
  20954. * Clones the current emitter and returns a copy of it
  20955. * @returns the new emitter
  20956. */
  20957. clone(): CylinderParticleEmitter;
  20958. /**
  20959. * Called by the GPUParticleSystem to setup the update shader
  20960. * @param effect defines the update shader
  20961. */
  20962. applyToShader(effect: Effect): void;
  20963. /**
  20964. * Returns a string to use to update the GPU particles update shader
  20965. * @returns a string containng the defines string
  20966. */
  20967. getEffectDefines(): string;
  20968. /**
  20969. * Returns the string "CylinderParticleEmitter"
  20970. * @returns a string containing the class name
  20971. */
  20972. getClassName(): string;
  20973. /**
  20974. * Serializes the particle system to a JSON object.
  20975. * @returns the JSON object
  20976. */
  20977. serialize(): any;
  20978. /**
  20979. * Parse properties from a JSON object
  20980. * @param serializationObject defines the JSON object
  20981. */
  20982. parse(serializationObject: any): void;
  20983. }
  20984. /**
  20985. * Particle emitter emitting particles from the inside of a cylinder.
  20986. * It emits the particles randomly between two vectors.
  20987. */
  20988. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  20989. /**
  20990. * The min limit of the emission direction.
  20991. */
  20992. direction1: Vector3;
  20993. /**
  20994. * The max limit of the emission direction.
  20995. */
  20996. direction2: Vector3;
  20997. /**
  20998. * Creates a new instance CylinderDirectedParticleEmitter
  20999. * @param radius the radius of the emission cylinder (1 by default)
  21000. * @param height the height of the emission cylinder (1 by default)
  21001. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21002. * @param direction1 the min limit of the emission direction (up vector by default)
  21003. * @param direction2 the max limit of the emission direction (up vector by default)
  21004. */
  21005. constructor(radius?: number, height?: number, radiusRange?: number,
  21006. /**
  21007. * The min limit of the emission direction.
  21008. */
  21009. direction1?: Vector3,
  21010. /**
  21011. * The max limit of the emission direction.
  21012. */
  21013. direction2?: Vector3);
  21014. /**
  21015. * Called by the particle System when the direction is computed for the created particle.
  21016. * @param worldMatrix is the world matrix of the particle system
  21017. * @param directionToUpdate is the direction vector to update with the result
  21018. * @param particle is the particle we are computed the direction for
  21019. */
  21020. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21021. /**
  21022. * Clones the current emitter and returns a copy of it
  21023. * @returns the new emitter
  21024. */
  21025. clone(): CylinderDirectedParticleEmitter;
  21026. /**
  21027. * Called by the GPUParticleSystem to setup the update shader
  21028. * @param effect defines the update shader
  21029. */
  21030. applyToShader(effect: Effect): void;
  21031. /**
  21032. * Returns a string to use to update the GPU particles update shader
  21033. * @returns a string containng the defines string
  21034. */
  21035. getEffectDefines(): string;
  21036. /**
  21037. * Returns the string "CylinderDirectedParticleEmitter"
  21038. * @returns a string containing the class name
  21039. */
  21040. getClassName(): string;
  21041. /**
  21042. * Serializes the particle system to a JSON object.
  21043. * @returns the JSON object
  21044. */
  21045. serialize(): any;
  21046. /**
  21047. * Parse properties from a JSON object
  21048. * @param serializationObject defines the JSON object
  21049. */
  21050. parse(serializationObject: any): void;
  21051. }
  21052. }
  21053. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  21054. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21055. import { Effect } from "babylonjs/Materials/effect";
  21056. import { Particle } from "babylonjs/Particles/particle";
  21057. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21058. /**
  21059. * Particle emitter emitting particles from the inside of a hemisphere.
  21060. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  21061. */
  21062. export class HemisphericParticleEmitter implements IParticleEmitterType {
  21063. /**
  21064. * The radius of the emission hemisphere.
  21065. */
  21066. radius: number;
  21067. /**
  21068. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21069. */
  21070. radiusRange: number;
  21071. /**
  21072. * How much to randomize the particle direction [0-1].
  21073. */
  21074. directionRandomizer: number;
  21075. /**
  21076. * Creates a new instance HemisphericParticleEmitter
  21077. * @param radius the radius of the emission hemisphere (1 by default)
  21078. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21079. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21080. */
  21081. constructor(
  21082. /**
  21083. * The radius of the emission hemisphere.
  21084. */
  21085. radius?: number,
  21086. /**
  21087. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21088. */
  21089. radiusRange?: number,
  21090. /**
  21091. * How much to randomize the particle direction [0-1].
  21092. */
  21093. directionRandomizer?: number);
  21094. /**
  21095. * Called by the particle System when the direction is computed for the created particle.
  21096. * @param worldMatrix is the world matrix of the particle system
  21097. * @param directionToUpdate is the direction vector to update with the result
  21098. * @param particle is the particle we are computed the direction for
  21099. */
  21100. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21101. /**
  21102. * Called by the particle System when the position is computed for the created particle.
  21103. * @param worldMatrix is the world matrix of the particle system
  21104. * @param positionToUpdate is the position vector to update with the result
  21105. * @param particle is the particle we are computed the position for
  21106. */
  21107. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21108. /**
  21109. * Clones the current emitter and returns a copy of it
  21110. * @returns the new emitter
  21111. */
  21112. clone(): HemisphericParticleEmitter;
  21113. /**
  21114. * Called by the GPUParticleSystem to setup the update shader
  21115. * @param effect defines the update shader
  21116. */
  21117. applyToShader(effect: Effect): void;
  21118. /**
  21119. * Returns a string to use to update the GPU particles update shader
  21120. * @returns a string containng the defines string
  21121. */
  21122. getEffectDefines(): string;
  21123. /**
  21124. * Returns the string "HemisphericParticleEmitter"
  21125. * @returns a string containing the class name
  21126. */
  21127. getClassName(): string;
  21128. /**
  21129. * Serializes the particle system to a JSON object.
  21130. * @returns the JSON object
  21131. */
  21132. serialize(): any;
  21133. /**
  21134. * Parse properties from a JSON object
  21135. * @param serializationObject defines the JSON object
  21136. */
  21137. parse(serializationObject: any): void;
  21138. }
  21139. }
  21140. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  21141. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21142. import { Effect } from "babylonjs/Materials/effect";
  21143. import { Particle } from "babylonjs/Particles/particle";
  21144. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21145. /**
  21146. * Particle emitter emitting particles from a point.
  21147. * It emits the particles randomly between 2 given directions.
  21148. */
  21149. export class PointParticleEmitter implements IParticleEmitterType {
  21150. /**
  21151. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21152. */
  21153. direction1: Vector3;
  21154. /**
  21155. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21156. */
  21157. direction2: Vector3;
  21158. /**
  21159. * Creates a new instance PointParticleEmitter
  21160. */
  21161. constructor();
  21162. /**
  21163. * Called by the particle System when the direction is computed for the created particle.
  21164. * @param worldMatrix is the world matrix of the particle system
  21165. * @param directionToUpdate is the direction vector to update with the result
  21166. * @param particle is the particle we are computed the direction for
  21167. */
  21168. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21169. /**
  21170. * Called by the particle System when the position is computed for the created particle.
  21171. * @param worldMatrix is the world matrix of the particle system
  21172. * @param positionToUpdate is the position vector to update with the result
  21173. * @param particle is the particle we are computed the position for
  21174. */
  21175. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21176. /**
  21177. * Clones the current emitter and returns a copy of it
  21178. * @returns the new emitter
  21179. */
  21180. clone(): PointParticleEmitter;
  21181. /**
  21182. * Called by the GPUParticleSystem to setup the update shader
  21183. * @param effect defines the update shader
  21184. */
  21185. applyToShader(effect: Effect): void;
  21186. /**
  21187. * Returns a string to use to update the GPU particles update shader
  21188. * @returns a string containng the defines string
  21189. */
  21190. getEffectDefines(): string;
  21191. /**
  21192. * Returns the string "PointParticleEmitter"
  21193. * @returns a string containing the class name
  21194. */
  21195. getClassName(): string;
  21196. /**
  21197. * Serializes the particle system to a JSON object.
  21198. * @returns the JSON object
  21199. */
  21200. serialize(): any;
  21201. /**
  21202. * Parse properties from a JSON object
  21203. * @param serializationObject defines the JSON object
  21204. */
  21205. parse(serializationObject: any): void;
  21206. }
  21207. }
  21208. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  21209. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21210. import { Effect } from "babylonjs/Materials/effect";
  21211. import { Particle } from "babylonjs/Particles/particle";
  21212. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21213. /**
  21214. * Particle emitter emitting particles from the inside of a sphere.
  21215. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  21216. */
  21217. export class SphereParticleEmitter implements IParticleEmitterType {
  21218. /**
  21219. * The radius of the emission sphere.
  21220. */
  21221. radius: number;
  21222. /**
  21223. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21224. */
  21225. radiusRange: number;
  21226. /**
  21227. * How much to randomize the particle direction [0-1].
  21228. */
  21229. directionRandomizer: number;
  21230. /**
  21231. * Creates a new instance SphereParticleEmitter
  21232. * @param radius the radius of the emission sphere (1 by default)
  21233. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21234. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21235. */
  21236. constructor(
  21237. /**
  21238. * The radius of the emission sphere.
  21239. */
  21240. radius?: number,
  21241. /**
  21242. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21243. */
  21244. radiusRange?: number,
  21245. /**
  21246. * How much to randomize the particle direction [0-1].
  21247. */
  21248. directionRandomizer?: number);
  21249. /**
  21250. * Called by the particle System when the direction is computed for the created particle.
  21251. * @param worldMatrix is the world matrix of the particle system
  21252. * @param directionToUpdate is the direction vector to update with the result
  21253. * @param particle is the particle we are computed the direction for
  21254. */
  21255. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21256. /**
  21257. * Called by the particle System when the position is computed for the created particle.
  21258. * @param worldMatrix is the world matrix of the particle system
  21259. * @param positionToUpdate is the position vector to update with the result
  21260. * @param particle is the particle we are computed the position for
  21261. */
  21262. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21263. /**
  21264. * Clones the current emitter and returns a copy of it
  21265. * @returns the new emitter
  21266. */
  21267. clone(): SphereParticleEmitter;
  21268. /**
  21269. * Called by the GPUParticleSystem to setup the update shader
  21270. * @param effect defines the update shader
  21271. */
  21272. applyToShader(effect: Effect): void;
  21273. /**
  21274. * Returns a string to use to update the GPU particles update shader
  21275. * @returns a string containng the defines string
  21276. */
  21277. getEffectDefines(): string;
  21278. /**
  21279. * Returns the string "SphereParticleEmitter"
  21280. * @returns a string containing the class name
  21281. */
  21282. getClassName(): string;
  21283. /**
  21284. * Serializes the particle system to a JSON object.
  21285. * @returns the JSON object
  21286. */
  21287. serialize(): any;
  21288. /**
  21289. * Parse properties from a JSON object
  21290. * @param serializationObject defines the JSON object
  21291. */
  21292. parse(serializationObject: any): void;
  21293. }
  21294. /**
  21295. * Particle emitter emitting particles from the inside of a sphere.
  21296. * It emits the particles randomly between two vectors.
  21297. */
  21298. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  21299. /**
  21300. * The min limit of the emission direction.
  21301. */
  21302. direction1: Vector3;
  21303. /**
  21304. * The max limit of the emission direction.
  21305. */
  21306. direction2: Vector3;
  21307. /**
  21308. * Creates a new instance SphereDirectedParticleEmitter
  21309. * @param radius the radius of the emission sphere (1 by default)
  21310. * @param direction1 the min limit of the emission direction (up vector by default)
  21311. * @param direction2 the max limit of the emission direction (up vector by default)
  21312. */
  21313. constructor(radius?: number,
  21314. /**
  21315. * The min limit of the emission direction.
  21316. */
  21317. direction1?: Vector3,
  21318. /**
  21319. * The max limit of the emission direction.
  21320. */
  21321. direction2?: Vector3);
  21322. /**
  21323. * Called by the particle System when the direction is computed for the created particle.
  21324. * @param worldMatrix is the world matrix of the particle system
  21325. * @param directionToUpdate is the direction vector to update with the result
  21326. * @param particle is the particle we are computed the direction for
  21327. */
  21328. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21329. /**
  21330. * Clones the current emitter and returns a copy of it
  21331. * @returns the new emitter
  21332. */
  21333. clone(): SphereDirectedParticleEmitter;
  21334. /**
  21335. * Called by the GPUParticleSystem to setup the update shader
  21336. * @param effect defines the update shader
  21337. */
  21338. applyToShader(effect: Effect): void;
  21339. /**
  21340. * Returns a string to use to update the GPU particles update shader
  21341. * @returns a string containng the defines string
  21342. */
  21343. getEffectDefines(): string;
  21344. /**
  21345. * Returns the string "SphereDirectedParticleEmitter"
  21346. * @returns a string containing the class name
  21347. */
  21348. getClassName(): string;
  21349. /**
  21350. * Serializes the particle system to a JSON object.
  21351. * @returns the JSON object
  21352. */
  21353. serialize(): any;
  21354. /**
  21355. * Parse properties from a JSON object
  21356. * @param serializationObject defines the JSON object
  21357. */
  21358. parse(serializationObject: any): void;
  21359. }
  21360. }
  21361. declare module "babylonjs/Particles/EmitterTypes/index" {
  21362. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  21363. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  21364. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  21365. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  21366. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21367. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  21368. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  21369. }
  21370. declare module "babylonjs/Particles/IParticleSystem" {
  21371. import { Nullable } from "babylonjs/types";
  21372. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  21373. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21374. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21375. import { Texture } from "babylonjs/Materials/Textures/texture";
  21376. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  21377. import { Scene } from "babylonjs/scene";
  21378. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  21379. import { Animation } from "babylonjs/Animations/animation";
  21380. /**
  21381. * Interface representing a particle system in Babylon.js.
  21382. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  21383. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  21384. */
  21385. export interface IParticleSystem {
  21386. /**
  21387. * List of animations used by the particle system.
  21388. */
  21389. animations: Animation[];
  21390. /**
  21391. * The id of the Particle system.
  21392. */
  21393. id: string;
  21394. /**
  21395. * The name of the Particle system.
  21396. */
  21397. name: string;
  21398. /**
  21399. * The emitter represents the Mesh or position we are attaching the particle system to.
  21400. */
  21401. emitter: Nullable<AbstractMesh | Vector3>;
  21402. /**
  21403. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  21404. */
  21405. isBillboardBased: boolean;
  21406. /**
  21407. * The rendering group used by the Particle system to chose when to render.
  21408. */
  21409. renderingGroupId: number;
  21410. /**
  21411. * The layer mask we are rendering the particles through.
  21412. */
  21413. layerMask: number;
  21414. /**
  21415. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  21416. */
  21417. updateSpeed: number;
  21418. /**
  21419. * The amount of time the particle system is running (depends of the overall update speed).
  21420. */
  21421. targetStopDuration: number;
  21422. /**
  21423. * The texture used to render each particle. (this can be a spritesheet)
  21424. */
  21425. particleTexture: Nullable<Texture>;
  21426. /**
  21427. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  21428. */
  21429. blendMode: number;
  21430. /**
  21431. * Minimum life time of emitting particles.
  21432. */
  21433. minLifeTime: number;
  21434. /**
  21435. * Maximum life time of emitting particles.
  21436. */
  21437. maxLifeTime: number;
  21438. /**
  21439. * Minimum Size of emitting particles.
  21440. */
  21441. minSize: number;
  21442. /**
  21443. * Maximum Size of emitting particles.
  21444. */
  21445. maxSize: number;
  21446. /**
  21447. * Minimum scale of emitting particles on X axis.
  21448. */
  21449. minScaleX: number;
  21450. /**
  21451. * Maximum scale of emitting particles on X axis.
  21452. */
  21453. maxScaleX: number;
  21454. /**
  21455. * Minimum scale of emitting particles on Y axis.
  21456. */
  21457. minScaleY: number;
  21458. /**
  21459. * Maximum scale of emitting particles on Y axis.
  21460. */
  21461. maxScaleY: number;
  21462. /**
  21463. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21464. */
  21465. color1: Color4;
  21466. /**
  21467. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21468. */
  21469. color2: Color4;
  21470. /**
  21471. * Color the particle will have at the end of its lifetime.
  21472. */
  21473. colorDead: Color4;
  21474. /**
  21475. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  21476. */
  21477. emitRate: number;
  21478. /**
  21479. * You can use gravity if you want to give an orientation to your particles.
  21480. */
  21481. gravity: Vector3;
  21482. /**
  21483. * Minimum power of emitting particles.
  21484. */
  21485. minEmitPower: number;
  21486. /**
  21487. * Maximum power of emitting particles.
  21488. */
  21489. maxEmitPower: number;
  21490. /**
  21491. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  21492. */
  21493. minAngularSpeed: number;
  21494. /**
  21495. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  21496. */
  21497. maxAngularSpeed: number;
  21498. /**
  21499. * Gets or sets the minimal initial rotation in radians.
  21500. */
  21501. minInitialRotation: number;
  21502. /**
  21503. * Gets or sets the maximal initial rotation in radians.
  21504. */
  21505. maxInitialRotation: number;
  21506. /**
  21507. * The particle emitter type defines the emitter used by the particle system.
  21508. * It can be for example box, sphere, or cone...
  21509. */
  21510. particleEmitterType: Nullable<IParticleEmitterType>;
  21511. /**
  21512. * Defines the delay in milliseconds before starting the system (0 by default)
  21513. */
  21514. startDelay: number;
  21515. /**
  21516. * 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
  21517. */
  21518. preWarmCycles: number;
  21519. /**
  21520. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  21521. */
  21522. preWarmStepOffset: number;
  21523. /**
  21524. * 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)
  21525. */
  21526. spriteCellChangeSpeed: number;
  21527. /**
  21528. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  21529. */
  21530. startSpriteCellID: number;
  21531. /**
  21532. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  21533. */
  21534. endSpriteCellID: number;
  21535. /**
  21536. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  21537. */
  21538. spriteCellWidth: number;
  21539. /**
  21540. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  21541. */
  21542. spriteCellHeight: number;
  21543. /**
  21544. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  21545. */
  21546. spriteRandomStartCell: boolean;
  21547. /**
  21548. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  21549. */
  21550. isAnimationSheetEnabled: boolean;
  21551. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  21552. translationPivot: Vector2;
  21553. /**
  21554. * Gets or sets a texture used to add random noise to particle positions
  21555. */
  21556. noiseTexture: Nullable<BaseTexture>;
  21557. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  21558. noiseStrength: Vector3;
  21559. /**
  21560. * Gets or sets the billboard mode to use when isBillboardBased = true.
  21561. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  21562. */
  21563. billboardMode: number;
  21564. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  21565. limitVelocityDamping: number;
  21566. /**
  21567. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  21568. */
  21569. beginAnimationOnStart: boolean;
  21570. /**
  21571. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  21572. */
  21573. beginAnimationFrom: number;
  21574. /**
  21575. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  21576. */
  21577. beginAnimationTo: number;
  21578. /**
  21579. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  21580. */
  21581. beginAnimationLoop: boolean;
  21582. /**
  21583. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  21584. */
  21585. disposeOnStop: boolean;
  21586. /**
  21587. * Gets the maximum number of particles active at the same time.
  21588. * @returns The max number of active particles.
  21589. */
  21590. getCapacity(): number;
  21591. /**
  21592. * Gets if the system has been started. (Note: this will still be true after stop is called)
  21593. * @returns True if it has been started, otherwise false.
  21594. */
  21595. isStarted(): boolean;
  21596. /**
  21597. * Animates the particle system for this frame.
  21598. */
  21599. animate(): void;
  21600. /**
  21601. * Renders the particle system in its current state.
  21602. * @returns the current number of particles
  21603. */
  21604. render(): number;
  21605. /**
  21606. * Dispose the particle system and frees its associated resources.
  21607. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  21608. */
  21609. dispose(disposeTexture?: boolean): void;
  21610. /**
  21611. * Clones the particle system.
  21612. * @param name The name of the cloned object
  21613. * @param newEmitter The new emitter to use
  21614. * @returns the cloned particle system
  21615. */
  21616. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  21617. /**
  21618. * Serializes the particle system to a JSON object.
  21619. * @returns the JSON object
  21620. */
  21621. serialize(): any;
  21622. /**
  21623. * Rebuild the particle system
  21624. */
  21625. rebuild(): void;
  21626. /**
  21627. * Starts the particle system and begins to emit
  21628. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  21629. */
  21630. start(delay?: number): void;
  21631. /**
  21632. * Stops the particle system.
  21633. */
  21634. stop(): void;
  21635. /**
  21636. * Remove all active particles
  21637. */
  21638. reset(): void;
  21639. /**
  21640. * Is this system ready to be used/rendered
  21641. * @return true if the system is ready
  21642. */
  21643. isReady(): boolean;
  21644. /**
  21645. * Adds a new color gradient
  21646. * @param gradient defines the gradient to use (between 0 and 1)
  21647. * @param color1 defines the color to affect to the specified gradient
  21648. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  21649. * @returns the current particle system
  21650. */
  21651. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  21652. /**
  21653. * Remove a specific color gradient
  21654. * @param gradient defines the gradient to remove
  21655. * @returns the current particle system
  21656. */
  21657. removeColorGradient(gradient: number): IParticleSystem;
  21658. /**
  21659. * Adds a new size gradient
  21660. * @param gradient defines the gradient to use (between 0 and 1)
  21661. * @param factor defines the size factor to affect to the specified gradient
  21662. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21663. * @returns the current particle system
  21664. */
  21665. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21666. /**
  21667. * Remove a specific size gradient
  21668. * @param gradient defines the gradient to remove
  21669. * @returns the current particle system
  21670. */
  21671. removeSizeGradient(gradient: number): IParticleSystem;
  21672. /**
  21673. * Gets the current list of color gradients.
  21674. * You must use addColorGradient and removeColorGradient to udpate this list
  21675. * @returns the list of color gradients
  21676. */
  21677. getColorGradients(): Nullable<Array<ColorGradient>>;
  21678. /**
  21679. * Gets the current list of size gradients.
  21680. * You must use addSizeGradient and removeSizeGradient to udpate this list
  21681. * @returns the list of size gradients
  21682. */
  21683. getSizeGradients(): Nullable<Array<FactorGradient>>;
  21684. /**
  21685. * Gets the current list of angular speed gradients.
  21686. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  21687. * @returns the list of angular speed gradients
  21688. */
  21689. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  21690. /**
  21691. * Adds a new angular speed gradient
  21692. * @param gradient defines the gradient to use (between 0 and 1)
  21693. * @param factor defines the angular speed to affect to the specified gradient
  21694. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21695. * @returns the current particle system
  21696. */
  21697. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21698. /**
  21699. * Remove a specific angular speed gradient
  21700. * @param gradient defines the gradient to remove
  21701. * @returns the current particle system
  21702. */
  21703. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  21704. /**
  21705. * Gets the current list of velocity gradients.
  21706. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  21707. * @returns the list of velocity gradients
  21708. */
  21709. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  21710. /**
  21711. * Adds a new velocity gradient
  21712. * @param gradient defines the gradient to use (between 0 and 1)
  21713. * @param factor defines the velocity to affect to the specified gradient
  21714. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21715. * @returns the current particle system
  21716. */
  21717. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21718. /**
  21719. * Remove a specific velocity gradient
  21720. * @param gradient defines the gradient to remove
  21721. * @returns the current particle system
  21722. */
  21723. removeVelocityGradient(gradient: number): IParticleSystem;
  21724. /**
  21725. * Gets the current list of limit velocity gradients.
  21726. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  21727. * @returns the list of limit velocity gradients
  21728. */
  21729. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  21730. /**
  21731. * Adds a new limit velocity gradient
  21732. * @param gradient defines the gradient to use (between 0 and 1)
  21733. * @param factor defines the limit velocity to affect to the specified gradient
  21734. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21735. * @returns the current particle system
  21736. */
  21737. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21738. /**
  21739. * Remove a specific limit velocity gradient
  21740. * @param gradient defines the gradient to remove
  21741. * @returns the current particle system
  21742. */
  21743. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  21744. /**
  21745. * Adds a new drag gradient
  21746. * @param gradient defines the gradient to use (between 0 and 1)
  21747. * @param factor defines the drag to affect to the specified gradient
  21748. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21749. * @returns the current particle system
  21750. */
  21751. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21752. /**
  21753. * Remove a specific drag gradient
  21754. * @param gradient defines the gradient to remove
  21755. * @returns the current particle system
  21756. */
  21757. removeDragGradient(gradient: number): IParticleSystem;
  21758. /**
  21759. * Gets the current list of drag gradients.
  21760. * You must use addDragGradient and removeDragGradient to udpate this list
  21761. * @returns the list of drag gradients
  21762. */
  21763. getDragGradients(): Nullable<Array<FactorGradient>>;
  21764. /**
  21765. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  21766. * @param gradient defines the gradient to use (between 0 and 1)
  21767. * @param factor defines the emit rate to affect to the specified gradient
  21768. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21769. * @returns the current particle system
  21770. */
  21771. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21772. /**
  21773. * Remove a specific emit rate gradient
  21774. * @param gradient defines the gradient to remove
  21775. * @returns the current particle system
  21776. */
  21777. removeEmitRateGradient(gradient: number): IParticleSystem;
  21778. /**
  21779. * Gets the current list of emit rate gradients.
  21780. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  21781. * @returns the list of emit rate gradients
  21782. */
  21783. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  21784. /**
  21785. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  21786. * @param gradient defines the gradient to use (between 0 and 1)
  21787. * @param factor defines the start size to affect to the specified gradient
  21788. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21789. * @returns the current particle system
  21790. */
  21791. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21792. /**
  21793. * Remove a specific start size gradient
  21794. * @param gradient defines the gradient to remove
  21795. * @returns the current particle system
  21796. */
  21797. removeStartSizeGradient(gradient: number): IParticleSystem;
  21798. /**
  21799. * Gets the current list of start size gradients.
  21800. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  21801. * @returns the list of start size gradients
  21802. */
  21803. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  21804. /**
  21805. * Adds a new life time gradient
  21806. * @param gradient defines the gradient to use (between 0 and 1)
  21807. * @param factor defines the life time factor to affect to the specified gradient
  21808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21809. * @returns the current particle system
  21810. */
  21811. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21812. /**
  21813. * Remove a specific life time gradient
  21814. * @param gradient defines the gradient to remove
  21815. * @returns the current particle system
  21816. */
  21817. removeLifeTimeGradient(gradient: number): IParticleSystem;
  21818. /**
  21819. * Gets the current list of life time gradients.
  21820. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  21821. * @returns the list of life time gradients
  21822. */
  21823. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  21824. /**
  21825. * Gets the current list of color gradients.
  21826. * You must use addColorGradient and removeColorGradient to udpate this list
  21827. * @returns the list of color gradients
  21828. */
  21829. getColorGradients(): Nullable<Array<ColorGradient>>;
  21830. /**
  21831. * Adds a new ramp gradient used to remap particle colors
  21832. * @param gradient defines the gradient to use (between 0 and 1)
  21833. * @param color defines the color to affect to the specified gradient
  21834. * @returns the current particle system
  21835. */
  21836. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  21837. /**
  21838. * Gets the current list of ramp gradients.
  21839. * You must use addRampGradient and removeRampGradient to udpate this list
  21840. * @returns the list of ramp gradients
  21841. */
  21842. getRampGradients(): Nullable<Array<Color3Gradient>>;
  21843. /** Gets or sets a boolean indicating that ramp gradients must be used
  21844. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  21845. */
  21846. useRampGradients: boolean;
  21847. /**
  21848. * Adds a new color remap gradient
  21849. * @param gradient defines the gradient to use (between 0 and 1)
  21850. * @param min defines the color remap minimal range
  21851. * @param max defines the color remap maximal range
  21852. * @returns the current particle system
  21853. */
  21854. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21855. /**
  21856. * Gets the current list of color remap gradients.
  21857. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  21858. * @returns the list of color remap gradients
  21859. */
  21860. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  21861. /**
  21862. * Adds a new alpha remap gradient
  21863. * @param gradient defines the gradient to use (between 0 and 1)
  21864. * @param min defines the alpha remap minimal range
  21865. * @param max defines the alpha remap maximal range
  21866. * @returns the current particle system
  21867. */
  21868. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21869. /**
  21870. * Gets the current list of alpha remap gradients.
  21871. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  21872. * @returns the list of alpha remap gradients
  21873. */
  21874. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  21875. /**
  21876. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  21877. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21878. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21879. * @returns the emitter
  21880. */
  21881. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  21882. /**
  21883. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  21884. * @param radius The radius of the hemisphere to emit from
  21885. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21886. * @returns the emitter
  21887. */
  21888. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  21889. /**
  21890. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  21891. * @param radius The radius of the sphere to emit from
  21892. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21893. * @returns the emitter
  21894. */
  21895. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  21896. /**
  21897. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  21898. * @param radius The radius of the sphere to emit from
  21899. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  21900. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  21901. * @returns the emitter
  21902. */
  21903. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21904. /**
  21905. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  21906. * @param radius The radius of the emission cylinder
  21907. * @param height The height of the emission cylinder
  21908. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  21909. * @param directionRandomizer How much to randomize the particle direction [0-1]
  21910. * @returns the emitter
  21911. */
  21912. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  21913. /**
  21914. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  21915. * @param radius The radius of the cylinder to emit from
  21916. * @param height The height of the emission cylinder
  21917. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21918. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  21919. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  21920. * @returns the emitter
  21921. */
  21922. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21923. /**
  21924. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21925. * @param radius The radius of the cone to emit from
  21926. * @param angle The base angle of the cone
  21927. * @returns the emitter
  21928. */
  21929. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  21930. /**
  21931. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21932. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21933. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21934. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21935. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21936. * @returns the emitter
  21937. */
  21938. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21939. /**
  21940. * Get hosting scene
  21941. * @returns the scene
  21942. */
  21943. getScene(): Scene;
  21944. }
  21945. }
  21946. declare module "babylonjs/Shaders/line.fragment" {
  21947. /** @hidden */
  21948. export var linePixelShader: {
  21949. name: string;
  21950. shader: string;
  21951. };
  21952. }
  21953. declare module "babylonjs/Shaders/line.vertex" {
  21954. /** @hidden */
  21955. export var lineVertexShader: {
  21956. name: string;
  21957. shader: string;
  21958. };
  21959. }
  21960. declare module "babylonjs/Rendering/edgesRenderer" {
  21961. import { Nullable } from "babylonjs/types";
  21962. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21964. import { Vector3 } from "babylonjs/Maths/math";
  21965. import { IDisposable } from "babylonjs/scene";
  21966. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  21967. import "babylonjs/Shaders/line.fragment";
  21968. import "babylonjs/Shaders/line.vertex";
  21969. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21970. module "babylonjs/Meshes/abstractMesh" {
  21971. interface AbstractMesh {
  21972. /**
  21973. * Gets the edgesRenderer associated with the mesh
  21974. */
  21975. edgesRenderer: Nullable<EdgesRenderer>;
  21976. }
  21977. }
  21978. module "babylonjs/Meshes/linesMesh" {
  21979. interface LinesMesh {
  21980. /**
  21981. * Enables the edge rendering mode on the mesh.
  21982. * This mode makes the mesh edges visible
  21983. * @param epsilon defines the maximal distance between two angles to detect a face
  21984. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21985. * @returns the currentAbstractMesh
  21986. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21987. */
  21988. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21989. }
  21990. }
  21991. module "babylonjs/Meshes/linesMesh" {
  21992. interface InstancedLinesMesh {
  21993. /**
  21994. * Enables the edge rendering mode on the mesh.
  21995. * This mode makes the mesh edges visible
  21996. * @param epsilon defines the maximal distance between two angles to detect a face
  21997. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21998. * @returns the current InstancedLinesMesh
  21999. * @see https://www.babylonjs-playground.com/#19O9TU#0
  22000. */
  22001. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  22002. }
  22003. }
  22004. /**
  22005. * Defines the minimum contract an Edges renderer should follow.
  22006. */
  22007. export interface IEdgesRenderer extends IDisposable {
  22008. /**
  22009. * Gets or sets a boolean indicating if the edgesRenderer is active
  22010. */
  22011. isEnabled: boolean;
  22012. /**
  22013. * Renders the edges of the attached mesh,
  22014. */
  22015. render(): void;
  22016. /**
  22017. * Checks wether or not the edges renderer is ready to render.
  22018. * @return true if ready, otherwise false.
  22019. */
  22020. isReady(): boolean;
  22021. }
  22022. /**
  22023. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  22024. */
  22025. export class EdgesRenderer implements IEdgesRenderer {
  22026. /**
  22027. * Define the size of the edges with an orthographic camera
  22028. */
  22029. edgesWidthScalerForOrthographic: number;
  22030. /**
  22031. * Define the size of the edges with a perspective camera
  22032. */
  22033. edgesWidthScalerForPerspective: number;
  22034. protected _source: AbstractMesh;
  22035. protected _linesPositions: number[];
  22036. protected _linesNormals: number[];
  22037. protected _linesIndices: number[];
  22038. protected _epsilon: number;
  22039. protected _indicesCount: number;
  22040. protected _lineShader: ShaderMaterial;
  22041. protected _ib: DataBuffer;
  22042. protected _buffers: {
  22043. [key: string]: Nullable<VertexBuffer>;
  22044. };
  22045. protected _checkVerticesInsteadOfIndices: boolean;
  22046. private _meshRebuildObserver;
  22047. private _meshDisposeObserver;
  22048. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  22049. isEnabled: boolean;
  22050. /**
  22051. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  22052. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  22053. * @param source Mesh used to create edges
  22054. * @param epsilon sum of angles in adjacency to check for edge
  22055. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  22056. * @param generateEdgesLines - should generate Lines or only prepare resources.
  22057. */
  22058. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  22059. protected _prepareRessources(): void;
  22060. /** @hidden */
  22061. _rebuild(): void;
  22062. /**
  22063. * Releases the required resources for the edges renderer
  22064. */
  22065. dispose(): void;
  22066. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  22067. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  22068. /**
  22069. * Checks if the pair of p0 and p1 is en edge
  22070. * @param faceIndex
  22071. * @param edge
  22072. * @param faceNormals
  22073. * @param p0
  22074. * @param p1
  22075. * @private
  22076. */
  22077. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  22078. /**
  22079. * push line into the position, normal and index buffer
  22080. * @protected
  22081. */
  22082. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  22083. /**
  22084. * Generates lines edges from adjacencjes
  22085. * @private
  22086. */
  22087. _generateEdgesLines(): void;
  22088. /**
  22089. * Checks wether or not the edges renderer is ready to render.
  22090. * @return true if ready, otherwise false.
  22091. */
  22092. isReady(): boolean;
  22093. /**
  22094. * Renders the edges of the attached mesh,
  22095. */
  22096. render(): void;
  22097. }
  22098. /**
  22099. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  22100. */
  22101. export class LineEdgesRenderer extends EdgesRenderer {
  22102. /**
  22103. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  22104. * @param source LineMesh used to generate edges
  22105. * @param epsilon not important (specified angle for edge detection)
  22106. * @param checkVerticesInsteadOfIndices not important for LineMesh
  22107. */
  22108. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  22109. /**
  22110. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  22111. */
  22112. _generateEdgesLines(): void;
  22113. }
  22114. }
  22115. declare module "babylonjs/Rendering/renderingGroup" {
  22116. import { SmartArray } from "babylonjs/Misc/smartArray";
  22117. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22119. import { Nullable } from "babylonjs/types";
  22120. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22121. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  22122. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22123. import { Material } from "babylonjs/Materials/material";
  22124. import { Scene } from "babylonjs/scene";
  22125. /**
  22126. * This represents the object necessary to create a rendering group.
  22127. * This is exclusively used and created by the rendering manager.
  22128. * To modify the behavior, you use the available helpers in your scene or meshes.
  22129. * @hidden
  22130. */
  22131. export class RenderingGroup {
  22132. index: number;
  22133. private static _zeroVector;
  22134. private _scene;
  22135. private _opaqueSubMeshes;
  22136. private _transparentSubMeshes;
  22137. private _alphaTestSubMeshes;
  22138. private _depthOnlySubMeshes;
  22139. private _particleSystems;
  22140. private _spriteManagers;
  22141. private _opaqueSortCompareFn;
  22142. private _alphaTestSortCompareFn;
  22143. private _transparentSortCompareFn;
  22144. private _renderOpaque;
  22145. private _renderAlphaTest;
  22146. private _renderTransparent;
  22147. /** @hidden */
  22148. _edgesRenderers: SmartArray<IEdgesRenderer>;
  22149. onBeforeTransparentRendering: () => void;
  22150. /**
  22151. * Set the opaque sort comparison function.
  22152. * If null the sub meshes will be render in the order they were created
  22153. */
  22154. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22155. /**
  22156. * Set the alpha test sort comparison function.
  22157. * If null the sub meshes will be render in the order they were created
  22158. */
  22159. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22160. /**
  22161. * Set the transparent sort comparison function.
  22162. * If null the sub meshes will be render in the order they were created
  22163. */
  22164. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22165. /**
  22166. * Creates a new rendering group.
  22167. * @param index The rendering group index
  22168. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  22169. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  22170. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  22171. */
  22172. 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>);
  22173. /**
  22174. * Render all the sub meshes contained in the group.
  22175. * @param customRenderFunction Used to override the default render behaviour of the group.
  22176. * @returns true if rendered some submeshes.
  22177. */
  22178. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  22179. /**
  22180. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  22181. * @param subMeshes The submeshes to render
  22182. */
  22183. private renderOpaqueSorted;
  22184. /**
  22185. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  22186. * @param subMeshes The submeshes to render
  22187. */
  22188. private renderAlphaTestSorted;
  22189. /**
  22190. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  22191. * @param subMeshes The submeshes to render
  22192. */
  22193. private renderTransparentSorted;
  22194. /**
  22195. * Renders the submeshes in a specified order.
  22196. * @param subMeshes The submeshes to sort before render
  22197. * @param sortCompareFn The comparison function use to sort
  22198. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  22199. * @param transparent Specifies to activate blending if true
  22200. */
  22201. private static renderSorted;
  22202. /**
  22203. * Renders the submeshes in the order they were dispatched (no sort applied).
  22204. * @param subMeshes The submeshes to render
  22205. */
  22206. private static renderUnsorted;
  22207. /**
  22208. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22209. * are rendered back to front if in the same alpha index.
  22210. *
  22211. * @param a The first submesh
  22212. * @param b The second submesh
  22213. * @returns The result of the comparison
  22214. */
  22215. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  22216. /**
  22217. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22218. * are rendered back to front.
  22219. *
  22220. * @param a The first submesh
  22221. * @param b The second submesh
  22222. * @returns The result of the comparison
  22223. */
  22224. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  22225. /**
  22226. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22227. * are rendered front to back (prevent overdraw).
  22228. *
  22229. * @param a The first submesh
  22230. * @param b The second submesh
  22231. * @returns The result of the comparison
  22232. */
  22233. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  22234. /**
  22235. * Resets the different lists of submeshes to prepare a new frame.
  22236. */
  22237. prepare(): void;
  22238. dispose(): void;
  22239. /**
  22240. * Inserts the submesh in its correct queue depending on its material.
  22241. * @param subMesh The submesh to dispatch
  22242. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22243. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22244. */
  22245. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22246. dispatchSprites(spriteManager: ISpriteManager): void;
  22247. dispatchParticles(particleSystem: IParticleSystem): void;
  22248. private _renderParticles;
  22249. private _renderSprites;
  22250. }
  22251. }
  22252. declare module "babylonjs/Rendering/renderingManager" {
  22253. import { Nullable } from "babylonjs/types";
  22254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22255. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22256. import { SmartArray } from "babylonjs/Misc/smartArray";
  22257. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22258. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22259. import { Material } from "babylonjs/Materials/material";
  22260. import { Scene } from "babylonjs/scene";
  22261. import { Camera } from "babylonjs/Cameras/camera";
  22262. /**
  22263. * Interface describing the different options available in the rendering manager
  22264. * regarding Auto Clear between groups.
  22265. */
  22266. export interface IRenderingManagerAutoClearSetup {
  22267. /**
  22268. * Defines whether or not autoclear is enable.
  22269. */
  22270. autoClear: boolean;
  22271. /**
  22272. * Defines whether or not to autoclear the depth buffer.
  22273. */
  22274. depth: boolean;
  22275. /**
  22276. * Defines whether or not to autoclear the stencil buffer.
  22277. */
  22278. stencil: boolean;
  22279. }
  22280. /**
  22281. * This class is used by the onRenderingGroupObservable
  22282. */
  22283. export class RenderingGroupInfo {
  22284. /**
  22285. * The Scene that being rendered
  22286. */
  22287. scene: Scene;
  22288. /**
  22289. * The camera currently used for the rendering pass
  22290. */
  22291. camera: Nullable<Camera>;
  22292. /**
  22293. * The ID of the renderingGroup being processed
  22294. */
  22295. renderingGroupId: number;
  22296. }
  22297. /**
  22298. * This is the manager responsible of all the rendering for meshes sprites and particles.
  22299. * It is enable to manage the different groups as well as the different necessary sort functions.
  22300. * This should not be used directly aside of the few static configurations
  22301. */
  22302. export class RenderingManager {
  22303. /**
  22304. * The max id used for rendering groups (not included)
  22305. */
  22306. static MAX_RENDERINGGROUPS: number;
  22307. /**
  22308. * The min id used for rendering groups (included)
  22309. */
  22310. static MIN_RENDERINGGROUPS: number;
  22311. /**
  22312. * Used to globally prevent autoclearing scenes.
  22313. */
  22314. static AUTOCLEAR: boolean;
  22315. /**
  22316. * @hidden
  22317. */
  22318. _useSceneAutoClearSetup: boolean;
  22319. private _scene;
  22320. private _renderingGroups;
  22321. private _depthStencilBufferAlreadyCleaned;
  22322. private _autoClearDepthStencil;
  22323. private _customOpaqueSortCompareFn;
  22324. private _customAlphaTestSortCompareFn;
  22325. private _customTransparentSortCompareFn;
  22326. private _renderingGroupInfo;
  22327. /**
  22328. * Instantiates a new rendering group for a particular scene
  22329. * @param scene Defines the scene the groups belongs to
  22330. */
  22331. constructor(scene: Scene);
  22332. private _clearDepthStencilBuffer;
  22333. /**
  22334. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  22335. * @hidden
  22336. */
  22337. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  22338. /**
  22339. * Resets the different information of the group to prepare a new frame
  22340. * @hidden
  22341. */
  22342. reset(): void;
  22343. /**
  22344. * Dispose and release the group and its associated resources.
  22345. * @hidden
  22346. */
  22347. dispose(): void;
  22348. /**
  22349. * Clear the info related to rendering groups preventing retention points during dispose.
  22350. */
  22351. freeRenderingGroups(): void;
  22352. private _prepareRenderingGroup;
  22353. /**
  22354. * Add a sprite manager to the rendering manager in order to render it this frame.
  22355. * @param spriteManager Define the sprite manager to render
  22356. */
  22357. dispatchSprites(spriteManager: ISpriteManager): void;
  22358. /**
  22359. * Add a particle system to the rendering manager in order to render it this frame.
  22360. * @param particleSystem Define the particle system to render
  22361. */
  22362. dispatchParticles(particleSystem: IParticleSystem): void;
  22363. /**
  22364. * Add a submesh to the manager in order to render it this frame
  22365. * @param subMesh The submesh to dispatch
  22366. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22367. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22368. */
  22369. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22370. /**
  22371. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22372. * This allowed control for front to back rendering or reversly depending of the special needs.
  22373. *
  22374. * @param renderingGroupId The rendering group id corresponding to its index
  22375. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22376. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22377. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22378. */
  22379. 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;
  22380. /**
  22381. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22382. *
  22383. * @param renderingGroupId The rendering group id corresponding to its index
  22384. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22385. * @param depth Automatically clears depth between groups if true and autoClear is true.
  22386. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  22387. */
  22388. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  22389. /**
  22390. * Gets the current auto clear configuration for one rendering group of the rendering
  22391. * manager.
  22392. * @param index the rendering group index to get the information for
  22393. * @returns The auto clear setup for the requested rendering group
  22394. */
  22395. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  22396. }
  22397. }
  22398. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  22399. import { Observable } from "babylonjs/Misc/observable";
  22400. import { SmartArray } from "babylonjs/Misc/smartArray";
  22401. import { Nullable } from "babylonjs/types";
  22402. import { Camera } from "babylonjs/Cameras/camera";
  22403. import { Scene } from "babylonjs/scene";
  22404. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  22405. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  22406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22407. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22408. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  22409. import { Texture } from "babylonjs/Materials/Textures/texture";
  22410. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  22411. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  22412. import "babylonjs/Engines/Extensions/engine.renderTarget";
  22413. import { Engine } from "babylonjs/Engines/engine";
  22414. /**
  22415. * This Helps creating a texture that will be created from a camera in your scene.
  22416. * It is basically a dynamic texture that could be used to create special effects for instance.
  22417. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  22418. */
  22419. export class RenderTargetTexture extends Texture {
  22420. isCube: boolean;
  22421. /**
  22422. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  22423. */
  22424. static readonly REFRESHRATE_RENDER_ONCE: number;
  22425. /**
  22426. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  22427. */
  22428. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  22429. /**
  22430. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  22431. * the central point of your effect and can save a lot of performances.
  22432. */
  22433. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  22434. /**
  22435. * Use this predicate to dynamically define the list of mesh you want to render.
  22436. * If set, the renderList property will be overwritten.
  22437. */
  22438. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  22439. private _renderList;
  22440. /**
  22441. * Use this list to define the list of mesh you want to render.
  22442. */
  22443. renderList: Nullable<Array<AbstractMesh>>;
  22444. private _hookArray;
  22445. /**
  22446. * Define if particles should be rendered in your texture.
  22447. */
  22448. renderParticles: boolean;
  22449. /**
  22450. * Define if sprites should be rendered in your texture.
  22451. */
  22452. renderSprites: boolean;
  22453. /**
  22454. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  22455. */
  22456. coordinatesMode: number;
  22457. /**
  22458. * Define the camera used to render the texture.
  22459. */
  22460. activeCamera: Nullable<Camera>;
  22461. /**
  22462. * Override the render function of the texture with your own one.
  22463. */
  22464. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  22465. /**
  22466. * Define if camera post processes should be use while rendering the texture.
  22467. */
  22468. useCameraPostProcesses: boolean;
  22469. /**
  22470. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  22471. */
  22472. ignoreCameraViewport: boolean;
  22473. private _postProcessManager;
  22474. private _postProcesses;
  22475. private _resizeObserver;
  22476. /**
  22477. * An event triggered when the texture is unbind.
  22478. */
  22479. onBeforeBindObservable: Observable<RenderTargetTexture>;
  22480. /**
  22481. * An event triggered when the texture is unbind.
  22482. */
  22483. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  22484. private _onAfterUnbindObserver;
  22485. /**
  22486. * Set a after unbind callback in the texture.
  22487. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  22488. */
  22489. onAfterUnbind: () => void;
  22490. /**
  22491. * An event triggered before rendering the texture
  22492. */
  22493. onBeforeRenderObservable: Observable<number>;
  22494. private _onBeforeRenderObserver;
  22495. /**
  22496. * Set a before render callback in the texture.
  22497. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  22498. */
  22499. onBeforeRender: (faceIndex: number) => void;
  22500. /**
  22501. * An event triggered after rendering the texture
  22502. */
  22503. onAfterRenderObservable: Observable<number>;
  22504. private _onAfterRenderObserver;
  22505. /**
  22506. * Set a after render callback in the texture.
  22507. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  22508. */
  22509. onAfterRender: (faceIndex: number) => void;
  22510. /**
  22511. * An event triggered after the texture clear
  22512. */
  22513. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  22514. private _onClearObserver;
  22515. /**
  22516. * Set a clear callback in the texture.
  22517. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  22518. */
  22519. onClear: (Engine: Engine) => void;
  22520. /**
  22521. * Define the clear color of the Render Target if it should be different from the scene.
  22522. */
  22523. clearColor: Color4;
  22524. protected _size: number | {
  22525. width: number;
  22526. height: number;
  22527. };
  22528. protected _initialSizeParameter: number | {
  22529. width: number;
  22530. height: number;
  22531. } | {
  22532. ratio: number;
  22533. };
  22534. protected _sizeRatio: Nullable<number>;
  22535. /** @hidden */
  22536. _generateMipMaps: boolean;
  22537. protected _renderingManager: RenderingManager;
  22538. /** @hidden */
  22539. _waitingRenderList: string[];
  22540. protected _doNotChangeAspectRatio: boolean;
  22541. protected _currentRefreshId: number;
  22542. protected _refreshRate: number;
  22543. protected _textureMatrix: Matrix;
  22544. protected _samples: number;
  22545. protected _renderTargetOptions: RenderTargetCreationOptions;
  22546. /**
  22547. * Gets render target creation options that were used.
  22548. */
  22549. readonly renderTargetOptions: RenderTargetCreationOptions;
  22550. protected _engine: Engine;
  22551. protected _onRatioRescale(): void;
  22552. /**
  22553. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  22554. * It must define where the camera used to render the texture is set
  22555. */
  22556. boundingBoxPosition: Vector3;
  22557. private _boundingBoxSize;
  22558. /**
  22559. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  22560. * When defined, the cubemap will switch to local mode
  22561. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  22562. * @example https://www.babylonjs-playground.com/#RNASML
  22563. */
  22564. boundingBoxSize: Vector3;
  22565. /**
  22566. * In case the RTT has been created with a depth texture, get the associated
  22567. * depth texture.
  22568. * Otherwise, return null.
  22569. */
  22570. depthStencilTexture: Nullable<InternalTexture>;
  22571. /**
  22572. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  22573. * or used a shadow, depth texture...
  22574. * @param name The friendly name of the texture
  22575. * @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)
  22576. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  22577. * @param generateMipMaps True if mip maps need to be generated after render.
  22578. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  22579. * @param type The type of the buffer in the RTT (int, half float, float...)
  22580. * @param isCube True if a cube texture needs to be created
  22581. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  22582. * @param generateDepthBuffer True to generate a depth buffer
  22583. * @param generateStencilBuffer True to generate a stencil buffer
  22584. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  22585. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  22586. * @param delayAllocation if the texture allocation should be delayed (default: false)
  22587. */
  22588. constructor(name: string, size: number | {
  22589. width: number;
  22590. height: number;
  22591. } | {
  22592. ratio: number;
  22593. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  22594. /**
  22595. * Creates a depth stencil texture.
  22596. * This is only available in WebGL 2 or with the depth texture extension available.
  22597. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  22598. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  22599. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  22600. */
  22601. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  22602. private _processSizeParameter;
  22603. /**
  22604. * Define the number of samples to use in case of MSAA.
  22605. * It defaults to one meaning no MSAA has been enabled.
  22606. */
  22607. samples: number;
  22608. /**
  22609. * Resets the refresh counter of the texture and start bak from scratch.
  22610. * Could be useful to regenerate the texture if it is setup to render only once.
  22611. */
  22612. resetRefreshCounter(): void;
  22613. /**
  22614. * Define the refresh rate of the texture or the rendering frequency.
  22615. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  22616. */
  22617. refreshRate: number;
  22618. /**
  22619. * Adds a post process to the render target rendering passes.
  22620. * @param postProcess define the post process to add
  22621. */
  22622. addPostProcess(postProcess: PostProcess): void;
  22623. /**
  22624. * Clear all the post processes attached to the render target
  22625. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  22626. */
  22627. clearPostProcesses(dispose?: boolean): void;
  22628. /**
  22629. * Remove one of the post process from the list of attached post processes to the texture
  22630. * @param postProcess define the post process to remove from the list
  22631. */
  22632. removePostProcess(postProcess: PostProcess): void;
  22633. /** @hidden */
  22634. _shouldRender(): boolean;
  22635. /**
  22636. * Gets the actual render size of the texture.
  22637. * @returns the width of the render size
  22638. */
  22639. getRenderSize(): number;
  22640. /**
  22641. * Gets the actual render width of the texture.
  22642. * @returns the width of the render size
  22643. */
  22644. getRenderWidth(): number;
  22645. /**
  22646. * Gets the actual render height of the texture.
  22647. * @returns the height of the render size
  22648. */
  22649. getRenderHeight(): number;
  22650. /**
  22651. * Get if the texture can be rescaled or not.
  22652. */
  22653. readonly canRescale: boolean;
  22654. /**
  22655. * Resize the texture using a ratio.
  22656. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  22657. */
  22658. scale(ratio: number): void;
  22659. /**
  22660. * Get the texture reflection matrix used to rotate/transform the reflection.
  22661. * @returns the reflection matrix
  22662. */
  22663. getReflectionTextureMatrix(): Matrix;
  22664. /**
  22665. * Resize the texture to a new desired size.
  22666. * Be carrefull as it will recreate all the data in the new texture.
  22667. * @param size Define the new size. It can be:
  22668. * - a number for squared texture,
  22669. * - an object containing { width: number, height: number }
  22670. * - or an object containing a ratio { ratio: number }
  22671. */
  22672. resize(size: number | {
  22673. width: number;
  22674. height: number;
  22675. } | {
  22676. ratio: number;
  22677. }): void;
  22678. /**
  22679. * Renders all the objects from the render list into the texture.
  22680. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  22681. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  22682. */
  22683. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  22684. private _bestReflectionRenderTargetDimension;
  22685. /**
  22686. * @hidden
  22687. * @param faceIndex face index to bind to if this is a cubetexture
  22688. */
  22689. _bindFrameBuffer(faceIndex?: number): void;
  22690. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  22691. private renderToTarget;
  22692. /**
  22693. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22694. * This allowed control for front to back rendering or reversly depending of the special needs.
  22695. *
  22696. * @param renderingGroupId The rendering group id corresponding to its index
  22697. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22698. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22699. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22700. */
  22701. 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;
  22702. /**
  22703. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22704. *
  22705. * @param renderingGroupId The rendering group id corresponding to its index
  22706. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22707. */
  22708. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  22709. /**
  22710. * Clones the texture.
  22711. * @returns the cloned texture
  22712. */
  22713. clone(): RenderTargetTexture;
  22714. /**
  22715. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  22716. * @returns The JSON representation of the texture
  22717. */
  22718. serialize(): any;
  22719. /**
  22720. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  22721. */
  22722. disposeFramebufferObjects(): void;
  22723. /**
  22724. * Dispose the texture and release its associated resources.
  22725. */
  22726. dispose(): void;
  22727. /** @hidden */
  22728. _rebuild(): void;
  22729. /**
  22730. * Clear the info related to rendering groups preventing retention point in material dispose.
  22731. */
  22732. freeRenderingGroups(): void;
  22733. /**
  22734. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  22735. * @returns the view count
  22736. */
  22737. getViewCount(): number;
  22738. }
  22739. }
  22740. declare module "babylonjs/Materials/material" {
  22741. import { IAnimatable } from "babylonjs/Misc/tools";
  22742. import { SmartArray } from "babylonjs/Misc/smartArray";
  22743. import { Observable } from "babylonjs/Misc/observable";
  22744. import { Nullable } from "babylonjs/types";
  22745. import { Scene } from "babylonjs/scene";
  22746. import { Matrix } from "babylonjs/Maths/math";
  22747. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22749. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22750. import { Effect } from "babylonjs/Materials/effect";
  22751. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22752. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22753. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22754. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22755. import { Mesh } from "babylonjs/Meshes/mesh";
  22756. import { Animation } from "babylonjs/Animations/animation";
  22757. /**
  22758. * Base class for the main features of a material in Babylon.js
  22759. */
  22760. export class Material implements IAnimatable {
  22761. /**
  22762. * Returns the triangle fill mode
  22763. */
  22764. static readonly TriangleFillMode: number;
  22765. /**
  22766. * Returns the wireframe mode
  22767. */
  22768. static readonly WireFrameFillMode: number;
  22769. /**
  22770. * Returns the point fill mode
  22771. */
  22772. static readonly PointFillMode: number;
  22773. /**
  22774. * Returns the point list draw mode
  22775. */
  22776. static readonly PointListDrawMode: number;
  22777. /**
  22778. * Returns the line list draw mode
  22779. */
  22780. static readonly LineListDrawMode: number;
  22781. /**
  22782. * Returns the line loop draw mode
  22783. */
  22784. static readonly LineLoopDrawMode: number;
  22785. /**
  22786. * Returns the line strip draw mode
  22787. */
  22788. static readonly LineStripDrawMode: number;
  22789. /**
  22790. * Returns the triangle strip draw mode
  22791. */
  22792. static readonly TriangleStripDrawMode: number;
  22793. /**
  22794. * Returns the triangle fan draw mode
  22795. */
  22796. static readonly TriangleFanDrawMode: number;
  22797. /**
  22798. * Stores the clock-wise side orientation
  22799. */
  22800. static readonly ClockWiseSideOrientation: number;
  22801. /**
  22802. * Stores the counter clock-wise side orientation
  22803. */
  22804. static readonly CounterClockWiseSideOrientation: number;
  22805. /**
  22806. * The dirty texture flag value
  22807. */
  22808. static readonly TextureDirtyFlag: number;
  22809. /**
  22810. * The dirty light flag value
  22811. */
  22812. static readonly LightDirtyFlag: number;
  22813. /**
  22814. * The dirty fresnel flag value
  22815. */
  22816. static readonly FresnelDirtyFlag: number;
  22817. /**
  22818. * The dirty attribute flag value
  22819. */
  22820. static readonly AttributesDirtyFlag: number;
  22821. /**
  22822. * The dirty misc flag value
  22823. */
  22824. static readonly MiscDirtyFlag: number;
  22825. /**
  22826. * The all dirty flag value
  22827. */
  22828. static readonly AllDirtyFlag: number;
  22829. /**
  22830. * The ID of the material
  22831. */
  22832. id: string;
  22833. /**
  22834. * Gets or sets the unique id of the material
  22835. */
  22836. uniqueId: number;
  22837. /**
  22838. * The name of the material
  22839. */
  22840. name: string;
  22841. /**
  22842. * Gets or sets user defined metadata
  22843. */
  22844. metadata: any;
  22845. /**
  22846. * For internal use only. Please do not use.
  22847. */
  22848. reservedDataStore: any;
  22849. /**
  22850. * Specifies if the ready state should be checked on each call
  22851. */
  22852. checkReadyOnEveryCall: boolean;
  22853. /**
  22854. * Specifies if the ready state should be checked once
  22855. */
  22856. checkReadyOnlyOnce: boolean;
  22857. /**
  22858. * The state of the material
  22859. */
  22860. state: string;
  22861. /**
  22862. * The alpha value of the material
  22863. */
  22864. protected _alpha: number;
  22865. /**
  22866. * List of inspectable custom properties (used by the Inspector)
  22867. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22868. */
  22869. inspectableCustomProperties: IInspectable[];
  22870. /**
  22871. * Sets the alpha value of the material
  22872. */
  22873. /**
  22874. * Gets the alpha value of the material
  22875. */
  22876. alpha: number;
  22877. /**
  22878. * Specifies if back face culling is enabled
  22879. */
  22880. protected _backFaceCulling: boolean;
  22881. /**
  22882. * Sets the back-face culling state
  22883. */
  22884. /**
  22885. * Gets the back-face culling state
  22886. */
  22887. backFaceCulling: boolean;
  22888. /**
  22889. * Stores the value for side orientation
  22890. */
  22891. sideOrientation: number;
  22892. /**
  22893. * Callback triggered when the material is compiled
  22894. */
  22895. onCompiled: Nullable<(effect: Effect) => void>;
  22896. /**
  22897. * Callback triggered when an error occurs
  22898. */
  22899. onError: Nullable<(effect: Effect, errors: string) => void>;
  22900. /**
  22901. * Callback triggered to get the render target textures
  22902. */
  22903. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22904. /**
  22905. * Gets a boolean indicating that current material needs to register RTT
  22906. */
  22907. readonly hasRenderTargetTextures: boolean;
  22908. /**
  22909. * Specifies if the material should be serialized
  22910. */
  22911. doNotSerialize: boolean;
  22912. /**
  22913. * @hidden
  22914. */
  22915. _storeEffectOnSubMeshes: boolean;
  22916. /**
  22917. * Stores the animations for the material
  22918. */
  22919. animations: Nullable<Array<Animation>>;
  22920. /**
  22921. * An event triggered when the material is disposed
  22922. */
  22923. onDisposeObservable: Observable<Material>;
  22924. /**
  22925. * An observer which watches for dispose events
  22926. */
  22927. private _onDisposeObserver;
  22928. private _onUnBindObservable;
  22929. /**
  22930. * Called during a dispose event
  22931. */
  22932. onDispose: () => void;
  22933. private _onBindObservable;
  22934. /**
  22935. * An event triggered when the material is bound
  22936. */
  22937. readonly onBindObservable: Observable<AbstractMesh>;
  22938. /**
  22939. * An observer which watches for bind events
  22940. */
  22941. private _onBindObserver;
  22942. /**
  22943. * Called during a bind event
  22944. */
  22945. onBind: (Mesh: AbstractMesh) => void;
  22946. /**
  22947. * An event triggered when the material is unbound
  22948. */
  22949. readonly onUnBindObservable: Observable<Material>;
  22950. /**
  22951. * Stores the value of the alpha mode
  22952. */
  22953. private _alphaMode;
  22954. /**
  22955. * Sets the value of the alpha mode.
  22956. *
  22957. * | Value | Type | Description |
  22958. * | --- | --- | --- |
  22959. * | 0 | ALPHA_DISABLE | |
  22960. * | 1 | ALPHA_ADD | |
  22961. * | 2 | ALPHA_COMBINE | |
  22962. * | 3 | ALPHA_SUBTRACT | |
  22963. * | 4 | ALPHA_MULTIPLY | |
  22964. * | 5 | ALPHA_MAXIMIZED | |
  22965. * | 6 | ALPHA_ONEONE | |
  22966. * | 7 | ALPHA_PREMULTIPLIED | |
  22967. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22968. * | 9 | ALPHA_INTERPOLATE | |
  22969. * | 10 | ALPHA_SCREENMODE | |
  22970. *
  22971. */
  22972. /**
  22973. * Gets the value of the alpha mode
  22974. */
  22975. alphaMode: number;
  22976. /**
  22977. * Stores the state of the need depth pre-pass value
  22978. */
  22979. private _needDepthPrePass;
  22980. /**
  22981. * Sets the need depth pre-pass value
  22982. */
  22983. /**
  22984. * Gets the depth pre-pass value
  22985. */
  22986. needDepthPrePass: boolean;
  22987. /**
  22988. * Specifies if depth writing should be disabled
  22989. */
  22990. disableDepthWrite: boolean;
  22991. /**
  22992. * Specifies if depth writing should be forced
  22993. */
  22994. forceDepthWrite: boolean;
  22995. /**
  22996. * Specifies if there should be a separate pass for culling
  22997. */
  22998. separateCullingPass: boolean;
  22999. /**
  23000. * Stores the state specifing if fog should be enabled
  23001. */
  23002. private _fogEnabled;
  23003. /**
  23004. * Sets the state for enabling fog
  23005. */
  23006. /**
  23007. * Gets the value of the fog enabled state
  23008. */
  23009. fogEnabled: boolean;
  23010. /**
  23011. * Stores the size of points
  23012. */
  23013. pointSize: number;
  23014. /**
  23015. * Stores the z offset value
  23016. */
  23017. zOffset: number;
  23018. /**
  23019. * Gets a value specifying if wireframe mode is enabled
  23020. */
  23021. /**
  23022. * Sets the state of wireframe mode
  23023. */
  23024. wireframe: boolean;
  23025. /**
  23026. * Gets the value specifying if point clouds are enabled
  23027. */
  23028. /**
  23029. * Sets the state of point cloud mode
  23030. */
  23031. pointsCloud: boolean;
  23032. /**
  23033. * Gets the material fill mode
  23034. */
  23035. /**
  23036. * Sets the material fill mode
  23037. */
  23038. fillMode: number;
  23039. /**
  23040. * @hidden
  23041. * Stores the effects for the material
  23042. */
  23043. _effect: Nullable<Effect>;
  23044. /**
  23045. * @hidden
  23046. * Specifies if the material was previously ready
  23047. */
  23048. _wasPreviouslyReady: boolean;
  23049. /**
  23050. * Specifies if uniform buffers should be used
  23051. */
  23052. private _useUBO;
  23053. /**
  23054. * Stores a reference to the scene
  23055. */
  23056. private _scene;
  23057. /**
  23058. * Stores the fill mode state
  23059. */
  23060. private _fillMode;
  23061. /**
  23062. * Specifies if the depth write state should be cached
  23063. */
  23064. private _cachedDepthWriteState;
  23065. /**
  23066. * Stores the uniform buffer
  23067. */
  23068. protected _uniformBuffer: UniformBuffer;
  23069. /** @hidden */
  23070. _indexInSceneMaterialArray: number;
  23071. /** @hidden */
  23072. meshMap: Nullable<{
  23073. [id: string]: AbstractMesh | undefined;
  23074. }>;
  23075. /**
  23076. * Creates a material instance
  23077. * @param name defines the name of the material
  23078. * @param scene defines the scene to reference
  23079. * @param doNotAdd specifies if the material should be added to the scene
  23080. */
  23081. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  23082. /**
  23083. * Returns a string representation of the current material
  23084. * @param fullDetails defines a boolean indicating which levels of logging is desired
  23085. * @returns a string with material information
  23086. */
  23087. toString(fullDetails?: boolean): string;
  23088. /**
  23089. * Gets the class name of the material
  23090. * @returns a string with the class name of the material
  23091. */
  23092. getClassName(): string;
  23093. /**
  23094. * Specifies if updates for the material been locked
  23095. */
  23096. readonly isFrozen: boolean;
  23097. /**
  23098. * Locks updates for the material
  23099. */
  23100. freeze(): void;
  23101. /**
  23102. * Unlocks updates for the material
  23103. */
  23104. unfreeze(): void;
  23105. /**
  23106. * Specifies if the material is ready to be used
  23107. * @param mesh defines the mesh to check
  23108. * @param useInstances specifies if instances should be used
  23109. * @returns a boolean indicating if the material is ready to be used
  23110. */
  23111. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  23112. /**
  23113. * Specifies that the submesh is ready to be used
  23114. * @param mesh defines the mesh to check
  23115. * @param subMesh defines which submesh to check
  23116. * @param useInstances specifies that instances should be used
  23117. * @returns a boolean indicating that the submesh is ready or not
  23118. */
  23119. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  23120. /**
  23121. * Returns the material effect
  23122. * @returns the effect associated with the material
  23123. */
  23124. getEffect(): Nullable<Effect>;
  23125. /**
  23126. * Returns the current scene
  23127. * @returns a Scene
  23128. */
  23129. getScene(): Scene;
  23130. /**
  23131. * Specifies if the material will require alpha blending
  23132. * @returns a boolean specifying if alpha blending is needed
  23133. */
  23134. needAlphaBlending(): boolean;
  23135. /**
  23136. * Specifies if the mesh will require alpha blending
  23137. * @param mesh defines the mesh to check
  23138. * @returns a boolean specifying if alpha blending is needed for the mesh
  23139. */
  23140. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  23141. /**
  23142. * Specifies if this material should be rendered in alpha test mode
  23143. * @returns a boolean specifying if an alpha test is needed.
  23144. */
  23145. needAlphaTesting(): boolean;
  23146. /**
  23147. * Gets the texture used for the alpha test
  23148. * @returns the texture to use for alpha testing
  23149. */
  23150. getAlphaTestTexture(): Nullable<BaseTexture>;
  23151. /**
  23152. * Marks the material to indicate that it needs to be re-calculated
  23153. */
  23154. markDirty(): void;
  23155. /** @hidden */
  23156. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  23157. /**
  23158. * Binds the material to the mesh
  23159. * @param world defines the world transformation matrix
  23160. * @param mesh defines the mesh to bind the material to
  23161. */
  23162. bind(world: Matrix, mesh?: Mesh): void;
  23163. /**
  23164. * Binds the submesh to the material
  23165. * @param world defines the world transformation matrix
  23166. * @param mesh defines the mesh containing the submesh
  23167. * @param subMesh defines the submesh to bind the material to
  23168. */
  23169. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23170. /**
  23171. * Binds the world matrix to the material
  23172. * @param world defines the world transformation matrix
  23173. */
  23174. bindOnlyWorldMatrix(world: Matrix): void;
  23175. /**
  23176. * Binds the scene's uniform buffer to the effect.
  23177. * @param effect defines the effect to bind to the scene uniform buffer
  23178. * @param sceneUbo defines the uniform buffer storing scene data
  23179. */
  23180. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  23181. /**
  23182. * Binds the view matrix to the effect
  23183. * @param effect defines the effect to bind the view matrix to
  23184. */
  23185. bindView(effect: Effect): void;
  23186. /**
  23187. * Binds the view projection matrix to the effect
  23188. * @param effect defines the effect to bind the view projection matrix to
  23189. */
  23190. bindViewProjection(effect: Effect): void;
  23191. /**
  23192. * Specifies if material alpha testing should be turned on for the mesh
  23193. * @param mesh defines the mesh to check
  23194. */
  23195. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  23196. /**
  23197. * Processes to execute after binding the material to a mesh
  23198. * @param mesh defines the rendered mesh
  23199. */
  23200. protected _afterBind(mesh?: Mesh): void;
  23201. /**
  23202. * Unbinds the material from the mesh
  23203. */
  23204. unbind(): void;
  23205. /**
  23206. * Gets the active textures from the material
  23207. * @returns an array of textures
  23208. */
  23209. getActiveTextures(): BaseTexture[];
  23210. /**
  23211. * Specifies if the material uses a texture
  23212. * @param texture defines the texture to check against the material
  23213. * @returns a boolean specifying if the material uses the texture
  23214. */
  23215. hasTexture(texture: BaseTexture): boolean;
  23216. /**
  23217. * Makes a duplicate of the material, and gives it a new name
  23218. * @param name defines the new name for the duplicated material
  23219. * @returns the cloned material
  23220. */
  23221. clone(name: string): Nullable<Material>;
  23222. /**
  23223. * Gets the meshes bound to the material
  23224. * @returns an array of meshes bound to the material
  23225. */
  23226. getBindedMeshes(): AbstractMesh[];
  23227. /**
  23228. * Force shader compilation
  23229. * @param mesh defines the mesh associated with this material
  23230. * @param onCompiled defines a function to execute once the material is compiled
  23231. * @param options defines the options to configure the compilation
  23232. */
  23233. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23234. clipPlane: boolean;
  23235. }>): void;
  23236. /**
  23237. * Force shader compilation
  23238. * @param mesh defines the mesh that will use this material
  23239. * @param options defines additional options for compiling the shaders
  23240. * @returns a promise that resolves when the compilation completes
  23241. */
  23242. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23243. clipPlane: boolean;
  23244. }>): Promise<void>;
  23245. private static readonly _AllDirtyCallBack;
  23246. private static readonly _ImageProcessingDirtyCallBack;
  23247. private static readonly _TextureDirtyCallBack;
  23248. private static readonly _FresnelDirtyCallBack;
  23249. private static readonly _MiscDirtyCallBack;
  23250. private static readonly _LightsDirtyCallBack;
  23251. private static readonly _AttributeDirtyCallBack;
  23252. private static _FresnelAndMiscDirtyCallBack;
  23253. private static _TextureAndMiscDirtyCallBack;
  23254. private static readonly _DirtyCallbackArray;
  23255. private static readonly _RunDirtyCallBacks;
  23256. /**
  23257. * Marks a define in the material to indicate that it needs to be re-computed
  23258. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23259. */
  23260. markAsDirty(flag: number): void;
  23261. /**
  23262. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23263. * @param func defines a function which checks material defines against the submeshes
  23264. */
  23265. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23266. /**
  23267. * Indicates that we need to re-calculated for all submeshes
  23268. */
  23269. protected _markAllSubMeshesAsAllDirty(): void;
  23270. /**
  23271. * Indicates that image processing needs to be re-calculated for all submeshes
  23272. */
  23273. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23274. /**
  23275. * Indicates that textures need to be re-calculated for all submeshes
  23276. */
  23277. protected _markAllSubMeshesAsTexturesDirty(): void;
  23278. /**
  23279. * Indicates that fresnel needs to be re-calculated for all submeshes
  23280. */
  23281. protected _markAllSubMeshesAsFresnelDirty(): void;
  23282. /**
  23283. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23284. */
  23285. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23286. /**
  23287. * Indicates that lights need to be re-calculated for all submeshes
  23288. */
  23289. protected _markAllSubMeshesAsLightsDirty(): void;
  23290. /**
  23291. * Indicates that attributes need to be re-calculated for all submeshes
  23292. */
  23293. protected _markAllSubMeshesAsAttributesDirty(): void;
  23294. /**
  23295. * Indicates that misc needs to be re-calculated for all submeshes
  23296. */
  23297. protected _markAllSubMeshesAsMiscDirty(): void;
  23298. /**
  23299. * Indicates that textures and misc need to be re-calculated for all submeshes
  23300. */
  23301. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23302. /**
  23303. * Disposes the material
  23304. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23305. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23306. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23307. */
  23308. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23309. /** @hidden */
  23310. private releaseVertexArrayObject;
  23311. /**
  23312. * Serializes this material
  23313. * @returns the serialized material object
  23314. */
  23315. serialize(): any;
  23316. /**
  23317. * Creates a material from parsed material data
  23318. * @param parsedMaterial defines parsed material data
  23319. * @param scene defines the hosting scene
  23320. * @param rootUrl defines the root URL to use to load textures
  23321. * @returns a new material
  23322. */
  23323. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23324. }
  23325. }
  23326. declare module "babylonjs/Meshes/subMesh" {
  23327. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23328. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23329. import { Engine } from "babylonjs/Engines/engine";
  23330. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23331. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23332. import { Effect } from "babylonjs/Materials/effect";
  23333. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23334. import { Collider } from "babylonjs/Collisions/collider";
  23335. import { Material } from "babylonjs/Materials/material";
  23336. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23338. import { Mesh } from "babylonjs/Meshes/mesh";
  23339. import { Ray } from "babylonjs/Culling/ray";
  23340. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23341. /**
  23342. * Base class for submeshes
  23343. */
  23344. export class BaseSubMesh {
  23345. /** @hidden */
  23346. _materialDefines: Nullable<MaterialDefines>;
  23347. /** @hidden */
  23348. _materialEffect: Nullable<Effect>;
  23349. /**
  23350. * Gets associated effect
  23351. */
  23352. readonly effect: Nullable<Effect>;
  23353. /**
  23354. * Sets associated effect (effect used to render this submesh)
  23355. * @param effect defines the effect to associate with
  23356. * @param defines defines the set of defines used to compile this effect
  23357. */
  23358. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23359. }
  23360. /**
  23361. * Defines a subdivision inside a mesh
  23362. */
  23363. export class SubMesh extends BaseSubMesh implements ICullable {
  23364. /** the material index to use */
  23365. materialIndex: number;
  23366. /** vertex index start */
  23367. verticesStart: number;
  23368. /** vertices count */
  23369. verticesCount: number;
  23370. /** index start */
  23371. indexStart: number;
  23372. /** indices count */
  23373. indexCount: number;
  23374. /** @hidden */
  23375. _linesIndexCount: number;
  23376. private _mesh;
  23377. private _renderingMesh;
  23378. private _boundingInfo;
  23379. private _linesIndexBuffer;
  23380. /** @hidden */
  23381. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23382. /** @hidden */
  23383. _trianglePlanes: Plane[];
  23384. /** @hidden */
  23385. _lastColliderTransformMatrix: Nullable<Matrix>;
  23386. /** @hidden */
  23387. _renderId: number;
  23388. /** @hidden */
  23389. _alphaIndex: number;
  23390. /** @hidden */
  23391. _distanceToCamera: number;
  23392. /** @hidden */
  23393. _id: number;
  23394. private _currentMaterial;
  23395. /**
  23396. * Add a new submesh to a mesh
  23397. * @param materialIndex defines the material index to use
  23398. * @param verticesStart defines vertex index start
  23399. * @param verticesCount defines vertices count
  23400. * @param indexStart defines index start
  23401. * @param indexCount defines indices count
  23402. * @param mesh defines the parent mesh
  23403. * @param renderingMesh defines an optional rendering mesh
  23404. * @param createBoundingBox defines if bounding box should be created for this submesh
  23405. * @returns the new submesh
  23406. */
  23407. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23408. /**
  23409. * Creates a new submesh
  23410. * @param materialIndex defines the material index to use
  23411. * @param verticesStart defines vertex index start
  23412. * @param verticesCount defines vertices count
  23413. * @param indexStart defines index start
  23414. * @param indexCount defines indices count
  23415. * @param mesh defines the parent mesh
  23416. * @param renderingMesh defines an optional rendering mesh
  23417. * @param createBoundingBox defines if bounding box should be created for this submesh
  23418. */
  23419. constructor(
  23420. /** the material index to use */
  23421. materialIndex: number,
  23422. /** vertex index start */
  23423. verticesStart: number,
  23424. /** vertices count */
  23425. verticesCount: number,
  23426. /** index start */
  23427. indexStart: number,
  23428. /** indices count */
  23429. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23430. /**
  23431. * Returns true if this submesh covers the entire parent mesh
  23432. * @ignorenaming
  23433. */
  23434. readonly IsGlobal: boolean;
  23435. /**
  23436. * Returns the submesh BoudingInfo object
  23437. * @returns current bounding info (or mesh's one if the submesh is global)
  23438. */
  23439. getBoundingInfo(): BoundingInfo;
  23440. /**
  23441. * Sets the submesh BoundingInfo
  23442. * @param boundingInfo defines the new bounding info to use
  23443. * @returns the SubMesh
  23444. */
  23445. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23446. /**
  23447. * Returns the mesh of the current submesh
  23448. * @return the parent mesh
  23449. */
  23450. getMesh(): AbstractMesh;
  23451. /**
  23452. * Returns the rendering mesh of the submesh
  23453. * @returns the rendering mesh (could be different from parent mesh)
  23454. */
  23455. getRenderingMesh(): Mesh;
  23456. /**
  23457. * Returns the submesh material
  23458. * @returns null or the current material
  23459. */
  23460. getMaterial(): Nullable<Material>;
  23461. /**
  23462. * Sets a new updated BoundingInfo object to the submesh
  23463. * @param data defines an optional position array to use to determine the bounding info
  23464. * @returns the SubMesh
  23465. */
  23466. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23467. /** @hidden */
  23468. _checkCollision(collider: Collider): boolean;
  23469. /**
  23470. * Updates the submesh BoundingInfo
  23471. * @param world defines the world matrix to use to update the bounding info
  23472. * @returns the submesh
  23473. */
  23474. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23475. /**
  23476. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23477. * @param frustumPlanes defines the frustum planes
  23478. * @returns true if the submesh is intersecting with the frustum
  23479. */
  23480. isInFrustum(frustumPlanes: Plane[]): boolean;
  23481. /**
  23482. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23483. * @param frustumPlanes defines the frustum planes
  23484. * @returns true if the submesh is inside the frustum
  23485. */
  23486. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23487. /**
  23488. * Renders the submesh
  23489. * @param enableAlphaMode defines if alpha needs to be used
  23490. * @returns the submesh
  23491. */
  23492. render(enableAlphaMode: boolean): SubMesh;
  23493. /**
  23494. * @hidden
  23495. */
  23496. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23497. /**
  23498. * Checks if the submesh intersects with a ray
  23499. * @param ray defines the ray to test
  23500. * @returns true is the passed ray intersects the submesh bounding box
  23501. */
  23502. canIntersects(ray: Ray): boolean;
  23503. /**
  23504. * Intersects current submesh with a ray
  23505. * @param ray defines the ray to test
  23506. * @param positions defines mesh's positions array
  23507. * @param indices defines mesh's indices array
  23508. * @param fastCheck defines if only bounding info should be used
  23509. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23510. * @returns intersection info or null if no intersection
  23511. */
  23512. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23513. /** @hidden */
  23514. private _intersectLines;
  23515. /** @hidden */
  23516. private _intersectUnIndexedLines;
  23517. /** @hidden */
  23518. private _intersectTriangles;
  23519. /** @hidden */
  23520. private _intersectUnIndexedTriangles;
  23521. /** @hidden */
  23522. _rebuild(): void;
  23523. /**
  23524. * Creates a new submesh from the passed mesh
  23525. * @param newMesh defines the new hosting mesh
  23526. * @param newRenderingMesh defines an optional rendering mesh
  23527. * @returns the new submesh
  23528. */
  23529. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23530. /**
  23531. * Release associated resources
  23532. */
  23533. dispose(): void;
  23534. /**
  23535. * Gets the class name
  23536. * @returns the string "SubMesh".
  23537. */
  23538. getClassName(): string;
  23539. /**
  23540. * Creates a new submesh from indices data
  23541. * @param materialIndex the index of the main mesh material
  23542. * @param startIndex the index where to start the copy in the mesh indices array
  23543. * @param indexCount the number of indices to copy then from the startIndex
  23544. * @param mesh the main mesh to create the submesh from
  23545. * @param renderingMesh the optional rendering mesh
  23546. * @returns a new submesh
  23547. */
  23548. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23549. }
  23550. }
  23551. declare module "babylonjs/Meshes/geometry" {
  23552. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23553. import { Scene } from "babylonjs/scene";
  23554. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23555. import { Engine } from "babylonjs/Engines/engine";
  23556. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23557. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23558. import { Effect } from "babylonjs/Materials/effect";
  23559. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23560. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23561. import { Mesh } from "babylonjs/Meshes/mesh";
  23562. /**
  23563. * Class used to store geometry data (vertex buffers + index buffer)
  23564. */
  23565. export class Geometry implements IGetSetVerticesData {
  23566. /**
  23567. * Gets or sets the ID of the geometry
  23568. */
  23569. id: string;
  23570. /**
  23571. * Gets or sets the unique ID of the geometry
  23572. */
  23573. uniqueId: number;
  23574. /**
  23575. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23576. */
  23577. delayLoadState: number;
  23578. /**
  23579. * Gets the file containing the data to load when running in delay load state
  23580. */
  23581. delayLoadingFile: Nullable<string>;
  23582. /**
  23583. * Callback called when the geometry is updated
  23584. */
  23585. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23586. private _scene;
  23587. private _engine;
  23588. private _meshes;
  23589. private _totalVertices;
  23590. /** @hidden */
  23591. _indices: IndicesArray;
  23592. /** @hidden */
  23593. _vertexBuffers: {
  23594. [key: string]: VertexBuffer;
  23595. };
  23596. private _isDisposed;
  23597. private _extend;
  23598. private _boundingBias;
  23599. /** @hidden */
  23600. _delayInfo: Array<string>;
  23601. private _indexBuffer;
  23602. private _indexBufferIsUpdatable;
  23603. /** @hidden */
  23604. _boundingInfo: Nullable<BoundingInfo>;
  23605. /** @hidden */
  23606. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23607. /** @hidden */
  23608. _softwareSkinningFrameId: number;
  23609. private _vertexArrayObjects;
  23610. private _updatable;
  23611. /** @hidden */
  23612. _positions: Nullable<Vector3[]>;
  23613. /**
  23614. * 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
  23615. */
  23616. /**
  23617. * 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
  23618. */
  23619. boundingBias: Vector2;
  23620. /**
  23621. * Static function used to attach a new empty geometry to a mesh
  23622. * @param mesh defines the mesh to attach the geometry to
  23623. * @returns the new Geometry
  23624. */
  23625. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23626. /**
  23627. * Creates a new geometry
  23628. * @param id defines the unique ID
  23629. * @param scene defines the hosting scene
  23630. * @param vertexData defines the VertexData used to get geometry data
  23631. * @param updatable defines if geometry must be updatable (false by default)
  23632. * @param mesh defines the mesh that will be associated with the geometry
  23633. */
  23634. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23635. /**
  23636. * Gets the current extend of the geometry
  23637. */
  23638. readonly extend: {
  23639. minimum: Vector3;
  23640. maximum: Vector3;
  23641. };
  23642. /**
  23643. * Gets the hosting scene
  23644. * @returns the hosting Scene
  23645. */
  23646. getScene(): Scene;
  23647. /**
  23648. * Gets the hosting engine
  23649. * @returns the hosting Engine
  23650. */
  23651. getEngine(): Engine;
  23652. /**
  23653. * Defines if the geometry is ready to use
  23654. * @returns true if the geometry is ready to be used
  23655. */
  23656. isReady(): boolean;
  23657. /**
  23658. * Gets a value indicating that the geometry should not be serialized
  23659. */
  23660. readonly doNotSerialize: boolean;
  23661. /** @hidden */
  23662. _rebuild(): void;
  23663. /**
  23664. * Affects all geometry data in one call
  23665. * @param vertexData defines the geometry data
  23666. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23667. */
  23668. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23669. /**
  23670. * Set specific vertex data
  23671. * @param kind defines the data kind (Position, normal, etc...)
  23672. * @param data defines the vertex data to use
  23673. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23674. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23675. */
  23676. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23677. /**
  23678. * Removes a specific vertex data
  23679. * @param kind defines the data kind (Position, normal, etc...)
  23680. */
  23681. removeVerticesData(kind: string): void;
  23682. /**
  23683. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23684. * @param buffer defines the vertex buffer to use
  23685. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23686. */
  23687. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23688. /**
  23689. * Update a specific vertex buffer
  23690. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23691. * It will do nothing if the buffer is not updatable
  23692. * @param kind defines the data kind (Position, normal, etc...)
  23693. * @param data defines the data to use
  23694. * @param offset defines the offset in the target buffer where to store the data
  23695. * @param useBytes set to true if the offset is in bytes
  23696. */
  23697. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23698. /**
  23699. * Update a specific vertex buffer
  23700. * This function will create a new buffer if the current one is not updatable
  23701. * @param kind defines the data kind (Position, normal, etc...)
  23702. * @param data defines the data to use
  23703. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23704. */
  23705. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23706. private _updateBoundingInfo;
  23707. /** @hidden */
  23708. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23709. /**
  23710. * Gets total number of vertices
  23711. * @returns the total number of vertices
  23712. */
  23713. getTotalVertices(): number;
  23714. /**
  23715. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23716. * @param kind defines the data kind (Position, normal, etc...)
  23717. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23718. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23719. * @returns a float array containing vertex data
  23720. */
  23721. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23722. /**
  23723. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23724. * @param kind defines the data kind (Position, normal, etc...)
  23725. * @returns true if the vertex buffer with the specified kind is updatable
  23726. */
  23727. isVertexBufferUpdatable(kind: string): boolean;
  23728. /**
  23729. * Gets a specific vertex buffer
  23730. * @param kind defines the data kind (Position, normal, etc...)
  23731. * @returns a VertexBuffer
  23732. */
  23733. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23734. /**
  23735. * Returns all vertex buffers
  23736. * @return an object holding all vertex buffers indexed by kind
  23737. */
  23738. getVertexBuffers(): Nullable<{
  23739. [key: string]: VertexBuffer;
  23740. }>;
  23741. /**
  23742. * Gets a boolean indicating if specific vertex buffer is present
  23743. * @param kind defines the data kind (Position, normal, etc...)
  23744. * @returns true if data is present
  23745. */
  23746. isVerticesDataPresent(kind: string): boolean;
  23747. /**
  23748. * Gets a list of all attached data kinds (Position, normal, etc...)
  23749. * @returns a list of string containing all kinds
  23750. */
  23751. getVerticesDataKinds(): string[];
  23752. /**
  23753. * Update index buffer
  23754. * @param indices defines the indices to store in the index buffer
  23755. * @param offset defines the offset in the target buffer where to store the data
  23756. * @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)
  23757. */
  23758. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23759. /**
  23760. * Creates a new index buffer
  23761. * @param indices defines the indices to store in the index buffer
  23762. * @param totalVertices defines the total number of vertices (could be null)
  23763. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23764. */
  23765. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23766. /**
  23767. * Return the total number of indices
  23768. * @returns the total number of indices
  23769. */
  23770. getTotalIndices(): number;
  23771. /**
  23772. * Gets the index buffer array
  23773. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23774. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23775. * @returns the index buffer array
  23776. */
  23777. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23778. /**
  23779. * Gets the index buffer
  23780. * @return the index buffer
  23781. */
  23782. getIndexBuffer(): Nullable<DataBuffer>;
  23783. /** @hidden */
  23784. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23785. /**
  23786. * Release the associated resources for a specific mesh
  23787. * @param mesh defines the source mesh
  23788. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23789. */
  23790. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23791. /**
  23792. * Apply current geometry to a given mesh
  23793. * @param mesh defines the mesh to apply geometry to
  23794. */
  23795. applyToMesh(mesh: Mesh): void;
  23796. private _updateExtend;
  23797. private _applyToMesh;
  23798. private notifyUpdate;
  23799. /**
  23800. * Load the geometry if it was flagged as delay loaded
  23801. * @param scene defines the hosting scene
  23802. * @param onLoaded defines a callback called when the geometry is loaded
  23803. */
  23804. load(scene: Scene, onLoaded?: () => void): void;
  23805. private _queueLoad;
  23806. /**
  23807. * Invert the geometry to move from a right handed system to a left handed one.
  23808. */
  23809. toLeftHanded(): void;
  23810. /** @hidden */
  23811. _resetPointsArrayCache(): void;
  23812. /** @hidden */
  23813. _generatePointsArray(): boolean;
  23814. /**
  23815. * Gets a value indicating if the geometry is disposed
  23816. * @returns true if the geometry was disposed
  23817. */
  23818. isDisposed(): boolean;
  23819. private _disposeVertexArrayObjects;
  23820. /**
  23821. * Free all associated resources
  23822. */
  23823. dispose(): void;
  23824. /**
  23825. * Clone the current geometry into a new geometry
  23826. * @param id defines the unique ID of the new geometry
  23827. * @returns a new geometry object
  23828. */
  23829. copy(id: string): Geometry;
  23830. /**
  23831. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23832. * @return a JSON representation of the current geometry data (without the vertices data)
  23833. */
  23834. serialize(): any;
  23835. private toNumberArray;
  23836. /**
  23837. * Serialize all vertices data into a JSON oject
  23838. * @returns a JSON representation of the current geometry data
  23839. */
  23840. serializeVerticeData(): any;
  23841. /**
  23842. * Extracts a clone of a mesh geometry
  23843. * @param mesh defines the source mesh
  23844. * @param id defines the unique ID of the new geometry object
  23845. * @returns the new geometry object
  23846. */
  23847. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23848. /**
  23849. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23850. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23851. * Be aware Math.random() could cause collisions, but:
  23852. * "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"
  23853. * @returns a string containing a new GUID
  23854. */
  23855. static RandomId(): string;
  23856. /** @hidden */
  23857. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23858. private static _CleanMatricesWeights;
  23859. /**
  23860. * Create a new geometry from persisted data (Using .babylon file format)
  23861. * @param parsedVertexData defines the persisted data
  23862. * @param scene defines the hosting scene
  23863. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23864. * @returns the new geometry object
  23865. */
  23866. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23867. }
  23868. }
  23869. declare module "babylonjs/Meshes/mesh.vertexData" {
  23870. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23871. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23872. import { Geometry } from "babylonjs/Meshes/geometry";
  23873. import { Mesh } from "babylonjs/Meshes/mesh";
  23874. /**
  23875. * Define an interface for all classes that will get and set the data on vertices
  23876. */
  23877. export interface IGetSetVerticesData {
  23878. /**
  23879. * Gets a boolean indicating if specific vertex data is present
  23880. * @param kind defines the vertex data kind to use
  23881. * @returns true is data kind is present
  23882. */
  23883. isVerticesDataPresent(kind: string): boolean;
  23884. /**
  23885. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23886. * @param kind defines the data kind (Position, normal, etc...)
  23887. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23888. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23889. * @returns a float array containing vertex data
  23890. */
  23891. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23892. /**
  23893. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23894. * @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.
  23895. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23896. * @returns the indices array or an empty array if the mesh has no geometry
  23897. */
  23898. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23899. /**
  23900. * Set specific vertex data
  23901. * @param kind defines the data kind (Position, normal, etc...)
  23902. * @param data defines the vertex data to use
  23903. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23904. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23905. */
  23906. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23907. /**
  23908. * Update a specific associated vertex buffer
  23909. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23910. * - VertexBuffer.PositionKind
  23911. * - VertexBuffer.UVKind
  23912. * - VertexBuffer.UV2Kind
  23913. * - VertexBuffer.UV3Kind
  23914. * - VertexBuffer.UV4Kind
  23915. * - VertexBuffer.UV5Kind
  23916. * - VertexBuffer.UV6Kind
  23917. * - VertexBuffer.ColorKind
  23918. * - VertexBuffer.MatricesIndicesKind
  23919. * - VertexBuffer.MatricesIndicesExtraKind
  23920. * - VertexBuffer.MatricesWeightsKind
  23921. * - VertexBuffer.MatricesWeightsExtraKind
  23922. * @param data defines the data source
  23923. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23924. * @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)
  23925. */
  23926. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23927. /**
  23928. * Creates a new index buffer
  23929. * @param indices defines the indices to store in the index buffer
  23930. * @param totalVertices defines the total number of vertices (could be null)
  23931. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23932. */
  23933. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23934. }
  23935. /**
  23936. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23937. */
  23938. export class VertexData {
  23939. /**
  23940. * Mesh side orientation : usually the external or front surface
  23941. */
  23942. static readonly FRONTSIDE: number;
  23943. /**
  23944. * Mesh side orientation : usually the internal or back surface
  23945. */
  23946. static readonly BACKSIDE: number;
  23947. /**
  23948. * Mesh side orientation : both internal and external or front and back surfaces
  23949. */
  23950. static readonly DOUBLESIDE: number;
  23951. /**
  23952. * Mesh side orientation : by default, `FRONTSIDE`
  23953. */
  23954. static readonly DEFAULTSIDE: number;
  23955. /**
  23956. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23957. */
  23958. positions: Nullable<FloatArray>;
  23959. /**
  23960. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23961. */
  23962. normals: Nullable<FloatArray>;
  23963. /**
  23964. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23965. */
  23966. tangents: Nullable<FloatArray>;
  23967. /**
  23968. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23969. */
  23970. uvs: Nullable<FloatArray>;
  23971. /**
  23972. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23973. */
  23974. uvs2: Nullable<FloatArray>;
  23975. /**
  23976. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23977. */
  23978. uvs3: Nullable<FloatArray>;
  23979. /**
  23980. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23981. */
  23982. uvs4: Nullable<FloatArray>;
  23983. /**
  23984. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23985. */
  23986. uvs5: Nullable<FloatArray>;
  23987. /**
  23988. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23989. */
  23990. uvs6: Nullable<FloatArray>;
  23991. /**
  23992. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23993. */
  23994. colors: Nullable<FloatArray>;
  23995. /**
  23996. * 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).
  23997. */
  23998. matricesIndices: Nullable<FloatArray>;
  23999. /**
  24000. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  24001. */
  24002. matricesWeights: Nullable<FloatArray>;
  24003. /**
  24004. * An array extending the number of possible indices
  24005. */
  24006. matricesIndicesExtra: Nullable<FloatArray>;
  24007. /**
  24008. * An array extending the number of possible weights when the number of indices is extended
  24009. */
  24010. matricesWeightsExtra: Nullable<FloatArray>;
  24011. /**
  24012. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  24013. */
  24014. indices: Nullable<IndicesArray>;
  24015. /**
  24016. * Uses the passed data array to set the set the values for the specified kind of data
  24017. * @param data a linear array of floating numbers
  24018. * @param kind the type of data that is being set, eg positions, colors etc
  24019. */
  24020. set(data: FloatArray, kind: string): void;
  24021. /**
  24022. * Associates the vertexData to the passed Mesh.
  24023. * Sets it as updatable or not (default `false`)
  24024. * @param mesh the mesh the vertexData is applied to
  24025. * @param updatable when used and having the value true allows new data to update the vertexData
  24026. * @returns the VertexData
  24027. */
  24028. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  24029. /**
  24030. * Associates the vertexData to the passed Geometry.
  24031. * Sets it as updatable or not (default `false`)
  24032. * @param geometry the geometry the vertexData is applied to
  24033. * @param updatable when used and having the value true allows new data to update the vertexData
  24034. * @returns VertexData
  24035. */
  24036. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  24037. /**
  24038. * Updates the associated mesh
  24039. * @param mesh the mesh to be updated
  24040. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  24041. * @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
  24042. * @returns VertexData
  24043. */
  24044. updateMesh(mesh: Mesh): VertexData;
  24045. /**
  24046. * Updates the associated geometry
  24047. * @param geometry the geometry to be updated
  24048. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  24049. * @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
  24050. * @returns VertexData.
  24051. */
  24052. updateGeometry(geometry: Geometry): VertexData;
  24053. private _applyTo;
  24054. private _update;
  24055. /**
  24056. * Transforms each position and each normal of the vertexData according to the passed Matrix
  24057. * @param matrix the transforming matrix
  24058. * @returns the VertexData
  24059. */
  24060. transform(matrix: Matrix): VertexData;
  24061. /**
  24062. * Merges the passed VertexData into the current one
  24063. * @param other the VertexData to be merged into the current one
  24064. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  24065. * @returns the modified VertexData
  24066. */
  24067. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  24068. private _mergeElement;
  24069. private _validate;
  24070. /**
  24071. * Serializes the VertexData
  24072. * @returns a serialized object
  24073. */
  24074. serialize(): any;
  24075. /**
  24076. * Extracts the vertexData from a mesh
  24077. * @param mesh the mesh from which to extract the VertexData
  24078. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  24079. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24080. * @returns the object VertexData associated to the passed mesh
  24081. */
  24082. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24083. /**
  24084. * Extracts the vertexData from the geometry
  24085. * @param geometry the geometry from which to extract the VertexData
  24086. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  24087. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24088. * @returns the object VertexData associated to the passed mesh
  24089. */
  24090. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24091. private static _ExtractFrom;
  24092. /**
  24093. * Creates the VertexData for a Ribbon
  24094. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  24095. * * pathArray array of paths, each of which an array of successive Vector3
  24096. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  24097. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  24098. * * 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
  24099. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24100. * * 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)
  24101. * * 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)
  24102. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  24103. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  24104. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  24105. * @returns the VertexData of the ribbon
  24106. */
  24107. static CreateRibbon(options: {
  24108. pathArray: Vector3[][];
  24109. closeArray?: boolean;
  24110. closePath?: boolean;
  24111. offset?: number;
  24112. sideOrientation?: number;
  24113. frontUVs?: Vector4;
  24114. backUVs?: Vector4;
  24115. invertUV?: boolean;
  24116. uvs?: Vector2[];
  24117. colors?: Color4[];
  24118. }): VertexData;
  24119. /**
  24120. * Creates the VertexData for a box
  24121. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24122. * * size sets the width, height and depth of the box to the value of size, optional default 1
  24123. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  24124. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  24125. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  24126. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24127. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24128. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24129. * * 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)
  24130. * * 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)
  24131. * @returns the VertexData of the box
  24132. */
  24133. static CreateBox(options: {
  24134. size?: number;
  24135. width?: number;
  24136. height?: number;
  24137. depth?: number;
  24138. faceUV?: Vector4[];
  24139. faceColors?: Color4[];
  24140. sideOrientation?: number;
  24141. frontUVs?: Vector4;
  24142. backUVs?: Vector4;
  24143. }): VertexData;
  24144. /**
  24145. * Creates the VertexData for a tiled box
  24146. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24147. * * faceTiles sets the pattern, tile size and number of tiles for a face
  24148. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24149. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24150. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24151. * @returns the VertexData of the box
  24152. */
  24153. static CreateTiledBox(options: {
  24154. pattern?: number;
  24155. width?: number;
  24156. height?: number;
  24157. depth?: number;
  24158. tileSize?: number;
  24159. tileWidth?: number;
  24160. tileHeight?: number;
  24161. alignHorizontal?: number;
  24162. alignVertical?: number;
  24163. faceUV?: Vector4[];
  24164. faceColors?: Color4[];
  24165. sideOrientation?: number;
  24166. }): VertexData;
  24167. /**
  24168. * Creates the VertexData for a tiled plane
  24169. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24170. * * pattern a limited pattern arrangement depending on the number
  24171. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  24172. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  24173. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  24174. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24175. * * 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)
  24176. * * 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)
  24177. * @returns the VertexData of the tiled plane
  24178. */
  24179. static CreateTiledPlane(options: {
  24180. pattern?: number;
  24181. tileSize?: number;
  24182. tileWidth?: number;
  24183. tileHeight?: number;
  24184. size?: number;
  24185. width?: number;
  24186. height?: number;
  24187. alignHorizontal?: number;
  24188. alignVertical?: number;
  24189. sideOrientation?: number;
  24190. frontUVs?: Vector4;
  24191. backUVs?: Vector4;
  24192. }): VertexData;
  24193. /**
  24194. * Creates the VertexData for an ellipsoid, defaults to a sphere
  24195. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24196. * * segments sets the number of horizontal strips optional, default 32
  24197. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  24198. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  24199. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  24200. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  24201. * * 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
  24202. * * 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
  24203. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24204. * * 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)
  24205. * * 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)
  24206. * @returns the VertexData of the ellipsoid
  24207. */
  24208. static CreateSphere(options: {
  24209. segments?: number;
  24210. diameter?: number;
  24211. diameterX?: number;
  24212. diameterY?: number;
  24213. diameterZ?: number;
  24214. arc?: number;
  24215. slice?: number;
  24216. sideOrientation?: number;
  24217. frontUVs?: Vector4;
  24218. backUVs?: Vector4;
  24219. }): VertexData;
  24220. /**
  24221. * Creates the VertexData for a cylinder, cone or prism
  24222. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24223. * * height sets the height (y direction) of the cylinder, optional, default 2
  24224. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  24225. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  24226. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  24227. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24228. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  24229. * * 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
  24230. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24231. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24232. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  24233. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  24234. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24235. * * 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)
  24236. * * 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)
  24237. * @returns the VertexData of the cylinder, cone or prism
  24238. */
  24239. static CreateCylinder(options: {
  24240. height?: number;
  24241. diameterTop?: number;
  24242. diameterBottom?: number;
  24243. diameter?: number;
  24244. tessellation?: number;
  24245. subdivisions?: number;
  24246. arc?: number;
  24247. faceColors?: Color4[];
  24248. faceUV?: Vector4[];
  24249. hasRings?: boolean;
  24250. enclose?: boolean;
  24251. sideOrientation?: number;
  24252. frontUVs?: Vector4;
  24253. backUVs?: Vector4;
  24254. }): VertexData;
  24255. /**
  24256. * Creates the VertexData for a torus
  24257. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24258. * * diameter the diameter of the torus, optional default 1
  24259. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24260. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24261. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24262. * * 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)
  24263. * * 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)
  24264. * @returns the VertexData of the torus
  24265. */
  24266. static CreateTorus(options: {
  24267. diameter?: number;
  24268. thickness?: number;
  24269. tessellation?: number;
  24270. sideOrientation?: number;
  24271. frontUVs?: Vector4;
  24272. backUVs?: Vector4;
  24273. }): VertexData;
  24274. /**
  24275. * Creates the VertexData of the LineSystem
  24276. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24277. * - lines an array of lines, each line being an array of successive Vector3
  24278. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24279. * @returns the VertexData of the LineSystem
  24280. */
  24281. static CreateLineSystem(options: {
  24282. lines: Vector3[][];
  24283. colors?: Nullable<Color4[][]>;
  24284. }): VertexData;
  24285. /**
  24286. * Create the VertexData for a DashedLines
  24287. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24288. * - points an array successive Vector3
  24289. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24290. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24291. * - dashNb the intended total number of dashes, optional, default 200
  24292. * @returns the VertexData for the DashedLines
  24293. */
  24294. static CreateDashedLines(options: {
  24295. points: Vector3[];
  24296. dashSize?: number;
  24297. gapSize?: number;
  24298. dashNb?: number;
  24299. }): VertexData;
  24300. /**
  24301. * Creates the VertexData for a Ground
  24302. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24303. * - width the width (x direction) of the ground, optional, default 1
  24304. * - height the height (z direction) of the ground, optional, default 1
  24305. * - subdivisions the number of subdivisions per side, optional, default 1
  24306. * @returns the VertexData of the Ground
  24307. */
  24308. static CreateGround(options: {
  24309. width?: number;
  24310. height?: number;
  24311. subdivisions?: number;
  24312. subdivisionsX?: number;
  24313. subdivisionsY?: number;
  24314. }): VertexData;
  24315. /**
  24316. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24317. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24318. * * xmin the ground minimum X coordinate, optional, default -1
  24319. * * zmin the ground minimum Z coordinate, optional, default -1
  24320. * * xmax the ground maximum X coordinate, optional, default 1
  24321. * * zmax the ground maximum Z coordinate, optional, default 1
  24322. * * 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}
  24323. * * 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}
  24324. * @returns the VertexData of the TiledGround
  24325. */
  24326. static CreateTiledGround(options: {
  24327. xmin: number;
  24328. zmin: number;
  24329. xmax: number;
  24330. zmax: number;
  24331. subdivisions?: {
  24332. w: number;
  24333. h: number;
  24334. };
  24335. precision?: {
  24336. w: number;
  24337. h: number;
  24338. };
  24339. }): VertexData;
  24340. /**
  24341. * Creates the VertexData of the Ground designed from a heightmap
  24342. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24343. * * width the width (x direction) of the ground
  24344. * * height the height (z direction) of the ground
  24345. * * subdivisions the number of subdivisions per side
  24346. * * minHeight the minimum altitude on the ground, optional, default 0
  24347. * * maxHeight the maximum altitude on the ground, optional default 1
  24348. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24349. * * buffer the array holding the image color data
  24350. * * bufferWidth the width of image
  24351. * * bufferHeight the height of image
  24352. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24353. * @returns the VertexData of the Ground designed from a heightmap
  24354. */
  24355. static CreateGroundFromHeightMap(options: {
  24356. width: number;
  24357. height: number;
  24358. subdivisions: number;
  24359. minHeight: number;
  24360. maxHeight: number;
  24361. colorFilter: Color3;
  24362. buffer: Uint8Array;
  24363. bufferWidth: number;
  24364. bufferHeight: number;
  24365. alphaFilter: number;
  24366. }): VertexData;
  24367. /**
  24368. * Creates the VertexData for a Plane
  24369. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24370. * * size sets the width and height of the plane to the value of size, optional default 1
  24371. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24372. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24373. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24374. * * 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)
  24375. * * 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)
  24376. * @returns the VertexData of the box
  24377. */
  24378. static CreatePlane(options: {
  24379. size?: number;
  24380. width?: number;
  24381. height?: number;
  24382. sideOrientation?: number;
  24383. frontUVs?: Vector4;
  24384. backUVs?: Vector4;
  24385. }): VertexData;
  24386. /**
  24387. * Creates the VertexData of the Disc or regular Polygon
  24388. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24389. * * radius the radius of the disc, optional default 0.5
  24390. * * tessellation the number of polygon sides, optional, default 64
  24391. * * 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
  24392. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24393. * * 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)
  24394. * * 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)
  24395. * @returns the VertexData of the box
  24396. */
  24397. static CreateDisc(options: {
  24398. radius?: number;
  24399. tessellation?: number;
  24400. arc?: number;
  24401. sideOrientation?: number;
  24402. frontUVs?: Vector4;
  24403. backUVs?: Vector4;
  24404. }): VertexData;
  24405. /**
  24406. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24407. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24408. * @param polygon a mesh built from polygonTriangulation.build()
  24409. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24410. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24411. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24412. * @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)
  24413. * @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)
  24414. * @returns the VertexData of the Polygon
  24415. */
  24416. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24417. /**
  24418. * Creates the VertexData of the IcoSphere
  24419. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24420. * * radius the radius of the IcoSphere, optional default 1
  24421. * * radiusX allows stretching in the x direction, optional, default radius
  24422. * * radiusY allows stretching in the y direction, optional, default radius
  24423. * * radiusZ allows stretching in the z direction, optional, default radius
  24424. * * flat when true creates a flat shaded mesh, optional, default true
  24425. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24426. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24427. * * 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)
  24428. * * 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)
  24429. * @returns the VertexData of the IcoSphere
  24430. */
  24431. static CreateIcoSphere(options: {
  24432. radius?: number;
  24433. radiusX?: number;
  24434. radiusY?: number;
  24435. radiusZ?: number;
  24436. flat?: boolean;
  24437. subdivisions?: number;
  24438. sideOrientation?: number;
  24439. frontUVs?: Vector4;
  24440. backUVs?: Vector4;
  24441. }): VertexData;
  24442. /**
  24443. * Creates the VertexData for a Polyhedron
  24444. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24445. * * type provided types are:
  24446. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24447. * * 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)
  24448. * * size the size of the IcoSphere, optional default 1
  24449. * * sizeX allows stretching in the x direction, optional, default size
  24450. * * sizeY allows stretching in the y direction, optional, default size
  24451. * * sizeZ allows stretching in the z direction, optional, default size
  24452. * * 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
  24453. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24454. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24455. * * flat when true creates a flat shaded mesh, optional, default true
  24456. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24457. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24458. * * 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)
  24459. * * 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)
  24460. * @returns the VertexData of the Polyhedron
  24461. */
  24462. static CreatePolyhedron(options: {
  24463. type?: number;
  24464. size?: number;
  24465. sizeX?: number;
  24466. sizeY?: number;
  24467. sizeZ?: number;
  24468. custom?: any;
  24469. faceUV?: Vector4[];
  24470. faceColors?: Color4[];
  24471. flat?: boolean;
  24472. sideOrientation?: number;
  24473. frontUVs?: Vector4;
  24474. backUVs?: Vector4;
  24475. }): VertexData;
  24476. /**
  24477. * Creates the VertexData for a TorusKnot
  24478. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24479. * * radius the radius of the torus knot, optional, default 2
  24480. * * tube the thickness of the tube, optional, default 0.5
  24481. * * radialSegments the number of sides on each tube segments, optional, default 32
  24482. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24483. * * p the number of windings around the z axis, optional, default 2
  24484. * * q the number of windings around the x axis, optional, default 3
  24485. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24486. * * 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)
  24487. * * 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)
  24488. * @returns the VertexData of the Torus Knot
  24489. */
  24490. static CreateTorusKnot(options: {
  24491. radius?: number;
  24492. tube?: number;
  24493. radialSegments?: number;
  24494. tubularSegments?: number;
  24495. p?: number;
  24496. q?: number;
  24497. sideOrientation?: number;
  24498. frontUVs?: Vector4;
  24499. backUVs?: Vector4;
  24500. }): VertexData;
  24501. /**
  24502. * Compute normals for given positions and indices
  24503. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24504. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24505. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24506. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24507. * * facetNormals : optional array of facet normals (vector3)
  24508. * * facetPositions : optional array of facet positions (vector3)
  24509. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24510. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24511. * * bInfo : optional bounding info, required for facetPartitioning computation
  24512. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24513. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24514. * * useRightHandedSystem: optional boolean to for right handed system computation
  24515. * * depthSort : optional boolean to enable the facet depth sort computation
  24516. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24517. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24518. */
  24519. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24520. facetNormals?: any;
  24521. facetPositions?: any;
  24522. facetPartitioning?: any;
  24523. ratio?: number;
  24524. bInfo?: any;
  24525. bbSize?: Vector3;
  24526. subDiv?: any;
  24527. useRightHandedSystem?: boolean;
  24528. depthSort?: boolean;
  24529. distanceTo?: Vector3;
  24530. depthSortedFacets?: any;
  24531. }): void;
  24532. /** @hidden */
  24533. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24534. /**
  24535. * Applies VertexData created from the imported parameters to the geometry
  24536. * @param parsedVertexData the parsed data from an imported file
  24537. * @param geometry the geometry to apply the VertexData to
  24538. */
  24539. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24540. }
  24541. }
  24542. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24543. import { Nullable } from "babylonjs/types";
  24544. import { Scene } from "babylonjs/scene";
  24545. import { Vector4 } from "babylonjs/Maths/math";
  24546. import { Mesh } from "babylonjs/Meshes/mesh";
  24547. /**
  24548. * Class containing static functions to help procedurally build meshes
  24549. */
  24550. export class DiscBuilder {
  24551. /**
  24552. * Creates a plane polygonal mesh. By default, this is a disc
  24553. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24554. * * 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
  24555. * * 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
  24556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24557. * * 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
  24558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24559. * @param name defines the name of the mesh
  24560. * @param options defines the options used to create the mesh
  24561. * @param scene defines the hosting scene
  24562. * @returns the plane polygonal mesh
  24563. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24564. */
  24565. static CreateDisc(name: string, options: {
  24566. radius?: number;
  24567. tessellation?: number;
  24568. arc?: number;
  24569. updatable?: boolean;
  24570. sideOrientation?: number;
  24571. frontUVs?: Vector4;
  24572. backUVs?: Vector4;
  24573. }, scene?: Nullable<Scene>): Mesh;
  24574. }
  24575. }
  24576. declare module "babylonjs/Particles/solidParticleSystem" {
  24577. import { Vector3 } from "babylonjs/Maths/math";
  24578. import { Mesh } from "babylonjs/Meshes/mesh";
  24579. import { Scene, IDisposable } from "babylonjs/scene";
  24580. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24581. /**
  24582. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24583. *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.
  24584. * The SPS is also a particle system. It provides some methods to manage the particles.
  24585. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24586. *
  24587. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24588. */
  24589. export class SolidParticleSystem implements IDisposable {
  24590. /**
  24591. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24592. * Example : var p = SPS.particles[i];
  24593. */
  24594. particles: SolidParticle[];
  24595. /**
  24596. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24597. */
  24598. nbParticles: number;
  24599. /**
  24600. * If the particles must ever face the camera (default false). Useful for planar particles.
  24601. */
  24602. billboard: boolean;
  24603. /**
  24604. * Recompute normals when adding a shape
  24605. */
  24606. recomputeNormals: boolean;
  24607. /**
  24608. * This a counter ofr your own usage. It's not set by any SPS functions.
  24609. */
  24610. counter: number;
  24611. /**
  24612. * The SPS name. This name is also given to the underlying mesh.
  24613. */
  24614. name: string;
  24615. /**
  24616. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24617. */
  24618. mesh: Mesh;
  24619. /**
  24620. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24621. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24622. */
  24623. vars: any;
  24624. /**
  24625. * This array is populated when the SPS is set as 'pickable'.
  24626. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24627. * Each element of this array is an object `{idx: int, faceId: int}`.
  24628. * `idx` is the picked particle index in the `SPS.particles` array
  24629. * `faceId` is the picked face index counted within this particle.
  24630. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24631. */
  24632. pickedParticles: {
  24633. idx: number;
  24634. faceId: number;
  24635. }[];
  24636. /**
  24637. * This array is populated when `enableDepthSort` is set to true.
  24638. * Each element of this array is an instance of the class DepthSortedParticle.
  24639. */
  24640. depthSortedParticles: DepthSortedParticle[];
  24641. /**
  24642. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24643. * @hidden
  24644. */
  24645. _bSphereOnly: boolean;
  24646. /**
  24647. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24648. * @hidden
  24649. */
  24650. _bSphereRadiusFactor: number;
  24651. private _scene;
  24652. private _positions;
  24653. private _indices;
  24654. private _normals;
  24655. private _colors;
  24656. private _uvs;
  24657. private _indices32;
  24658. private _positions32;
  24659. private _normals32;
  24660. private _fixedNormal32;
  24661. private _colors32;
  24662. private _uvs32;
  24663. private _index;
  24664. private _updatable;
  24665. private _pickable;
  24666. private _isVisibilityBoxLocked;
  24667. private _alwaysVisible;
  24668. private _depthSort;
  24669. private _shapeCounter;
  24670. private _copy;
  24671. private _color;
  24672. private _computeParticleColor;
  24673. private _computeParticleTexture;
  24674. private _computeParticleRotation;
  24675. private _computeParticleVertex;
  24676. private _computeBoundingBox;
  24677. private _depthSortParticles;
  24678. private _camera;
  24679. private _mustUnrotateFixedNormals;
  24680. private _particlesIntersect;
  24681. private _needs32Bits;
  24682. /**
  24683. * Creates a SPS (Solid Particle System) object.
  24684. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24685. * @param scene (Scene) is the scene in which the SPS is added.
  24686. * @param options defines the options of the sps e.g.
  24687. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24688. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24689. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24690. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24691. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24692. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24693. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24694. */
  24695. constructor(name: string, scene: Scene, options?: {
  24696. updatable?: boolean;
  24697. isPickable?: boolean;
  24698. enableDepthSort?: boolean;
  24699. particleIntersection?: boolean;
  24700. boundingSphereOnly?: boolean;
  24701. bSphereRadiusFactor?: number;
  24702. });
  24703. /**
  24704. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24705. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24706. * @returns the created mesh
  24707. */
  24708. buildMesh(): Mesh;
  24709. /**
  24710. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24711. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24712. * Thus the particles generated from `digest()` have their property `position` set yet.
  24713. * @param mesh ( Mesh ) is the mesh to be digested
  24714. * @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
  24715. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24716. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24717. * @returns the current SPS
  24718. */
  24719. digest(mesh: Mesh, options?: {
  24720. facetNb?: number;
  24721. number?: number;
  24722. delta?: number;
  24723. }): SolidParticleSystem;
  24724. private _unrotateFixedNormals;
  24725. private _resetCopy;
  24726. private _meshBuilder;
  24727. private _posToShape;
  24728. private _uvsToShapeUV;
  24729. private _addParticle;
  24730. /**
  24731. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24732. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24733. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24734. * @param nb (positive integer) the number of particles to be created from this model
  24735. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24736. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24737. * @returns the number of shapes in the system
  24738. */
  24739. addShape(mesh: Mesh, nb: number, options?: {
  24740. positionFunction?: any;
  24741. vertexFunction?: any;
  24742. }): number;
  24743. private _rebuildParticle;
  24744. /**
  24745. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24746. * @returns the SPS.
  24747. */
  24748. rebuildMesh(): SolidParticleSystem;
  24749. /**
  24750. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24751. * This method calls `updateParticle()` for each particle of the SPS.
  24752. * For an animated SPS, it is usually called within the render loop.
  24753. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24754. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24755. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24756. * @returns the SPS.
  24757. */
  24758. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24759. /**
  24760. * Disposes the SPS.
  24761. */
  24762. dispose(): void;
  24763. /**
  24764. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24765. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24766. * @returns the SPS.
  24767. */
  24768. refreshVisibleSize(): SolidParticleSystem;
  24769. /**
  24770. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24771. * @param size the size (float) of the visibility box
  24772. * note : this doesn't lock the SPS mesh bounding box.
  24773. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24774. */
  24775. setVisibilityBox(size: number): void;
  24776. /**
  24777. * Gets whether the SPS as always visible or not
  24778. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24779. */
  24780. /**
  24781. * Sets the SPS as always visible or not
  24782. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24783. */
  24784. isAlwaysVisible: boolean;
  24785. /**
  24786. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24787. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24788. */
  24789. /**
  24790. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24791. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24792. */
  24793. isVisibilityBoxLocked: boolean;
  24794. /**
  24795. * Tells to `setParticles()` to compute the particle rotations or not.
  24796. * Default value : true. The SPS is faster when it's set to false.
  24797. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24798. */
  24799. /**
  24800. * Gets if `setParticles()` computes the particle rotations or not.
  24801. * Default value : true. The SPS is faster when it's set to false.
  24802. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24803. */
  24804. computeParticleRotation: boolean;
  24805. /**
  24806. * Tells to `setParticles()` to compute the particle colors or not.
  24807. * Default value : true. The SPS is faster when it's set to false.
  24808. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24809. */
  24810. /**
  24811. * Gets if `setParticles()` computes the particle colors or not.
  24812. * Default value : true. The SPS is faster when it's set to false.
  24813. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24814. */
  24815. computeParticleColor: boolean;
  24816. /**
  24817. * Gets if `setParticles()` computes the particle textures or not.
  24818. * Default value : true. The SPS is faster when it's set to false.
  24819. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24820. */
  24821. computeParticleTexture: boolean;
  24822. /**
  24823. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24824. * Default value : false. The SPS is faster when it's set to false.
  24825. * Note : the particle custom vertex positions aren't stored values.
  24826. */
  24827. /**
  24828. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24829. * Default value : false. The SPS is faster when it's set to false.
  24830. * Note : the particle custom vertex positions aren't stored values.
  24831. */
  24832. computeParticleVertex: boolean;
  24833. /**
  24834. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24835. */
  24836. /**
  24837. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24838. */
  24839. computeBoundingBox: boolean;
  24840. /**
  24841. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24842. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24843. * Default : `true`
  24844. */
  24845. /**
  24846. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24847. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24848. * Default : `true`
  24849. */
  24850. depthSortParticles: boolean;
  24851. /**
  24852. * This function does nothing. It may be overwritten to set all the particle first values.
  24853. * The SPS doesn't call this function, you may have to call it by your own.
  24854. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24855. */
  24856. initParticles(): void;
  24857. /**
  24858. * This function does nothing. It may be overwritten to recycle a particle.
  24859. * The SPS doesn't call this function, you may have to call it by your own.
  24860. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24861. * @param particle The particle to recycle
  24862. * @returns the recycled particle
  24863. */
  24864. recycleParticle(particle: SolidParticle): SolidParticle;
  24865. /**
  24866. * Updates a particle : this function should be overwritten by the user.
  24867. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24868. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24869. * @example : just set a particle position or velocity and recycle conditions
  24870. * @param particle The particle to update
  24871. * @returns the updated particle
  24872. */
  24873. updateParticle(particle: SolidParticle): SolidParticle;
  24874. /**
  24875. * Updates a vertex of a particle : it can be overwritten by the user.
  24876. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24877. * @param particle the current particle
  24878. * @param vertex the current index of the current particle
  24879. * @param pt the index of the current vertex in the particle shape
  24880. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24881. * @example : just set a vertex particle position
  24882. * @returns the updated vertex
  24883. */
  24884. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24885. /**
  24886. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24887. * This does nothing and may be overwritten by the user.
  24888. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24889. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24890. * @param update the boolean update value actually passed to setParticles()
  24891. */
  24892. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24893. /**
  24894. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24895. * This will be passed three parameters.
  24896. * This does nothing and may be overwritten by the user.
  24897. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24898. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24899. * @param update the boolean update value actually passed to setParticles()
  24900. */
  24901. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24902. }
  24903. }
  24904. declare module "babylonjs/Particles/solidParticle" {
  24905. import { Nullable } from "babylonjs/types";
  24906. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24907. import { Mesh } from "babylonjs/Meshes/mesh";
  24908. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24909. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24910. /**
  24911. * Represents one particle of a solid particle system.
  24912. */
  24913. export class SolidParticle {
  24914. /**
  24915. * particle global index
  24916. */
  24917. idx: number;
  24918. /**
  24919. * The color of the particle
  24920. */
  24921. color: Nullable<Color4>;
  24922. /**
  24923. * The world space position of the particle.
  24924. */
  24925. position: Vector3;
  24926. /**
  24927. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24928. */
  24929. rotation: Vector3;
  24930. /**
  24931. * The world space rotation quaternion of the particle.
  24932. */
  24933. rotationQuaternion: Nullable<Quaternion>;
  24934. /**
  24935. * The scaling of the particle.
  24936. */
  24937. scaling: Vector3;
  24938. /**
  24939. * The uvs of the particle.
  24940. */
  24941. uvs: Vector4;
  24942. /**
  24943. * The current speed of the particle.
  24944. */
  24945. velocity: Vector3;
  24946. /**
  24947. * The pivot point in the particle local space.
  24948. */
  24949. pivot: Vector3;
  24950. /**
  24951. * Must the particle be translated from its pivot point in its local space ?
  24952. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24953. * Default : false
  24954. */
  24955. translateFromPivot: boolean;
  24956. /**
  24957. * Is the particle active or not ?
  24958. */
  24959. alive: boolean;
  24960. /**
  24961. * Is the particle visible or not ?
  24962. */
  24963. isVisible: boolean;
  24964. /**
  24965. * Index of this particle in the global "positions" array (Internal use)
  24966. * @hidden
  24967. */
  24968. _pos: number;
  24969. /**
  24970. * @hidden Index of this particle in the global "indices" array (Internal use)
  24971. */
  24972. _ind: number;
  24973. /**
  24974. * @hidden ModelShape of this particle (Internal use)
  24975. */
  24976. _model: ModelShape;
  24977. /**
  24978. * ModelShape id of this particle
  24979. */
  24980. shapeId: number;
  24981. /**
  24982. * Index of the particle in its shape id (Internal use)
  24983. */
  24984. idxInShape: number;
  24985. /**
  24986. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24987. */
  24988. _modelBoundingInfo: BoundingInfo;
  24989. /**
  24990. * @hidden Particle BoundingInfo object (Internal use)
  24991. */
  24992. _boundingInfo: BoundingInfo;
  24993. /**
  24994. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24995. */
  24996. _sps: SolidParticleSystem;
  24997. /**
  24998. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24999. */
  25000. _stillInvisible: boolean;
  25001. /**
  25002. * @hidden Last computed particle rotation matrix
  25003. */
  25004. _rotationMatrix: number[];
  25005. /**
  25006. * Parent particle Id, if any.
  25007. * Default null.
  25008. */
  25009. parentId: Nullable<number>;
  25010. /**
  25011. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25012. * The possible values are :
  25013. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25014. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25015. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25016. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25017. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25018. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25019. * */
  25020. cullingStrategy: number;
  25021. /**
  25022. * @hidden Internal global position in the SPS.
  25023. */
  25024. _globalPosition: Vector3;
  25025. /**
  25026. * Creates a Solid Particle object.
  25027. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25028. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25029. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25030. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25031. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25032. * @param shapeId (integer) is the model shape identifier in the SPS.
  25033. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25034. * @param sps defines the sps it is associated to
  25035. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25036. */
  25037. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25038. /**
  25039. * Legacy support, changed scale to scaling
  25040. */
  25041. /**
  25042. * Legacy support, changed scale to scaling
  25043. */
  25044. scale: Vector3;
  25045. /**
  25046. * Legacy support, changed quaternion to rotationQuaternion
  25047. */
  25048. /**
  25049. * Legacy support, changed quaternion to rotationQuaternion
  25050. */
  25051. quaternion: Nullable<Quaternion>;
  25052. /**
  25053. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25054. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25055. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25056. * @returns true if it intersects
  25057. */
  25058. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25059. /**
  25060. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25061. * A particle is in the frustum if its bounding box intersects the frustum
  25062. * @param frustumPlanes defines the frustum to test
  25063. * @returns true if the particle is in the frustum planes
  25064. */
  25065. isInFrustum(frustumPlanes: Plane[]): boolean;
  25066. /**
  25067. * get the rotation matrix of the particle
  25068. * @hidden
  25069. */
  25070. getRotationMatrix(m: Matrix): void;
  25071. }
  25072. /**
  25073. * Represents the shape of the model used by one particle of a solid particle system.
  25074. * SPS internal tool, don't use it manually.
  25075. */
  25076. export class ModelShape {
  25077. /**
  25078. * The shape id
  25079. * @hidden
  25080. */
  25081. shapeID: number;
  25082. /**
  25083. * flat array of model positions (internal use)
  25084. * @hidden
  25085. */
  25086. _shape: Vector3[];
  25087. /**
  25088. * flat array of model UVs (internal use)
  25089. * @hidden
  25090. */
  25091. _shapeUV: number[];
  25092. /**
  25093. * length of the shape in the model indices array (internal use)
  25094. * @hidden
  25095. */
  25096. _indicesLength: number;
  25097. /**
  25098. * Custom position function (internal use)
  25099. * @hidden
  25100. */
  25101. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25102. /**
  25103. * Custom vertex function (internal use)
  25104. * @hidden
  25105. */
  25106. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25107. /**
  25108. * 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.
  25109. * SPS internal tool, don't use it manually.
  25110. * @hidden
  25111. */
  25112. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25113. }
  25114. /**
  25115. * Represents a Depth Sorted Particle in the solid particle system.
  25116. */
  25117. export class DepthSortedParticle {
  25118. /**
  25119. * Index of the particle in the "indices" array
  25120. */
  25121. ind: number;
  25122. /**
  25123. * Length of the particle shape in the "indices" array
  25124. */
  25125. indicesLength: number;
  25126. /**
  25127. * Squared distance from the particle to the camera
  25128. */
  25129. sqDistance: number;
  25130. }
  25131. }
  25132. declare module "babylonjs/Collisions/meshCollisionData" {
  25133. import { Collider } from "babylonjs/Collisions/collider";
  25134. import { Vector3 } from "babylonjs/Maths/math";
  25135. import { Nullable } from "babylonjs/types";
  25136. import { Observer } from "babylonjs/Misc/observable";
  25137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25138. /**
  25139. * @hidden
  25140. */
  25141. export class _MeshCollisionData {
  25142. _checkCollisions: boolean;
  25143. _collisionMask: number;
  25144. _collisionGroup: number;
  25145. _collider: Nullable<Collider>;
  25146. _oldPositionForCollisions: Vector3;
  25147. _diffPositionForCollisions: Vector3;
  25148. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25149. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25150. }
  25151. }
  25152. declare module "babylonjs/Meshes/abstractMesh" {
  25153. import { Observable } from "babylonjs/Misc/observable";
  25154. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  25155. import { Camera } from "babylonjs/Cameras/camera";
  25156. import { Scene, IDisposable } from "babylonjs/scene";
  25157. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  25158. import { Node } from "babylonjs/node";
  25159. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25160. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25161. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25162. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25163. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25164. import { Material } from "babylonjs/Materials/material";
  25165. import { Light } from "babylonjs/Lights/light";
  25166. import { Skeleton } from "babylonjs/Bones/skeleton";
  25167. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  25168. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  25169. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25170. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  25171. import { Ray } from "babylonjs/Culling/ray";
  25172. import { Collider } from "babylonjs/Collisions/collider";
  25173. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25174. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  25175. /** @hidden */
  25176. class _FacetDataStorage {
  25177. facetPositions: Vector3[];
  25178. facetNormals: Vector3[];
  25179. facetPartitioning: number[][];
  25180. facetNb: number;
  25181. partitioningSubdivisions: number;
  25182. partitioningBBoxRatio: number;
  25183. facetDataEnabled: boolean;
  25184. facetParameters: any;
  25185. bbSize: Vector3;
  25186. subDiv: {
  25187. max: number;
  25188. X: number;
  25189. Y: number;
  25190. Z: number;
  25191. };
  25192. facetDepthSort: boolean;
  25193. facetDepthSortEnabled: boolean;
  25194. depthSortedIndices: IndicesArray;
  25195. depthSortedFacets: {
  25196. ind: number;
  25197. sqDistance: number;
  25198. }[];
  25199. facetDepthSortFunction: (f1: {
  25200. ind: number;
  25201. sqDistance: number;
  25202. }, f2: {
  25203. ind: number;
  25204. sqDistance: number;
  25205. }) => number;
  25206. facetDepthSortFrom: Vector3;
  25207. facetDepthSortOrigin: Vector3;
  25208. invertedMatrix: Matrix;
  25209. }
  25210. /**
  25211. * @hidden
  25212. **/
  25213. class _InternalAbstractMeshDataInfo {
  25214. _hasVertexAlpha: boolean;
  25215. _useVertexColors: boolean;
  25216. _numBoneInfluencers: number;
  25217. _applyFog: boolean;
  25218. _receiveShadows: boolean;
  25219. _facetData: _FacetDataStorage;
  25220. _visibility: number;
  25221. _skeleton: Nullable<Skeleton>;
  25222. _layerMask: number;
  25223. _computeBonesUsingShaders: boolean;
  25224. _isActive: boolean;
  25225. _onlyForInstances: boolean;
  25226. _isActiveIntermediate: boolean;
  25227. _onlyForInstancesIntermediate: boolean;
  25228. }
  25229. /**
  25230. * Class used to store all common mesh properties
  25231. */
  25232. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25233. /** No occlusion */
  25234. static OCCLUSION_TYPE_NONE: number;
  25235. /** Occlusion set to optimisitic */
  25236. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25237. /** Occlusion set to strict */
  25238. static OCCLUSION_TYPE_STRICT: number;
  25239. /** Use an accurante occlusion algorithm */
  25240. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25241. /** Use a conservative occlusion algorithm */
  25242. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25243. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25244. * Test order :
  25245. * Is the bounding sphere outside the frustum ?
  25246. * If not, are the bounding box vertices outside the frustum ?
  25247. * It not, then the cullable object is in the frustum.
  25248. */
  25249. static readonly CULLINGSTRATEGY_STANDARD: number;
  25250. /** Culling strategy : Bounding Sphere Only.
  25251. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25252. * It's also less accurate than the standard because some not visible objects can still be selected.
  25253. * Test : is the bounding sphere outside the frustum ?
  25254. * If not, then the cullable object is in the frustum.
  25255. */
  25256. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25257. /** Culling strategy : Optimistic Inclusion.
  25258. * This in an inclusion test first, then the standard exclusion test.
  25259. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25260. * 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.
  25261. * Anyway, it's as accurate as the standard strategy.
  25262. * Test :
  25263. * Is the cullable object bounding sphere center in the frustum ?
  25264. * If not, apply the default culling strategy.
  25265. */
  25266. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25267. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25268. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25269. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25270. * 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.
  25271. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25272. * Test :
  25273. * Is the cullable object bounding sphere center in the frustum ?
  25274. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25275. */
  25276. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25277. /**
  25278. * No billboard
  25279. */
  25280. static readonly BILLBOARDMODE_NONE: number;
  25281. /** Billboard on X axis */
  25282. static readonly BILLBOARDMODE_X: number;
  25283. /** Billboard on Y axis */
  25284. static readonly BILLBOARDMODE_Y: number;
  25285. /** Billboard on Z axis */
  25286. static readonly BILLBOARDMODE_Z: number;
  25287. /** Billboard on all axes */
  25288. static readonly BILLBOARDMODE_ALL: number;
  25289. /** @hidden */
  25290. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25291. /**
  25292. * The culling strategy to use to check whether the mesh must be rendered or not.
  25293. * This value can be changed at any time and will be used on the next render mesh selection.
  25294. * The possible values are :
  25295. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25296. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25297. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25298. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25299. * Please read each static variable documentation to get details about the culling process.
  25300. * */
  25301. cullingStrategy: number;
  25302. /**
  25303. * Gets the number of facets in the mesh
  25304. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25305. */
  25306. readonly facetNb: number;
  25307. /**
  25308. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25309. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25310. */
  25311. partitioningSubdivisions: number;
  25312. /**
  25313. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25314. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25315. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25316. */
  25317. partitioningBBoxRatio: number;
  25318. /**
  25319. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25320. * Works only for updatable meshes.
  25321. * Doesn't work with multi-materials
  25322. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25323. */
  25324. mustDepthSortFacets: boolean;
  25325. /**
  25326. * The location (Vector3) where the facet depth sort must be computed from.
  25327. * By default, the active camera position.
  25328. * Used only when facet depth sort is enabled
  25329. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25330. */
  25331. facetDepthSortFrom: Vector3;
  25332. /**
  25333. * gets a boolean indicating if facetData is enabled
  25334. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25335. */
  25336. readonly isFacetDataEnabled: boolean;
  25337. /** @hidden */
  25338. _updateNonUniformScalingState(value: boolean): boolean;
  25339. /**
  25340. * An event triggered when this mesh collides with another one
  25341. */
  25342. onCollideObservable: Observable<AbstractMesh>;
  25343. /** Set a function to call when this mesh collides with another one */
  25344. onCollide: () => void;
  25345. /**
  25346. * An event triggered when the collision's position changes
  25347. */
  25348. onCollisionPositionChangeObservable: Observable<Vector3>;
  25349. /** Set a function to call when the collision's position changes */
  25350. onCollisionPositionChange: () => void;
  25351. /**
  25352. * An event triggered when material is changed
  25353. */
  25354. onMaterialChangedObservable: Observable<AbstractMesh>;
  25355. /**
  25356. * Gets or sets the orientation for POV movement & rotation
  25357. */
  25358. definedFacingForward: boolean;
  25359. /** @hidden */
  25360. _occlusionQuery: Nullable<WebGLQuery>;
  25361. /** @hidden */
  25362. _renderingGroup: Nullable<RenderingGroup>;
  25363. /**
  25364. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25365. */
  25366. /**
  25367. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25368. */
  25369. visibility: number;
  25370. /** Gets or sets the alpha index used to sort transparent meshes
  25371. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25372. */
  25373. alphaIndex: number;
  25374. /**
  25375. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25376. */
  25377. isVisible: boolean;
  25378. /**
  25379. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25380. */
  25381. isPickable: boolean;
  25382. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25383. showSubMeshesBoundingBox: boolean;
  25384. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25385. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25386. */
  25387. isBlocker: boolean;
  25388. /**
  25389. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25390. */
  25391. enablePointerMoveEvents: boolean;
  25392. /**
  25393. * Specifies the rendering group id for this mesh (0 by default)
  25394. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25395. */
  25396. renderingGroupId: number;
  25397. private _material;
  25398. /** Gets or sets current material */
  25399. material: Nullable<Material>;
  25400. /**
  25401. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25402. * @see http://doc.babylonjs.com/babylon101/shadows
  25403. */
  25404. receiveShadows: boolean;
  25405. /** Defines color to use when rendering outline */
  25406. outlineColor: Color3;
  25407. /** Define width to use when rendering outline */
  25408. outlineWidth: number;
  25409. /** Defines color to use when rendering overlay */
  25410. overlayColor: Color3;
  25411. /** Defines alpha to use when rendering overlay */
  25412. overlayAlpha: number;
  25413. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25414. hasVertexAlpha: boolean;
  25415. /** 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) */
  25416. useVertexColors: boolean;
  25417. /**
  25418. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25419. */
  25420. computeBonesUsingShaders: boolean;
  25421. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25422. numBoneInfluencers: number;
  25423. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25424. applyFog: boolean;
  25425. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25426. useOctreeForRenderingSelection: boolean;
  25427. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25428. useOctreeForPicking: boolean;
  25429. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25430. useOctreeForCollisions: boolean;
  25431. /**
  25432. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25433. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25434. */
  25435. layerMask: number;
  25436. /**
  25437. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25438. */
  25439. alwaysSelectAsActiveMesh: boolean;
  25440. /**
  25441. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25442. */
  25443. doNotSyncBoundingInfo: boolean;
  25444. /**
  25445. * Gets or sets the current action manager
  25446. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25447. */
  25448. actionManager: Nullable<AbstractActionManager>;
  25449. private _meshCollisionData;
  25450. /**
  25451. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25452. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25453. */
  25454. ellipsoid: Vector3;
  25455. /**
  25456. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25457. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25458. */
  25459. ellipsoidOffset: Vector3;
  25460. /**
  25461. * Gets or sets a collision mask used to mask collisions (default is -1).
  25462. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25463. */
  25464. collisionMask: number;
  25465. /**
  25466. * Gets or sets the current collision group mask (-1 by default).
  25467. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25468. */
  25469. collisionGroup: number;
  25470. /**
  25471. * Defines edge width used when edgesRenderer is enabled
  25472. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25473. */
  25474. edgesWidth: number;
  25475. /**
  25476. * Defines edge color used when edgesRenderer is enabled
  25477. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25478. */
  25479. edgesColor: Color4;
  25480. /** @hidden */
  25481. _edgesRenderer: Nullable<IEdgesRenderer>;
  25482. /** @hidden */
  25483. _masterMesh: Nullable<AbstractMesh>;
  25484. /** @hidden */
  25485. _boundingInfo: Nullable<BoundingInfo>;
  25486. /** @hidden */
  25487. _renderId: number;
  25488. /**
  25489. * Gets or sets the list of subMeshes
  25490. * @see http://doc.babylonjs.com/how_to/multi_materials
  25491. */
  25492. subMeshes: SubMesh[];
  25493. /** @hidden */
  25494. _intersectionsInProgress: AbstractMesh[];
  25495. /** @hidden */
  25496. _unIndexed: boolean;
  25497. /** @hidden */
  25498. _lightSources: Light[];
  25499. /** Gets the list of lights affecting that mesh */
  25500. readonly lightSources: Light[];
  25501. /** @hidden */
  25502. readonly _positions: Nullable<Vector3[]>;
  25503. /** @hidden */
  25504. _waitingData: {
  25505. lods: Nullable<any>;
  25506. actions: Nullable<any>;
  25507. freezeWorldMatrix: Nullable<boolean>;
  25508. };
  25509. /** @hidden */
  25510. _bonesTransformMatrices: Nullable<Float32Array>;
  25511. /** @hidden */
  25512. _transformMatrixTexture: Nullable<RawTexture>;
  25513. /**
  25514. * Gets or sets a skeleton to apply skining transformations
  25515. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25516. */
  25517. skeleton: Nullable<Skeleton>;
  25518. /**
  25519. * An event triggered when the mesh is rebuilt.
  25520. */
  25521. onRebuildObservable: Observable<AbstractMesh>;
  25522. /**
  25523. * Creates a new AbstractMesh
  25524. * @param name defines the name of the mesh
  25525. * @param scene defines the hosting scene
  25526. */
  25527. constructor(name: string, scene?: Nullable<Scene>);
  25528. /**
  25529. * Returns the string "AbstractMesh"
  25530. * @returns "AbstractMesh"
  25531. */
  25532. getClassName(): string;
  25533. /**
  25534. * Gets a string representation of the current mesh
  25535. * @param fullDetails defines a boolean indicating if full details must be included
  25536. * @returns a string representation of the current mesh
  25537. */
  25538. toString(fullDetails?: boolean): string;
  25539. /**
  25540. * @hidden
  25541. */
  25542. protected _getEffectiveParent(): Nullable<Node>;
  25543. /** @hidden */
  25544. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25545. /** @hidden */
  25546. _rebuild(): void;
  25547. /** @hidden */
  25548. _resyncLightSources(): void;
  25549. /** @hidden */
  25550. _resyncLighSource(light: Light): void;
  25551. /** @hidden */
  25552. _unBindEffect(): void;
  25553. /** @hidden */
  25554. _removeLightSource(light: Light): void;
  25555. private _markSubMeshesAsDirty;
  25556. /** @hidden */
  25557. _markSubMeshesAsLightDirty(): void;
  25558. /** @hidden */
  25559. _markSubMeshesAsAttributesDirty(): void;
  25560. /** @hidden */
  25561. _markSubMeshesAsMiscDirty(): void;
  25562. /**
  25563. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25564. */
  25565. scaling: Vector3;
  25566. /**
  25567. * Returns true if the mesh is blocked. Implemented by child classes
  25568. */
  25569. readonly isBlocked: boolean;
  25570. /**
  25571. * Returns the mesh itself by default. Implemented by child classes
  25572. * @param camera defines the camera to use to pick the right LOD level
  25573. * @returns the currentAbstractMesh
  25574. */
  25575. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25576. /**
  25577. * Returns 0 by default. Implemented by child classes
  25578. * @returns an integer
  25579. */
  25580. getTotalVertices(): number;
  25581. /**
  25582. * Returns a positive integer : the total number of indices in this mesh geometry.
  25583. * @returns the numner of indices or zero if the mesh has no geometry.
  25584. */
  25585. getTotalIndices(): number;
  25586. /**
  25587. * Returns null by default. Implemented by child classes
  25588. * @returns null
  25589. */
  25590. getIndices(): Nullable<IndicesArray>;
  25591. /**
  25592. * Returns the array of the requested vertex data kind. Implemented by child classes
  25593. * @param kind defines the vertex data kind to use
  25594. * @returns null
  25595. */
  25596. getVerticesData(kind: string): Nullable<FloatArray>;
  25597. /**
  25598. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25599. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25600. * Note that a new underlying VertexBuffer object is created each call.
  25601. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25602. * @param kind defines vertex data kind:
  25603. * * VertexBuffer.PositionKind
  25604. * * VertexBuffer.UVKind
  25605. * * VertexBuffer.UV2Kind
  25606. * * VertexBuffer.UV3Kind
  25607. * * VertexBuffer.UV4Kind
  25608. * * VertexBuffer.UV5Kind
  25609. * * VertexBuffer.UV6Kind
  25610. * * VertexBuffer.ColorKind
  25611. * * VertexBuffer.MatricesIndicesKind
  25612. * * VertexBuffer.MatricesIndicesExtraKind
  25613. * * VertexBuffer.MatricesWeightsKind
  25614. * * VertexBuffer.MatricesWeightsExtraKind
  25615. * @param data defines the data source
  25616. * @param updatable defines if the data must be flagged as updatable (or static)
  25617. * @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
  25618. * @returns the current mesh
  25619. */
  25620. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25621. /**
  25622. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25623. * If the mesh has no geometry, it is simply returned as it is.
  25624. * @param kind defines vertex data kind:
  25625. * * VertexBuffer.PositionKind
  25626. * * VertexBuffer.UVKind
  25627. * * VertexBuffer.UV2Kind
  25628. * * VertexBuffer.UV3Kind
  25629. * * VertexBuffer.UV4Kind
  25630. * * VertexBuffer.UV5Kind
  25631. * * VertexBuffer.UV6Kind
  25632. * * VertexBuffer.ColorKind
  25633. * * VertexBuffer.MatricesIndicesKind
  25634. * * VertexBuffer.MatricesIndicesExtraKind
  25635. * * VertexBuffer.MatricesWeightsKind
  25636. * * VertexBuffer.MatricesWeightsExtraKind
  25637. * @param data defines the data source
  25638. * @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
  25639. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25640. * @returns the current mesh
  25641. */
  25642. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25643. /**
  25644. * Sets the mesh indices,
  25645. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25646. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25647. * @param totalVertices Defines the total number of vertices
  25648. * @returns the current mesh
  25649. */
  25650. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25651. /**
  25652. * Gets a boolean indicating if specific vertex data is present
  25653. * @param kind defines the vertex data kind to use
  25654. * @returns true is data kind is present
  25655. */
  25656. isVerticesDataPresent(kind: string): boolean;
  25657. /**
  25658. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25659. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25660. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25661. * @returns a BoundingInfo
  25662. */
  25663. getBoundingInfo(): BoundingInfo;
  25664. /**
  25665. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25666. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25667. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25668. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25669. * @returns the current mesh
  25670. */
  25671. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25672. /**
  25673. * Overwrite the current bounding info
  25674. * @param boundingInfo defines the new bounding info
  25675. * @returns the current mesh
  25676. */
  25677. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25678. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25679. readonly useBones: boolean;
  25680. /** @hidden */
  25681. _preActivate(): void;
  25682. /** @hidden */
  25683. _preActivateForIntermediateRendering(renderId: number): void;
  25684. /** @hidden */
  25685. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25686. /** @hidden */
  25687. _postActivate(): void;
  25688. /** @hidden */
  25689. _freeze(): void;
  25690. /** @hidden */
  25691. _unFreeze(): void;
  25692. /**
  25693. * Gets the current world matrix
  25694. * @returns a Matrix
  25695. */
  25696. getWorldMatrix(): Matrix;
  25697. /** @hidden */
  25698. _getWorldMatrixDeterminant(): number;
  25699. /**
  25700. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25701. */
  25702. readonly isAnInstance: boolean;
  25703. /**
  25704. * Perform relative position change from the point of view of behind the front of the mesh.
  25705. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25706. * Supports definition of mesh facing forward or backward
  25707. * @param amountRight defines the distance on the right axis
  25708. * @param amountUp defines the distance on the up axis
  25709. * @param amountForward defines the distance on the forward axis
  25710. * @returns the current mesh
  25711. */
  25712. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25713. /**
  25714. * Calculate relative position change from the point of view of behind the front of the mesh.
  25715. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25716. * Supports definition of mesh facing forward or backward
  25717. * @param amountRight defines the distance on the right axis
  25718. * @param amountUp defines the distance on the up axis
  25719. * @param amountForward defines the distance on the forward axis
  25720. * @returns the new displacement vector
  25721. */
  25722. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25723. /**
  25724. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25725. * Supports definition of mesh facing forward or backward
  25726. * @param flipBack defines the flip
  25727. * @param twirlClockwise defines the twirl
  25728. * @param tiltRight defines the tilt
  25729. * @returns the current mesh
  25730. */
  25731. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25732. /**
  25733. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25734. * Supports definition of mesh facing forward or backward.
  25735. * @param flipBack defines the flip
  25736. * @param twirlClockwise defines the twirl
  25737. * @param tiltRight defines the tilt
  25738. * @returns the new rotation vector
  25739. */
  25740. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25741. /**
  25742. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25743. * This means the mesh underlying bounding box and sphere are recomputed.
  25744. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25745. * @returns the current mesh
  25746. */
  25747. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25748. /** @hidden */
  25749. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25750. /** @hidden */
  25751. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25752. /** @hidden */
  25753. _updateBoundingInfo(): AbstractMesh;
  25754. /** @hidden */
  25755. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25756. /** @hidden */
  25757. protected _afterComputeWorldMatrix(): void;
  25758. /** @hidden */
  25759. readonly _effectiveMesh: AbstractMesh;
  25760. /**
  25761. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25762. * A mesh is in the frustum if its bounding box intersects the frustum
  25763. * @param frustumPlanes defines the frustum to test
  25764. * @returns true if the mesh is in the frustum planes
  25765. */
  25766. isInFrustum(frustumPlanes: Plane[]): boolean;
  25767. /**
  25768. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25769. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25770. * @param frustumPlanes defines the frustum to test
  25771. * @returns true if the mesh is completely in the frustum planes
  25772. */
  25773. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25774. /**
  25775. * True if the mesh intersects another mesh or a SolidParticle object
  25776. * @param mesh defines a target mesh or SolidParticle to test
  25777. * @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)
  25778. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25779. * @returns true if there is an intersection
  25780. */
  25781. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25782. /**
  25783. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25784. * @param point defines the point to test
  25785. * @returns true if there is an intersection
  25786. */
  25787. intersectsPoint(point: Vector3): boolean;
  25788. /**
  25789. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25790. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25791. */
  25792. checkCollisions: boolean;
  25793. /**
  25794. * Gets Collider object used to compute collisions (not physics)
  25795. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25796. */
  25797. readonly collider: Nullable<Collider>;
  25798. /**
  25799. * Move the mesh using collision engine
  25800. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25801. * @param displacement defines the requested displacement vector
  25802. * @returns the current mesh
  25803. */
  25804. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25805. private _onCollisionPositionChange;
  25806. /** @hidden */
  25807. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25808. /** @hidden */
  25809. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25810. /** @hidden */
  25811. _checkCollision(collider: Collider): AbstractMesh;
  25812. /** @hidden */
  25813. _generatePointsArray(): boolean;
  25814. /**
  25815. * Checks if the passed Ray intersects with the mesh
  25816. * @param ray defines the ray to use
  25817. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25818. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25819. * @returns the picking info
  25820. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25821. */
  25822. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25823. /**
  25824. * Clones the current mesh
  25825. * @param name defines the mesh name
  25826. * @param newParent defines the new mesh parent
  25827. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25828. * @returns the new mesh
  25829. */
  25830. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25831. /**
  25832. * Disposes all the submeshes of the current meshnp
  25833. * @returns the current mesh
  25834. */
  25835. releaseSubMeshes(): AbstractMesh;
  25836. /**
  25837. * Releases resources associated with this abstract mesh.
  25838. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25839. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25840. */
  25841. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25842. /**
  25843. * Adds the passed mesh as a child to the current mesh
  25844. * @param mesh defines the child mesh
  25845. * @returns the current mesh
  25846. */
  25847. addChild(mesh: AbstractMesh): AbstractMesh;
  25848. /**
  25849. * Removes the passed mesh from the current mesh children list
  25850. * @param mesh defines the child mesh
  25851. * @returns the current mesh
  25852. */
  25853. removeChild(mesh: AbstractMesh): AbstractMesh;
  25854. /** @hidden */
  25855. private _initFacetData;
  25856. /**
  25857. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25858. * This method can be called within the render loop.
  25859. * 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
  25860. * @returns the current mesh
  25861. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25862. */
  25863. updateFacetData(): AbstractMesh;
  25864. /**
  25865. * Returns the facetLocalNormals array.
  25866. * The normals are expressed in the mesh local spac
  25867. * @returns an array of Vector3
  25868. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25869. */
  25870. getFacetLocalNormals(): Vector3[];
  25871. /**
  25872. * Returns the facetLocalPositions array.
  25873. * The facet positions are expressed in the mesh local space
  25874. * @returns an array of Vector3
  25875. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25876. */
  25877. getFacetLocalPositions(): Vector3[];
  25878. /**
  25879. * Returns the facetLocalPartioning array
  25880. * @returns an array of array of numbers
  25881. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25882. */
  25883. getFacetLocalPartitioning(): number[][];
  25884. /**
  25885. * Returns the i-th facet position in the world system.
  25886. * This method allocates a new Vector3 per call
  25887. * @param i defines the facet index
  25888. * @returns a new Vector3
  25889. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25890. */
  25891. getFacetPosition(i: number): Vector3;
  25892. /**
  25893. * Sets the reference Vector3 with the i-th facet position in the world system
  25894. * @param i defines the facet index
  25895. * @param ref defines the target vector
  25896. * @returns the current mesh
  25897. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25898. */
  25899. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25900. /**
  25901. * Returns the i-th facet normal in the world system.
  25902. * This method allocates a new Vector3 per call
  25903. * @param i defines the facet index
  25904. * @returns a new Vector3
  25905. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25906. */
  25907. getFacetNormal(i: number): Vector3;
  25908. /**
  25909. * Sets the reference Vector3 with the i-th facet normal in the world system
  25910. * @param i defines the facet index
  25911. * @param ref defines the target vector
  25912. * @returns the current mesh
  25913. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25914. */
  25915. getFacetNormalToRef(i: number, ref: Vector3): this;
  25916. /**
  25917. * 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)
  25918. * @param x defines x coordinate
  25919. * @param y defines y coordinate
  25920. * @param z defines z coordinate
  25921. * @returns the array of facet indexes
  25922. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25923. */
  25924. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25925. /**
  25926. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25927. * @param projected sets as the (x,y,z) world projection on the facet
  25928. * @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
  25929. * @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
  25930. * @param x defines x coordinate
  25931. * @param y defines y coordinate
  25932. * @param z defines z coordinate
  25933. * @returns the face index if found (or null instead)
  25934. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25935. */
  25936. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25937. /**
  25938. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25939. * @param projected sets as the (x,y,z) local projection on the facet
  25940. * @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
  25941. * @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
  25942. * @param x defines x coordinate
  25943. * @param y defines y coordinate
  25944. * @param z defines z coordinate
  25945. * @returns the face index if found (or null instead)
  25946. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25947. */
  25948. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25949. /**
  25950. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25951. * @returns the parameters
  25952. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25953. */
  25954. getFacetDataParameters(): any;
  25955. /**
  25956. * Disables the feature FacetData and frees the related memory
  25957. * @returns the current mesh
  25958. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25959. */
  25960. disableFacetData(): AbstractMesh;
  25961. /**
  25962. * Updates the AbstractMesh indices array
  25963. * @param indices defines the data source
  25964. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25965. * @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)
  25966. * @returns the current mesh
  25967. */
  25968. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25969. /**
  25970. * Creates new normals data for the mesh
  25971. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25972. * @returns the current mesh
  25973. */
  25974. createNormals(updatable: boolean): AbstractMesh;
  25975. /**
  25976. * Align the mesh with a normal
  25977. * @param normal defines the normal to use
  25978. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25979. * @returns the current mesh
  25980. */
  25981. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25982. /** @hidden */
  25983. _checkOcclusionQuery(): boolean;
  25984. /**
  25985. * Disables the mesh edge rendering mode
  25986. * @returns the currentAbstractMesh
  25987. */
  25988. disableEdgesRendering(): AbstractMesh;
  25989. /**
  25990. * Enables the edge rendering mode on the mesh.
  25991. * This mode makes the mesh edges visible
  25992. * @param epsilon defines the maximal distance between two angles to detect a face
  25993. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25994. * @returns the currentAbstractMesh
  25995. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25996. */
  25997. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25998. }
  25999. }
  26000. declare module "babylonjs/Actions/actionEvent" {
  26001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26002. import { Nullable } from "babylonjs/types";
  26003. import { Sprite } from "babylonjs/Sprites/sprite";
  26004. import { Scene } from "babylonjs/scene";
  26005. import { Vector2 } from "babylonjs/Maths/math";
  26006. /**
  26007. * Interface used to define ActionEvent
  26008. */
  26009. export interface IActionEvent {
  26010. /** The mesh or sprite that triggered the action */
  26011. source: any;
  26012. /** The X mouse cursor position at the time of the event */
  26013. pointerX: number;
  26014. /** The Y mouse cursor position at the time of the event */
  26015. pointerY: number;
  26016. /** The mesh that is currently pointed at (can be null) */
  26017. meshUnderPointer: Nullable<AbstractMesh>;
  26018. /** the original (browser) event that triggered the ActionEvent */
  26019. sourceEvent?: any;
  26020. /** additional data for the event */
  26021. additionalData?: any;
  26022. }
  26023. /**
  26024. * ActionEvent is the event being sent when an action is triggered.
  26025. */
  26026. export class ActionEvent implements IActionEvent {
  26027. /** The mesh or sprite that triggered the action */
  26028. source: any;
  26029. /** The X mouse cursor position at the time of the event */
  26030. pointerX: number;
  26031. /** The Y mouse cursor position at the time of the event */
  26032. pointerY: number;
  26033. /** The mesh that is currently pointed at (can be null) */
  26034. meshUnderPointer: Nullable<AbstractMesh>;
  26035. /** the original (browser) event that triggered the ActionEvent */
  26036. sourceEvent?: any;
  26037. /** additional data for the event */
  26038. additionalData?: any;
  26039. /**
  26040. * Creates a new ActionEvent
  26041. * @param source The mesh or sprite that triggered the action
  26042. * @param pointerX The X mouse cursor position at the time of the event
  26043. * @param pointerY The Y mouse cursor position at the time of the event
  26044. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26045. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26046. * @param additionalData additional data for the event
  26047. */
  26048. constructor(
  26049. /** The mesh or sprite that triggered the action */
  26050. source: any,
  26051. /** The X mouse cursor position at the time of the event */
  26052. pointerX: number,
  26053. /** The Y mouse cursor position at the time of the event */
  26054. pointerY: number,
  26055. /** The mesh that is currently pointed at (can be null) */
  26056. meshUnderPointer: Nullable<AbstractMesh>,
  26057. /** the original (browser) event that triggered the ActionEvent */
  26058. sourceEvent?: any,
  26059. /** additional data for the event */
  26060. additionalData?: any);
  26061. /**
  26062. * Helper function to auto-create an ActionEvent from a source mesh.
  26063. * @param source The source mesh that triggered the event
  26064. * @param evt The original (browser) event
  26065. * @param additionalData additional data for the event
  26066. * @returns the new ActionEvent
  26067. */
  26068. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26069. /**
  26070. * Helper function to auto-create an ActionEvent from a source sprite
  26071. * @param source The source sprite that triggered the event
  26072. * @param scene Scene associated with the sprite
  26073. * @param evt The original (browser) event
  26074. * @param additionalData additional data for the event
  26075. * @returns the new ActionEvent
  26076. */
  26077. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26078. /**
  26079. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26080. * @param scene the scene where the event occurred
  26081. * @param evt The original (browser) event
  26082. * @returns the new ActionEvent
  26083. */
  26084. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26085. /**
  26086. * Helper function to auto-create an ActionEvent from a primitive
  26087. * @param prim defines the target primitive
  26088. * @param pointerPos defines the pointer position
  26089. * @param evt The original (browser) event
  26090. * @param additionalData additional data for the event
  26091. * @returns the new ActionEvent
  26092. */
  26093. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26094. }
  26095. }
  26096. declare module "babylonjs/Actions/abstractActionManager" {
  26097. import { IDisposable } from "babylonjs/scene";
  26098. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  26099. import { IAction } from "babylonjs/Actions/action";
  26100. import { Nullable } from "babylonjs/types";
  26101. /**
  26102. * Abstract class used to decouple action Manager from scene and meshes.
  26103. * Do not instantiate.
  26104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26105. */
  26106. export abstract class AbstractActionManager implements IDisposable {
  26107. /** Gets the list of active triggers */
  26108. static Triggers: {
  26109. [key: string]: number;
  26110. };
  26111. /** Gets the cursor to use when hovering items */
  26112. hoverCursor: string;
  26113. /** Gets the list of actions */
  26114. actions: IAction[];
  26115. /**
  26116. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26117. */
  26118. isRecursive: boolean;
  26119. /**
  26120. * Releases all associated resources
  26121. */
  26122. abstract dispose(): void;
  26123. /**
  26124. * Does this action manager has pointer triggers
  26125. */
  26126. abstract readonly hasPointerTriggers: boolean;
  26127. /**
  26128. * Does this action manager has pick triggers
  26129. */
  26130. abstract readonly hasPickTriggers: boolean;
  26131. /**
  26132. * Process a specific trigger
  26133. * @param trigger defines the trigger to process
  26134. * @param evt defines the event details to be processed
  26135. */
  26136. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26137. /**
  26138. * Does this action manager handles actions of any of the given triggers
  26139. * @param triggers defines the triggers to be tested
  26140. * @return a boolean indicating whether one (or more) of the triggers is handled
  26141. */
  26142. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26143. /**
  26144. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26145. * speed.
  26146. * @param triggerA defines the trigger to be tested
  26147. * @param triggerB defines the trigger to be tested
  26148. * @return a boolean indicating whether one (or more) of the triggers is handled
  26149. */
  26150. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26151. /**
  26152. * Does this action manager handles actions of a given trigger
  26153. * @param trigger defines the trigger to be tested
  26154. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26155. * @return whether the trigger is handled
  26156. */
  26157. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26158. /**
  26159. * Serialize this manager to a JSON object
  26160. * @param name defines the property name to store this manager
  26161. * @returns a JSON representation of this manager
  26162. */
  26163. abstract serialize(name: string): any;
  26164. /**
  26165. * Registers an action to this action manager
  26166. * @param action defines the action to be registered
  26167. * @return the action amended (prepared) after registration
  26168. */
  26169. abstract registerAction(action: IAction): Nullable<IAction>;
  26170. /**
  26171. * Unregisters an action to this action manager
  26172. * @param action defines the action to be unregistered
  26173. * @return a boolean indicating whether the action has been unregistered
  26174. */
  26175. abstract unregisterAction(action: IAction): Boolean;
  26176. /**
  26177. * Does exist one action manager with at least one trigger
  26178. **/
  26179. static readonly HasTriggers: boolean;
  26180. /**
  26181. * Does exist one action manager with at least one pick trigger
  26182. **/
  26183. static readonly HasPickTriggers: boolean;
  26184. /**
  26185. * Does exist one action manager that handles actions of a given trigger
  26186. * @param trigger defines the trigger to be tested
  26187. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26188. **/
  26189. static HasSpecificTrigger(trigger: number): boolean;
  26190. }
  26191. }
  26192. declare module "babylonjs/node" {
  26193. import { Scene } from "babylonjs/scene";
  26194. import { Nullable } from "babylonjs/types";
  26195. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  26196. import { Engine } from "babylonjs/Engines/engine";
  26197. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  26198. import { Observable } from "babylonjs/Misc/observable";
  26199. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26200. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26201. import { Animatable } from "babylonjs/Animations/animatable";
  26202. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26203. import { Animation } from "babylonjs/Animations/animation";
  26204. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26205. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26206. /**
  26207. * Defines how a node can be built from a string name.
  26208. */
  26209. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26210. /**
  26211. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26212. */
  26213. export class Node implements IBehaviorAware<Node> {
  26214. /** @hidden */
  26215. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  26216. private static _NodeConstructors;
  26217. /**
  26218. * Add a new node constructor
  26219. * @param type defines the type name of the node to construct
  26220. * @param constructorFunc defines the constructor function
  26221. */
  26222. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26223. /**
  26224. * Returns a node constructor based on type name
  26225. * @param type defines the type name
  26226. * @param name defines the new node name
  26227. * @param scene defines the hosting scene
  26228. * @param options defines optional options to transmit to constructors
  26229. * @returns the new constructor or null
  26230. */
  26231. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26232. /**
  26233. * Gets or sets the name of the node
  26234. */
  26235. name: string;
  26236. /**
  26237. * Gets or sets the id of the node
  26238. */
  26239. id: string;
  26240. /**
  26241. * Gets or sets the unique id of the node
  26242. */
  26243. uniqueId: number;
  26244. /**
  26245. * Gets or sets a string used to store user defined state for the node
  26246. */
  26247. state: string;
  26248. /**
  26249. * Gets or sets an object used to store user defined information for the node
  26250. */
  26251. metadata: any;
  26252. /**
  26253. * For internal use only. Please do not use.
  26254. */
  26255. reservedDataStore: any;
  26256. /**
  26257. * List of inspectable custom properties (used by the Inspector)
  26258. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26259. */
  26260. inspectableCustomProperties: IInspectable[];
  26261. /**
  26262. * Gets or sets a boolean used to define if the node must be serialized
  26263. */
  26264. doNotSerialize: boolean;
  26265. /** @hidden */
  26266. _isDisposed: boolean;
  26267. /**
  26268. * Gets a list of Animations associated with the node
  26269. */
  26270. animations: import("babylonjs/Animations/animation").Animation[];
  26271. protected _ranges: {
  26272. [name: string]: Nullable<AnimationRange>;
  26273. };
  26274. /**
  26275. * Callback raised when the node is ready to be used
  26276. */
  26277. onReady: Nullable<(node: Node) => void>;
  26278. private _isEnabled;
  26279. private _isParentEnabled;
  26280. private _isReady;
  26281. /** @hidden */
  26282. _currentRenderId: number;
  26283. private _parentUpdateId;
  26284. /** @hidden */
  26285. _childUpdateId: number;
  26286. /** @hidden */
  26287. _waitingParentId: Nullable<string>;
  26288. /** @hidden */
  26289. _scene: Scene;
  26290. /** @hidden */
  26291. _cache: any;
  26292. private _parentNode;
  26293. private _children;
  26294. /** @hidden */
  26295. _worldMatrix: Matrix;
  26296. /** @hidden */
  26297. _worldMatrixDeterminant: number;
  26298. /** @hidden */
  26299. _worldMatrixDeterminantIsDirty: boolean;
  26300. /** @hidden */
  26301. private _sceneRootNodesIndex;
  26302. /**
  26303. * Gets a boolean indicating if the node has been disposed
  26304. * @returns true if the node was disposed
  26305. */
  26306. isDisposed(): boolean;
  26307. /**
  26308. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26309. * @see https://doc.babylonjs.com/how_to/parenting
  26310. */
  26311. parent: Nullable<Node>;
  26312. private addToSceneRootNodes;
  26313. private removeFromSceneRootNodes;
  26314. private _animationPropertiesOverride;
  26315. /**
  26316. * Gets or sets the animation properties override
  26317. */
  26318. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26319. /**
  26320. * Gets a string idenfifying the name of the class
  26321. * @returns "Node" string
  26322. */
  26323. getClassName(): string;
  26324. /** @hidden */
  26325. readonly _isNode: boolean;
  26326. /**
  26327. * An event triggered when the mesh is disposed
  26328. */
  26329. onDisposeObservable: Observable<Node>;
  26330. private _onDisposeObserver;
  26331. /**
  26332. * Sets a callback that will be raised when the node will be disposed
  26333. */
  26334. onDispose: () => void;
  26335. /**
  26336. * Creates a new Node
  26337. * @param name the name and id to be given to this node
  26338. * @param scene the scene this node will be added to
  26339. * @param addToRootNodes the node will be added to scene.rootNodes
  26340. */
  26341. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26342. /**
  26343. * Gets the scene of the node
  26344. * @returns a scene
  26345. */
  26346. getScene(): Scene;
  26347. /**
  26348. * Gets the engine of the node
  26349. * @returns a Engine
  26350. */
  26351. getEngine(): Engine;
  26352. private _behaviors;
  26353. /**
  26354. * Attach a behavior to the node
  26355. * @see http://doc.babylonjs.com/features/behaviour
  26356. * @param behavior defines the behavior to attach
  26357. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26358. * @returns the current Node
  26359. */
  26360. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26361. /**
  26362. * Remove an attached behavior
  26363. * @see http://doc.babylonjs.com/features/behaviour
  26364. * @param behavior defines the behavior to attach
  26365. * @returns the current Node
  26366. */
  26367. removeBehavior(behavior: Behavior<Node>): Node;
  26368. /**
  26369. * Gets the list of attached behaviors
  26370. * @see http://doc.babylonjs.com/features/behaviour
  26371. */
  26372. readonly behaviors: Behavior<Node>[];
  26373. /**
  26374. * Gets an attached behavior by name
  26375. * @param name defines the name of the behavior to look for
  26376. * @see http://doc.babylonjs.com/features/behaviour
  26377. * @returns null if behavior was not found else the requested behavior
  26378. */
  26379. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26380. /**
  26381. * Returns the latest update of the World matrix
  26382. * @returns a Matrix
  26383. */
  26384. getWorldMatrix(): Matrix;
  26385. /** @hidden */
  26386. _getWorldMatrixDeterminant(): number;
  26387. /**
  26388. * Returns directly the latest state of the mesh World matrix.
  26389. * A Matrix is returned.
  26390. */
  26391. readonly worldMatrixFromCache: Matrix;
  26392. /** @hidden */
  26393. _initCache(): void;
  26394. /** @hidden */
  26395. updateCache(force?: boolean): void;
  26396. /** @hidden */
  26397. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26398. /** @hidden */
  26399. _updateCache(ignoreParentClass?: boolean): void;
  26400. /** @hidden */
  26401. _isSynchronized(): boolean;
  26402. /** @hidden */
  26403. _markSyncedWithParent(): void;
  26404. /** @hidden */
  26405. isSynchronizedWithParent(): boolean;
  26406. /** @hidden */
  26407. isSynchronized(): boolean;
  26408. /**
  26409. * Is this node ready to be used/rendered
  26410. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26411. * @return true if the node is ready
  26412. */
  26413. isReady(completeCheck?: boolean): boolean;
  26414. /**
  26415. * Is this node enabled?
  26416. * 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
  26417. * @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
  26418. * @return whether this node (and its parent) is enabled
  26419. */
  26420. isEnabled(checkAncestors?: boolean): boolean;
  26421. /** @hidden */
  26422. protected _syncParentEnabledState(): void;
  26423. /**
  26424. * Set the enabled state of this node
  26425. * @param value defines the new enabled state
  26426. */
  26427. setEnabled(value: boolean): void;
  26428. /**
  26429. * Is this node a descendant of the given node?
  26430. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26431. * @param ancestor defines the parent node to inspect
  26432. * @returns a boolean indicating if this node is a descendant of the given node
  26433. */
  26434. isDescendantOf(ancestor: Node): boolean;
  26435. /** @hidden */
  26436. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26437. /**
  26438. * Will return all nodes that have this node as ascendant
  26439. * @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
  26440. * @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
  26441. * @return all children nodes of all types
  26442. */
  26443. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26444. /**
  26445. * Get all child-meshes of this node
  26446. * @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)
  26447. * @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
  26448. * @returns an array of AbstractMesh
  26449. */
  26450. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26451. /**
  26452. * Get all direct children of this node
  26453. * @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
  26454. * @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)
  26455. * @returns an array of Node
  26456. */
  26457. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26458. /** @hidden */
  26459. _setReady(state: boolean): void;
  26460. /**
  26461. * Get an animation by name
  26462. * @param name defines the name of the animation to look for
  26463. * @returns null if not found else the requested animation
  26464. */
  26465. getAnimationByName(name: string): Nullable<Animation>;
  26466. /**
  26467. * Creates an animation range for this node
  26468. * @param name defines the name of the range
  26469. * @param from defines the starting key
  26470. * @param to defines the end key
  26471. */
  26472. createAnimationRange(name: string, from: number, to: number): void;
  26473. /**
  26474. * Delete a specific animation range
  26475. * @param name defines the name of the range to delete
  26476. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26477. */
  26478. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26479. /**
  26480. * Get an animation range by name
  26481. * @param name defines the name of the animation range to look for
  26482. * @returns null if not found else the requested animation range
  26483. */
  26484. getAnimationRange(name: string): Nullable<AnimationRange>;
  26485. /**
  26486. * Gets the list of all animation ranges defined on this node
  26487. * @returns an array
  26488. */
  26489. getAnimationRanges(): Nullable<AnimationRange>[];
  26490. /**
  26491. * Will start the animation sequence
  26492. * @param name defines the range frames for animation sequence
  26493. * @param loop defines if the animation should loop (false by default)
  26494. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26495. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26496. * @returns the object created for this animation. If range does not exist, it will return null
  26497. */
  26498. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26499. /**
  26500. * Serialize animation ranges into a JSON compatible object
  26501. * @returns serialization object
  26502. */
  26503. serializeAnimationRanges(): any;
  26504. /**
  26505. * Computes the world matrix of the node
  26506. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26507. * @returns the world matrix
  26508. */
  26509. computeWorldMatrix(force?: boolean): Matrix;
  26510. /**
  26511. * Releases resources associated with this node.
  26512. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26513. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26514. */
  26515. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26516. /**
  26517. * Parse animation range data from a serialization object and store them into a given node
  26518. * @param node defines where to store the animation ranges
  26519. * @param parsedNode defines the serialization object to read data from
  26520. * @param scene defines the hosting scene
  26521. */
  26522. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26523. /**
  26524. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26525. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26526. * @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
  26527. * @returns the new bounding vectors
  26528. */
  26529. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26530. min: Vector3;
  26531. max: Vector3;
  26532. };
  26533. }
  26534. }
  26535. declare module "babylonjs/Animations/animation" {
  26536. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26537. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26538. import { Nullable } from "babylonjs/types";
  26539. import { Scene } from "babylonjs/scene";
  26540. import { IAnimatable } from "babylonjs/Misc/tools";
  26541. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26542. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26543. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26544. import { Node } from "babylonjs/node";
  26545. import { Animatable } from "babylonjs/Animations/animatable";
  26546. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26547. /**
  26548. * @hidden
  26549. */
  26550. export class _IAnimationState {
  26551. key: number;
  26552. repeatCount: number;
  26553. workValue?: any;
  26554. loopMode?: number;
  26555. offsetValue?: any;
  26556. highLimitValue?: any;
  26557. }
  26558. /**
  26559. * Class used to store any kind of animation
  26560. */
  26561. export class Animation {
  26562. /**Name of the animation */
  26563. name: string;
  26564. /**Property to animate */
  26565. targetProperty: string;
  26566. /**The frames per second of the animation */
  26567. framePerSecond: number;
  26568. /**The data type of the animation */
  26569. dataType: number;
  26570. /**The loop mode of the animation */
  26571. loopMode?: number | undefined;
  26572. /**Specifies if blending should be enabled */
  26573. enableBlending?: boolean | undefined;
  26574. /**
  26575. * Use matrix interpolation instead of using direct key value when animating matrices
  26576. */
  26577. static AllowMatricesInterpolation: boolean;
  26578. /**
  26579. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26580. */
  26581. static AllowMatrixDecomposeForInterpolation: boolean;
  26582. /**
  26583. * Stores the key frames of the animation
  26584. */
  26585. private _keys;
  26586. /**
  26587. * Stores the easing function of the animation
  26588. */
  26589. private _easingFunction;
  26590. /**
  26591. * @hidden Internal use only
  26592. */
  26593. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26594. /**
  26595. * The set of event that will be linked to this animation
  26596. */
  26597. private _events;
  26598. /**
  26599. * Stores an array of target property paths
  26600. */
  26601. targetPropertyPath: string[];
  26602. /**
  26603. * Stores the blending speed of the animation
  26604. */
  26605. blendingSpeed: number;
  26606. /**
  26607. * Stores the animation ranges for the animation
  26608. */
  26609. private _ranges;
  26610. /**
  26611. * @hidden Internal use
  26612. */
  26613. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26614. /**
  26615. * Sets up an animation
  26616. * @param property The property to animate
  26617. * @param animationType The animation type to apply
  26618. * @param framePerSecond The frames per second of the animation
  26619. * @param easingFunction The easing function used in the animation
  26620. * @returns The created animation
  26621. */
  26622. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26623. /**
  26624. * Create and start an animation on a node
  26625. * @param name defines the name of the global animation that will be run on all nodes
  26626. * @param node defines the root node where the animation will take place
  26627. * @param targetProperty defines property to animate
  26628. * @param framePerSecond defines the number of frame per second yo use
  26629. * @param totalFrame defines the number of frames in total
  26630. * @param from defines the initial value
  26631. * @param to defines the final value
  26632. * @param loopMode defines which loop mode you want to use (off by default)
  26633. * @param easingFunction defines the easing function to use (linear by default)
  26634. * @param onAnimationEnd defines the callback to call when animation end
  26635. * @returns the animatable created for this animation
  26636. */
  26637. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26638. /**
  26639. * Create and start an animation on a node and its descendants
  26640. * @param name defines the name of the global animation that will be run on all nodes
  26641. * @param node defines the root node where the animation will take place
  26642. * @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
  26643. * @param targetProperty defines property to animate
  26644. * @param framePerSecond defines the number of frame per second to use
  26645. * @param totalFrame defines the number of frames in total
  26646. * @param from defines the initial value
  26647. * @param to defines the final value
  26648. * @param loopMode defines which loop mode you want to use (off by default)
  26649. * @param easingFunction defines the easing function to use (linear by default)
  26650. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26651. * @returns the list of animatables created for all nodes
  26652. * @example https://www.babylonjs-playground.com/#MH0VLI
  26653. */
  26654. 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[]>;
  26655. /**
  26656. * Creates a new animation, merges it with the existing animations and starts it
  26657. * @param name Name of the animation
  26658. * @param node Node which contains the scene that begins the animations
  26659. * @param targetProperty Specifies which property to animate
  26660. * @param framePerSecond The frames per second of the animation
  26661. * @param totalFrame The total number of frames
  26662. * @param from The frame at the beginning of the animation
  26663. * @param to The frame at the end of the animation
  26664. * @param loopMode Specifies the loop mode of the animation
  26665. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26666. * @param onAnimationEnd Callback to run once the animation is complete
  26667. * @returns Nullable animation
  26668. */
  26669. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26670. /**
  26671. * Transition property of an host to the target Value
  26672. * @param property The property to transition
  26673. * @param targetValue The target Value of the property
  26674. * @param host The object where the property to animate belongs
  26675. * @param scene Scene used to run the animation
  26676. * @param frameRate Framerate (in frame/s) to use
  26677. * @param transition The transition type we want to use
  26678. * @param duration The duration of the animation, in milliseconds
  26679. * @param onAnimationEnd Callback trigger at the end of the animation
  26680. * @returns Nullable animation
  26681. */
  26682. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26683. /**
  26684. * Return the array of runtime animations currently using this animation
  26685. */
  26686. readonly runtimeAnimations: RuntimeAnimation[];
  26687. /**
  26688. * Specifies if any of the runtime animations are currently running
  26689. */
  26690. readonly hasRunningRuntimeAnimations: boolean;
  26691. /**
  26692. * Initializes the animation
  26693. * @param name Name of the animation
  26694. * @param targetProperty Property to animate
  26695. * @param framePerSecond The frames per second of the animation
  26696. * @param dataType The data type of the animation
  26697. * @param loopMode The loop mode of the animation
  26698. * @param enableBlending Specifies if blending should be enabled
  26699. */
  26700. constructor(
  26701. /**Name of the animation */
  26702. name: string,
  26703. /**Property to animate */
  26704. targetProperty: string,
  26705. /**The frames per second of the animation */
  26706. framePerSecond: number,
  26707. /**The data type of the animation */
  26708. dataType: number,
  26709. /**The loop mode of the animation */
  26710. loopMode?: number | undefined,
  26711. /**Specifies if blending should be enabled */
  26712. enableBlending?: boolean | undefined);
  26713. /**
  26714. * Converts the animation to a string
  26715. * @param fullDetails support for multiple levels of logging within scene loading
  26716. * @returns String form of the animation
  26717. */
  26718. toString(fullDetails?: boolean): string;
  26719. /**
  26720. * Add an event to this animation
  26721. * @param event Event to add
  26722. */
  26723. addEvent(event: AnimationEvent): void;
  26724. /**
  26725. * Remove all events found at the given frame
  26726. * @param frame The frame to remove events from
  26727. */
  26728. removeEvents(frame: number): void;
  26729. /**
  26730. * Retrieves all the events from the animation
  26731. * @returns Events from the animation
  26732. */
  26733. getEvents(): AnimationEvent[];
  26734. /**
  26735. * Creates an animation range
  26736. * @param name Name of the animation range
  26737. * @param from Starting frame of the animation range
  26738. * @param to Ending frame of the animation
  26739. */
  26740. createRange(name: string, from: number, to: number): void;
  26741. /**
  26742. * Deletes an animation range by name
  26743. * @param name Name of the animation range to delete
  26744. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26745. */
  26746. deleteRange(name: string, deleteFrames?: boolean): void;
  26747. /**
  26748. * Gets the animation range by name, or null if not defined
  26749. * @param name Name of the animation range
  26750. * @returns Nullable animation range
  26751. */
  26752. getRange(name: string): Nullable<AnimationRange>;
  26753. /**
  26754. * Gets the key frames from the animation
  26755. * @returns The key frames of the animation
  26756. */
  26757. getKeys(): Array<IAnimationKey>;
  26758. /**
  26759. * Gets the highest frame rate of the animation
  26760. * @returns Highest frame rate of the animation
  26761. */
  26762. getHighestFrame(): number;
  26763. /**
  26764. * Gets the easing function of the animation
  26765. * @returns Easing function of the animation
  26766. */
  26767. getEasingFunction(): IEasingFunction;
  26768. /**
  26769. * Sets the easing function of the animation
  26770. * @param easingFunction A custom mathematical formula for animation
  26771. */
  26772. setEasingFunction(easingFunction: EasingFunction): void;
  26773. /**
  26774. * Interpolates a scalar linearly
  26775. * @param startValue Start value of the animation curve
  26776. * @param endValue End value of the animation curve
  26777. * @param gradient Scalar amount to interpolate
  26778. * @returns Interpolated scalar value
  26779. */
  26780. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26781. /**
  26782. * Interpolates a scalar cubically
  26783. * @param startValue Start value of the animation curve
  26784. * @param outTangent End tangent of the animation
  26785. * @param endValue End value of the animation curve
  26786. * @param inTangent Start tangent of the animation curve
  26787. * @param gradient Scalar amount to interpolate
  26788. * @returns Interpolated scalar value
  26789. */
  26790. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26791. /**
  26792. * Interpolates a quaternion using a spherical linear interpolation
  26793. * @param startValue Start value of the animation curve
  26794. * @param endValue End value of the animation curve
  26795. * @param gradient Scalar amount to interpolate
  26796. * @returns Interpolated quaternion value
  26797. */
  26798. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26799. /**
  26800. * Interpolates a quaternion cubically
  26801. * @param startValue Start value of the animation curve
  26802. * @param outTangent End tangent of the animation curve
  26803. * @param endValue End value of the animation curve
  26804. * @param inTangent Start tangent of the animation curve
  26805. * @param gradient Scalar amount to interpolate
  26806. * @returns Interpolated quaternion value
  26807. */
  26808. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26809. /**
  26810. * Interpolates a Vector3 linearl
  26811. * @param startValue Start value of the animation curve
  26812. * @param endValue End value of the animation curve
  26813. * @param gradient Scalar amount to interpolate
  26814. * @returns Interpolated scalar value
  26815. */
  26816. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26817. /**
  26818. * Interpolates a Vector3 cubically
  26819. * @param startValue Start value of the animation curve
  26820. * @param outTangent End tangent of the animation
  26821. * @param endValue End value of the animation curve
  26822. * @param inTangent Start tangent of the animation curve
  26823. * @param gradient Scalar amount to interpolate
  26824. * @returns InterpolatedVector3 value
  26825. */
  26826. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26827. /**
  26828. * Interpolates a Vector2 linearly
  26829. * @param startValue Start value of the animation curve
  26830. * @param endValue End value of the animation curve
  26831. * @param gradient Scalar amount to interpolate
  26832. * @returns Interpolated Vector2 value
  26833. */
  26834. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26835. /**
  26836. * Interpolates a Vector2 cubically
  26837. * @param startValue Start value of the animation curve
  26838. * @param outTangent End tangent of the animation
  26839. * @param endValue End value of the animation curve
  26840. * @param inTangent Start tangent of the animation curve
  26841. * @param gradient Scalar amount to interpolate
  26842. * @returns Interpolated Vector2 value
  26843. */
  26844. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26845. /**
  26846. * Interpolates a size linearly
  26847. * @param startValue Start value of the animation curve
  26848. * @param endValue End value of the animation curve
  26849. * @param gradient Scalar amount to interpolate
  26850. * @returns Interpolated Size value
  26851. */
  26852. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26853. /**
  26854. * Interpolates a Color3 linearly
  26855. * @param startValue Start value of the animation curve
  26856. * @param endValue End value of the animation curve
  26857. * @param gradient Scalar amount to interpolate
  26858. * @returns Interpolated Color3 value
  26859. */
  26860. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26861. /**
  26862. * @hidden Internal use only
  26863. */
  26864. _getKeyValue(value: any): any;
  26865. /**
  26866. * @hidden Internal use only
  26867. */
  26868. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26869. /**
  26870. * Defines the function to use to interpolate matrices
  26871. * @param startValue defines the start matrix
  26872. * @param endValue defines the end matrix
  26873. * @param gradient defines the gradient between both matrices
  26874. * @param result defines an optional target matrix where to store the interpolation
  26875. * @returns the interpolated matrix
  26876. */
  26877. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26878. /**
  26879. * Makes a copy of the animation
  26880. * @returns Cloned animation
  26881. */
  26882. clone(): Animation;
  26883. /**
  26884. * Sets the key frames of the animation
  26885. * @param values The animation key frames to set
  26886. */
  26887. setKeys(values: Array<IAnimationKey>): void;
  26888. /**
  26889. * Serializes the animation to an object
  26890. * @returns Serialized object
  26891. */
  26892. serialize(): any;
  26893. /**
  26894. * Float animation type
  26895. */
  26896. private static _ANIMATIONTYPE_FLOAT;
  26897. /**
  26898. * Vector3 animation type
  26899. */
  26900. private static _ANIMATIONTYPE_VECTOR3;
  26901. /**
  26902. * Quaternion animation type
  26903. */
  26904. private static _ANIMATIONTYPE_QUATERNION;
  26905. /**
  26906. * Matrix animation type
  26907. */
  26908. private static _ANIMATIONTYPE_MATRIX;
  26909. /**
  26910. * Color3 animation type
  26911. */
  26912. private static _ANIMATIONTYPE_COLOR3;
  26913. /**
  26914. * Vector2 animation type
  26915. */
  26916. private static _ANIMATIONTYPE_VECTOR2;
  26917. /**
  26918. * Size animation type
  26919. */
  26920. private static _ANIMATIONTYPE_SIZE;
  26921. /**
  26922. * Relative Loop Mode
  26923. */
  26924. private static _ANIMATIONLOOPMODE_RELATIVE;
  26925. /**
  26926. * Cycle Loop Mode
  26927. */
  26928. private static _ANIMATIONLOOPMODE_CYCLE;
  26929. /**
  26930. * Constant Loop Mode
  26931. */
  26932. private static _ANIMATIONLOOPMODE_CONSTANT;
  26933. /**
  26934. * Get the float animation type
  26935. */
  26936. static readonly ANIMATIONTYPE_FLOAT: number;
  26937. /**
  26938. * Get the Vector3 animation type
  26939. */
  26940. static readonly ANIMATIONTYPE_VECTOR3: number;
  26941. /**
  26942. * Get the Vector2 animation type
  26943. */
  26944. static readonly ANIMATIONTYPE_VECTOR2: number;
  26945. /**
  26946. * Get the Size animation type
  26947. */
  26948. static readonly ANIMATIONTYPE_SIZE: number;
  26949. /**
  26950. * Get the Quaternion animation type
  26951. */
  26952. static readonly ANIMATIONTYPE_QUATERNION: number;
  26953. /**
  26954. * Get the Matrix animation type
  26955. */
  26956. static readonly ANIMATIONTYPE_MATRIX: number;
  26957. /**
  26958. * Get the Color3 animation type
  26959. */
  26960. static readonly ANIMATIONTYPE_COLOR3: number;
  26961. /**
  26962. * Get the Relative Loop Mode
  26963. */
  26964. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26965. /**
  26966. * Get the Cycle Loop Mode
  26967. */
  26968. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26969. /**
  26970. * Get the Constant Loop Mode
  26971. */
  26972. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26973. /** @hidden */
  26974. static _UniversalLerp(left: any, right: any, amount: number): any;
  26975. /**
  26976. * Parses an animation object and creates an animation
  26977. * @param parsedAnimation Parsed animation object
  26978. * @returns Animation object
  26979. */
  26980. static Parse(parsedAnimation: any): Animation;
  26981. /**
  26982. * Appends the serialized animations from the source animations
  26983. * @param source Source containing the animations
  26984. * @param destination Target to store the animations
  26985. */
  26986. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26987. }
  26988. }
  26989. declare module "babylonjs/Materials/Textures/baseTexture" {
  26990. import { Observable } from "babylonjs/Misc/observable";
  26991. import { IAnimatable } from "babylonjs/Misc/tools";
  26992. import { Nullable } from "babylonjs/types";
  26993. import { Scene } from "babylonjs/scene";
  26994. import { Matrix, ISize } from "babylonjs/Maths/math";
  26995. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26996. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26997. /**
  26998. * Base class of all the textures in babylon.
  26999. * It groups all the common properties the materials, post process, lights... might need
  27000. * in order to make a correct use of the texture.
  27001. */
  27002. export class BaseTexture implements IAnimatable {
  27003. /**
  27004. * Default anisotropic filtering level for the application.
  27005. * It is set to 4 as a good tradeoff between perf and quality.
  27006. */
  27007. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27008. /**
  27009. * Gets or sets the unique id of the texture
  27010. */
  27011. uniqueId: number;
  27012. /**
  27013. * Define the name of the texture.
  27014. */
  27015. name: string;
  27016. /**
  27017. * Gets or sets an object used to store user defined information.
  27018. */
  27019. metadata: any;
  27020. /**
  27021. * For internal use only. Please do not use.
  27022. */
  27023. reservedDataStore: any;
  27024. private _hasAlpha;
  27025. /**
  27026. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27027. */
  27028. hasAlpha: boolean;
  27029. /**
  27030. * Defines if the alpha value should be determined via the rgb values.
  27031. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27032. */
  27033. getAlphaFromRGB: boolean;
  27034. /**
  27035. * Intensity or strength of the texture.
  27036. * It is commonly used by materials to fine tune the intensity of the texture
  27037. */
  27038. level: number;
  27039. /**
  27040. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27041. * This is part of the texture as textures usually maps to one uv set.
  27042. */
  27043. coordinatesIndex: number;
  27044. private _coordinatesMode;
  27045. /**
  27046. * How a texture is mapped.
  27047. *
  27048. * | Value | Type | Description |
  27049. * | ----- | ----------------------------------- | ----------- |
  27050. * | 0 | EXPLICIT_MODE | |
  27051. * | 1 | SPHERICAL_MODE | |
  27052. * | 2 | PLANAR_MODE | |
  27053. * | 3 | CUBIC_MODE | |
  27054. * | 4 | PROJECTION_MODE | |
  27055. * | 5 | SKYBOX_MODE | |
  27056. * | 6 | INVCUBIC_MODE | |
  27057. * | 7 | EQUIRECTANGULAR_MODE | |
  27058. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27059. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27060. */
  27061. coordinatesMode: number;
  27062. /**
  27063. * | Value | Type | Description |
  27064. * | ----- | ------------------ | ----------- |
  27065. * | 0 | CLAMP_ADDRESSMODE | |
  27066. * | 1 | WRAP_ADDRESSMODE | |
  27067. * | 2 | MIRROR_ADDRESSMODE | |
  27068. */
  27069. wrapU: number;
  27070. /**
  27071. * | Value | Type | Description |
  27072. * | ----- | ------------------ | ----------- |
  27073. * | 0 | CLAMP_ADDRESSMODE | |
  27074. * | 1 | WRAP_ADDRESSMODE | |
  27075. * | 2 | MIRROR_ADDRESSMODE | |
  27076. */
  27077. wrapV: number;
  27078. /**
  27079. * | Value | Type | Description |
  27080. * | ----- | ------------------ | ----------- |
  27081. * | 0 | CLAMP_ADDRESSMODE | |
  27082. * | 1 | WRAP_ADDRESSMODE | |
  27083. * | 2 | MIRROR_ADDRESSMODE | |
  27084. */
  27085. wrapR: number;
  27086. /**
  27087. * With compliant hardware and browser (supporting anisotropic filtering)
  27088. * this defines the level of anisotropic filtering in the texture.
  27089. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27090. */
  27091. anisotropicFilteringLevel: number;
  27092. /**
  27093. * Define if the texture is a cube texture or if false a 2d texture.
  27094. */
  27095. isCube: boolean;
  27096. /**
  27097. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27098. */
  27099. is3D: boolean;
  27100. /**
  27101. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27102. * HDR texture are usually stored in linear space.
  27103. * This only impacts the PBR and Background materials
  27104. */
  27105. gammaSpace: boolean;
  27106. /**
  27107. * Gets whether or not the texture contains RGBD data.
  27108. */
  27109. readonly isRGBD: boolean;
  27110. /**
  27111. * Is Z inverted in the texture (useful in a cube texture).
  27112. */
  27113. invertZ: boolean;
  27114. /**
  27115. * Are mip maps generated for this texture or not.
  27116. */
  27117. readonly noMipmap: boolean;
  27118. /**
  27119. * @hidden
  27120. */
  27121. lodLevelInAlpha: boolean;
  27122. /**
  27123. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27124. */
  27125. lodGenerationOffset: number;
  27126. /**
  27127. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27128. */
  27129. lodGenerationScale: number;
  27130. /**
  27131. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27132. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27133. * average roughness values.
  27134. */
  27135. linearSpecularLOD: boolean;
  27136. /**
  27137. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27138. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27139. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27140. */
  27141. irradianceTexture: Nullable<BaseTexture>;
  27142. /**
  27143. * Define if the texture is a render target.
  27144. */
  27145. isRenderTarget: boolean;
  27146. /**
  27147. * Define the unique id of the texture in the scene.
  27148. */
  27149. readonly uid: string;
  27150. /**
  27151. * Return a string representation of the texture.
  27152. * @returns the texture as a string
  27153. */
  27154. toString(): string;
  27155. /**
  27156. * Get the class name of the texture.
  27157. * @returns "BaseTexture"
  27158. */
  27159. getClassName(): string;
  27160. /**
  27161. * Define the list of animation attached to the texture.
  27162. */
  27163. animations: import("babylonjs/Animations/animation").Animation[];
  27164. /**
  27165. * An event triggered when the texture is disposed.
  27166. */
  27167. onDisposeObservable: Observable<BaseTexture>;
  27168. private _onDisposeObserver;
  27169. /**
  27170. * Callback triggered when the texture has been disposed.
  27171. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27172. */
  27173. onDispose: () => void;
  27174. /**
  27175. * Define the current state of the loading sequence when in delayed load mode.
  27176. */
  27177. delayLoadState: number;
  27178. private _scene;
  27179. /** @hidden */
  27180. _texture: Nullable<InternalTexture>;
  27181. private _uid;
  27182. /**
  27183. * Define if the texture is preventinga material to render or not.
  27184. * If not and the texture is not ready, the engine will use a default black texture instead.
  27185. */
  27186. readonly isBlocking: boolean;
  27187. /**
  27188. * Instantiates a new BaseTexture.
  27189. * Base class of all the textures in babylon.
  27190. * It groups all the common properties the materials, post process, lights... might need
  27191. * in order to make a correct use of the texture.
  27192. * @param scene Define the scene the texture blongs to
  27193. */
  27194. constructor(scene: Nullable<Scene>);
  27195. /**
  27196. * Get the scene the texture belongs to.
  27197. * @returns the scene or null if undefined
  27198. */
  27199. getScene(): Nullable<Scene>;
  27200. /**
  27201. * Get the texture transform matrix used to offset tile the texture for istance.
  27202. * @returns the transformation matrix
  27203. */
  27204. getTextureMatrix(): Matrix;
  27205. /**
  27206. * Get the texture reflection matrix used to rotate/transform the reflection.
  27207. * @returns the reflection matrix
  27208. */
  27209. getReflectionTextureMatrix(): Matrix;
  27210. /**
  27211. * Get the underlying lower level texture from Babylon.
  27212. * @returns the insternal texture
  27213. */
  27214. getInternalTexture(): Nullable<InternalTexture>;
  27215. /**
  27216. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27217. * @returns true if ready or not blocking
  27218. */
  27219. isReadyOrNotBlocking(): boolean;
  27220. /**
  27221. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27222. * @returns true if fully ready
  27223. */
  27224. isReady(): boolean;
  27225. private _cachedSize;
  27226. /**
  27227. * Get the size of the texture.
  27228. * @returns the texture size.
  27229. */
  27230. getSize(): ISize;
  27231. /**
  27232. * Get the base size of the texture.
  27233. * It can be different from the size if the texture has been resized for POT for instance
  27234. * @returns the base size
  27235. */
  27236. getBaseSize(): ISize;
  27237. /**
  27238. * Update the sampling mode of the texture.
  27239. * Default is Trilinear mode.
  27240. *
  27241. * | Value | Type | Description |
  27242. * | ----- | ------------------ | ----------- |
  27243. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27244. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27245. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27246. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27247. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27248. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27249. * | 7 | NEAREST_LINEAR | |
  27250. * | 8 | NEAREST_NEAREST | |
  27251. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27252. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27253. * | 11 | LINEAR_LINEAR | |
  27254. * | 12 | LINEAR_NEAREST | |
  27255. *
  27256. * > _mag_: magnification filter (close to the viewer)
  27257. * > _min_: minification filter (far from the viewer)
  27258. * > _mip_: filter used between mip map levels
  27259. *@param samplingMode Define the new sampling mode of the texture
  27260. */
  27261. updateSamplingMode(samplingMode: number): void;
  27262. /**
  27263. * Scales the texture if is `canRescale()`
  27264. * @param ratio the resize factor we want to use to rescale
  27265. */
  27266. scale(ratio: number): void;
  27267. /**
  27268. * Get if the texture can rescale.
  27269. */
  27270. readonly canRescale: boolean;
  27271. /** @hidden */
  27272. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27273. /** @hidden */
  27274. _rebuild(): void;
  27275. /**
  27276. * Triggers the load sequence in delayed load mode.
  27277. */
  27278. delayLoad(): void;
  27279. /**
  27280. * Clones the texture.
  27281. * @returns the cloned texture
  27282. */
  27283. clone(): Nullable<BaseTexture>;
  27284. /**
  27285. * Get the texture underlying type (INT, FLOAT...)
  27286. */
  27287. readonly textureType: number;
  27288. /**
  27289. * Get the texture underlying format (RGB, RGBA...)
  27290. */
  27291. readonly textureFormat: number;
  27292. /**
  27293. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27294. * This will returns an RGBA array buffer containing either in values (0-255) or
  27295. * float values (0-1) depending of the underlying buffer type.
  27296. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27297. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27298. * @param buffer defines a user defined buffer to fill with data (can be null)
  27299. * @returns The Array buffer containing the pixels data.
  27300. */
  27301. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27302. /**
  27303. * Release and destroy the underlying lower level texture aka internalTexture.
  27304. */
  27305. releaseInternalTexture(): void;
  27306. /**
  27307. * Get the polynomial representation of the texture data.
  27308. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27309. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27310. */
  27311. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27312. /** @hidden */
  27313. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27314. /** @hidden */
  27315. readonly _lodTextureMid: Nullable<BaseTexture>;
  27316. /** @hidden */
  27317. readonly _lodTextureLow: Nullable<BaseTexture>;
  27318. /**
  27319. * Dispose the texture and release its associated resources.
  27320. */
  27321. dispose(): void;
  27322. /**
  27323. * Serialize the texture into a JSON representation that can be parsed later on.
  27324. * @returns the JSON representation of the texture
  27325. */
  27326. serialize(): any;
  27327. /**
  27328. * Helper function to be called back once a list of texture contains only ready textures.
  27329. * @param textures Define the list of textures to wait for
  27330. * @param callback Define the callback triggered once the entire list will be ready
  27331. */
  27332. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27333. }
  27334. }
  27335. declare module "babylonjs/Materials/uniformBuffer" {
  27336. import { Nullable, FloatArray } from "babylonjs/types";
  27337. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  27338. import { Engine } from "babylonjs/Engines/engine";
  27339. import { Effect } from "babylonjs/Materials/effect";
  27340. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27341. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27342. /**
  27343. * Uniform buffer objects.
  27344. *
  27345. * Handles blocks of uniform on the GPU.
  27346. *
  27347. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27348. *
  27349. * For more information, please refer to :
  27350. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27351. */
  27352. export class UniformBuffer {
  27353. private _engine;
  27354. private _buffer;
  27355. private _data;
  27356. private _bufferData;
  27357. private _dynamic?;
  27358. private _uniformLocations;
  27359. private _uniformSizes;
  27360. private _uniformLocationPointer;
  27361. private _needSync;
  27362. private _noUBO;
  27363. private _currentEffect;
  27364. private static _MAX_UNIFORM_SIZE;
  27365. private static _tempBuffer;
  27366. /**
  27367. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27368. * This is dynamic to allow compat with webgl 1 and 2.
  27369. * You will need to pass the name of the uniform as well as the value.
  27370. */
  27371. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27372. /**
  27373. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27374. * This is dynamic to allow compat with webgl 1 and 2.
  27375. * You will need to pass the name of the uniform as well as the value.
  27376. */
  27377. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27378. /**
  27379. * Lambda to Update a single float in a uniform buffer.
  27380. * This is dynamic to allow compat with webgl 1 and 2.
  27381. * You will need to pass the name of the uniform as well as the value.
  27382. */
  27383. updateFloat: (name: string, x: number) => void;
  27384. /**
  27385. * Lambda to Update a vec2 of float in a uniform buffer.
  27386. * This is dynamic to allow compat with webgl 1 and 2.
  27387. * You will need to pass the name of the uniform as well as the value.
  27388. */
  27389. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27390. /**
  27391. * Lambda to Update a vec3 of float in a uniform buffer.
  27392. * This is dynamic to allow compat with webgl 1 and 2.
  27393. * You will need to pass the name of the uniform as well as the value.
  27394. */
  27395. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27396. /**
  27397. * Lambda to Update a vec4 of float in a uniform buffer.
  27398. * This is dynamic to allow compat with webgl 1 and 2.
  27399. * You will need to pass the name of the uniform as well as the value.
  27400. */
  27401. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27402. /**
  27403. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27404. * This is dynamic to allow compat with webgl 1 and 2.
  27405. * You will need to pass the name of the uniform as well as the value.
  27406. */
  27407. updateMatrix: (name: string, mat: Matrix) => void;
  27408. /**
  27409. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27410. * This is dynamic to allow compat with webgl 1 and 2.
  27411. * You will need to pass the name of the uniform as well as the value.
  27412. */
  27413. updateVector3: (name: string, vector: Vector3) => void;
  27414. /**
  27415. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27416. * This is dynamic to allow compat with webgl 1 and 2.
  27417. * You will need to pass the name of the uniform as well as the value.
  27418. */
  27419. updateVector4: (name: string, vector: Vector4) => void;
  27420. /**
  27421. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27422. * This is dynamic to allow compat with webgl 1 and 2.
  27423. * You will need to pass the name of the uniform as well as the value.
  27424. */
  27425. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27426. /**
  27427. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27428. * This is dynamic to allow compat with webgl 1 and 2.
  27429. * You will need to pass the name of the uniform as well as the value.
  27430. */
  27431. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27432. /**
  27433. * Instantiates a new Uniform buffer objects.
  27434. *
  27435. * Handles blocks of uniform on the GPU.
  27436. *
  27437. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27438. *
  27439. * For more information, please refer to :
  27440. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27441. * @param engine Define the engine the buffer is associated with
  27442. * @param data Define the data contained in the buffer
  27443. * @param dynamic Define if the buffer is updatable
  27444. */
  27445. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27446. /**
  27447. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27448. * or just falling back on setUniformXXX calls.
  27449. */
  27450. readonly useUbo: boolean;
  27451. /**
  27452. * Indicates if the WebGL underlying uniform buffer is in sync
  27453. * with the javascript cache data.
  27454. */
  27455. readonly isSync: boolean;
  27456. /**
  27457. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27458. * Also, a dynamic UniformBuffer will disable cache verification and always
  27459. * update the underlying WebGL uniform buffer to the GPU.
  27460. * @returns if Dynamic, otherwise false
  27461. */
  27462. isDynamic(): boolean;
  27463. /**
  27464. * The data cache on JS side.
  27465. * @returns the underlying data as a float array
  27466. */
  27467. getData(): Float32Array;
  27468. /**
  27469. * The underlying WebGL Uniform buffer.
  27470. * @returns the webgl buffer
  27471. */
  27472. getBuffer(): Nullable<DataBuffer>;
  27473. /**
  27474. * std140 layout specifies how to align data within an UBO structure.
  27475. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27476. * for specs.
  27477. */
  27478. private _fillAlignment;
  27479. /**
  27480. * Adds an uniform in the buffer.
  27481. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27482. * for the layout to be correct !
  27483. * @param name Name of the uniform, as used in the uniform block in the shader.
  27484. * @param size Data size, or data directly.
  27485. */
  27486. addUniform(name: string, size: number | number[]): void;
  27487. /**
  27488. * Adds a Matrix 4x4 to the uniform buffer.
  27489. * @param name Name of the uniform, as used in the uniform block in the shader.
  27490. * @param mat A 4x4 matrix.
  27491. */
  27492. addMatrix(name: string, mat: Matrix): void;
  27493. /**
  27494. * Adds a vec2 to the uniform buffer.
  27495. * @param name Name of the uniform, as used in the uniform block in the shader.
  27496. * @param x Define the x component value of the vec2
  27497. * @param y Define the y component value of the vec2
  27498. */
  27499. addFloat2(name: string, x: number, y: number): void;
  27500. /**
  27501. * Adds a vec3 to the uniform buffer.
  27502. * @param name Name of the uniform, as used in the uniform block in the shader.
  27503. * @param x Define the x component value of the vec3
  27504. * @param y Define the y component value of the vec3
  27505. * @param z Define the z component value of the vec3
  27506. */
  27507. addFloat3(name: string, x: number, y: number, z: number): void;
  27508. /**
  27509. * Adds a vec3 to the uniform buffer.
  27510. * @param name Name of the uniform, as used in the uniform block in the shader.
  27511. * @param color Define the vec3 from a Color
  27512. */
  27513. addColor3(name: string, color: Color3): void;
  27514. /**
  27515. * Adds a vec4 to the uniform buffer.
  27516. * @param name Name of the uniform, as used in the uniform block in the shader.
  27517. * @param color Define the rgb components from a Color
  27518. * @param alpha Define the a component of the vec4
  27519. */
  27520. addColor4(name: string, color: Color3, alpha: number): void;
  27521. /**
  27522. * Adds a vec3 to the uniform buffer.
  27523. * @param name Name of the uniform, as used in the uniform block in the shader.
  27524. * @param vector Define the vec3 components from a Vector
  27525. */
  27526. addVector3(name: string, vector: Vector3): void;
  27527. /**
  27528. * Adds a Matrix 3x3 to the uniform buffer.
  27529. * @param name Name of the uniform, as used in the uniform block in the shader.
  27530. */
  27531. addMatrix3x3(name: string): void;
  27532. /**
  27533. * Adds a Matrix 2x2 to the uniform buffer.
  27534. * @param name Name of the uniform, as used in the uniform block in the shader.
  27535. */
  27536. addMatrix2x2(name: string): void;
  27537. /**
  27538. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27539. */
  27540. create(): void;
  27541. /** @hidden */
  27542. _rebuild(): void;
  27543. /**
  27544. * Updates the WebGL Uniform Buffer on the GPU.
  27545. * If the `dynamic` flag is set to true, no cache comparison is done.
  27546. * Otherwise, the buffer will be updated only if the cache differs.
  27547. */
  27548. update(): void;
  27549. /**
  27550. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27551. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27552. * @param data Define the flattened data
  27553. * @param size Define the size of the data.
  27554. */
  27555. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27556. private _updateMatrix3x3ForUniform;
  27557. private _updateMatrix3x3ForEffect;
  27558. private _updateMatrix2x2ForEffect;
  27559. private _updateMatrix2x2ForUniform;
  27560. private _updateFloatForEffect;
  27561. private _updateFloatForUniform;
  27562. private _updateFloat2ForEffect;
  27563. private _updateFloat2ForUniform;
  27564. private _updateFloat3ForEffect;
  27565. private _updateFloat3ForUniform;
  27566. private _updateFloat4ForEffect;
  27567. private _updateFloat4ForUniform;
  27568. private _updateMatrixForEffect;
  27569. private _updateMatrixForUniform;
  27570. private _updateVector3ForEffect;
  27571. private _updateVector3ForUniform;
  27572. private _updateVector4ForEffect;
  27573. private _updateVector4ForUniform;
  27574. private _updateColor3ForEffect;
  27575. private _updateColor3ForUniform;
  27576. private _updateColor4ForEffect;
  27577. private _updateColor4ForUniform;
  27578. /**
  27579. * Sets a sampler uniform on the effect.
  27580. * @param name Define the name of the sampler.
  27581. * @param texture Define the texture to set in the sampler
  27582. */
  27583. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27584. /**
  27585. * Directly updates the value of the uniform in the cache AND on the GPU.
  27586. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27587. * @param data Define the flattened data
  27588. */
  27589. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27590. /**
  27591. * Binds this uniform buffer to an effect.
  27592. * @param effect Define the effect to bind the buffer to
  27593. * @param name Name of the uniform block in the shader.
  27594. */
  27595. bindToEffect(effect: Effect, name: string): void;
  27596. /**
  27597. * Disposes the uniform buffer.
  27598. */
  27599. dispose(): void;
  27600. }
  27601. }
  27602. declare module "babylonjs/Audio/analyser" {
  27603. import { Scene } from "babylonjs/scene";
  27604. /**
  27605. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27607. */
  27608. export class Analyser {
  27609. /**
  27610. * Gets or sets the smoothing
  27611. * @ignorenaming
  27612. */
  27613. SMOOTHING: number;
  27614. /**
  27615. * Gets or sets the FFT table size
  27616. * @ignorenaming
  27617. */
  27618. FFT_SIZE: number;
  27619. /**
  27620. * Gets or sets the bar graph amplitude
  27621. * @ignorenaming
  27622. */
  27623. BARGRAPHAMPLITUDE: number;
  27624. /**
  27625. * Gets or sets the position of the debug canvas
  27626. * @ignorenaming
  27627. */
  27628. DEBUGCANVASPOS: {
  27629. x: number;
  27630. y: number;
  27631. };
  27632. /**
  27633. * Gets or sets the debug canvas size
  27634. * @ignorenaming
  27635. */
  27636. DEBUGCANVASSIZE: {
  27637. width: number;
  27638. height: number;
  27639. };
  27640. private _byteFreqs;
  27641. private _byteTime;
  27642. private _floatFreqs;
  27643. private _webAudioAnalyser;
  27644. private _debugCanvas;
  27645. private _debugCanvasContext;
  27646. private _scene;
  27647. private _registerFunc;
  27648. private _audioEngine;
  27649. /**
  27650. * Creates a new analyser
  27651. * @param scene defines hosting scene
  27652. */
  27653. constructor(scene: Scene);
  27654. /**
  27655. * Get the number of data values you will have to play with for the visualization
  27656. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27657. * @returns a number
  27658. */
  27659. getFrequencyBinCount(): number;
  27660. /**
  27661. * Gets the current frequency data as a byte array
  27662. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27663. * @returns a Uint8Array
  27664. */
  27665. getByteFrequencyData(): Uint8Array;
  27666. /**
  27667. * Gets the current waveform as a byte array
  27668. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27669. * @returns a Uint8Array
  27670. */
  27671. getByteTimeDomainData(): Uint8Array;
  27672. /**
  27673. * Gets the current frequency data as a float array
  27674. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27675. * @returns a Float32Array
  27676. */
  27677. getFloatFrequencyData(): Float32Array;
  27678. /**
  27679. * Renders the debug canvas
  27680. */
  27681. drawDebugCanvas(): void;
  27682. /**
  27683. * Stops rendering the debug canvas and removes it
  27684. */
  27685. stopDebugCanvas(): void;
  27686. /**
  27687. * Connects two audio nodes
  27688. * @param inputAudioNode defines first node to connect
  27689. * @param outputAudioNode defines second node to connect
  27690. */
  27691. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27692. /**
  27693. * Releases all associated resources
  27694. */
  27695. dispose(): void;
  27696. }
  27697. }
  27698. declare module "babylonjs/Audio/audioEngine" {
  27699. import { IDisposable } from "babylonjs/scene";
  27700. import { Analyser } from "babylonjs/Audio/analyser";
  27701. import { Nullable } from "babylonjs/types";
  27702. import { Observable } from "babylonjs/Misc/observable";
  27703. /**
  27704. * This represents an audio engine and it is responsible
  27705. * to play, synchronize and analyse sounds throughout the application.
  27706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27707. */
  27708. export interface IAudioEngine extends IDisposable {
  27709. /**
  27710. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27711. */
  27712. readonly canUseWebAudio: boolean;
  27713. /**
  27714. * Gets the current AudioContext if available.
  27715. */
  27716. readonly audioContext: Nullable<AudioContext>;
  27717. /**
  27718. * The master gain node defines the global audio volume of your audio engine.
  27719. */
  27720. readonly masterGain: GainNode;
  27721. /**
  27722. * Gets whether or not mp3 are supported by your browser.
  27723. */
  27724. readonly isMP3supported: boolean;
  27725. /**
  27726. * Gets whether or not ogg are supported by your browser.
  27727. */
  27728. readonly isOGGsupported: boolean;
  27729. /**
  27730. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27731. * @ignoreNaming
  27732. */
  27733. WarnedWebAudioUnsupported: boolean;
  27734. /**
  27735. * Defines if the audio engine relies on a custom unlocked button.
  27736. * In this case, the embedded button will not be displayed.
  27737. */
  27738. useCustomUnlockedButton: boolean;
  27739. /**
  27740. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27741. */
  27742. readonly unlocked: boolean;
  27743. /**
  27744. * Event raised when audio has been unlocked on the browser.
  27745. */
  27746. onAudioUnlockedObservable: Observable<AudioEngine>;
  27747. /**
  27748. * Event raised when audio has been locked on the browser.
  27749. */
  27750. onAudioLockedObservable: Observable<AudioEngine>;
  27751. /**
  27752. * Flags the audio engine in Locked state.
  27753. * This happens due to new browser policies preventing audio to autoplay.
  27754. */
  27755. lock(): void;
  27756. /**
  27757. * Unlocks the audio engine once a user action has been done on the dom.
  27758. * This is helpful to resume play once browser policies have been satisfied.
  27759. */
  27760. unlock(): void;
  27761. }
  27762. /**
  27763. * This represents the default audio engine used in babylon.
  27764. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27765. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27766. */
  27767. export class AudioEngine implements IAudioEngine {
  27768. private _audioContext;
  27769. private _audioContextInitialized;
  27770. private _muteButton;
  27771. private _hostElement;
  27772. /**
  27773. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27774. */
  27775. canUseWebAudio: boolean;
  27776. /**
  27777. * The master gain node defines the global audio volume of your audio engine.
  27778. */
  27779. masterGain: GainNode;
  27780. /**
  27781. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27782. * @ignoreNaming
  27783. */
  27784. WarnedWebAudioUnsupported: boolean;
  27785. /**
  27786. * Gets whether or not mp3 are supported by your browser.
  27787. */
  27788. isMP3supported: boolean;
  27789. /**
  27790. * Gets whether or not ogg are supported by your browser.
  27791. */
  27792. isOGGsupported: boolean;
  27793. /**
  27794. * Gets whether audio has been unlocked on the device.
  27795. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27796. * a user interaction has happened.
  27797. */
  27798. unlocked: boolean;
  27799. /**
  27800. * Defines if the audio engine relies on a custom unlocked button.
  27801. * In this case, the embedded button will not be displayed.
  27802. */
  27803. useCustomUnlockedButton: boolean;
  27804. /**
  27805. * Event raised when audio has been unlocked on the browser.
  27806. */
  27807. onAudioUnlockedObservable: Observable<AudioEngine>;
  27808. /**
  27809. * Event raised when audio has been locked on the browser.
  27810. */
  27811. onAudioLockedObservable: Observable<AudioEngine>;
  27812. /**
  27813. * Gets the current AudioContext if available.
  27814. */
  27815. readonly audioContext: Nullable<AudioContext>;
  27816. private _connectedAnalyser;
  27817. /**
  27818. * Instantiates a new audio engine.
  27819. *
  27820. * There should be only one per page as some browsers restrict the number
  27821. * of audio contexts you can create.
  27822. * @param hostElement defines the host element where to display the mute icon if necessary
  27823. */
  27824. constructor(hostElement?: Nullable<HTMLElement>);
  27825. /**
  27826. * Flags the audio engine in Locked state.
  27827. * This happens due to new browser policies preventing audio to autoplay.
  27828. */
  27829. lock(): void;
  27830. /**
  27831. * Unlocks the audio engine once a user action has been done on the dom.
  27832. * This is helpful to resume play once browser policies have been satisfied.
  27833. */
  27834. unlock(): void;
  27835. private _resumeAudioContext;
  27836. private _initializeAudioContext;
  27837. private _tryToRun;
  27838. private _triggerRunningState;
  27839. private _triggerSuspendedState;
  27840. private _displayMuteButton;
  27841. private _moveButtonToTopLeft;
  27842. private _onResize;
  27843. private _hideMuteButton;
  27844. /**
  27845. * Destroy and release the resources associated with the audio ccontext.
  27846. */
  27847. dispose(): void;
  27848. /**
  27849. * Gets the global volume sets on the master gain.
  27850. * @returns the global volume if set or -1 otherwise
  27851. */
  27852. getGlobalVolume(): number;
  27853. /**
  27854. * Sets the global volume of your experience (sets on the master gain).
  27855. * @param newVolume Defines the new global volume of the application
  27856. */
  27857. setGlobalVolume(newVolume: number): void;
  27858. /**
  27859. * Connect the audio engine to an audio analyser allowing some amazing
  27860. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27861. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27862. * @param analyser The analyser to connect to the engine
  27863. */
  27864. connectToAnalyser(analyser: Analyser): void;
  27865. }
  27866. }
  27867. declare module "babylonjs/Loading/loadingScreen" {
  27868. /**
  27869. * Interface used to present a loading screen while loading a scene
  27870. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27871. */
  27872. export interface ILoadingScreen {
  27873. /**
  27874. * Function called to display the loading screen
  27875. */
  27876. displayLoadingUI: () => void;
  27877. /**
  27878. * Function called to hide the loading screen
  27879. */
  27880. hideLoadingUI: () => void;
  27881. /**
  27882. * Gets or sets the color to use for the background
  27883. */
  27884. loadingUIBackgroundColor: string;
  27885. /**
  27886. * Gets or sets the text to display while loading
  27887. */
  27888. loadingUIText: string;
  27889. }
  27890. /**
  27891. * Class used for the default loading screen
  27892. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27893. */
  27894. export class DefaultLoadingScreen implements ILoadingScreen {
  27895. private _renderingCanvas;
  27896. private _loadingText;
  27897. private _loadingDivBackgroundColor;
  27898. private _loadingDiv;
  27899. private _loadingTextDiv;
  27900. /** Gets or sets the logo url to use for the default loading screen */
  27901. static DefaultLogoUrl: string;
  27902. /** Gets or sets the spinner url to use for the default loading screen */
  27903. static DefaultSpinnerUrl: string;
  27904. /**
  27905. * Creates a new default loading screen
  27906. * @param _renderingCanvas defines the canvas used to render the scene
  27907. * @param _loadingText defines the default text to display
  27908. * @param _loadingDivBackgroundColor defines the default background color
  27909. */
  27910. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27911. /**
  27912. * Function called to display the loading screen
  27913. */
  27914. displayLoadingUI(): void;
  27915. /**
  27916. * Function called to hide the loading screen
  27917. */
  27918. hideLoadingUI(): void;
  27919. /**
  27920. * Gets or sets the text to display while loading
  27921. */
  27922. loadingUIText: string;
  27923. /**
  27924. * Gets or sets the color to use for the background
  27925. */
  27926. loadingUIBackgroundColor: string;
  27927. private _resizeLoadingUI;
  27928. }
  27929. }
  27930. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27931. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27932. import { Engine } from "babylonjs/Engines/engine";
  27933. import { Nullable } from "babylonjs/types";
  27934. /** @hidden */
  27935. export class WebGLPipelineContext implements IPipelineContext {
  27936. engine: Engine;
  27937. program: Nullable<WebGLProgram>;
  27938. context?: WebGLRenderingContext;
  27939. vertexShader?: WebGLShader;
  27940. fragmentShader?: WebGLShader;
  27941. isParallelCompiled: boolean;
  27942. onCompiled?: () => void;
  27943. transformFeedback?: WebGLTransformFeedback | null;
  27944. readonly isAsync: boolean;
  27945. readonly isReady: boolean;
  27946. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27947. }
  27948. }
  27949. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27950. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27951. /** @hidden */
  27952. export class WebGLDataBuffer extends DataBuffer {
  27953. private _buffer;
  27954. constructor(resource: WebGLBuffer);
  27955. readonly underlyingResource: any;
  27956. }
  27957. }
  27958. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  27959. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27960. /** @hidden */
  27961. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27962. attributeProcessor(attribute: string): string;
  27963. varyingProcessor(varying: string, isFragment: boolean): string;
  27964. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27965. }
  27966. }
  27967. declare module "babylonjs/Materials/Textures/videoTexture" {
  27968. import { Observable } from "babylonjs/Misc/observable";
  27969. import { Nullable } from "babylonjs/types";
  27970. import { Scene } from "babylonjs/scene";
  27971. import { Texture } from "babylonjs/Materials/Textures/texture";
  27972. /**
  27973. * Settings for finer control over video usage
  27974. */
  27975. export interface VideoTextureSettings {
  27976. /**
  27977. * Applies `autoplay` to video, if specified
  27978. */
  27979. autoPlay?: boolean;
  27980. /**
  27981. * Applies `loop` to video, if specified
  27982. */
  27983. loop?: boolean;
  27984. /**
  27985. * Automatically updates internal texture from video at every frame in the render loop
  27986. */
  27987. autoUpdateTexture: boolean;
  27988. /**
  27989. * Image src displayed during the video loading or until the user interacts with the video.
  27990. */
  27991. poster?: string;
  27992. }
  27993. /**
  27994. * If you want to display a video in your scene, this is the special texture for that.
  27995. * This special texture works similar to other textures, with the exception of a few parameters.
  27996. * @see https://doc.babylonjs.com/how_to/video_texture
  27997. */
  27998. export class VideoTexture extends Texture {
  27999. /**
  28000. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  28001. */
  28002. readonly autoUpdateTexture: boolean;
  28003. /**
  28004. * The video instance used by the texture internally
  28005. */
  28006. readonly video: HTMLVideoElement;
  28007. private _onUserActionRequestedObservable;
  28008. /**
  28009. * Event triggerd when a dom action is required by the user to play the video.
  28010. * This happens due to recent changes in browser policies preventing video to auto start.
  28011. */
  28012. readonly onUserActionRequestedObservable: Observable<Texture>;
  28013. private _generateMipMaps;
  28014. private _engine;
  28015. private _stillImageCaptured;
  28016. private _displayingPosterTexture;
  28017. private _settings;
  28018. private _createInternalTextureOnEvent;
  28019. /**
  28020. * Creates a video texture.
  28021. * If you want to display a video in your scene, this is the special texture for that.
  28022. * This special texture works similar to other textures, with the exception of a few parameters.
  28023. * @see https://doc.babylonjs.com/how_to/video_texture
  28024. * @param name optional name, will detect from video source, if not defined
  28025. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28026. * @param scene is obviously the current scene.
  28027. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28028. * @param invertY is false by default but can be used to invert video on Y axis
  28029. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28030. * @param settings allows finer control over video usage
  28031. */
  28032. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28033. private _getName;
  28034. private _getVideo;
  28035. private _createInternalTexture;
  28036. private reset;
  28037. /**
  28038. * @hidden Internal method to initiate `update`.
  28039. */
  28040. _rebuild(): void;
  28041. /**
  28042. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28043. */
  28044. update(): void;
  28045. /**
  28046. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28047. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28048. */
  28049. updateTexture(isVisible: boolean): void;
  28050. protected _updateInternalTexture: () => void;
  28051. /**
  28052. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28053. * @param url New url.
  28054. */
  28055. updateURL(url: string): void;
  28056. /**
  28057. * Dispose the texture and release its associated resources.
  28058. */
  28059. dispose(): void;
  28060. /**
  28061. * Creates a video texture straight from a stream.
  28062. * @param scene Define the scene the texture should be created in
  28063. * @param stream Define the stream the texture should be created from
  28064. * @returns The created video texture as a promise
  28065. */
  28066. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28067. /**
  28068. * Creates a video texture straight from your WebCam video feed.
  28069. * @param scene Define the scene the texture should be created in
  28070. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28071. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28072. * @returns The created video texture as a promise
  28073. */
  28074. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28075. minWidth: number;
  28076. maxWidth: number;
  28077. minHeight: number;
  28078. maxHeight: number;
  28079. deviceId: string;
  28080. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28081. /**
  28082. * Creates a video texture straight from your WebCam video feed.
  28083. * @param scene Define the scene the texture should be created in
  28084. * @param onReady Define a callback to triggered once the texture will be ready
  28085. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28086. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28087. */
  28088. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28089. minWidth: number;
  28090. maxWidth: number;
  28091. minHeight: number;
  28092. maxHeight: number;
  28093. deviceId: string;
  28094. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28095. }
  28096. }
  28097. declare module "babylonjs/Engines/engine" {
  28098. import { Observable } from "babylonjs/Misc/observable";
  28099. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  28100. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  28101. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  28102. import { Camera } from "babylonjs/Cameras/camera";
  28103. import { Scene } from "babylonjs/scene";
  28104. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  28105. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28106. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28107. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  28108. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  28109. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28110. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28111. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  28112. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  28113. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  28114. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  28115. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  28116. import { WebRequest } from "babylonjs/Misc/webRequest";
  28117. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  28118. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28119. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28120. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  28121. import { Material } from "babylonjs/Materials/material";
  28122. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28123. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28124. /**
  28125. * Interface for attribute information associated with buffer instanciation
  28126. */
  28127. export class InstancingAttributeInfo {
  28128. /**
  28129. * Index/offset of the attribute in the vertex shader
  28130. */
  28131. index: number;
  28132. /**
  28133. * size of the attribute, 1, 2, 3 or 4
  28134. */
  28135. attributeSize: number;
  28136. /**
  28137. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28138. * default is FLOAT
  28139. */
  28140. attribyteType: number;
  28141. /**
  28142. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28143. */
  28144. normalized: boolean;
  28145. /**
  28146. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28147. */
  28148. offset: number;
  28149. /**
  28150. * Name of the GLSL attribute, for debugging purpose only
  28151. */
  28152. attributeName: string;
  28153. }
  28154. /**
  28155. * Define options used to create a depth texture
  28156. */
  28157. export class DepthTextureCreationOptions {
  28158. /** Specifies whether or not a stencil should be allocated in the texture */
  28159. generateStencil?: boolean;
  28160. /** Specifies whether or not bilinear filtering is enable on the texture */
  28161. bilinearFiltering?: boolean;
  28162. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  28163. comparisonFunction?: number;
  28164. /** Specifies if the created texture is a cube texture */
  28165. isCube?: boolean;
  28166. }
  28167. /**
  28168. * Class used to describe the capabilities of the engine relatively to the current browser
  28169. */
  28170. export class EngineCapabilities {
  28171. /** Maximum textures units per fragment shader */
  28172. maxTexturesImageUnits: number;
  28173. /** Maximum texture units per vertex shader */
  28174. maxVertexTextureImageUnits: number;
  28175. /** Maximum textures units in the entire pipeline */
  28176. maxCombinedTexturesImageUnits: number;
  28177. /** Maximum texture size */
  28178. maxTextureSize: number;
  28179. /** Maximum cube texture size */
  28180. maxCubemapTextureSize: number;
  28181. /** Maximum render texture size */
  28182. maxRenderTextureSize: number;
  28183. /** Maximum number of vertex attributes */
  28184. maxVertexAttribs: number;
  28185. /** Maximum number of varyings */
  28186. maxVaryingVectors: number;
  28187. /** Maximum number of uniforms per vertex shader */
  28188. maxVertexUniformVectors: number;
  28189. /** Maximum number of uniforms per fragment shader */
  28190. maxFragmentUniformVectors: number;
  28191. /** Defines if standard derivates (dx/dy) are supported */
  28192. standardDerivatives: boolean;
  28193. /** Defines if s3tc texture compression is supported */
  28194. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28195. /** Defines if pvrtc texture compression is supported */
  28196. pvrtc: any;
  28197. /** Defines if etc1 texture compression is supported */
  28198. etc1: any;
  28199. /** Defines if etc2 texture compression is supported */
  28200. etc2: any;
  28201. /** Defines if astc texture compression is supported */
  28202. astc: any;
  28203. /** Defines if float textures are supported */
  28204. textureFloat: boolean;
  28205. /** Defines if vertex array objects are supported */
  28206. vertexArrayObject: boolean;
  28207. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28208. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28209. /** Gets the maximum level of anisotropy supported */
  28210. maxAnisotropy: number;
  28211. /** Defines if instancing is supported */
  28212. instancedArrays: boolean;
  28213. /** Defines if 32 bits indices are supported */
  28214. uintIndices: boolean;
  28215. /** Defines if high precision shaders are supported */
  28216. highPrecisionShaderSupported: boolean;
  28217. /** Defines if depth reading in the fragment shader is supported */
  28218. fragmentDepthSupported: boolean;
  28219. /** Defines if float texture linear filtering is supported*/
  28220. textureFloatLinearFiltering: boolean;
  28221. /** Defines if rendering to float textures is supported */
  28222. textureFloatRender: boolean;
  28223. /** Defines if half float textures are supported*/
  28224. textureHalfFloat: boolean;
  28225. /** Defines if half float texture linear filtering is supported*/
  28226. textureHalfFloatLinearFiltering: boolean;
  28227. /** Defines if rendering to half float textures is supported */
  28228. textureHalfFloatRender: boolean;
  28229. /** Defines if textureLOD shader command is supported */
  28230. textureLOD: boolean;
  28231. /** Defines if draw buffers extension is supported */
  28232. drawBuffersExtension: boolean;
  28233. /** Defines if depth textures are supported */
  28234. depthTextureExtension: boolean;
  28235. /** Defines if float color buffer are supported */
  28236. colorBufferFloat: boolean;
  28237. /** Gets disjoint timer query extension (null if not supported) */
  28238. timerQuery: EXT_disjoint_timer_query;
  28239. /** Defines if timestamp can be used with timer query */
  28240. canUseTimestampForTimerQuery: boolean;
  28241. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28242. multiview: any;
  28243. /** Function used to let the system compiles shaders in background */
  28244. parallelShaderCompile: {
  28245. COMPLETION_STATUS_KHR: number;
  28246. };
  28247. }
  28248. /** Interface defining initialization parameters for Engine class */
  28249. export interface EngineOptions extends WebGLContextAttributes {
  28250. /**
  28251. * Defines if the engine should no exceed a specified device ratio
  28252. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28253. */
  28254. limitDeviceRatio?: number;
  28255. /**
  28256. * Defines if webvr should be enabled automatically
  28257. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28258. */
  28259. autoEnableWebVR?: boolean;
  28260. /**
  28261. * Defines if webgl2 should be turned off even if supported
  28262. * @see http://doc.babylonjs.com/features/webgl2
  28263. */
  28264. disableWebGL2Support?: boolean;
  28265. /**
  28266. * Defines if webaudio should be initialized as well
  28267. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28268. */
  28269. audioEngine?: boolean;
  28270. /**
  28271. * Defines if animations should run using a deterministic lock step
  28272. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28273. */
  28274. deterministicLockstep?: boolean;
  28275. /** Defines the maximum steps to use with deterministic lock step mode */
  28276. lockstepMaxSteps?: number;
  28277. /**
  28278. * Defines that engine should ignore context lost events
  28279. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28280. */
  28281. doNotHandleContextLost?: boolean;
  28282. /**
  28283. * Defines that engine should ignore modifying touch action attribute and style
  28284. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28285. */
  28286. doNotHandleTouchAction?: boolean;
  28287. /**
  28288. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28289. */
  28290. useHighPrecisionFloats?: boolean;
  28291. }
  28292. /**
  28293. * Defines the interface used by display changed events
  28294. */
  28295. export interface IDisplayChangedEventArgs {
  28296. /** Gets the vrDisplay object (if any) */
  28297. vrDisplay: Nullable<any>;
  28298. /** Gets a boolean indicating if webVR is supported */
  28299. vrSupported: boolean;
  28300. }
  28301. /**
  28302. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28303. */
  28304. export class Engine {
  28305. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28306. static ExceptionList: ({
  28307. key: string;
  28308. capture: string;
  28309. captureConstraint: number;
  28310. targets: string[];
  28311. } | {
  28312. key: string;
  28313. capture: null;
  28314. captureConstraint: null;
  28315. targets: string[];
  28316. })[];
  28317. /** Gets the list of created engines */
  28318. static readonly Instances: Engine[];
  28319. /**
  28320. * Gets the latest created engine
  28321. */
  28322. static readonly LastCreatedEngine: Nullable<Engine>;
  28323. /**
  28324. * Gets the latest created scene
  28325. */
  28326. static readonly LastCreatedScene: Nullable<Scene>;
  28327. /**
  28328. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28329. * @param flag defines which part of the materials must be marked as dirty
  28330. * @param predicate defines a predicate used to filter which materials should be affected
  28331. */
  28332. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  28333. /** @hidden */
  28334. static _TextureLoaders: IInternalTextureLoader[];
  28335. /** Defines that alpha blending is disabled */
  28336. static readonly ALPHA_DISABLE: number;
  28337. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  28338. static readonly ALPHA_ADD: number;
  28339. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  28340. static readonly ALPHA_COMBINE: number;
  28341. /** Defines that alpha blending to DEST - SRC * DEST */
  28342. static readonly ALPHA_SUBTRACT: number;
  28343. /** Defines that alpha blending to SRC * DEST */
  28344. static readonly ALPHA_MULTIPLY: number;
  28345. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  28346. static readonly ALPHA_MAXIMIZED: number;
  28347. /** Defines that alpha blending to SRC + DEST */
  28348. static readonly ALPHA_ONEONE: number;
  28349. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  28350. static readonly ALPHA_PREMULTIPLIED: number;
  28351. /**
  28352. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28353. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28354. */
  28355. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28356. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28357. static readonly ALPHA_INTERPOLATE: number;
  28358. /**
  28359. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28360. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28361. */
  28362. static readonly ALPHA_SCREENMODE: number;
  28363. /** Defines that the ressource is not delayed*/
  28364. static readonly DELAYLOADSTATE_NONE: number;
  28365. /** Defines that the ressource was successfully delay loaded */
  28366. static readonly DELAYLOADSTATE_LOADED: number;
  28367. /** Defines that the ressource is currently delay loading */
  28368. static readonly DELAYLOADSTATE_LOADING: number;
  28369. /** Defines that the ressource is delayed and has not started loading */
  28370. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28371. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28372. static readonly NEVER: number;
  28373. /** 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 */
  28374. static readonly ALWAYS: number;
  28375. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28376. static readonly LESS: number;
  28377. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28378. static readonly EQUAL: number;
  28379. /** 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 */
  28380. static readonly LEQUAL: number;
  28381. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28382. static readonly GREATER: number;
  28383. /** 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 */
  28384. static readonly GEQUAL: number;
  28385. /** 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 */
  28386. static readonly NOTEQUAL: number;
  28387. /** Passed to stencilOperation to specify that stencil value must be kept */
  28388. static readonly KEEP: number;
  28389. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28390. static readonly REPLACE: number;
  28391. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28392. static readonly INCR: number;
  28393. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28394. static readonly DECR: number;
  28395. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28396. static readonly INVERT: number;
  28397. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28398. static readonly INCR_WRAP: number;
  28399. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28400. static readonly DECR_WRAP: number;
  28401. /** Texture is not repeating outside of 0..1 UVs */
  28402. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28403. /** Texture is repeating outside of 0..1 UVs */
  28404. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28405. /** Texture is repeating and mirrored */
  28406. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28407. /** ALPHA */
  28408. static readonly TEXTUREFORMAT_ALPHA: number;
  28409. /** LUMINANCE */
  28410. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28411. /** LUMINANCE_ALPHA */
  28412. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28413. /** RGB */
  28414. static readonly TEXTUREFORMAT_RGB: number;
  28415. /** RGBA */
  28416. static readonly TEXTUREFORMAT_RGBA: number;
  28417. /** RED */
  28418. static readonly TEXTUREFORMAT_RED: number;
  28419. /** RED (2nd reference) */
  28420. static readonly TEXTUREFORMAT_R: number;
  28421. /** RG */
  28422. static readonly TEXTUREFORMAT_RG: number;
  28423. /** RED_INTEGER */
  28424. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28425. /** RED_INTEGER (2nd reference) */
  28426. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28427. /** RG_INTEGER */
  28428. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28429. /** RGB_INTEGER */
  28430. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28431. /** RGBA_INTEGER */
  28432. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28433. /** UNSIGNED_BYTE */
  28434. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28435. /** UNSIGNED_BYTE (2nd reference) */
  28436. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28437. /** FLOAT */
  28438. static readonly TEXTURETYPE_FLOAT: number;
  28439. /** HALF_FLOAT */
  28440. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28441. /** BYTE */
  28442. static readonly TEXTURETYPE_BYTE: number;
  28443. /** SHORT */
  28444. static readonly TEXTURETYPE_SHORT: number;
  28445. /** UNSIGNED_SHORT */
  28446. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28447. /** INT */
  28448. static readonly TEXTURETYPE_INT: number;
  28449. /** UNSIGNED_INT */
  28450. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28451. /** UNSIGNED_SHORT_4_4_4_4 */
  28452. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28453. /** UNSIGNED_SHORT_5_5_5_1 */
  28454. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28455. /** UNSIGNED_SHORT_5_6_5 */
  28456. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28457. /** UNSIGNED_INT_2_10_10_10_REV */
  28458. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28459. /** UNSIGNED_INT_24_8 */
  28460. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28461. /** UNSIGNED_INT_10F_11F_11F_REV */
  28462. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28463. /** UNSIGNED_INT_5_9_9_9_REV */
  28464. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28465. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28466. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28467. /** nearest is mag = nearest and min = nearest and mip = linear */
  28468. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28469. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28470. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28471. /** Trilinear is mag = linear and min = linear and mip = linear */
  28472. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28473. /** nearest is mag = nearest and min = nearest and mip = linear */
  28474. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28475. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28476. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28477. /** Trilinear is mag = linear and min = linear and mip = linear */
  28478. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28479. /** mag = nearest and min = nearest and mip = nearest */
  28480. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28481. /** mag = nearest and min = linear and mip = nearest */
  28482. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28483. /** mag = nearest and min = linear and mip = linear */
  28484. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28485. /** mag = nearest and min = linear and mip = none */
  28486. static readonly TEXTURE_NEAREST_LINEAR: number;
  28487. /** mag = nearest and min = nearest and mip = none */
  28488. static readonly TEXTURE_NEAREST_NEAREST: number;
  28489. /** mag = linear and min = nearest and mip = nearest */
  28490. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28491. /** mag = linear and min = nearest and mip = linear */
  28492. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28493. /** mag = linear and min = linear and mip = none */
  28494. static readonly TEXTURE_LINEAR_LINEAR: number;
  28495. /** mag = linear and min = nearest and mip = none */
  28496. static readonly TEXTURE_LINEAR_NEAREST: number;
  28497. /** Explicit coordinates mode */
  28498. static readonly TEXTURE_EXPLICIT_MODE: number;
  28499. /** Spherical coordinates mode */
  28500. static readonly TEXTURE_SPHERICAL_MODE: number;
  28501. /** Planar coordinates mode */
  28502. static readonly TEXTURE_PLANAR_MODE: number;
  28503. /** Cubic coordinates mode */
  28504. static readonly TEXTURE_CUBIC_MODE: number;
  28505. /** Projection coordinates mode */
  28506. static readonly TEXTURE_PROJECTION_MODE: number;
  28507. /** Skybox coordinates mode */
  28508. static readonly TEXTURE_SKYBOX_MODE: number;
  28509. /** Inverse Cubic coordinates mode */
  28510. static readonly TEXTURE_INVCUBIC_MODE: number;
  28511. /** Equirectangular coordinates mode */
  28512. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28513. /** Equirectangular Fixed coordinates mode */
  28514. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28515. /** Equirectangular Fixed Mirrored coordinates mode */
  28516. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28517. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28518. static readonly SCALEMODE_FLOOR: number;
  28519. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28520. static readonly SCALEMODE_NEAREST: number;
  28521. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28522. static readonly SCALEMODE_CEILING: number;
  28523. /**
  28524. * Returns the current npm package of the sdk
  28525. */
  28526. static readonly NpmPackage: string;
  28527. /**
  28528. * Returns the current version of the framework
  28529. */
  28530. static readonly Version: string;
  28531. /**
  28532. * Returns a string describing the current engine
  28533. */
  28534. readonly description: string;
  28535. /**
  28536. * Gets or sets the epsilon value used by collision engine
  28537. */
  28538. static CollisionsEpsilon: number;
  28539. /**
  28540. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28541. */
  28542. static ShadersRepository: string;
  28543. /**
  28544. * Method called to create the default loading screen.
  28545. * This can be overriden in your own app.
  28546. * @param canvas The rendering canvas element
  28547. * @returns The loading screen
  28548. */
  28549. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28550. /**
  28551. * Method called to create the default rescale post process on each engine.
  28552. */
  28553. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28554. /** @hidden */
  28555. _shaderProcessor: IShaderProcessor;
  28556. /**
  28557. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28558. */
  28559. forcePOTTextures: boolean;
  28560. /**
  28561. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28562. */
  28563. isFullscreen: boolean;
  28564. /**
  28565. * Gets a boolean indicating if the pointer is currently locked
  28566. */
  28567. isPointerLock: boolean;
  28568. /**
  28569. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28570. */
  28571. cullBackFaces: boolean;
  28572. /**
  28573. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28574. */
  28575. renderEvenInBackground: boolean;
  28576. /**
  28577. * Gets or sets a boolean indicating that cache can be kept between frames
  28578. */
  28579. preventCacheWipeBetweenFrames: boolean;
  28580. /**
  28581. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28582. **/
  28583. enableOfflineSupport: boolean;
  28584. /**
  28585. * 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)
  28586. **/
  28587. disableManifestCheck: boolean;
  28588. /**
  28589. * Gets the list of created scenes
  28590. */
  28591. scenes: Scene[];
  28592. /**
  28593. * Event raised when a new scene is created
  28594. */
  28595. onNewSceneAddedObservable: Observable<Scene>;
  28596. /**
  28597. * Gets the list of created postprocesses
  28598. */
  28599. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28600. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28601. validateShaderPrograms: boolean;
  28602. /**
  28603. * Observable event triggered each time the rendering canvas is resized
  28604. */
  28605. onResizeObservable: Observable<Engine>;
  28606. /**
  28607. * Observable event triggered each time the canvas loses focus
  28608. */
  28609. onCanvasBlurObservable: Observable<Engine>;
  28610. /**
  28611. * Observable event triggered each time the canvas gains focus
  28612. */
  28613. onCanvasFocusObservable: Observable<Engine>;
  28614. /**
  28615. * Observable event triggered each time the canvas receives pointerout event
  28616. */
  28617. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28618. /**
  28619. * Observable event triggered before each texture is initialized
  28620. */
  28621. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28622. /**
  28623. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28624. */
  28625. disableUniformBuffers: boolean;
  28626. /** @hidden */
  28627. _uniformBuffers: UniformBuffer[];
  28628. /**
  28629. * Gets a boolean indicating that the engine supports uniform buffers
  28630. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28631. */
  28632. readonly supportsUniformBuffers: boolean;
  28633. /**
  28634. * Observable raised when the engine begins a new frame
  28635. */
  28636. onBeginFrameObservable: Observable<Engine>;
  28637. /**
  28638. * If set, will be used to request the next animation frame for the render loop
  28639. */
  28640. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28641. /**
  28642. * Observable raised when the engine ends the current frame
  28643. */
  28644. onEndFrameObservable: Observable<Engine>;
  28645. /**
  28646. * Observable raised when the engine is about to compile a shader
  28647. */
  28648. onBeforeShaderCompilationObservable: Observable<Engine>;
  28649. /**
  28650. * Observable raised when the engine has jsut compiled a shader
  28651. */
  28652. onAfterShaderCompilationObservable: Observable<Engine>;
  28653. /** @hidden */
  28654. _gl: WebGLRenderingContext;
  28655. private _renderingCanvas;
  28656. private _windowIsBackground;
  28657. private _webGLVersion;
  28658. protected _highPrecisionShadersAllowed: boolean;
  28659. /** @hidden */
  28660. readonly _shouldUseHighPrecisionShader: boolean;
  28661. /**
  28662. * Gets a boolean indicating that only power of 2 textures are supported
  28663. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28664. */
  28665. readonly needPOTTextures: boolean;
  28666. /** @hidden */
  28667. _badOS: boolean;
  28668. /** @hidden */
  28669. _badDesktopOS: boolean;
  28670. /**
  28671. * Gets the audio engine
  28672. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28673. * @ignorenaming
  28674. */
  28675. static audioEngine: IAudioEngine;
  28676. /**
  28677. * Default AudioEngine factory responsible of creating the Audio Engine.
  28678. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28679. */
  28680. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28681. /**
  28682. * Default offline support factory responsible of creating a tool used to store data locally.
  28683. * By default, this will create a Database object if the workload has been embedded.
  28684. */
  28685. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28686. private _onFocus;
  28687. private _onBlur;
  28688. private _onCanvasPointerOut;
  28689. private _onCanvasBlur;
  28690. private _onCanvasFocus;
  28691. private _onFullscreenChange;
  28692. private _onPointerLockChange;
  28693. private _hardwareScalingLevel;
  28694. /** @hidden */
  28695. _caps: EngineCapabilities;
  28696. private _pointerLockRequested;
  28697. private _isStencilEnable;
  28698. private _colorWrite;
  28699. private _loadingScreen;
  28700. /** @hidden */
  28701. _drawCalls: PerfCounter;
  28702. private _glVersion;
  28703. private _glRenderer;
  28704. private _glVendor;
  28705. private _videoTextureSupported;
  28706. private _renderingQueueLaunched;
  28707. private _activeRenderLoops;
  28708. private _deterministicLockstep;
  28709. private _lockstepMaxSteps;
  28710. /**
  28711. * Observable signaled when a context lost event is raised
  28712. */
  28713. onContextLostObservable: Observable<Engine>;
  28714. /**
  28715. * Observable signaled when a context restored event is raised
  28716. */
  28717. onContextRestoredObservable: Observable<Engine>;
  28718. private _onContextLost;
  28719. private _onContextRestored;
  28720. private _contextWasLost;
  28721. /** @hidden */
  28722. _doNotHandleContextLost: boolean;
  28723. /**
  28724. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28725. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28726. */
  28727. doNotHandleContextLost: boolean;
  28728. private _performanceMonitor;
  28729. private _fps;
  28730. private _deltaTime;
  28731. /**
  28732. * Turn this value on if you want to pause FPS computation when in background
  28733. */
  28734. disablePerformanceMonitorInBackground: boolean;
  28735. /**
  28736. * Gets the performance monitor attached to this engine
  28737. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28738. */
  28739. readonly performanceMonitor: PerformanceMonitor;
  28740. /**
  28741. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28742. */
  28743. disableVertexArrayObjects: boolean;
  28744. /** @hidden */
  28745. protected _depthCullingState: _DepthCullingState;
  28746. /** @hidden */
  28747. protected _stencilState: _StencilState;
  28748. /** @hidden */
  28749. protected _alphaState: _AlphaState;
  28750. /** @hidden */
  28751. protected _alphaMode: number;
  28752. /** @hidden */
  28753. _internalTexturesCache: InternalTexture[];
  28754. /** @hidden */
  28755. protected _activeChannel: number;
  28756. private _currentTextureChannel;
  28757. /** @hidden */
  28758. protected _boundTexturesCache: {
  28759. [key: string]: Nullable<InternalTexture>;
  28760. };
  28761. /** @hidden */
  28762. protected _currentEffect: Nullable<Effect>;
  28763. /** @hidden */
  28764. protected _currentProgram: Nullable<WebGLProgram>;
  28765. private _compiledEffects;
  28766. private _vertexAttribArraysEnabled;
  28767. /** @hidden */
  28768. protected _cachedViewport: Nullable<Viewport>;
  28769. private _cachedVertexArrayObject;
  28770. /** @hidden */
  28771. protected _cachedVertexBuffers: any;
  28772. /** @hidden */
  28773. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28774. /** @hidden */
  28775. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28776. /** @hidden */
  28777. _currentRenderTarget: Nullable<InternalTexture>;
  28778. private _uintIndicesCurrentlySet;
  28779. private _currentBoundBuffer;
  28780. /** @hidden */
  28781. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28782. private _currentBufferPointers;
  28783. private _currentInstanceLocations;
  28784. private _currentInstanceBuffers;
  28785. private _textureUnits;
  28786. /** @hidden */
  28787. _workingCanvas: Nullable<HTMLCanvasElement>;
  28788. /** @hidden */
  28789. _workingContext: Nullable<CanvasRenderingContext2D>;
  28790. private _rescalePostProcess;
  28791. private _dummyFramebuffer;
  28792. private _externalData;
  28793. /** @hidden */
  28794. _bindedRenderFunction: any;
  28795. private _vaoRecordInProgress;
  28796. private _mustWipeVertexAttributes;
  28797. private _emptyTexture;
  28798. private _emptyCubeTexture;
  28799. private _emptyTexture3D;
  28800. /** @hidden */
  28801. _frameHandler: number;
  28802. private _nextFreeTextureSlots;
  28803. private _maxSimultaneousTextures;
  28804. private _activeRequests;
  28805. private _texturesSupported;
  28806. /** @hidden */
  28807. _textureFormatInUse: Nullable<string>;
  28808. /**
  28809. * Gets the list of texture formats supported
  28810. */
  28811. readonly texturesSupported: Array<string>;
  28812. /**
  28813. * Gets the list of texture formats in use
  28814. */
  28815. readonly textureFormatInUse: Nullable<string>;
  28816. /**
  28817. * Gets the current viewport
  28818. */
  28819. readonly currentViewport: Nullable<Viewport>;
  28820. /**
  28821. * Gets the default empty texture
  28822. */
  28823. readonly emptyTexture: InternalTexture;
  28824. /**
  28825. * Gets the default empty 3D texture
  28826. */
  28827. readonly emptyTexture3D: InternalTexture;
  28828. /**
  28829. * Gets the default empty cube texture
  28830. */
  28831. readonly emptyCubeTexture: InternalTexture;
  28832. /**
  28833. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28834. */
  28835. readonly premultipliedAlpha: boolean;
  28836. /**
  28837. * Creates a new engine
  28838. * @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
  28839. * @param antialias defines enable antialiasing (default: false)
  28840. * @param options defines further options to be sent to the getContext() function
  28841. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28842. */
  28843. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28844. /**
  28845. * Initializes a webVR display and starts listening to display change events
  28846. * The onVRDisplayChangedObservable will be notified upon these changes
  28847. * @returns The onVRDisplayChangedObservable
  28848. */
  28849. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28850. /** @hidden */
  28851. _prepareVRComponent(): void;
  28852. /** @hidden */
  28853. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28854. /** @hidden */
  28855. _submitVRFrame(): void;
  28856. /**
  28857. * Call this function to leave webVR mode
  28858. * Will do nothing if webVR is not supported or if there is no webVR device
  28859. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28860. */
  28861. disableVR(): void;
  28862. /**
  28863. * Gets a boolean indicating that the system is in VR mode and is presenting
  28864. * @returns true if VR mode is engaged
  28865. */
  28866. isVRPresenting(): boolean;
  28867. /** @hidden */
  28868. _requestVRFrame(): void;
  28869. private _disableTouchAction;
  28870. private _rebuildInternalTextures;
  28871. private _rebuildEffects;
  28872. /**
  28873. * Gets a boolean indicating if all created effects are ready
  28874. * @returns true if all effects are ready
  28875. */
  28876. areAllEffectsReady(): boolean;
  28877. private _rebuildBuffers;
  28878. private _initGLContext;
  28879. /**
  28880. * Gets version of the current webGL context
  28881. */
  28882. readonly webGLVersion: number;
  28883. /**
  28884. * Gets a string idenfifying the name of the class
  28885. * @returns "Engine" string
  28886. */
  28887. getClassName(): string;
  28888. /**
  28889. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28890. */
  28891. readonly isStencilEnable: boolean;
  28892. /** @hidden */
  28893. _prepareWorkingCanvas(): void;
  28894. /**
  28895. * Reset the texture cache to empty state
  28896. */
  28897. resetTextureCache(): void;
  28898. /**
  28899. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28900. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28901. * @returns true if engine is in deterministic lock step mode
  28902. */
  28903. isDeterministicLockStep(): boolean;
  28904. /**
  28905. * Gets the max steps when engine is running in deterministic lock step
  28906. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28907. * @returns the max steps
  28908. */
  28909. getLockstepMaxSteps(): number;
  28910. /**
  28911. * Gets an object containing information about the current webGL context
  28912. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28913. */
  28914. getGlInfo(): {
  28915. vendor: string;
  28916. renderer: string;
  28917. version: string;
  28918. };
  28919. /**
  28920. * Gets current aspect ratio
  28921. * @param camera defines the camera to use to get the aspect ratio
  28922. * @param useScreen defines if screen size must be used (or the current render target if any)
  28923. * @returns a number defining the aspect ratio
  28924. */
  28925. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28926. /**
  28927. * Gets current screen aspect ratio
  28928. * @returns a number defining the aspect ratio
  28929. */
  28930. getScreenAspectRatio(): number;
  28931. /**
  28932. * Gets the current render width
  28933. * @param useScreen defines if screen size must be used (or the current render target if any)
  28934. * @returns a number defining the current render width
  28935. */
  28936. getRenderWidth(useScreen?: boolean): number;
  28937. /**
  28938. * Gets the current render height
  28939. * @param useScreen defines if screen size must be used (or the current render target if any)
  28940. * @returns a number defining the current render height
  28941. */
  28942. getRenderHeight(useScreen?: boolean): number;
  28943. /**
  28944. * Gets the HTML canvas attached with the current webGL context
  28945. * @returns a HTML canvas
  28946. */
  28947. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28948. /**
  28949. * Gets the client rect of the HTML canvas attached with the current webGL context
  28950. * @returns a client rectanglee
  28951. */
  28952. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28953. /**
  28954. * Defines the hardware scaling level.
  28955. * By default the hardware scaling level is computed from the window device ratio.
  28956. * 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.
  28957. * @param level defines the level to use
  28958. */
  28959. setHardwareScalingLevel(level: number): void;
  28960. /**
  28961. * Gets the current hardware scaling level.
  28962. * By default the hardware scaling level is computed from the window device ratio.
  28963. * 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.
  28964. * @returns a number indicating the current hardware scaling level
  28965. */
  28966. getHardwareScalingLevel(): number;
  28967. /**
  28968. * Gets the list of loaded textures
  28969. * @returns an array containing all loaded textures
  28970. */
  28971. getLoadedTexturesCache(): InternalTexture[];
  28972. /**
  28973. * Gets the object containing all engine capabilities
  28974. * @returns the EngineCapabilities object
  28975. */
  28976. getCaps(): EngineCapabilities;
  28977. /**
  28978. * Gets the current depth function
  28979. * @returns a number defining the depth function
  28980. */
  28981. getDepthFunction(): Nullable<number>;
  28982. /**
  28983. * Sets the current depth function
  28984. * @param depthFunc defines the function to use
  28985. */
  28986. setDepthFunction(depthFunc: number): void;
  28987. /**
  28988. * Sets the current depth function to GREATER
  28989. */
  28990. setDepthFunctionToGreater(): void;
  28991. /**
  28992. * Sets the current depth function to GEQUAL
  28993. */
  28994. setDepthFunctionToGreaterOrEqual(): void;
  28995. /**
  28996. * Sets the current depth function to LESS
  28997. */
  28998. setDepthFunctionToLess(): void;
  28999. private _cachedStencilBuffer;
  29000. private _cachedStencilFunction;
  29001. private _cachedStencilMask;
  29002. private _cachedStencilOperationPass;
  29003. private _cachedStencilOperationFail;
  29004. private _cachedStencilOperationDepthFail;
  29005. private _cachedStencilReference;
  29006. /**
  29007. * Caches the the state of the stencil buffer
  29008. */
  29009. cacheStencilState(): void;
  29010. /**
  29011. * Restores the state of the stencil buffer
  29012. */
  29013. restoreStencilState(): void;
  29014. /**
  29015. * Sets the current depth function to LEQUAL
  29016. */
  29017. setDepthFunctionToLessOrEqual(): void;
  29018. /**
  29019. * Gets a boolean indicating if stencil buffer is enabled
  29020. * @returns the current stencil buffer state
  29021. */
  29022. getStencilBuffer(): boolean;
  29023. /**
  29024. * Enable or disable the stencil buffer
  29025. * @param enable defines if the stencil buffer must be enabled or disabled
  29026. */
  29027. setStencilBuffer(enable: boolean): void;
  29028. /**
  29029. * Gets the current stencil mask
  29030. * @returns a number defining the new stencil mask to use
  29031. */
  29032. getStencilMask(): number;
  29033. /**
  29034. * Sets the current stencil mask
  29035. * @param mask defines the new stencil mask to use
  29036. */
  29037. setStencilMask(mask: number): void;
  29038. /**
  29039. * Gets the current stencil function
  29040. * @returns a number defining the stencil function to use
  29041. */
  29042. getStencilFunction(): number;
  29043. /**
  29044. * Gets the current stencil reference value
  29045. * @returns a number defining the stencil reference value to use
  29046. */
  29047. getStencilFunctionReference(): number;
  29048. /**
  29049. * Gets the current stencil mask
  29050. * @returns a number defining the stencil mask to use
  29051. */
  29052. getStencilFunctionMask(): number;
  29053. /**
  29054. * Sets the current stencil function
  29055. * @param stencilFunc defines the new stencil function to use
  29056. */
  29057. setStencilFunction(stencilFunc: number): void;
  29058. /**
  29059. * Sets the current stencil reference
  29060. * @param reference defines the new stencil reference to use
  29061. */
  29062. setStencilFunctionReference(reference: number): void;
  29063. /**
  29064. * Sets the current stencil mask
  29065. * @param mask defines the new stencil mask to use
  29066. */
  29067. setStencilFunctionMask(mask: number): void;
  29068. /**
  29069. * Gets the current stencil operation when stencil fails
  29070. * @returns a number defining stencil operation to use when stencil fails
  29071. */
  29072. getStencilOperationFail(): number;
  29073. /**
  29074. * Gets the current stencil operation when depth fails
  29075. * @returns a number defining stencil operation to use when depth fails
  29076. */
  29077. getStencilOperationDepthFail(): number;
  29078. /**
  29079. * Gets the current stencil operation when stencil passes
  29080. * @returns a number defining stencil operation to use when stencil passes
  29081. */
  29082. getStencilOperationPass(): number;
  29083. /**
  29084. * Sets the stencil operation to use when stencil fails
  29085. * @param operation defines the stencil operation to use when stencil fails
  29086. */
  29087. setStencilOperationFail(operation: number): void;
  29088. /**
  29089. * Sets the stencil operation to use when depth fails
  29090. * @param operation defines the stencil operation to use when depth fails
  29091. */
  29092. setStencilOperationDepthFail(operation: number): void;
  29093. /**
  29094. * Sets the stencil operation to use when stencil passes
  29095. * @param operation defines the stencil operation to use when stencil passes
  29096. */
  29097. setStencilOperationPass(operation: number): void;
  29098. /**
  29099. * Sets a boolean indicating if the dithering state is enabled or disabled
  29100. * @param value defines the dithering state
  29101. */
  29102. setDitheringState(value: boolean): void;
  29103. /**
  29104. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  29105. * @param value defines the rasterizer state
  29106. */
  29107. setRasterizerState(value: boolean): void;
  29108. /**
  29109. * stop executing a render loop function and remove it from the execution array
  29110. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29111. */
  29112. stopRenderLoop(renderFunction?: () => void): void;
  29113. /** @hidden */
  29114. _renderLoop(): void;
  29115. /**
  29116. * Register and execute a render loop. The engine can have more than one render function
  29117. * @param renderFunction defines the function to continuously execute
  29118. */
  29119. runRenderLoop(renderFunction: () => void): void;
  29120. /**
  29121. * Toggle full screen mode
  29122. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29123. */
  29124. switchFullscreen(requestPointerLock: boolean): void;
  29125. /**
  29126. * Enters full screen mode
  29127. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29128. */
  29129. enterFullscreen(requestPointerLock: boolean): void;
  29130. /**
  29131. * Exits full screen mode
  29132. */
  29133. exitFullscreen(): void;
  29134. /**
  29135. * Enters Pointerlock mode
  29136. */
  29137. enterPointerlock(): void;
  29138. /**
  29139. * Exits Pointerlock mode
  29140. */
  29141. exitPointerlock(): void;
  29142. /**
  29143. * Clear the current render buffer or the current render target (if any is set up)
  29144. * @param color defines the color to use
  29145. * @param backBuffer defines if the back buffer must be cleared
  29146. * @param depth defines if the depth buffer must be cleared
  29147. * @param stencil defines if the stencil buffer must be cleared
  29148. */
  29149. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29150. /**
  29151. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29152. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29153. * @param y defines the y-coordinate of the corner of the clear rectangle
  29154. * @param width defines the width of the clear rectangle
  29155. * @param height defines the height of the clear rectangle
  29156. * @param clearColor defines the clear color
  29157. */
  29158. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  29159. /**
  29160. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29161. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29162. * @param y defines the y-coordinate of the corner of the clear rectangle
  29163. * @param width defines the width of the clear rectangle
  29164. * @param height defines the height of the clear rectangle
  29165. */
  29166. enableScissor(x: number, y: number, width: number, height: number): void;
  29167. /**
  29168. * Disable previously set scissor test rectangle
  29169. */
  29170. disableScissor(): void;
  29171. private _viewportCached;
  29172. /** @hidden */
  29173. _viewport(x: number, y: number, width: number, height: number): void;
  29174. /**
  29175. * Set the WebGL's viewport
  29176. * @param viewport defines the viewport element to be used
  29177. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29178. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29179. */
  29180. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  29181. /**
  29182. * Directly set the WebGL Viewport
  29183. * @param x defines the x coordinate of the viewport (in screen space)
  29184. * @param y defines the y coordinate of the viewport (in screen space)
  29185. * @param width defines the width of the viewport (in screen space)
  29186. * @param height defines the height of the viewport (in screen space)
  29187. * @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
  29188. */
  29189. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  29190. /**
  29191. * Begin a new frame
  29192. */
  29193. beginFrame(): void;
  29194. /**
  29195. * Enf the current frame
  29196. */
  29197. endFrame(): void;
  29198. /**
  29199. * Resize the view according to the canvas' size
  29200. */
  29201. resize(): void;
  29202. /**
  29203. * Force a specific size of the canvas
  29204. * @param width defines the new canvas' width
  29205. * @param height defines the new canvas' height
  29206. */
  29207. setSize(width: number, height: number): void;
  29208. /**
  29209. * Binds the frame buffer to the specified texture.
  29210. * @param texture The texture to render to or null for the default canvas
  29211. * @param faceIndex The face of the texture to render to in case of cube texture
  29212. * @param requiredWidth The width of the target to render to
  29213. * @param requiredHeight The height of the target to render to
  29214. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29215. * @param depthStencilTexture The depth stencil texture to use to render
  29216. * @param lodLevel defines le lod level to bind to the frame buffer
  29217. */
  29218. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29219. /** @hidden */
  29220. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29221. /**
  29222. * Unbind the current render target texture from the webGL context
  29223. * @param texture defines the render target texture to unbind
  29224. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29225. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29226. */
  29227. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29228. /**
  29229. * Force the mipmap generation for the given render target texture
  29230. * @param texture defines the render target texture to use
  29231. */
  29232. generateMipMapsForCubemap(texture: InternalTexture): void;
  29233. /**
  29234. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29235. */
  29236. flushFramebuffer(): void;
  29237. /**
  29238. * Unbind the current render target and bind the default framebuffer
  29239. */
  29240. restoreDefaultFramebuffer(): void;
  29241. /**
  29242. * Create an uniform buffer
  29243. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29244. * @param elements defines the content of the uniform buffer
  29245. * @returns the webGL uniform buffer
  29246. */
  29247. createUniformBuffer(elements: FloatArray): DataBuffer;
  29248. /**
  29249. * Create a dynamic uniform buffer
  29250. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29251. * @param elements defines the content of the uniform buffer
  29252. * @returns the webGL uniform buffer
  29253. */
  29254. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  29255. /**
  29256. * Update an existing uniform buffer
  29257. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29258. * @param uniformBuffer defines the target uniform buffer
  29259. * @param elements defines the content to update
  29260. * @param offset defines the offset in the uniform buffer where update should start
  29261. * @param count defines the size of the data to update
  29262. */
  29263. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  29264. private _resetVertexBufferBinding;
  29265. /**
  29266. * Creates a vertex buffer
  29267. * @param data the data for the vertex buffer
  29268. * @returns the new WebGL static buffer
  29269. */
  29270. createVertexBuffer(data: DataArray): DataBuffer;
  29271. /**
  29272. * Creates a dynamic vertex buffer
  29273. * @param data the data for the dynamic vertex buffer
  29274. * @returns the new WebGL dynamic buffer
  29275. */
  29276. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29277. /**
  29278. * Update a dynamic index buffer
  29279. * @param indexBuffer defines the target index buffer
  29280. * @param indices defines the data to update
  29281. * @param offset defines the offset in the target index buffer where update should start
  29282. */
  29283. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29284. /**
  29285. * Updates a dynamic vertex buffer.
  29286. * @param vertexBuffer the vertex buffer to update
  29287. * @param data the data used to update the vertex buffer
  29288. * @param byteOffset the byte offset of the data
  29289. * @param byteLength the byte length of the data
  29290. */
  29291. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29292. private _resetIndexBufferBinding;
  29293. /**
  29294. * Creates a new index buffer
  29295. * @param indices defines the content of the index buffer
  29296. * @param updatable defines if the index buffer must be updatable
  29297. * @returns a new webGL buffer
  29298. */
  29299. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29300. /**
  29301. * Bind a webGL buffer to the webGL context
  29302. * @param buffer defines the buffer to bind
  29303. */
  29304. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29305. /**
  29306. * Bind an uniform buffer to the current webGL context
  29307. * @param buffer defines the buffer to bind
  29308. */
  29309. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  29310. /**
  29311. * Bind a buffer to the current webGL context at a given location
  29312. * @param buffer defines the buffer to bind
  29313. * @param location defines the index where to bind the buffer
  29314. */
  29315. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  29316. /**
  29317. * Bind a specific block at a given index in a specific shader program
  29318. * @param pipelineContext defines the pipeline context to use
  29319. * @param blockName defines the block name
  29320. * @param index defines the index where to bind the block
  29321. */
  29322. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  29323. private bindIndexBuffer;
  29324. private bindBuffer;
  29325. /**
  29326. * update the bound buffer with the given data
  29327. * @param data defines the data to update
  29328. */
  29329. updateArrayBuffer(data: Float32Array): void;
  29330. private _vertexAttribPointer;
  29331. private _bindIndexBufferWithCache;
  29332. private _bindVertexBuffersAttributes;
  29333. /**
  29334. * Records a vertex array object
  29335. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29336. * @param vertexBuffers defines the list of vertex buffers to store
  29337. * @param indexBuffer defines the index buffer to store
  29338. * @param effect defines the effect to store
  29339. * @returns the new vertex array object
  29340. */
  29341. recordVertexArrayObject(vertexBuffers: {
  29342. [key: string]: VertexBuffer;
  29343. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29344. /**
  29345. * Bind a specific vertex array object
  29346. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29347. * @param vertexArrayObject defines the vertex array object to bind
  29348. * @param indexBuffer defines the index buffer to bind
  29349. */
  29350. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29351. /**
  29352. * Bind webGl buffers directly to the webGL context
  29353. * @param vertexBuffer defines the vertex buffer to bind
  29354. * @param indexBuffer defines the index buffer to bind
  29355. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29356. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29357. * @param effect defines the effect associated with the vertex buffer
  29358. */
  29359. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29360. private _unbindVertexArrayObject;
  29361. /**
  29362. * Bind a list of vertex buffers to the webGL context
  29363. * @param vertexBuffers defines the list of vertex buffers to bind
  29364. * @param indexBuffer defines the index buffer to bind
  29365. * @param effect defines the effect associated with the vertex buffers
  29366. */
  29367. bindBuffers(vertexBuffers: {
  29368. [key: string]: Nullable<VertexBuffer>;
  29369. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29370. /**
  29371. * Unbind all instance attributes
  29372. */
  29373. unbindInstanceAttributes(): void;
  29374. /**
  29375. * Release and free the memory of a vertex array object
  29376. * @param vao defines the vertex array object to delete
  29377. */
  29378. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29379. /** @hidden */
  29380. _releaseBuffer(buffer: DataBuffer): boolean;
  29381. /**
  29382. * Creates a webGL buffer to use with instanciation
  29383. * @param capacity defines the size of the buffer
  29384. * @returns the webGL buffer
  29385. */
  29386. createInstancesBuffer(capacity: number): DataBuffer;
  29387. /**
  29388. * Delete a webGL buffer used with instanciation
  29389. * @param buffer defines the webGL buffer to delete
  29390. */
  29391. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29392. /**
  29393. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29394. * @param instancesBuffer defines the webGL buffer to update and bind
  29395. * @param data defines the data to store in the buffer
  29396. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29397. */
  29398. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29399. /**
  29400. * Apply all cached states (depth, culling, stencil and alpha)
  29401. */
  29402. applyStates(): void;
  29403. /**
  29404. * Send a draw order
  29405. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29406. * @param indexStart defines the starting index
  29407. * @param indexCount defines the number of index to draw
  29408. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29409. */
  29410. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29411. /**
  29412. * Draw a list of points
  29413. * @param verticesStart defines the index of first vertex to draw
  29414. * @param verticesCount defines the count of vertices to draw
  29415. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29416. */
  29417. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29418. /**
  29419. * Draw a list of unindexed primitives
  29420. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29421. * @param verticesStart defines the index of first vertex to draw
  29422. * @param verticesCount defines the count of vertices to draw
  29423. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29424. */
  29425. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29426. /**
  29427. * Draw a list of indexed primitives
  29428. * @param fillMode defines the primitive to use
  29429. * @param indexStart defines the starting index
  29430. * @param indexCount defines the number of index to draw
  29431. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29432. */
  29433. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29434. /**
  29435. * Draw a list of unindexed primitives
  29436. * @param fillMode defines the primitive to use
  29437. * @param verticesStart defines the index of first vertex to draw
  29438. * @param verticesCount defines the count of vertices to draw
  29439. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29440. */
  29441. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29442. private _drawMode;
  29443. /** @hidden */
  29444. _releaseEffect(effect: Effect): void;
  29445. /** @hidden */
  29446. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29447. /**
  29448. * Create a new effect (used to store vertex/fragment shaders)
  29449. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29450. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29451. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29452. * @param samplers defines an array of string used to represent textures
  29453. * @param defines defines the string containing the defines to use to compile the shaders
  29454. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29455. * @param onCompiled defines a function to call when the effect creation is successful
  29456. * @param onError defines a function to call when the effect creation has failed
  29457. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29458. * @returns the new Effect
  29459. */
  29460. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29461. private _compileShader;
  29462. private _compileRawShader;
  29463. /**
  29464. * Directly creates a webGL program
  29465. * @param pipelineContext defines the pipeline context to attach to
  29466. * @param vertexCode defines the vertex shader code to use
  29467. * @param fragmentCode defines the fragment shader code to use
  29468. * @param context defines the webGL context to use (if not set, the current one will be used)
  29469. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29470. * @returns the new webGL program
  29471. */
  29472. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29473. /**
  29474. * Creates a webGL program
  29475. * @param pipelineContext defines the pipeline context to attach to
  29476. * @param vertexCode defines the vertex shader code to use
  29477. * @param fragmentCode defines the fragment shader code to use
  29478. * @param defines defines the string containing the defines to use to compile the shaders
  29479. * @param context defines the webGL context to use (if not set, the current one will be used)
  29480. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29481. * @returns the new webGL program
  29482. */
  29483. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29484. /**
  29485. * Creates a new pipeline context
  29486. * @returns the new pipeline
  29487. */
  29488. createPipelineContext(): WebGLPipelineContext;
  29489. private _createShaderProgram;
  29490. private _finalizePipelineContext;
  29491. /** @hidden */
  29492. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29493. /** @hidden */
  29494. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29495. /** @hidden */
  29496. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29497. /**
  29498. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29499. * @param pipelineContext defines the pipeline context to use
  29500. * @param uniformsNames defines the list of uniform names
  29501. * @returns an array of webGL uniform locations
  29502. */
  29503. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29504. /**
  29505. * Gets the lsit of active attributes for a given webGL program
  29506. * @param pipelineContext defines the pipeline context to use
  29507. * @param attributesNames defines the list of attribute names to get
  29508. * @returns an array of indices indicating the offset of each attribute
  29509. */
  29510. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29511. /**
  29512. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29513. * @param effect defines the effect to activate
  29514. */
  29515. enableEffect(effect: Nullable<Effect>): void;
  29516. /**
  29517. * Set the value of an uniform to an array of int32
  29518. * @param uniform defines the webGL uniform location where to store the value
  29519. * @param array defines the array of int32 to store
  29520. */
  29521. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29522. /**
  29523. * Set the value of an uniform to an array of int32 (stored as vec2)
  29524. * @param uniform defines the webGL uniform location where to store the value
  29525. * @param array defines the array of int32 to store
  29526. */
  29527. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29528. /**
  29529. * Set the value of an uniform to an array of int32 (stored as vec3)
  29530. * @param uniform defines the webGL uniform location where to store the value
  29531. * @param array defines the array of int32 to store
  29532. */
  29533. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29534. /**
  29535. * Set the value of an uniform to an array of int32 (stored as vec4)
  29536. * @param uniform defines the webGL uniform location where to store the value
  29537. * @param array defines the array of int32 to store
  29538. */
  29539. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29540. /**
  29541. * Set the value of an uniform to an array of float32
  29542. * @param uniform defines the webGL uniform location where to store the value
  29543. * @param array defines the array of float32 to store
  29544. */
  29545. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29546. /**
  29547. * Set the value of an uniform to an array of float32 (stored as vec2)
  29548. * @param uniform defines the webGL uniform location where to store the value
  29549. * @param array defines the array of float32 to store
  29550. */
  29551. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29552. /**
  29553. * Set the value of an uniform to an array of float32 (stored as vec3)
  29554. * @param uniform defines the webGL uniform location where to store the value
  29555. * @param array defines the array of float32 to store
  29556. */
  29557. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29558. /**
  29559. * Set the value of an uniform to an array of float32 (stored as vec4)
  29560. * @param uniform defines the webGL uniform location where to store the value
  29561. * @param array defines the array of float32 to store
  29562. */
  29563. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29564. /**
  29565. * Set the value of an uniform to an array of number
  29566. * @param uniform defines the webGL uniform location where to store the value
  29567. * @param array defines the array of number to store
  29568. */
  29569. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29570. /**
  29571. * Set the value of an uniform to an array of number (stored as vec2)
  29572. * @param uniform defines the webGL uniform location where to store the value
  29573. * @param array defines the array of number to store
  29574. */
  29575. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29576. /**
  29577. * Set the value of an uniform to an array of number (stored as vec3)
  29578. * @param uniform defines the webGL uniform location where to store the value
  29579. * @param array defines the array of number to store
  29580. */
  29581. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29582. /**
  29583. * Set the value of an uniform to an array of number (stored as vec4)
  29584. * @param uniform defines the webGL uniform location where to store the value
  29585. * @param array defines the array of number to store
  29586. */
  29587. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29588. /**
  29589. * Set the value of an uniform to an array of float32 (stored as matrices)
  29590. * @param uniform defines the webGL uniform location where to store the value
  29591. * @param matrices defines the array of float32 to store
  29592. */
  29593. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29594. /**
  29595. * Set the value of an uniform to a matrix
  29596. * @param uniform defines the webGL uniform location where to store the value
  29597. * @param matrix defines the matrix to store
  29598. */
  29599. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29600. /**
  29601. * Set the value of an uniform to a matrix (3x3)
  29602. * @param uniform defines the webGL uniform location where to store the value
  29603. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29604. */
  29605. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29606. /**
  29607. * Set the value of an uniform to a matrix (2x2)
  29608. * @param uniform defines the webGL uniform location where to store the value
  29609. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29610. */
  29611. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29612. /**
  29613. * Set the value of an uniform to a number (int)
  29614. * @param uniform defines the webGL uniform location where to store the value
  29615. * @param value defines the int number to store
  29616. */
  29617. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29618. /**
  29619. * Set the value of an uniform to a number (float)
  29620. * @param uniform defines the webGL uniform location where to store the value
  29621. * @param value defines the float number to store
  29622. */
  29623. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29624. /**
  29625. * Set the value of an uniform to a vec2
  29626. * @param uniform defines the webGL uniform location where to store the value
  29627. * @param x defines the 1st component of the value
  29628. * @param y defines the 2nd component of the value
  29629. */
  29630. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29631. /**
  29632. * Set the value of an uniform to a vec3
  29633. * @param uniform defines the webGL uniform location where to store the value
  29634. * @param x defines the 1st component of the value
  29635. * @param y defines the 2nd component of the value
  29636. * @param z defines the 3rd component of the value
  29637. */
  29638. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29639. /**
  29640. * Set the value of an uniform to a boolean
  29641. * @param uniform defines the webGL uniform location where to store the value
  29642. * @param bool defines the boolean to store
  29643. */
  29644. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29645. /**
  29646. * Set the value of an uniform to a vec4
  29647. * @param uniform defines the webGL uniform location where to store the value
  29648. * @param x defines the 1st component of the value
  29649. * @param y defines the 2nd component of the value
  29650. * @param z defines the 3rd component of the value
  29651. * @param w defines the 4th component of the value
  29652. */
  29653. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29654. /**
  29655. * Set the value of an uniform to a Color3
  29656. * @param uniform defines the webGL uniform location where to store the value
  29657. * @param color3 defines the color to store
  29658. */
  29659. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29660. /**
  29661. * Set the value of an uniform to a Color3 and an alpha value
  29662. * @param uniform defines the webGL uniform location where to store the value
  29663. * @param color3 defines the color to store
  29664. * @param alpha defines the alpha component to store
  29665. */
  29666. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29667. /**
  29668. * Sets a Color4 on a uniform variable
  29669. * @param uniform defines the uniform location
  29670. * @param color4 defines the value to be set
  29671. */
  29672. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29673. /**
  29674. * Set various states to the webGL context
  29675. * @param culling defines backface culling state
  29676. * @param zOffset defines the value to apply to zOffset (0 by default)
  29677. * @param force defines if states must be applied even if cache is up to date
  29678. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29679. */
  29680. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29681. /**
  29682. * Set the z offset to apply to current rendering
  29683. * @param value defines the offset to apply
  29684. */
  29685. setZOffset(value: number): void;
  29686. /**
  29687. * Gets the current value of the zOffset
  29688. * @returns the current zOffset state
  29689. */
  29690. getZOffset(): number;
  29691. /**
  29692. * Enable or disable depth buffering
  29693. * @param enable defines the state to set
  29694. */
  29695. setDepthBuffer(enable: boolean): void;
  29696. /**
  29697. * Gets a boolean indicating if depth writing is enabled
  29698. * @returns the current depth writing state
  29699. */
  29700. getDepthWrite(): boolean;
  29701. /**
  29702. * Enable or disable depth writing
  29703. * @param enable defines the state to set
  29704. */
  29705. setDepthWrite(enable: boolean): void;
  29706. /**
  29707. * Enable or disable color writing
  29708. * @param enable defines the state to set
  29709. */
  29710. setColorWrite(enable: boolean): void;
  29711. /**
  29712. * Gets a boolean indicating if color writing is enabled
  29713. * @returns the current color writing state
  29714. */
  29715. getColorWrite(): boolean;
  29716. /**
  29717. * Sets alpha constants used by some alpha blending modes
  29718. * @param r defines the red component
  29719. * @param g defines the green component
  29720. * @param b defines the blue component
  29721. * @param a defines the alpha component
  29722. */
  29723. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29724. /**
  29725. * Sets the current alpha mode
  29726. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29727. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29728. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29729. */
  29730. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29731. /**
  29732. * Gets the current alpha mode
  29733. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29734. * @returns the current alpha mode
  29735. */
  29736. getAlphaMode(): number;
  29737. /**
  29738. * Clears the list of texture accessible through engine.
  29739. * This can help preventing texture load conflict due to name collision.
  29740. */
  29741. clearInternalTexturesCache(): void;
  29742. /**
  29743. * Force the entire cache to be cleared
  29744. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29745. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29746. */
  29747. wipeCaches(bruteForce?: boolean): void;
  29748. /**
  29749. * Set the compressed texture format to use, based on the formats you have, and the formats
  29750. * supported by the hardware / browser.
  29751. *
  29752. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29753. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29754. * to API arguments needed to compressed textures. This puts the burden on the container
  29755. * generator to house the arcane code for determining these for current & future formats.
  29756. *
  29757. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29758. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29759. *
  29760. * Note: The result of this call is not taken into account when a texture is base64.
  29761. *
  29762. * @param formatsAvailable defines the list of those format families you have created
  29763. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29764. *
  29765. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29766. * @returns The extension selected.
  29767. */
  29768. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29769. /** @hidden */
  29770. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29771. min: number;
  29772. mag: number;
  29773. };
  29774. /** @hidden */
  29775. _createTexture(): WebGLTexture;
  29776. /**
  29777. * Usually called from Texture.ts.
  29778. * Passed information to create a WebGLTexture
  29779. * @param urlArg defines a value which contains one of the following:
  29780. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29781. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29782. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29783. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29784. * @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)
  29785. * @param scene needed for loading to the correct scene
  29786. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29787. * @param onLoad optional callback to be called upon successful completion
  29788. * @param onError optional callback to be called upon failure
  29789. * @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
  29790. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29791. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29792. * @param forcedExtension defines the extension to use to pick the right loader
  29793. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29794. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29795. */
  29796. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  29797. /**
  29798. * @hidden
  29799. * Rescales a texture
  29800. * @param source input texutre
  29801. * @param destination destination texture
  29802. * @param scene scene to use to render the resize
  29803. * @param internalFormat format to use when resizing
  29804. * @param onComplete callback to be called when resize has completed
  29805. */
  29806. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  29807. private _unpackFlipYCached;
  29808. /**
  29809. * In case you are sharing the context with other applications, it might
  29810. * be interested to not cache the unpack flip y state to ensure a consistent
  29811. * value would be set.
  29812. */
  29813. enableUnpackFlipYCached: boolean;
  29814. /** @hidden */
  29815. _unpackFlipY(value: boolean): void;
  29816. /** @hidden */
  29817. _getUnpackAlignement(): number;
  29818. /**
  29819. * Creates a dynamic texture
  29820. * @param width defines the width of the texture
  29821. * @param height defines the height of the texture
  29822. * @param generateMipMaps defines if the engine should generate the mip levels
  29823. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29824. * @returns the dynamic texture inside an InternalTexture
  29825. */
  29826. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29827. /**
  29828. * Update the sampling mode of a given texture
  29829. * @param samplingMode defines the required sampling mode
  29830. * @param texture defines the texture to update
  29831. */
  29832. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29833. /**
  29834. * Update the content of a dynamic texture
  29835. * @param texture defines the texture to update
  29836. * @param canvas defines the canvas containing the source
  29837. * @param invertY defines if data must be stored with Y axis inverted
  29838. * @param premulAlpha defines if alpha is stored as premultiplied
  29839. * @param format defines the format of the data
  29840. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29841. */
  29842. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29843. /**
  29844. * Update a video texture
  29845. * @param texture defines the texture to update
  29846. * @param video defines the video element to use
  29847. * @param invertY defines if data must be stored with Y axis inverted
  29848. */
  29849. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29850. /**
  29851. * Updates a depth texture Comparison Mode and Function.
  29852. * If the comparison Function is equal to 0, the mode will be set to none.
  29853. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29854. * @param texture The texture to set the comparison function for
  29855. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29856. */
  29857. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29858. /** @hidden */
  29859. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29860. width: number;
  29861. height: number;
  29862. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29863. /**
  29864. * Creates a depth stencil texture.
  29865. * This is only available in WebGL 2 or with the depth texture extension available.
  29866. * @param size The size of face edge in the texture.
  29867. * @param options The options defining the texture.
  29868. * @returns The texture
  29869. */
  29870. createDepthStencilTexture(size: number | {
  29871. width: number;
  29872. height: number;
  29873. }, options: DepthTextureCreationOptions): InternalTexture;
  29874. /**
  29875. * Creates a depth stencil texture.
  29876. * This is only available in WebGL 2 or with the depth texture extension available.
  29877. * @param size The size of face edge in the texture.
  29878. * @param options The options defining the texture.
  29879. * @returns The texture
  29880. */
  29881. private _createDepthStencilTexture;
  29882. /**
  29883. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29884. * @param renderTarget The render target to set the frame buffer for
  29885. */
  29886. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29887. /**
  29888. * Creates a new render target texture
  29889. * @param size defines the size of the texture
  29890. * @param options defines the options used to create the texture
  29891. * @returns a new render target texture stored in an InternalTexture
  29892. */
  29893. createRenderTargetTexture(size: number | {
  29894. width: number;
  29895. height: number;
  29896. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29897. /** @hidden */
  29898. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29899. /**
  29900. * Updates the sample count of a render target texture
  29901. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29902. * @param texture defines the texture to update
  29903. * @param samples defines the sample count to set
  29904. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29905. */
  29906. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29907. /** @hidden */
  29908. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29909. /** @hidden */
  29910. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29911. /** @hidden */
  29912. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29913. /** @hidden */
  29914. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29915. /**
  29916. * @hidden
  29917. */
  29918. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29919. private _prepareWebGLTextureContinuation;
  29920. private _prepareWebGLTexture;
  29921. /** @hidden */
  29922. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29923. /** @hidden */
  29924. _releaseFramebufferObjects(texture: InternalTexture): void;
  29925. /** @hidden */
  29926. _releaseTexture(texture: InternalTexture): void;
  29927. private setProgram;
  29928. private _boundUniforms;
  29929. /**
  29930. * Binds an effect to the webGL context
  29931. * @param effect defines the effect to bind
  29932. */
  29933. bindSamplers(effect: Effect): void;
  29934. private _activateCurrentTexture;
  29935. /** @hidden */
  29936. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29937. /** @hidden */
  29938. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29939. /**
  29940. * Sets a texture to the webGL context from a postprocess
  29941. * @param channel defines the channel to use
  29942. * @param postProcess defines the source postprocess
  29943. */
  29944. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29945. /**
  29946. * Binds the output of the passed in post process to the texture channel specified
  29947. * @param channel The channel the texture should be bound to
  29948. * @param postProcess The post process which's output should be bound
  29949. */
  29950. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29951. /**
  29952. * Unbind all textures from the webGL context
  29953. */
  29954. unbindAllTextures(): void;
  29955. /**
  29956. * Sets a texture to the according uniform.
  29957. * @param channel The texture channel
  29958. * @param uniform The uniform to set
  29959. * @param texture The texture to apply
  29960. */
  29961. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29962. /**
  29963. * Sets a depth stencil texture from a render target to the according uniform.
  29964. * @param channel The texture channel
  29965. * @param uniform The uniform to set
  29966. * @param texture The render target texture containing the depth stencil texture to apply
  29967. */
  29968. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29969. private _bindSamplerUniformToChannel;
  29970. private _getTextureWrapMode;
  29971. private _setTexture;
  29972. /**
  29973. * Sets an array of texture to the webGL context
  29974. * @param channel defines the channel where the texture array must be set
  29975. * @param uniform defines the associated uniform location
  29976. * @param textures defines the array of textures to bind
  29977. */
  29978. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29979. /** @hidden */
  29980. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29981. private _setTextureParameterFloat;
  29982. private _setTextureParameterInteger;
  29983. /**
  29984. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29985. * @param x defines the x coordinate of the rectangle where pixels must be read
  29986. * @param y defines the y coordinate of the rectangle where pixels must be read
  29987. * @param width defines the width of the rectangle where pixels must be read
  29988. * @param height defines the height of the rectangle where pixels must be read
  29989. * @returns a Uint8Array containing RGBA colors
  29990. */
  29991. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29992. /**
  29993. * Add an externaly attached data from its key.
  29994. * This method call will fail and return false, if such key already exists.
  29995. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29996. * @param key the unique key that identifies the data
  29997. * @param data the data object to associate to the key for this Engine instance
  29998. * @return true if no such key were already present and the data was added successfully, false otherwise
  29999. */
  30000. addExternalData<T>(key: string, data: T): boolean;
  30001. /**
  30002. * Get an externaly attached data from its key
  30003. * @param key the unique key that identifies the data
  30004. * @return the associated data, if present (can be null), or undefined if not present
  30005. */
  30006. getExternalData<T>(key: string): T;
  30007. /**
  30008. * Get an externaly attached data from its key, create it using a factory if it's not already present
  30009. * @param key the unique key that identifies the data
  30010. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  30011. * @return the associated data, can be null if the factory returned null.
  30012. */
  30013. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  30014. /**
  30015. * Remove an externaly attached data from the Engine instance
  30016. * @param key the unique key that identifies the data
  30017. * @return true if the data was successfully removed, false if it doesn't exist
  30018. */
  30019. removeExternalData(key: string): boolean;
  30020. /**
  30021. * Unbind all vertex attributes from the webGL context
  30022. */
  30023. unbindAllAttributes(): void;
  30024. /**
  30025. * 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
  30026. */
  30027. releaseEffects(): void;
  30028. /**
  30029. * Dispose and release all associated resources
  30030. */
  30031. dispose(): void;
  30032. /**
  30033. * Display the loading screen
  30034. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30035. */
  30036. displayLoadingUI(): void;
  30037. /**
  30038. * Hide the loading screen
  30039. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30040. */
  30041. hideLoadingUI(): void;
  30042. /**
  30043. * Gets the current loading screen object
  30044. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30045. */
  30046. /**
  30047. * Sets the current loading screen object
  30048. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30049. */
  30050. loadingScreen: ILoadingScreen;
  30051. /**
  30052. * Sets the current loading screen text
  30053. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30054. */
  30055. loadingUIText: string;
  30056. /**
  30057. * Sets the current loading screen background color
  30058. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30059. */
  30060. loadingUIBackgroundColor: string;
  30061. /**
  30062. * Attach a new callback raised when context lost event is fired
  30063. * @param callback defines the callback to call
  30064. */
  30065. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30066. /**
  30067. * Attach a new callback raised when context restored event is fired
  30068. * @param callback defines the callback to call
  30069. */
  30070. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30071. /**
  30072. * Gets the source code of the vertex shader associated with a specific webGL program
  30073. * @param program defines the program to use
  30074. * @returns a string containing the source code of the vertex shader associated with the program
  30075. */
  30076. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  30077. /**
  30078. * Gets the source code of the fragment shader associated with a specific webGL program
  30079. * @param program defines the program to use
  30080. * @returns a string containing the source code of the fragment shader associated with the program
  30081. */
  30082. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  30083. /**
  30084. * Get the current error code of the webGL context
  30085. * @returns the error code
  30086. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30087. */
  30088. getError(): number;
  30089. /**
  30090. * Gets the current framerate
  30091. * @returns a number representing the framerate
  30092. */
  30093. getFps(): number;
  30094. /**
  30095. * Gets the time spent between current and previous frame
  30096. * @returns a number representing the delta time in ms
  30097. */
  30098. getDeltaTime(): number;
  30099. private _measureFps;
  30100. /** @hidden */
  30101. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  30102. private _canRenderToFloatFramebuffer;
  30103. private _canRenderToHalfFloatFramebuffer;
  30104. private _canRenderToFramebuffer;
  30105. /** @hidden */
  30106. _getWebGLTextureType(type: number): number;
  30107. /** @hidden */
  30108. _getInternalFormat(format: number): number;
  30109. /** @hidden */
  30110. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30111. /** @hidden */
  30112. _getRGBAMultiSampleBufferFormat(type: number): number;
  30113. /** @hidden */
  30114. _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;
  30115. /** @hidden */
  30116. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  30117. /**
  30118. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30119. * @returns true if the engine can be created
  30120. * @ignorenaming
  30121. */
  30122. static isSupported(): boolean;
  30123. }
  30124. }
  30125. declare module "babylonjs/Materials/effect" {
  30126. import { Observable } from "babylonjs/Misc/observable";
  30127. import { Nullable } from "babylonjs/types";
  30128. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  30129. import { IDisposable } from "babylonjs/scene";
  30130. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30131. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30132. import { Engine } from "babylonjs/Engines/engine";
  30133. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30134. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30135. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30136. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30138. /**
  30139. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  30140. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  30141. */
  30142. export class EffectFallbacks {
  30143. private _defines;
  30144. private _currentRank;
  30145. private _maxRank;
  30146. private _mesh;
  30147. /**
  30148. * Removes the fallback from the bound mesh.
  30149. */
  30150. unBindMesh(): void;
  30151. /**
  30152. * Adds a fallback on the specified property.
  30153. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30154. * @param define The name of the define in the shader
  30155. */
  30156. addFallback(rank: number, define: string): void;
  30157. /**
  30158. * Sets the mesh to use CPU skinning when needing to fallback.
  30159. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30160. * @param mesh The mesh to use the fallbacks.
  30161. */
  30162. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  30163. /**
  30164. * Checks to see if more fallbacks are still availible.
  30165. */
  30166. readonly isMoreFallbacks: boolean;
  30167. /**
  30168. * Removes the defines that should be removed when falling back.
  30169. * @param currentDefines defines the current define statements for the shader.
  30170. * @param effect defines the current effect we try to compile
  30171. * @returns The resulting defines with defines of the current rank removed.
  30172. */
  30173. reduce(currentDefines: string, effect: Effect): string;
  30174. }
  30175. /**
  30176. * Options to be used when creating an effect.
  30177. */
  30178. export class EffectCreationOptions {
  30179. /**
  30180. * Atrributes that will be used in the shader.
  30181. */
  30182. attributes: string[];
  30183. /**
  30184. * Uniform varible names that will be set in the shader.
  30185. */
  30186. uniformsNames: string[];
  30187. /**
  30188. * Uniform buffer varible names that will be set in the shader.
  30189. */
  30190. uniformBuffersNames: string[];
  30191. /**
  30192. * Sampler texture variable names that will be set in the shader.
  30193. */
  30194. samplers: string[];
  30195. /**
  30196. * Define statements that will be set in the shader.
  30197. */
  30198. defines: any;
  30199. /**
  30200. * Possible fallbacks for this effect to improve performance when needed.
  30201. */
  30202. fallbacks: Nullable<EffectFallbacks>;
  30203. /**
  30204. * Callback that will be called when the shader is compiled.
  30205. */
  30206. onCompiled: Nullable<(effect: Effect) => void>;
  30207. /**
  30208. * Callback that will be called if an error occurs during shader compilation.
  30209. */
  30210. onError: Nullable<(effect: Effect, errors: string) => void>;
  30211. /**
  30212. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30213. */
  30214. indexParameters: any;
  30215. /**
  30216. * Max number of lights that can be used in the shader.
  30217. */
  30218. maxSimultaneousLights: number;
  30219. /**
  30220. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30221. */
  30222. transformFeedbackVaryings: Nullable<string[]>;
  30223. }
  30224. /**
  30225. * Effect containing vertex and fragment shader that can be executed on an object.
  30226. */
  30227. export class Effect implements IDisposable {
  30228. /**
  30229. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30230. */
  30231. static ShadersRepository: string;
  30232. /**
  30233. * Name of the effect.
  30234. */
  30235. name: any;
  30236. /**
  30237. * String container all the define statements that should be set on the shader.
  30238. */
  30239. defines: string;
  30240. /**
  30241. * Callback that will be called when the shader is compiled.
  30242. */
  30243. onCompiled: Nullable<(effect: Effect) => void>;
  30244. /**
  30245. * Callback that will be called if an error occurs during shader compilation.
  30246. */
  30247. onError: Nullable<(effect: Effect, errors: string) => void>;
  30248. /**
  30249. * Callback that will be called when effect is bound.
  30250. */
  30251. onBind: Nullable<(effect: Effect) => void>;
  30252. /**
  30253. * Unique ID of the effect.
  30254. */
  30255. uniqueId: number;
  30256. /**
  30257. * Observable that will be called when the shader is compiled.
  30258. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30259. */
  30260. onCompileObservable: Observable<Effect>;
  30261. /**
  30262. * Observable that will be called if an error occurs during shader compilation.
  30263. */
  30264. onErrorObservable: Observable<Effect>;
  30265. /** @hidden */
  30266. _onBindObservable: Nullable<Observable<Effect>>;
  30267. /**
  30268. * Observable that will be called when effect is bound.
  30269. */
  30270. readonly onBindObservable: Observable<Effect>;
  30271. /** @hidden */
  30272. _bonesComputationForcedToCPU: boolean;
  30273. private static _uniqueIdSeed;
  30274. private _engine;
  30275. private _uniformBuffersNames;
  30276. private _uniformsNames;
  30277. private _samplerList;
  30278. private _samplers;
  30279. private _isReady;
  30280. private _compilationError;
  30281. private _attributesNames;
  30282. private _attributes;
  30283. private _uniforms;
  30284. /**
  30285. * Key for the effect.
  30286. * @hidden
  30287. */
  30288. _key: string;
  30289. private _indexParameters;
  30290. private _fallbacks;
  30291. private _vertexSourceCode;
  30292. private _fragmentSourceCode;
  30293. private _vertexSourceCodeOverride;
  30294. private _fragmentSourceCodeOverride;
  30295. private _transformFeedbackVaryings;
  30296. /**
  30297. * Compiled shader to webGL program.
  30298. * @hidden
  30299. */
  30300. _pipelineContext: Nullable<IPipelineContext>;
  30301. private _valueCache;
  30302. private static _baseCache;
  30303. /**
  30304. * Instantiates an effect.
  30305. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30306. * @param baseName Name of the effect.
  30307. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30308. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30309. * @param samplers List of sampler variables that will be passed to the shader.
  30310. * @param engine Engine to be used to render the effect
  30311. * @param defines Define statements to be added to the shader.
  30312. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30313. * @param onCompiled Callback that will be called when the shader is compiled.
  30314. * @param onError Callback that will be called if an error occurs during shader compilation.
  30315. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30316. */
  30317. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  30318. private _useFinalCode;
  30319. /**
  30320. * Unique key for this effect
  30321. */
  30322. readonly key: string;
  30323. /**
  30324. * If the effect has been compiled and prepared.
  30325. * @returns if the effect is compiled and prepared.
  30326. */
  30327. isReady(): boolean;
  30328. /**
  30329. * The engine the effect was initialized with.
  30330. * @returns the engine.
  30331. */
  30332. getEngine(): Engine;
  30333. /**
  30334. * The pipeline context for this effect
  30335. * @returns the associated pipeline context
  30336. */
  30337. getPipelineContext(): Nullable<IPipelineContext>;
  30338. /**
  30339. * The set of names of attribute variables for the shader.
  30340. * @returns An array of attribute names.
  30341. */
  30342. getAttributesNames(): string[];
  30343. /**
  30344. * Returns the attribute at the given index.
  30345. * @param index The index of the attribute.
  30346. * @returns The location of the attribute.
  30347. */
  30348. getAttributeLocation(index: number): number;
  30349. /**
  30350. * Returns the attribute based on the name of the variable.
  30351. * @param name of the attribute to look up.
  30352. * @returns the attribute location.
  30353. */
  30354. getAttributeLocationByName(name: string): number;
  30355. /**
  30356. * The number of attributes.
  30357. * @returns the numnber of attributes.
  30358. */
  30359. getAttributesCount(): number;
  30360. /**
  30361. * Gets the index of a uniform variable.
  30362. * @param uniformName of the uniform to look up.
  30363. * @returns the index.
  30364. */
  30365. getUniformIndex(uniformName: string): number;
  30366. /**
  30367. * Returns the attribute based on the name of the variable.
  30368. * @param uniformName of the uniform to look up.
  30369. * @returns the location of the uniform.
  30370. */
  30371. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30372. /**
  30373. * Returns an array of sampler variable names
  30374. * @returns The array of sampler variable neames.
  30375. */
  30376. getSamplers(): string[];
  30377. /**
  30378. * The error from the last compilation.
  30379. * @returns the error string.
  30380. */
  30381. getCompilationError(): string;
  30382. /**
  30383. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30384. * @param func The callback to be used.
  30385. */
  30386. executeWhenCompiled(func: (effect: Effect) => void): void;
  30387. private _checkIsReady;
  30388. /** @hidden */
  30389. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30390. /** @hidden */
  30391. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30392. /** @hidden */
  30393. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30394. /**
  30395. * Recompiles the webGL program
  30396. * @param vertexSourceCode The source code for the vertex shader.
  30397. * @param fragmentSourceCode The source code for the fragment shader.
  30398. * @param onCompiled Callback called when completed.
  30399. * @param onError Callback called on error.
  30400. * @hidden
  30401. */
  30402. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30403. /**
  30404. * Prepares the effect
  30405. * @hidden
  30406. */
  30407. _prepareEffect(): void;
  30408. /**
  30409. * Checks if the effect is supported. (Must be called after compilation)
  30410. */
  30411. readonly isSupported: boolean;
  30412. /**
  30413. * Binds a texture to the engine to be used as output of the shader.
  30414. * @param channel Name of the output variable.
  30415. * @param texture Texture to bind.
  30416. * @hidden
  30417. */
  30418. _bindTexture(channel: string, texture: InternalTexture): void;
  30419. /**
  30420. * Sets a texture on the engine to be used in the shader.
  30421. * @param channel Name of the sampler variable.
  30422. * @param texture Texture to set.
  30423. */
  30424. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30425. /**
  30426. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30427. * @param channel Name of the sampler variable.
  30428. * @param texture Texture to set.
  30429. */
  30430. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30431. /**
  30432. * Sets an array of textures on the engine to be used in the shader.
  30433. * @param channel Name of the variable.
  30434. * @param textures Textures to set.
  30435. */
  30436. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30437. /**
  30438. * 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)
  30439. * @param channel Name of the sampler variable.
  30440. * @param postProcess Post process to get the input texture from.
  30441. */
  30442. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30443. /**
  30444. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30445. * 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)
  30446. * @param channel Name of the sampler variable.
  30447. * @param postProcess Post process to get the output texture from.
  30448. */
  30449. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30450. /** @hidden */
  30451. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30452. /** @hidden */
  30453. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30454. /** @hidden */
  30455. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30456. /** @hidden */
  30457. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30458. /**
  30459. * Binds a buffer to a uniform.
  30460. * @param buffer Buffer to bind.
  30461. * @param name Name of the uniform variable to bind to.
  30462. */
  30463. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30464. /**
  30465. * Binds block to a uniform.
  30466. * @param blockName Name of the block to bind.
  30467. * @param index Index to bind.
  30468. */
  30469. bindUniformBlock(blockName: string, index: number): void;
  30470. /**
  30471. * Sets an interger value on a uniform variable.
  30472. * @param uniformName Name of the variable.
  30473. * @param value Value to be set.
  30474. * @returns this effect.
  30475. */
  30476. setInt(uniformName: string, value: number): Effect;
  30477. /**
  30478. * Sets an int array on a uniform variable.
  30479. * @param uniformName Name of the variable.
  30480. * @param array array to be set.
  30481. * @returns this effect.
  30482. */
  30483. setIntArray(uniformName: string, array: Int32Array): Effect;
  30484. /**
  30485. * 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)
  30486. * @param uniformName Name of the variable.
  30487. * @param array array to be set.
  30488. * @returns this effect.
  30489. */
  30490. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30491. /**
  30492. * 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)
  30493. * @param uniformName Name of the variable.
  30494. * @param array array to be set.
  30495. * @returns this effect.
  30496. */
  30497. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30498. /**
  30499. * 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)
  30500. * @param uniformName Name of the variable.
  30501. * @param array array to be set.
  30502. * @returns this effect.
  30503. */
  30504. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30505. /**
  30506. * Sets an float array on a uniform variable.
  30507. * @param uniformName Name of the variable.
  30508. * @param array array to be set.
  30509. * @returns this effect.
  30510. */
  30511. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30512. /**
  30513. * 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)
  30514. * @param uniformName Name of the variable.
  30515. * @param array array to be set.
  30516. * @returns this effect.
  30517. */
  30518. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30519. /**
  30520. * 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)
  30521. * @param uniformName Name of the variable.
  30522. * @param array array to be set.
  30523. * @returns this effect.
  30524. */
  30525. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30526. /**
  30527. * 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)
  30528. * @param uniformName Name of the variable.
  30529. * @param array array to be set.
  30530. * @returns this effect.
  30531. */
  30532. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30533. /**
  30534. * Sets an array on a uniform variable.
  30535. * @param uniformName Name of the variable.
  30536. * @param array array to be set.
  30537. * @returns this effect.
  30538. */
  30539. setArray(uniformName: string, array: number[]): Effect;
  30540. /**
  30541. * 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)
  30542. * @param uniformName Name of the variable.
  30543. * @param array array to be set.
  30544. * @returns this effect.
  30545. */
  30546. setArray2(uniformName: string, array: number[]): Effect;
  30547. /**
  30548. * 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)
  30549. * @param uniformName Name of the variable.
  30550. * @param array array to be set.
  30551. * @returns this effect.
  30552. */
  30553. setArray3(uniformName: string, array: number[]): Effect;
  30554. /**
  30555. * 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)
  30556. * @param uniformName Name of the variable.
  30557. * @param array array to be set.
  30558. * @returns this effect.
  30559. */
  30560. setArray4(uniformName: string, array: number[]): Effect;
  30561. /**
  30562. * Sets matrices on a uniform variable.
  30563. * @param uniformName Name of the variable.
  30564. * @param matrices matrices to be set.
  30565. * @returns this effect.
  30566. */
  30567. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30568. /**
  30569. * Sets matrix on a uniform variable.
  30570. * @param uniformName Name of the variable.
  30571. * @param matrix matrix to be set.
  30572. * @returns this effect.
  30573. */
  30574. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30575. /**
  30576. * 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)
  30577. * @param uniformName Name of the variable.
  30578. * @param matrix matrix to be set.
  30579. * @returns this effect.
  30580. */
  30581. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30582. /**
  30583. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30584. * @param uniformName Name of the variable.
  30585. * @param matrix matrix to be set.
  30586. * @returns this effect.
  30587. */
  30588. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30589. /**
  30590. * Sets a float on a uniform variable.
  30591. * @param uniformName Name of the variable.
  30592. * @param value value to be set.
  30593. * @returns this effect.
  30594. */
  30595. setFloat(uniformName: string, value: number): Effect;
  30596. /**
  30597. * Sets a boolean on a uniform variable.
  30598. * @param uniformName Name of the variable.
  30599. * @param bool value to be set.
  30600. * @returns this effect.
  30601. */
  30602. setBool(uniformName: string, bool: boolean): Effect;
  30603. /**
  30604. * Sets a Vector2 on a uniform variable.
  30605. * @param uniformName Name of the variable.
  30606. * @param vector2 vector2 to be set.
  30607. * @returns this effect.
  30608. */
  30609. setVector2(uniformName: string, vector2: Vector2): Effect;
  30610. /**
  30611. * Sets a float2 on a uniform variable.
  30612. * @param uniformName Name of the variable.
  30613. * @param x First float in float2.
  30614. * @param y Second float in float2.
  30615. * @returns this effect.
  30616. */
  30617. setFloat2(uniformName: string, x: number, y: number): Effect;
  30618. /**
  30619. * Sets a Vector3 on a uniform variable.
  30620. * @param uniformName Name of the variable.
  30621. * @param vector3 Value to be set.
  30622. * @returns this effect.
  30623. */
  30624. setVector3(uniformName: string, vector3: Vector3): Effect;
  30625. /**
  30626. * Sets a float3 on a uniform variable.
  30627. * @param uniformName Name of the variable.
  30628. * @param x First float in float3.
  30629. * @param y Second float in float3.
  30630. * @param z Third float in float3.
  30631. * @returns this effect.
  30632. */
  30633. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30634. /**
  30635. * Sets a Vector4 on a uniform variable.
  30636. * @param uniformName Name of the variable.
  30637. * @param vector4 Value to be set.
  30638. * @returns this effect.
  30639. */
  30640. setVector4(uniformName: string, vector4: Vector4): Effect;
  30641. /**
  30642. * Sets a float4 on a uniform variable.
  30643. * @param uniformName Name of the variable.
  30644. * @param x First float in float4.
  30645. * @param y Second float in float4.
  30646. * @param z Third float in float4.
  30647. * @param w Fourth float in float4.
  30648. * @returns this effect.
  30649. */
  30650. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30651. /**
  30652. * Sets a Color3 on a uniform variable.
  30653. * @param uniformName Name of the variable.
  30654. * @param color3 Value to be set.
  30655. * @returns this effect.
  30656. */
  30657. setColor3(uniformName: string, color3: Color3): Effect;
  30658. /**
  30659. * Sets a Color4 on a uniform variable.
  30660. * @param uniformName Name of the variable.
  30661. * @param color3 Value to be set.
  30662. * @param alpha Alpha value to be set.
  30663. * @returns this effect.
  30664. */
  30665. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30666. /**
  30667. * Sets a Color4 on a uniform variable
  30668. * @param uniformName defines the name of the variable
  30669. * @param color4 defines the value to be set
  30670. * @returns this effect.
  30671. */
  30672. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30673. /** Release all associated resources */
  30674. dispose(): void;
  30675. /**
  30676. * This function will add a new shader to the shader store
  30677. * @param name the name of the shader
  30678. * @param pixelShader optional pixel shader content
  30679. * @param vertexShader optional vertex shader content
  30680. */
  30681. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30682. /**
  30683. * Store of each shader (The can be looked up using effect.key)
  30684. */
  30685. static ShadersStore: {
  30686. [key: string]: string;
  30687. };
  30688. /**
  30689. * Store of each included file for a shader (The can be looked up using effect.key)
  30690. */
  30691. static IncludesShadersStore: {
  30692. [key: string]: string;
  30693. };
  30694. /**
  30695. * Resets the cache of effects.
  30696. */
  30697. static ResetCache(): void;
  30698. }
  30699. }
  30700. declare module "babylonjs/Materials/colorCurves" {
  30701. import { Effect } from "babylonjs/Materials/effect";
  30702. /**
  30703. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30704. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30705. * 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;
  30706. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30707. */
  30708. export class ColorCurves {
  30709. private _dirty;
  30710. private _tempColor;
  30711. private _globalCurve;
  30712. private _highlightsCurve;
  30713. private _midtonesCurve;
  30714. private _shadowsCurve;
  30715. private _positiveCurve;
  30716. private _negativeCurve;
  30717. private _globalHue;
  30718. private _globalDensity;
  30719. private _globalSaturation;
  30720. private _globalExposure;
  30721. /**
  30722. * Gets the global Hue value.
  30723. * 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).
  30724. */
  30725. /**
  30726. * Sets the global Hue value.
  30727. * 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).
  30728. */
  30729. globalHue: number;
  30730. /**
  30731. * Gets the global Density value.
  30732. * 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.
  30733. * Values less than zero provide a filter of opposite hue.
  30734. */
  30735. /**
  30736. * Sets the global Density value.
  30737. * 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.
  30738. * Values less than zero provide a filter of opposite hue.
  30739. */
  30740. globalDensity: number;
  30741. /**
  30742. * Gets the global Saturation value.
  30743. * 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.
  30744. */
  30745. /**
  30746. * Sets the global Saturation value.
  30747. * 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.
  30748. */
  30749. globalSaturation: number;
  30750. /**
  30751. * Gets the global Exposure value.
  30752. * 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.
  30753. */
  30754. /**
  30755. * Sets the global Exposure value.
  30756. * 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.
  30757. */
  30758. globalExposure: number;
  30759. private _highlightsHue;
  30760. private _highlightsDensity;
  30761. private _highlightsSaturation;
  30762. private _highlightsExposure;
  30763. /**
  30764. * Gets the highlights Hue value.
  30765. * 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).
  30766. */
  30767. /**
  30768. * Sets the highlights Hue value.
  30769. * 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).
  30770. */
  30771. highlightsHue: number;
  30772. /**
  30773. * Gets the highlights Density value.
  30774. * 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.
  30775. * Values less than zero provide a filter of opposite hue.
  30776. */
  30777. /**
  30778. * Sets the highlights Density value.
  30779. * 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.
  30780. * Values less than zero provide a filter of opposite hue.
  30781. */
  30782. highlightsDensity: number;
  30783. /**
  30784. * Gets the highlights Saturation value.
  30785. * 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.
  30786. */
  30787. /**
  30788. * Sets the highlights Saturation value.
  30789. * 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.
  30790. */
  30791. highlightsSaturation: number;
  30792. /**
  30793. * Gets the highlights Exposure value.
  30794. * 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.
  30795. */
  30796. /**
  30797. * Sets the highlights Exposure value.
  30798. * 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.
  30799. */
  30800. highlightsExposure: number;
  30801. private _midtonesHue;
  30802. private _midtonesDensity;
  30803. private _midtonesSaturation;
  30804. private _midtonesExposure;
  30805. /**
  30806. * Gets the midtones Hue value.
  30807. * 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).
  30808. */
  30809. /**
  30810. * Sets the midtones Hue value.
  30811. * 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).
  30812. */
  30813. midtonesHue: number;
  30814. /**
  30815. * Gets the midtones Density value.
  30816. * 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.
  30817. * Values less than zero provide a filter of opposite hue.
  30818. */
  30819. /**
  30820. * Sets the midtones Density value.
  30821. * 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.
  30822. * Values less than zero provide a filter of opposite hue.
  30823. */
  30824. midtonesDensity: number;
  30825. /**
  30826. * Gets the midtones Saturation value.
  30827. * 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.
  30828. */
  30829. /**
  30830. * Sets the midtones Saturation value.
  30831. * 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.
  30832. */
  30833. midtonesSaturation: number;
  30834. /**
  30835. * Gets the midtones Exposure value.
  30836. * 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.
  30837. */
  30838. /**
  30839. * Sets the midtones Exposure value.
  30840. * 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.
  30841. */
  30842. midtonesExposure: number;
  30843. private _shadowsHue;
  30844. private _shadowsDensity;
  30845. private _shadowsSaturation;
  30846. private _shadowsExposure;
  30847. /**
  30848. * Gets the shadows Hue value.
  30849. * 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).
  30850. */
  30851. /**
  30852. * Sets the shadows Hue value.
  30853. * 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).
  30854. */
  30855. shadowsHue: number;
  30856. /**
  30857. * Gets the shadows Density value.
  30858. * 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.
  30859. * Values less than zero provide a filter of opposite hue.
  30860. */
  30861. /**
  30862. * Sets the shadows Density value.
  30863. * 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.
  30864. * Values less than zero provide a filter of opposite hue.
  30865. */
  30866. shadowsDensity: number;
  30867. /**
  30868. * Gets the shadows Saturation value.
  30869. * 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.
  30870. */
  30871. /**
  30872. * Sets the shadows Saturation value.
  30873. * 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.
  30874. */
  30875. shadowsSaturation: number;
  30876. /**
  30877. * Gets the shadows Exposure value.
  30878. * 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.
  30879. */
  30880. /**
  30881. * Sets the shadows Exposure value.
  30882. * 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.
  30883. */
  30884. shadowsExposure: number;
  30885. /**
  30886. * Returns the class name
  30887. * @returns The class name
  30888. */
  30889. getClassName(): string;
  30890. /**
  30891. * Binds the color curves to the shader.
  30892. * @param colorCurves The color curve to bind
  30893. * @param effect The effect to bind to
  30894. * @param positiveUniform The positive uniform shader parameter
  30895. * @param neutralUniform The neutral uniform shader parameter
  30896. * @param negativeUniform The negative uniform shader parameter
  30897. */
  30898. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30899. /**
  30900. * Prepare the list of uniforms associated with the ColorCurves effects.
  30901. * @param uniformsList The list of uniforms used in the effect
  30902. */
  30903. static PrepareUniforms(uniformsList: string[]): void;
  30904. /**
  30905. * Returns color grading data based on a hue, density, saturation and exposure value.
  30906. * @param filterHue The hue of the color filter.
  30907. * @param filterDensity The density of the color filter.
  30908. * @param saturation The saturation.
  30909. * @param exposure The exposure.
  30910. * @param result The result data container.
  30911. */
  30912. private getColorGradingDataToRef;
  30913. /**
  30914. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30915. * @param value The input slider value in range [-100,100].
  30916. * @returns Adjusted value.
  30917. */
  30918. private static applyColorGradingSliderNonlinear;
  30919. /**
  30920. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30921. * @param hue The hue (H) input.
  30922. * @param saturation The saturation (S) input.
  30923. * @param brightness The brightness (B) input.
  30924. * @result An RGBA color represented as Vector4.
  30925. */
  30926. private static fromHSBToRef;
  30927. /**
  30928. * Returns a value clamped between min and max
  30929. * @param value The value to clamp
  30930. * @param min The minimum of value
  30931. * @param max The maximum of value
  30932. * @returns The clamped value.
  30933. */
  30934. private static clamp;
  30935. /**
  30936. * Clones the current color curve instance.
  30937. * @return The cloned curves
  30938. */
  30939. clone(): ColorCurves;
  30940. /**
  30941. * Serializes the current color curve instance to a json representation.
  30942. * @return a JSON representation
  30943. */
  30944. serialize(): any;
  30945. /**
  30946. * Parses the color curve from a json representation.
  30947. * @param source the JSON source to parse
  30948. * @return The parsed curves
  30949. */
  30950. static Parse(source: any): ColorCurves;
  30951. }
  30952. }
  30953. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30954. import { Observable } from "babylonjs/Misc/observable";
  30955. import { Nullable } from "babylonjs/types";
  30956. import { Color4 } from "babylonjs/Maths/math";
  30957. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30958. import { Effect } from "babylonjs/Materials/effect";
  30959. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30960. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30961. /**
  30962. * Interface to follow in your material defines to integrate easily the
  30963. * Image proccessing functions.
  30964. * @hidden
  30965. */
  30966. export interface IImageProcessingConfigurationDefines {
  30967. IMAGEPROCESSING: boolean;
  30968. VIGNETTE: boolean;
  30969. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30970. VIGNETTEBLENDMODEOPAQUE: boolean;
  30971. TONEMAPPING: boolean;
  30972. TONEMAPPING_ACES: boolean;
  30973. CONTRAST: boolean;
  30974. EXPOSURE: boolean;
  30975. COLORCURVES: boolean;
  30976. COLORGRADING: boolean;
  30977. COLORGRADING3D: boolean;
  30978. SAMPLER3DGREENDEPTH: boolean;
  30979. SAMPLER3DBGRMAP: boolean;
  30980. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30981. }
  30982. /**
  30983. * @hidden
  30984. */
  30985. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30986. IMAGEPROCESSING: boolean;
  30987. VIGNETTE: boolean;
  30988. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30989. VIGNETTEBLENDMODEOPAQUE: boolean;
  30990. TONEMAPPING: boolean;
  30991. TONEMAPPING_ACES: boolean;
  30992. CONTRAST: boolean;
  30993. COLORCURVES: boolean;
  30994. COLORGRADING: boolean;
  30995. COLORGRADING3D: boolean;
  30996. SAMPLER3DGREENDEPTH: boolean;
  30997. SAMPLER3DBGRMAP: boolean;
  30998. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30999. EXPOSURE: boolean;
  31000. constructor();
  31001. }
  31002. /**
  31003. * This groups together the common properties used for image processing either in direct forward pass
  31004. * or through post processing effect depending on the use of the image processing pipeline in your scene
  31005. * or not.
  31006. */
  31007. export class ImageProcessingConfiguration {
  31008. /**
  31009. * Default tone mapping applied in BabylonJS.
  31010. */
  31011. static readonly TONEMAPPING_STANDARD: number;
  31012. /**
  31013. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  31014. * to other engines rendering to increase portability.
  31015. */
  31016. static readonly TONEMAPPING_ACES: number;
  31017. /**
  31018. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  31019. */
  31020. colorCurves: Nullable<ColorCurves>;
  31021. private _colorCurvesEnabled;
  31022. /**
  31023. * Gets wether the color curves effect is enabled.
  31024. */
  31025. /**
  31026. * Sets wether the color curves effect is enabled.
  31027. */
  31028. colorCurvesEnabled: boolean;
  31029. private _colorGradingTexture;
  31030. /**
  31031. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  31032. */
  31033. /**
  31034. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  31035. */
  31036. colorGradingTexture: Nullable<BaseTexture>;
  31037. private _colorGradingEnabled;
  31038. /**
  31039. * Gets wether the color grading effect is enabled.
  31040. */
  31041. /**
  31042. * Sets wether the color grading effect is enabled.
  31043. */
  31044. colorGradingEnabled: boolean;
  31045. private _colorGradingWithGreenDepth;
  31046. /**
  31047. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  31048. */
  31049. /**
  31050. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  31051. */
  31052. colorGradingWithGreenDepth: boolean;
  31053. private _colorGradingBGR;
  31054. /**
  31055. * Gets wether the color grading texture contains BGR values.
  31056. */
  31057. /**
  31058. * Sets wether the color grading texture contains BGR values.
  31059. */
  31060. colorGradingBGR: boolean;
  31061. /** @hidden */
  31062. _exposure: number;
  31063. /**
  31064. * Gets the Exposure used in the effect.
  31065. */
  31066. /**
  31067. * Sets the Exposure used in the effect.
  31068. */
  31069. exposure: number;
  31070. private _toneMappingEnabled;
  31071. /**
  31072. * Gets wether the tone mapping effect is enabled.
  31073. */
  31074. /**
  31075. * Sets wether the tone mapping effect is enabled.
  31076. */
  31077. toneMappingEnabled: boolean;
  31078. private _toneMappingType;
  31079. /**
  31080. * Gets the type of tone mapping effect.
  31081. */
  31082. /**
  31083. * Sets the type of tone mapping effect used in BabylonJS.
  31084. */
  31085. toneMappingType: number;
  31086. protected _contrast: number;
  31087. /**
  31088. * Gets the contrast used in the effect.
  31089. */
  31090. /**
  31091. * Sets the contrast used in the effect.
  31092. */
  31093. contrast: number;
  31094. /**
  31095. * Vignette stretch size.
  31096. */
  31097. vignetteStretch: number;
  31098. /**
  31099. * Vignette centre X Offset.
  31100. */
  31101. vignetteCentreX: number;
  31102. /**
  31103. * Vignette centre Y Offset.
  31104. */
  31105. vignetteCentreY: number;
  31106. /**
  31107. * Vignette weight or intensity of the vignette effect.
  31108. */
  31109. vignetteWeight: number;
  31110. /**
  31111. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  31112. * if vignetteEnabled is set to true.
  31113. */
  31114. vignetteColor: Color4;
  31115. /**
  31116. * Camera field of view used by the Vignette effect.
  31117. */
  31118. vignetteCameraFov: number;
  31119. private _vignetteBlendMode;
  31120. /**
  31121. * Gets the vignette blend mode allowing different kind of effect.
  31122. */
  31123. /**
  31124. * Sets the vignette blend mode allowing different kind of effect.
  31125. */
  31126. vignetteBlendMode: number;
  31127. private _vignetteEnabled;
  31128. /**
  31129. * Gets wether the vignette effect is enabled.
  31130. */
  31131. /**
  31132. * Sets wether the vignette effect is enabled.
  31133. */
  31134. vignetteEnabled: boolean;
  31135. private _applyByPostProcess;
  31136. /**
  31137. * Gets wether the image processing is applied through a post process or not.
  31138. */
  31139. /**
  31140. * Sets wether the image processing is applied through a post process or not.
  31141. */
  31142. applyByPostProcess: boolean;
  31143. private _isEnabled;
  31144. /**
  31145. * Gets wether the image processing is enabled or not.
  31146. */
  31147. /**
  31148. * Sets wether the image processing is enabled or not.
  31149. */
  31150. isEnabled: boolean;
  31151. /**
  31152. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  31153. */
  31154. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  31155. /**
  31156. * Method called each time the image processing information changes requires to recompile the effect.
  31157. */
  31158. protected _updateParameters(): void;
  31159. /**
  31160. * Gets the current class name.
  31161. * @return "ImageProcessingConfiguration"
  31162. */
  31163. getClassName(): string;
  31164. /**
  31165. * Prepare the list of uniforms associated with the Image Processing effects.
  31166. * @param uniforms The list of uniforms used in the effect
  31167. * @param defines the list of defines currently in use
  31168. */
  31169. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  31170. /**
  31171. * Prepare the list of samplers associated with the Image Processing effects.
  31172. * @param samplersList The list of uniforms used in the effect
  31173. * @param defines the list of defines currently in use
  31174. */
  31175. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  31176. /**
  31177. * Prepare the list of defines associated to the shader.
  31178. * @param defines the list of defines to complete
  31179. * @param forPostProcess Define if we are currently in post process mode or not
  31180. */
  31181. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  31182. /**
  31183. * Returns true if all the image processing information are ready.
  31184. * @returns True if ready, otherwise, false
  31185. */
  31186. isReady(): boolean;
  31187. /**
  31188. * Binds the image processing to the shader.
  31189. * @param effect The effect to bind to
  31190. * @param aspectRatio Define the current aspect ratio of the effect
  31191. */
  31192. bind(effect: Effect, aspectRatio?: number): void;
  31193. /**
  31194. * Clones the current image processing instance.
  31195. * @return The cloned image processing
  31196. */
  31197. clone(): ImageProcessingConfiguration;
  31198. /**
  31199. * Serializes the current image processing instance to a json representation.
  31200. * @return a JSON representation
  31201. */
  31202. serialize(): any;
  31203. /**
  31204. * Parses the image processing from a json representation.
  31205. * @param source the JSON source to parse
  31206. * @return The parsed image processing
  31207. */
  31208. static Parse(source: any): ImageProcessingConfiguration;
  31209. private static _VIGNETTEMODE_MULTIPLY;
  31210. private static _VIGNETTEMODE_OPAQUE;
  31211. /**
  31212. * Used to apply the vignette as a mix with the pixel color.
  31213. */
  31214. static readonly VIGNETTEMODE_MULTIPLY: number;
  31215. /**
  31216. * Used to apply the vignette as a replacement of the pixel color.
  31217. */
  31218. static readonly VIGNETTEMODE_OPAQUE: number;
  31219. }
  31220. }
  31221. declare module "babylonjs/Materials/fresnelParameters" {
  31222. import { Color3 } from "babylonjs/Maths/math";
  31223. /**
  31224. * This represents all the required information to add a fresnel effect on a material:
  31225. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31226. */
  31227. export class FresnelParameters {
  31228. private _isEnabled;
  31229. /**
  31230. * Define if the fresnel effect is enable or not.
  31231. */
  31232. isEnabled: boolean;
  31233. /**
  31234. * Define the color used on edges (grazing angle)
  31235. */
  31236. leftColor: Color3;
  31237. /**
  31238. * Define the color used on center
  31239. */
  31240. rightColor: Color3;
  31241. /**
  31242. * Define bias applied to computed fresnel term
  31243. */
  31244. bias: number;
  31245. /**
  31246. * Defined the power exponent applied to fresnel term
  31247. */
  31248. power: number;
  31249. /**
  31250. * Clones the current fresnel and its valuues
  31251. * @returns a clone fresnel configuration
  31252. */
  31253. clone(): FresnelParameters;
  31254. /**
  31255. * Serializes the current fresnel parameters to a JSON representation.
  31256. * @return the JSON serialization
  31257. */
  31258. serialize(): any;
  31259. /**
  31260. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31261. * @param parsedFresnelParameters Define the JSON representation
  31262. * @returns the parsed parameters
  31263. */
  31264. static Parse(parsedFresnelParameters: any): FresnelParameters;
  31265. }
  31266. }
  31267. declare module "babylonjs/Misc/decorators" {
  31268. import { Nullable } from "babylonjs/types";
  31269. import { Scene } from "babylonjs/scene";
  31270. import { IAnimatable } from "babylonjs/Misc/tools";
  31271. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31272. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31273. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31274. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31275. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31276. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31277. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31278. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31279. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31280. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31281. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31282. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31283. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31284. /**
  31285. * Decorator used to define property that can be serialized as reference to a camera
  31286. * @param sourceName defines the name of the property to decorate
  31287. */
  31288. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31289. /**
  31290. * Class used to help serialization objects
  31291. */
  31292. export class SerializationHelper {
  31293. /** @hidden */
  31294. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31295. /** @hidden */
  31296. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31297. /** @hidden */
  31298. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31299. /** @hidden */
  31300. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31301. /**
  31302. * Appends the serialized animations from the source animations
  31303. * @param source Source containing the animations
  31304. * @param destination Target to store the animations
  31305. */
  31306. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31307. /**
  31308. * Static function used to serialized a specific entity
  31309. * @param entity defines the entity to serialize
  31310. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31311. * @returns a JSON compatible object representing the serialization of the entity
  31312. */
  31313. static Serialize<T>(entity: T, serializationObject?: any): any;
  31314. /**
  31315. * Creates a new entity from a serialization data object
  31316. * @param creationFunction defines a function used to instanciated the new entity
  31317. * @param source defines the source serialization data
  31318. * @param scene defines the hosting scene
  31319. * @param rootUrl defines the root url for resources
  31320. * @returns a new entity
  31321. */
  31322. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31323. /**
  31324. * Clones an object
  31325. * @param creationFunction defines the function used to instanciate the new object
  31326. * @param source defines the source object
  31327. * @returns the cloned object
  31328. */
  31329. static Clone<T>(creationFunction: () => T, source: T): T;
  31330. /**
  31331. * Instanciates a new object based on a source one (some data will be shared between both object)
  31332. * @param creationFunction defines the function used to instanciate the new object
  31333. * @param source defines the source object
  31334. * @returns the new object
  31335. */
  31336. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31337. }
  31338. }
  31339. declare module "babylonjs/Cameras/camera" {
  31340. import { SmartArray } from "babylonjs/Misc/smartArray";
  31341. import { Observable } from "babylonjs/Misc/observable";
  31342. import { Nullable } from "babylonjs/types";
  31343. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31344. import { Scene } from "babylonjs/scene";
  31345. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31346. import { Node } from "babylonjs/node";
  31347. import { Mesh } from "babylonjs/Meshes/mesh";
  31348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31349. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31350. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31351. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31352. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31353. import { Ray } from "babylonjs/Culling/ray";
  31354. /**
  31355. * This is the base class of all the camera used in the application.
  31356. * @see http://doc.babylonjs.com/features/cameras
  31357. */
  31358. export class Camera extends Node {
  31359. /** @hidden */
  31360. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31361. /**
  31362. * This is the default projection mode used by the cameras.
  31363. * It helps recreating a feeling of perspective and better appreciate depth.
  31364. * This is the best way to simulate real life cameras.
  31365. */
  31366. static readonly PERSPECTIVE_CAMERA: number;
  31367. /**
  31368. * This helps creating camera with an orthographic mode.
  31369. * 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.
  31370. */
  31371. static readonly ORTHOGRAPHIC_CAMERA: number;
  31372. /**
  31373. * This is the default FOV mode for perspective cameras.
  31374. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31375. */
  31376. static readonly FOVMODE_VERTICAL_FIXED: number;
  31377. /**
  31378. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31379. */
  31380. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31381. /**
  31382. * This specifies ther is no need for a camera rig.
  31383. * Basically only one eye is rendered corresponding to the camera.
  31384. */
  31385. static readonly RIG_MODE_NONE: number;
  31386. /**
  31387. * Simulates a camera Rig with one blue eye and one red eye.
  31388. * This can be use with 3d blue and red glasses.
  31389. */
  31390. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31391. /**
  31392. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31393. */
  31394. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31395. /**
  31396. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31397. */
  31398. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31399. /**
  31400. * Defines that both eyes of the camera will be rendered over under each other.
  31401. */
  31402. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31403. /**
  31404. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31405. */
  31406. static readonly RIG_MODE_VR: number;
  31407. /**
  31408. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31409. */
  31410. static readonly RIG_MODE_WEBVR: number;
  31411. /**
  31412. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31413. */
  31414. static readonly RIG_MODE_CUSTOM: number;
  31415. /**
  31416. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31417. */
  31418. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31419. /**
  31420. * Define the input manager associated with the camera.
  31421. */
  31422. inputs: CameraInputsManager<Camera>;
  31423. /** @hidden */
  31424. _position: Vector3;
  31425. /**
  31426. * Define the current local position of the camera in the scene
  31427. */
  31428. position: Vector3;
  31429. /**
  31430. * The vector the camera should consider as up.
  31431. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31432. */
  31433. upVector: Vector3;
  31434. /**
  31435. * Define the current limit on the left side for an orthographic camera
  31436. * In scene unit
  31437. */
  31438. orthoLeft: Nullable<number>;
  31439. /**
  31440. * Define the current limit on the right side for an orthographic camera
  31441. * In scene unit
  31442. */
  31443. orthoRight: Nullable<number>;
  31444. /**
  31445. * Define the current limit on the bottom side for an orthographic camera
  31446. * In scene unit
  31447. */
  31448. orthoBottom: Nullable<number>;
  31449. /**
  31450. * Define the current limit on the top side for an orthographic camera
  31451. * In scene unit
  31452. */
  31453. orthoTop: Nullable<number>;
  31454. /**
  31455. * Field Of View is set in Radians. (default is 0.8)
  31456. */
  31457. fov: number;
  31458. /**
  31459. * Define the minimum distance the camera can see from.
  31460. * This is important to note that the depth buffer are not infinite and the closer it starts
  31461. * the more your scene might encounter depth fighting issue.
  31462. */
  31463. minZ: number;
  31464. /**
  31465. * Define the maximum distance the camera can see to.
  31466. * This is important to note that the depth buffer are not infinite and the further it end
  31467. * the more your scene might encounter depth fighting issue.
  31468. */
  31469. maxZ: number;
  31470. /**
  31471. * Define the default inertia of the camera.
  31472. * This helps giving a smooth feeling to the camera movement.
  31473. */
  31474. inertia: number;
  31475. /**
  31476. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  31477. */
  31478. mode: number;
  31479. /**
  31480. * Define wether the camera is intermediate.
  31481. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31482. */
  31483. isIntermediate: boolean;
  31484. /**
  31485. * Define the viewport of the camera.
  31486. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31487. */
  31488. viewport: Viewport;
  31489. /**
  31490. * Restricts the camera to viewing objects with the same layerMask.
  31491. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31492. */
  31493. layerMask: number;
  31494. /**
  31495. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31496. */
  31497. fovMode: number;
  31498. /**
  31499. * Rig mode of the camera.
  31500. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31501. * This is normally controlled byt the camera themselves as internal use.
  31502. */
  31503. cameraRigMode: number;
  31504. /**
  31505. * Defines the distance between both "eyes" in case of a RIG
  31506. */
  31507. interaxialDistance: number;
  31508. /**
  31509. * Defines if stereoscopic rendering is done side by side or over under.
  31510. */
  31511. isStereoscopicSideBySide: boolean;
  31512. /**
  31513. * 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
  31514. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31515. * else in the scene.
  31516. */
  31517. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31518. /**
  31519. * When set, the camera will render to this render target instead of the default canvas
  31520. */
  31521. outputRenderTarget: Nullable<RenderTargetTexture>;
  31522. /**
  31523. * Observable triggered when the camera view matrix has changed.
  31524. */
  31525. onViewMatrixChangedObservable: Observable<Camera>;
  31526. /**
  31527. * Observable triggered when the camera Projection matrix has changed.
  31528. */
  31529. onProjectionMatrixChangedObservable: Observable<Camera>;
  31530. /**
  31531. * Observable triggered when the inputs have been processed.
  31532. */
  31533. onAfterCheckInputsObservable: Observable<Camera>;
  31534. /**
  31535. * Observable triggered when reset has been called and applied to the camera.
  31536. */
  31537. onRestoreStateObservable: Observable<Camera>;
  31538. /** @hidden */
  31539. _cameraRigParams: any;
  31540. /** @hidden */
  31541. _rigCameras: Camera[];
  31542. /** @hidden */
  31543. _rigPostProcess: Nullable<PostProcess>;
  31544. protected _webvrViewMatrix: Matrix;
  31545. /** @hidden */
  31546. _skipRendering: boolean;
  31547. /** @hidden */
  31548. _projectionMatrix: Matrix;
  31549. /** @hidden */
  31550. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31551. /** @hidden */
  31552. _activeMeshes: SmartArray<AbstractMesh>;
  31553. protected _globalPosition: Vector3;
  31554. /** @hidden */
  31555. _computedViewMatrix: Matrix;
  31556. private _doNotComputeProjectionMatrix;
  31557. private _transformMatrix;
  31558. private _frustumPlanes;
  31559. private _refreshFrustumPlanes;
  31560. private _storedFov;
  31561. private _stateStored;
  31562. /**
  31563. * Instantiates a new camera object.
  31564. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31565. * @see http://doc.babylonjs.com/features/cameras
  31566. * @param name Defines the name of the camera in the scene
  31567. * @param position Defines the position of the camera
  31568. * @param scene Defines the scene the camera belongs too
  31569. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31570. */
  31571. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31572. /**
  31573. * Store current camera state (fov, position, etc..)
  31574. * @returns the camera
  31575. */
  31576. storeState(): Camera;
  31577. /**
  31578. * Restores the camera state values if it has been stored. You must call storeState() first
  31579. */
  31580. protected _restoreStateValues(): boolean;
  31581. /**
  31582. * Restored camera state. You must call storeState() first.
  31583. * @returns true if restored and false otherwise
  31584. */
  31585. restoreState(): boolean;
  31586. /**
  31587. * Gets the class name of the camera.
  31588. * @returns the class name
  31589. */
  31590. getClassName(): string;
  31591. /** @hidden */
  31592. readonly _isCamera: boolean;
  31593. /**
  31594. * Gets a string representation of the camera useful for debug purpose.
  31595. * @param fullDetails Defines that a more verboe level of logging is required
  31596. * @returns the string representation
  31597. */
  31598. toString(fullDetails?: boolean): string;
  31599. /**
  31600. * Gets the current world space position of the camera.
  31601. */
  31602. readonly globalPosition: Vector3;
  31603. /**
  31604. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31605. * @returns the active meshe list
  31606. */
  31607. getActiveMeshes(): SmartArray<AbstractMesh>;
  31608. /**
  31609. * Check wether a mesh is part of the current active mesh list of the camera
  31610. * @param mesh Defines the mesh to check
  31611. * @returns true if active, false otherwise
  31612. */
  31613. isActiveMesh(mesh: Mesh): boolean;
  31614. /**
  31615. * Is this camera ready to be used/rendered
  31616. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31617. * @return true if the camera is ready
  31618. */
  31619. isReady(completeCheck?: boolean): boolean;
  31620. /** @hidden */
  31621. _initCache(): void;
  31622. /** @hidden */
  31623. _updateCache(ignoreParentClass?: boolean): void;
  31624. /** @hidden */
  31625. _isSynchronized(): boolean;
  31626. /** @hidden */
  31627. _isSynchronizedViewMatrix(): boolean;
  31628. /** @hidden */
  31629. _isSynchronizedProjectionMatrix(): boolean;
  31630. /**
  31631. * Attach the input controls to a specific dom element to get the input from.
  31632. * @param element Defines the element the controls should be listened from
  31633. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31634. */
  31635. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31636. /**
  31637. * Detach the current controls from the specified dom element.
  31638. * @param element Defines the element to stop listening the inputs from
  31639. */
  31640. detachControl(element: HTMLElement): void;
  31641. /**
  31642. * Update the camera state according to the different inputs gathered during the frame.
  31643. */
  31644. update(): void;
  31645. /** @hidden */
  31646. _checkInputs(): void;
  31647. /** @hidden */
  31648. readonly rigCameras: Camera[];
  31649. /**
  31650. * Gets the post process used by the rig cameras
  31651. */
  31652. readonly rigPostProcess: Nullable<PostProcess>;
  31653. /**
  31654. * Internal, gets the first post proces.
  31655. * @returns the first post process to be run on this camera.
  31656. */
  31657. _getFirstPostProcess(): Nullable<PostProcess>;
  31658. private _cascadePostProcessesToRigCams;
  31659. /**
  31660. * Attach a post process to the camera.
  31661. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31662. * @param postProcess The post process to attach to the camera
  31663. * @param insertAt The position of the post process in case several of them are in use in the scene
  31664. * @returns the position the post process has been inserted at
  31665. */
  31666. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31667. /**
  31668. * Detach a post process to the camera.
  31669. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31670. * @param postProcess The post process to detach from the camera
  31671. */
  31672. detachPostProcess(postProcess: PostProcess): void;
  31673. /**
  31674. * Gets the current world matrix of the camera
  31675. */
  31676. getWorldMatrix(): Matrix;
  31677. /** @hidden */
  31678. _getViewMatrix(): Matrix;
  31679. /**
  31680. * Gets the current view matrix of the camera.
  31681. * @param force forces the camera to recompute the matrix without looking at the cached state
  31682. * @returns the view matrix
  31683. */
  31684. getViewMatrix(force?: boolean): Matrix;
  31685. /**
  31686. * Freeze the projection matrix.
  31687. * It will prevent the cache check of the camera projection compute and can speed up perf
  31688. * if no parameter of the camera are meant to change
  31689. * @param projection Defines manually a projection if necessary
  31690. */
  31691. freezeProjectionMatrix(projection?: Matrix): void;
  31692. /**
  31693. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31694. */
  31695. unfreezeProjectionMatrix(): void;
  31696. /**
  31697. * Gets the current projection matrix of the camera.
  31698. * @param force forces the camera to recompute the matrix without looking at the cached state
  31699. * @returns the projection matrix
  31700. */
  31701. getProjectionMatrix(force?: boolean): Matrix;
  31702. /**
  31703. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31704. * @returns a Matrix
  31705. */
  31706. getTransformationMatrix(): Matrix;
  31707. private _updateFrustumPlanes;
  31708. /**
  31709. * Checks if a cullable object (mesh...) is in the camera frustum
  31710. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31711. * @param target The object to check
  31712. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31713. * @returns true if the object is in frustum otherwise false
  31714. */
  31715. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31716. /**
  31717. * Checks if a cullable object (mesh...) is in the camera frustum
  31718. * Unlike isInFrustum this cheks the full bounding box
  31719. * @param target The object to check
  31720. * @returns true if the object is in frustum otherwise false
  31721. */
  31722. isCompletelyInFrustum(target: ICullable): boolean;
  31723. /**
  31724. * Gets a ray in the forward direction from the camera.
  31725. * @param length Defines the length of the ray to create
  31726. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31727. * @param origin Defines the start point of the ray which defaults to the camera position
  31728. * @returns the forward ray
  31729. */
  31730. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31731. /**
  31732. * Releases resources associated with this node.
  31733. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31734. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31735. */
  31736. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31737. /** @hidden */
  31738. _isLeftCamera: boolean;
  31739. /**
  31740. * Gets the left camera of a rig setup in case of Rigged Camera
  31741. */
  31742. readonly isLeftCamera: boolean;
  31743. /** @hidden */
  31744. _isRightCamera: boolean;
  31745. /**
  31746. * Gets the right camera of a rig setup in case of Rigged Camera
  31747. */
  31748. readonly isRightCamera: boolean;
  31749. /**
  31750. * Gets the left camera of a rig setup in case of Rigged Camera
  31751. */
  31752. readonly leftCamera: Nullable<FreeCamera>;
  31753. /**
  31754. * Gets the right camera of a rig setup in case of Rigged Camera
  31755. */
  31756. readonly rightCamera: Nullable<FreeCamera>;
  31757. /**
  31758. * Gets the left camera target of a rig setup in case of Rigged Camera
  31759. * @returns the target position
  31760. */
  31761. getLeftTarget(): Nullable<Vector3>;
  31762. /**
  31763. * Gets the right camera target of a rig setup in case of Rigged Camera
  31764. * @returns the target position
  31765. */
  31766. getRightTarget(): Nullable<Vector3>;
  31767. /**
  31768. * @hidden
  31769. */
  31770. setCameraRigMode(mode: number, rigParams: any): void;
  31771. /** @hidden */
  31772. static _setStereoscopicRigMode(camera: Camera): void;
  31773. /** @hidden */
  31774. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31775. /** @hidden */
  31776. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31777. /** @hidden */
  31778. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31779. /** @hidden */
  31780. _getVRProjectionMatrix(): Matrix;
  31781. protected _updateCameraRotationMatrix(): void;
  31782. protected _updateWebVRCameraRotationMatrix(): void;
  31783. /**
  31784. * This function MUST be overwritten by the different WebVR cameras available.
  31785. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31786. * @hidden
  31787. */
  31788. _getWebVRProjectionMatrix(): Matrix;
  31789. /**
  31790. * This function MUST be overwritten by the different WebVR cameras available.
  31791. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31792. * @hidden
  31793. */
  31794. _getWebVRViewMatrix(): Matrix;
  31795. /** @hidden */
  31796. setCameraRigParameter(name: string, value: any): void;
  31797. /**
  31798. * needs to be overridden by children so sub has required properties to be copied
  31799. * @hidden
  31800. */
  31801. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31802. /**
  31803. * May need to be overridden by children
  31804. * @hidden
  31805. */
  31806. _updateRigCameras(): void;
  31807. /** @hidden */
  31808. _setupInputs(): void;
  31809. /**
  31810. * Serialiaze the camera setup to a json represention
  31811. * @returns the JSON representation
  31812. */
  31813. serialize(): any;
  31814. /**
  31815. * Clones the current camera.
  31816. * @param name The cloned camera name
  31817. * @returns the cloned camera
  31818. */
  31819. clone(name: string): Camera;
  31820. /**
  31821. * Gets the direction of the camera relative to a given local axis.
  31822. * @param localAxis Defines the reference axis to provide a relative direction.
  31823. * @return the direction
  31824. */
  31825. getDirection(localAxis: Vector3): Vector3;
  31826. /**
  31827. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31828. * @param localAxis Defines the reference axis to provide a relative direction.
  31829. * @param result Defines the vector to store the result in
  31830. */
  31831. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31832. /**
  31833. * Gets a camera constructor for a given camera type
  31834. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31835. * @param name The name of the camera the result will be able to instantiate
  31836. * @param scene The scene the result will construct the camera in
  31837. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31838. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31839. * @returns a factory method to construc the camera
  31840. */
  31841. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31842. /**
  31843. * Compute the world matrix of the camera.
  31844. * @returns the camera workd matrix
  31845. */
  31846. computeWorldMatrix(): Matrix;
  31847. /**
  31848. * Parse a JSON and creates the camera from the parsed information
  31849. * @param parsedCamera The JSON to parse
  31850. * @param scene The scene to instantiate the camera in
  31851. * @returns the newly constructed camera
  31852. */
  31853. static Parse(parsedCamera: any, scene: Scene): Camera;
  31854. }
  31855. }
  31856. declare module "babylonjs/Misc/tools" {
  31857. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31858. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31859. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31860. import { Observable } from "babylonjs/Misc/observable";
  31861. import { DomManagement } from "babylonjs/Misc/domManagement";
  31862. import { WebRequest } from "babylonjs/Misc/webRequest";
  31863. import { Camera } from "babylonjs/Cameras/camera";
  31864. import { Engine } from "babylonjs/Engines/engine";
  31865. import { Animation } from "babylonjs/Animations/animation";
  31866. /**
  31867. * Interface for any object that can request an animation frame
  31868. */
  31869. export interface ICustomAnimationFrameRequester {
  31870. /**
  31871. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31872. */
  31873. renderFunction?: Function;
  31874. /**
  31875. * Called to request the next frame to render to
  31876. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31877. */
  31878. requestAnimationFrame: Function;
  31879. /**
  31880. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31881. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31882. */
  31883. requestID?: number;
  31884. }
  31885. /**
  31886. * Interface containing an array of animations
  31887. */
  31888. export interface IAnimatable {
  31889. /**
  31890. * Array of animations
  31891. */
  31892. animations: Nullable<Array<Animation>>;
  31893. }
  31894. /** Interface used by value gradients (color, factor, ...) */
  31895. export interface IValueGradient {
  31896. /**
  31897. * Gets or sets the gradient value (between 0 and 1)
  31898. */
  31899. gradient: number;
  31900. }
  31901. /** Class used to store color4 gradient */
  31902. export class ColorGradient implements IValueGradient {
  31903. /**
  31904. * Gets or sets the gradient value (between 0 and 1)
  31905. */
  31906. gradient: number;
  31907. /**
  31908. * Gets or sets first associated color
  31909. */
  31910. color1: Color4;
  31911. /**
  31912. * Gets or sets second associated color
  31913. */
  31914. color2?: Color4;
  31915. /**
  31916. * Will get a color picked randomly between color1 and color2.
  31917. * If color2 is undefined then color1 will be used
  31918. * @param result defines the target Color4 to store the result in
  31919. */
  31920. getColorToRef(result: Color4): void;
  31921. }
  31922. /** Class used to store color 3 gradient */
  31923. export class Color3Gradient implements IValueGradient {
  31924. /**
  31925. * Gets or sets the gradient value (between 0 and 1)
  31926. */
  31927. gradient: number;
  31928. /**
  31929. * Gets or sets the associated color
  31930. */
  31931. color: Color3;
  31932. }
  31933. /** Class used to store factor gradient */
  31934. export class FactorGradient implements IValueGradient {
  31935. /**
  31936. * Gets or sets the gradient value (between 0 and 1)
  31937. */
  31938. gradient: number;
  31939. /**
  31940. * Gets or sets first associated factor
  31941. */
  31942. factor1: number;
  31943. /**
  31944. * Gets or sets second associated factor
  31945. */
  31946. factor2?: number;
  31947. /**
  31948. * Will get a number picked randomly between factor1 and factor2.
  31949. * If factor2 is undefined then factor1 will be used
  31950. * @returns the picked number
  31951. */
  31952. getFactor(): number;
  31953. }
  31954. /**
  31955. * @ignore
  31956. * Application error to support additional information when loading a file
  31957. */
  31958. export class LoadFileError extends Error {
  31959. /** defines the optional web request */
  31960. request?: WebRequest | undefined;
  31961. private static _setPrototypeOf;
  31962. /**
  31963. * Creates a new LoadFileError
  31964. * @param message defines the message of the error
  31965. * @param request defines the optional web request
  31966. */
  31967. constructor(message: string,
  31968. /** defines the optional web request */
  31969. request?: WebRequest | undefined);
  31970. }
  31971. /**
  31972. * Class used to define a retry strategy when error happens while loading assets
  31973. */
  31974. export class RetryStrategy {
  31975. /**
  31976. * Function used to defines an exponential back off strategy
  31977. * @param maxRetries defines the maximum number of retries (3 by default)
  31978. * @param baseInterval defines the interval between retries
  31979. * @returns the strategy function to use
  31980. */
  31981. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31982. }
  31983. /**
  31984. * File request interface
  31985. */
  31986. export interface IFileRequest {
  31987. /**
  31988. * Raised when the request is complete (success or error).
  31989. */
  31990. onCompleteObservable: Observable<IFileRequest>;
  31991. /**
  31992. * Aborts the request for a file.
  31993. */
  31994. abort: () => void;
  31995. }
  31996. /**
  31997. * Class containing a set of static utilities functions
  31998. */
  31999. export class Tools {
  32000. /**
  32001. * Gets or sets the base URL to use to load assets
  32002. */
  32003. static BaseUrl: string;
  32004. /**
  32005. * Enable/Disable Custom HTTP Request Headers globally.
  32006. * default = false
  32007. * @see CustomRequestHeaders
  32008. */
  32009. static UseCustomRequestHeaders: boolean;
  32010. /**
  32011. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32012. * i.e. when loading files, where the server/service expects an Authorization header
  32013. */
  32014. static CustomRequestHeaders: {
  32015. [key: string]: string;
  32016. };
  32017. /**
  32018. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32019. */
  32020. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32021. /**
  32022. * Default behaviour for cors in the application.
  32023. * It can be a string if the expected behavior is identical in the entire app.
  32024. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32025. */
  32026. static CorsBehavior: string | ((url: string | string[]) => string);
  32027. /**
  32028. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32029. * @ignorenaming
  32030. */
  32031. static UseFallbackTexture: boolean;
  32032. /**
  32033. * Use this object to register external classes like custom textures or material
  32034. * to allow the laoders to instantiate them
  32035. */
  32036. static RegisteredExternalClasses: {
  32037. [key: string]: Object;
  32038. };
  32039. /**
  32040. * Texture content used if a texture cannot loaded
  32041. * @ignorenaming
  32042. */
  32043. static fallbackTexture: string;
  32044. /**
  32045. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32046. * @param u defines the coordinate on X axis
  32047. * @param v defines the coordinate on Y axis
  32048. * @param width defines the width of the source data
  32049. * @param height defines the height of the source data
  32050. * @param pixels defines the source byte array
  32051. * @param color defines the output color
  32052. */
  32053. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  32054. /**
  32055. * Interpolates between a and b via alpha
  32056. * @param a The lower value (returned when alpha = 0)
  32057. * @param b The upper value (returned when alpha = 1)
  32058. * @param alpha The interpolation-factor
  32059. * @return The mixed value
  32060. */
  32061. static Mix(a: number, b: number, alpha: number): number;
  32062. /**
  32063. * Tries to instantiate a new object from a given class name
  32064. * @param className defines the class name to instantiate
  32065. * @returns the new object or null if the system was not able to do the instantiation
  32066. */
  32067. static Instantiate(className: string): any;
  32068. /**
  32069. * Provides a slice function that will work even on IE
  32070. * @param data defines the array to slice
  32071. * @param start defines the start of the data (optional)
  32072. * @param end defines the end of the data (optional)
  32073. * @returns the new sliced array
  32074. */
  32075. static Slice<T>(data: T, start?: number, end?: number): T;
  32076. /**
  32077. * Polyfill for setImmediate
  32078. * @param action defines the action to execute after the current execution block
  32079. */
  32080. static SetImmediate(action: () => void): void;
  32081. /**
  32082. * Function indicating if a number is an exponent of 2
  32083. * @param value defines the value to test
  32084. * @returns true if the value is an exponent of 2
  32085. */
  32086. static IsExponentOfTwo(value: number): boolean;
  32087. private static _tmpFloatArray;
  32088. /**
  32089. * Returns the nearest 32-bit single precision float representation of a Number
  32090. * @param value A Number. If the parameter is of a different type, it will get converted
  32091. * to a number or to NaN if it cannot be converted
  32092. * @returns number
  32093. */
  32094. static FloatRound(value: number): number;
  32095. /**
  32096. * Find the next highest power of two.
  32097. * @param x Number to start search from.
  32098. * @return Next highest power of two.
  32099. */
  32100. static CeilingPOT(x: number): number;
  32101. /**
  32102. * Find the next lowest power of two.
  32103. * @param x Number to start search from.
  32104. * @return Next lowest power of two.
  32105. */
  32106. static FloorPOT(x: number): number;
  32107. /**
  32108. * Find the nearest power of two.
  32109. * @param x Number to start search from.
  32110. * @return Next nearest power of two.
  32111. */
  32112. static NearestPOT(x: number): number;
  32113. /**
  32114. * Get the closest exponent of two
  32115. * @param value defines the value to approximate
  32116. * @param max defines the maximum value to return
  32117. * @param mode defines how to define the closest value
  32118. * @returns closest exponent of two of the given value
  32119. */
  32120. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32121. /**
  32122. * Extracts the filename from a path
  32123. * @param path defines the path to use
  32124. * @returns the filename
  32125. */
  32126. static GetFilename(path: string): string;
  32127. /**
  32128. * Extracts the "folder" part of a path (everything before the filename).
  32129. * @param uri The URI to extract the info from
  32130. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32131. * @returns The "folder" part of the path
  32132. */
  32133. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32134. /**
  32135. * Extracts text content from a DOM element hierarchy
  32136. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32137. */
  32138. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32139. /**
  32140. * Convert an angle in radians to degrees
  32141. * @param angle defines the angle to convert
  32142. * @returns the angle in degrees
  32143. */
  32144. static ToDegrees(angle: number): number;
  32145. /**
  32146. * Convert an angle in degrees to radians
  32147. * @param angle defines the angle to convert
  32148. * @returns the angle in radians
  32149. */
  32150. static ToRadians(angle: number): number;
  32151. /**
  32152. * Encode a buffer to a base64 string
  32153. * @param buffer defines the buffer to encode
  32154. * @returns the encoded string
  32155. */
  32156. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32157. /**
  32158. * Extracts minimum and maximum values from a list of indexed positions
  32159. * @param positions defines the positions to use
  32160. * @param indices defines the indices to the positions
  32161. * @param indexStart defines the start index
  32162. * @param indexCount defines the end index
  32163. * @param bias defines bias value to add to the result
  32164. * @return minimum and maximum values
  32165. */
  32166. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  32167. minimum: Vector3;
  32168. maximum: Vector3;
  32169. };
  32170. /**
  32171. * Extracts minimum and maximum values from a list of positions
  32172. * @param positions defines the positions to use
  32173. * @param start defines the start index in the positions array
  32174. * @param count defines the number of positions to handle
  32175. * @param bias defines bias value to add to the result
  32176. * @param stride defines the stride size to use (distance between two positions in the positions array)
  32177. * @return minimum and maximum values
  32178. */
  32179. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  32180. minimum: Vector3;
  32181. maximum: Vector3;
  32182. };
  32183. /**
  32184. * Returns an array if obj is not an array
  32185. * @param obj defines the object to evaluate as an array
  32186. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32187. * @returns either obj directly if obj is an array or a new array containing obj
  32188. */
  32189. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32190. /**
  32191. * Gets the pointer prefix to use
  32192. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32193. */
  32194. static GetPointerPrefix(): string;
  32195. /**
  32196. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32197. * @param func - the function to be called
  32198. * @param requester - the object that will request the next frame. Falls back to window.
  32199. * @returns frame number
  32200. */
  32201. static QueueNewFrame(func: () => void, requester?: any): number;
  32202. /**
  32203. * Ask the browser to promote the current element to fullscreen rendering mode
  32204. * @param element defines the DOM element to promote
  32205. */
  32206. static RequestFullscreen(element: HTMLElement): void;
  32207. /**
  32208. * Asks the browser to exit fullscreen mode
  32209. */
  32210. static ExitFullscreen(): void;
  32211. /**
  32212. * Ask the browser to promote the current element to pointerlock mode
  32213. * @param element defines the DOM element to promote
  32214. */
  32215. static RequestPointerlock(element: HTMLElement): void;
  32216. /**
  32217. * Asks the browser to exit pointerlock mode
  32218. */
  32219. static ExitPointerlock(): void;
  32220. /**
  32221. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32222. * @param url define the url we are trying
  32223. * @param element define the dom element where to configure the cors policy
  32224. */
  32225. static SetCorsBehavior(url: string | string[], element: {
  32226. crossOrigin: string | null;
  32227. }): void;
  32228. /**
  32229. * Removes unwanted characters from an url
  32230. * @param url defines the url to clean
  32231. * @returns the cleaned url
  32232. */
  32233. static CleanUrl(url: string): string;
  32234. /**
  32235. * Gets or sets a function used to pre-process url before using them to load assets
  32236. */
  32237. static PreprocessUrl: (url: string) => string;
  32238. /**
  32239. * Loads an image as an HTMLImageElement.
  32240. * @param input url string, ArrayBuffer, or Blob to load
  32241. * @param onLoad callback called when the image successfully loads
  32242. * @param onError callback called when the image fails to load
  32243. * @param offlineProvider offline provider for caching
  32244. * @returns the HTMLImageElement of the loaded image
  32245. */
  32246. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32247. /**
  32248. * Loads a file
  32249. * @param url url string, ArrayBuffer, or Blob to load
  32250. * @param onSuccess callback called when the file successfully loads
  32251. * @param onProgress callback called while file is loading (if the server supports this mode)
  32252. * @param offlineProvider defines the offline provider for caching
  32253. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32254. * @param onError callback called when the file fails to load
  32255. * @returns a file request object
  32256. */
  32257. 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;
  32258. /**
  32259. * Loads a file from a url
  32260. * @param url the file url to load
  32261. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32262. */
  32263. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32264. /**
  32265. * Load a script (identified by an url). When the url returns, the
  32266. * content of this file is added into a new script element, attached to the DOM (body element)
  32267. * @param scriptUrl defines the url of the script to laod
  32268. * @param onSuccess defines the callback called when the script is loaded
  32269. * @param onError defines the callback to call if an error occurs
  32270. * @param scriptId defines the id of the script element
  32271. */
  32272. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32273. /**
  32274. * Load an asynchronous script (identified by an url). When the url returns, the
  32275. * content of this file is added into a new script element, attached to the DOM (body element)
  32276. * @param scriptUrl defines the url of the script to laod
  32277. * @param scriptId defines the id of the script element
  32278. * @returns a promise request object
  32279. */
  32280. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32281. /**
  32282. * Loads a file from a blob
  32283. * @param fileToLoad defines the blob to use
  32284. * @param callback defines the callback to call when data is loaded
  32285. * @param progressCallback defines the callback to call during loading process
  32286. * @returns a file request object
  32287. */
  32288. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32289. /**
  32290. * Loads a file
  32291. * @param fileToLoad defines the file to load
  32292. * @param callback defines the callback to call when data is loaded
  32293. * @param progressCallBack defines the callback to call during loading process
  32294. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32295. * @returns a file request object
  32296. */
  32297. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32298. /**
  32299. * Creates a data url from a given string content
  32300. * @param content defines the content to convert
  32301. * @returns the new data url link
  32302. */
  32303. static FileAsURL(content: string): string;
  32304. /**
  32305. * Format the given number to a specific decimal format
  32306. * @param value defines the number to format
  32307. * @param decimals defines the number of decimals to use
  32308. * @returns the formatted string
  32309. */
  32310. static Format(value: number, decimals?: number): string;
  32311. /**
  32312. * Checks if a given vector is inside a specific range
  32313. * @param v defines the vector to test
  32314. * @param min defines the minimum range
  32315. * @param max defines the maximum range
  32316. */
  32317. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32318. /**
  32319. * Tries to copy an object by duplicating every property
  32320. * @param source defines the source object
  32321. * @param destination defines the target object
  32322. * @param doNotCopyList defines a list of properties to avoid
  32323. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32324. */
  32325. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32326. /**
  32327. * Gets a boolean indicating if the given object has no own property
  32328. * @param obj defines the object to test
  32329. * @returns true if object has no own property
  32330. */
  32331. static IsEmpty(obj: any): boolean;
  32332. /**
  32333. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  32334. * @param str Source string
  32335. * @param suffix Suffix to search for in the source string
  32336. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32337. */
  32338. static EndsWith(str: string, suffix: string): boolean;
  32339. /**
  32340. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  32341. * @param str Source string
  32342. * @param suffix Suffix to search for in the source string
  32343. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32344. */
  32345. static StartsWith(str: string, suffix: string): boolean;
  32346. /**
  32347. * Function used to register events at window level
  32348. * @param events defines the events to register
  32349. */
  32350. static RegisterTopRootEvents(events: {
  32351. name: string;
  32352. handler: Nullable<(e: FocusEvent) => any>;
  32353. }[]): void;
  32354. /**
  32355. * Function used to unregister events from window level
  32356. * @param events defines the events to unregister
  32357. */
  32358. static UnregisterTopRootEvents(events: {
  32359. name: string;
  32360. handler: Nullable<(e: FocusEvent) => any>;
  32361. }[]): void;
  32362. /**
  32363. * @ignore
  32364. */
  32365. static _ScreenshotCanvas: HTMLCanvasElement;
  32366. /**
  32367. * Dumps the current bound framebuffer
  32368. * @param width defines the rendering width
  32369. * @param height defines the rendering height
  32370. * @param engine defines the hosting engine
  32371. * @param successCallback defines the callback triggered once the data are available
  32372. * @param mimeType defines the mime type of the result
  32373. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32374. */
  32375. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32376. /**
  32377. * Converts the canvas data to blob.
  32378. * This acts as a polyfill for browsers not supporting the to blob function.
  32379. * @param canvas Defines the canvas to extract the data from
  32380. * @param successCallback Defines the callback triggered once the data are available
  32381. * @param mimeType Defines the mime type of the result
  32382. */
  32383. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32384. /**
  32385. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32386. * @param successCallback defines the callback triggered once the data are available
  32387. * @param mimeType defines the mime type of the result
  32388. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32389. */
  32390. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32391. /**
  32392. * Downloads a blob in the browser
  32393. * @param blob defines the blob to download
  32394. * @param fileName defines the name of the downloaded file
  32395. */
  32396. static Download(blob: Blob, fileName: string): void;
  32397. /**
  32398. * Captures a screenshot of the current rendering
  32399. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32400. * @param engine defines the rendering engine
  32401. * @param camera defines the source camera
  32402. * @param size This parameter can be set to a single number or to an object with the
  32403. * following (optional) properties: precision, width, height. If a single number is passed,
  32404. * it will be used for both width and height. If an object is passed, the screenshot size
  32405. * will be derived from the parameters. The precision property is a multiplier allowing
  32406. * rendering at a higher or lower resolution
  32407. * @param successCallback defines the callback receives a single parameter which contains the
  32408. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32409. * src parameter of an <img> to display it
  32410. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32411. * Check your browser for supported MIME types
  32412. */
  32413. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32414. /**
  32415. * Generates an image screenshot from the specified camera.
  32416. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32417. * @param engine The engine to use for rendering
  32418. * @param camera The camera to use for rendering
  32419. * @param size This parameter can be set to a single number or to an object with the
  32420. * following (optional) properties: precision, width, height. If a single number is passed,
  32421. * it will be used for both width and height. If an object is passed, the screenshot size
  32422. * will be derived from the parameters. The precision property is a multiplier allowing
  32423. * rendering at a higher or lower resolution
  32424. * @param successCallback The callback receives a single parameter which contains the
  32425. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32426. * src parameter of an <img> to display it
  32427. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32428. * Check your browser for supported MIME types
  32429. * @param samples Texture samples (default: 1)
  32430. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32431. * @param fileName A name for for the downloaded file.
  32432. */
  32433. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32434. /**
  32435. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32436. * Be aware Math.random() could cause collisions, but:
  32437. * "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"
  32438. * @returns a pseudo random id
  32439. */
  32440. static RandomId(): string;
  32441. /**
  32442. * Test if the given uri is a base64 string
  32443. * @param uri The uri to test
  32444. * @return True if the uri is a base64 string or false otherwise
  32445. */
  32446. static IsBase64(uri: string): boolean;
  32447. /**
  32448. * Decode the given base64 uri.
  32449. * @param uri The uri to decode
  32450. * @return The decoded base64 data.
  32451. */
  32452. static DecodeBase64(uri: string): ArrayBuffer;
  32453. /**
  32454. * Gets the absolute url.
  32455. * @param url the input url
  32456. * @return the absolute url
  32457. */
  32458. static GetAbsoluteUrl(url: string): string;
  32459. /**
  32460. * No log
  32461. */
  32462. static readonly NoneLogLevel: number;
  32463. /**
  32464. * Only message logs
  32465. */
  32466. static readonly MessageLogLevel: number;
  32467. /**
  32468. * Only warning logs
  32469. */
  32470. static readonly WarningLogLevel: number;
  32471. /**
  32472. * Only error logs
  32473. */
  32474. static readonly ErrorLogLevel: number;
  32475. /**
  32476. * All logs
  32477. */
  32478. static readonly AllLogLevel: number;
  32479. /**
  32480. * Gets a value indicating the number of loading errors
  32481. * @ignorenaming
  32482. */
  32483. static readonly errorsCount: number;
  32484. /**
  32485. * Callback called when a new log is added
  32486. */
  32487. static OnNewCacheEntry: (entry: string) => void;
  32488. /**
  32489. * Log a message to the console
  32490. * @param message defines the message to log
  32491. */
  32492. static Log(message: string): void;
  32493. /**
  32494. * Write a warning message to the console
  32495. * @param message defines the message to log
  32496. */
  32497. static Warn(message: string): void;
  32498. /**
  32499. * Write an error message to the console
  32500. * @param message defines the message to log
  32501. */
  32502. static Error(message: string): void;
  32503. /**
  32504. * Gets current log cache (list of logs)
  32505. */
  32506. static readonly LogCache: string;
  32507. /**
  32508. * Clears the log cache
  32509. */
  32510. static ClearLogCache(): void;
  32511. /**
  32512. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32513. */
  32514. static LogLevels: number;
  32515. /**
  32516. * Checks if the loaded document was accessed via `file:`-Protocol.
  32517. * @returns boolean
  32518. */
  32519. static IsFileURL(): boolean;
  32520. /**
  32521. * Checks if the window object exists
  32522. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32523. */
  32524. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32525. /**
  32526. * No performance log
  32527. */
  32528. static readonly PerformanceNoneLogLevel: number;
  32529. /**
  32530. * Use user marks to log performance
  32531. */
  32532. static readonly PerformanceUserMarkLogLevel: number;
  32533. /**
  32534. * Log performance to the console
  32535. */
  32536. static readonly PerformanceConsoleLogLevel: number;
  32537. private static _performance;
  32538. /**
  32539. * Sets the current performance log level
  32540. */
  32541. static PerformanceLogLevel: number;
  32542. private static _StartPerformanceCounterDisabled;
  32543. private static _EndPerformanceCounterDisabled;
  32544. private static _StartUserMark;
  32545. private static _EndUserMark;
  32546. private static _StartPerformanceConsole;
  32547. private static _EndPerformanceConsole;
  32548. /**
  32549. * Starts a performance counter
  32550. */
  32551. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32552. /**
  32553. * Ends a specific performance coutner
  32554. */
  32555. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32556. /**
  32557. * Gets either window.performance.now() if supported or Date.now() else
  32558. */
  32559. static readonly Now: number;
  32560. /**
  32561. * This method will return the name of the class used to create the instance of the given object.
  32562. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32563. * @param object the object to get the class name from
  32564. * @param isType defines if the object is actually a type
  32565. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32566. */
  32567. static GetClassName(object: any, isType?: boolean): string;
  32568. /**
  32569. * Gets the first element of an array satisfying a given predicate
  32570. * @param array defines the array to browse
  32571. * @param predicate defines the predicate to use
  32572. * @returns null if not found or the element
  32573. */
  32574. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32575. /**
  32576. * This method will return the name of the full name of the class, including its owning module (if any).
  32577. * 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).
  32578. * @param object the object to get the class name from
  32579. * @param isType defines if the object is actually a type
  32580. * @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.
  32581. * @ignorenaming
  32582. */
  32583. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32584. /**
  32585. * Returns a promise that resolves after the given amount of time.
  32586. * @param delay Number of milliseconds to delay
  32587. * @returns Promise that resolves after the given amount of time
  32588. */
  32589. static DelayAsync(delay: number): Promise<void>;
  32590. /**
  32591. * Gets the current gradient from an array of IValueGradient
  32592. * @param ratio defines the current ratio to get
  32593. * @param gradients defines the array of IValueGradient
  32594. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32595. */
  32596. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32597. }
  32598. /**
  32599. * This class is used to track a performance counter which is number based.
  32600. * The user has access to many properties which give statistics of different nature.
  32601. *
  32602. * The implementer can track two kinds of Performance Counter: time and count.
  32603. * 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.
  32604. * 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.
  32605. */
  32606. export class PerfCounter {
  32607. /**
  32608. * Gets or sets a global boolean to turn on and off all the counters
  32609. */
  32610. static Enabled: boolean;
  32611. /**
  32612. * Returns the smallest value ever
  32613. */
  32614. readonly min: number;
  32615. /**
  32616. * Returns the biggest value ever
  32617. */
  32618. readonly max: number;
  32619. /**
  32620. * Returns the average value since the performance counter is running
  32621. */
  32622. readonly average: number;
  32623. /**
  32624. * Returns the average value of the last second the counter was monitored
  32625. */
  32626. readonly lastSecAverage: number;
  32627. /**
  32628. * Returns the current value
  32629. */
  32630. readonly current: number;
  32631. /**
  32632. * Gets the accumulated total
  32633. */
  32634. readonly total: number;
  32635. /**
  32636. * Gets the total value count
  32637. */
  32638. readonly count: number;
  32639. /**
  32640. * Creates a new counter
  32641. */
  32642. constructor();
  32643. /**
  32644. * Call this method to start monitoring a new frame.
  32645. * 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.
  32646. */
  32647. fetchNewFrame(): void;
  32648. /**
  32649. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32650. * @param newCount the count value to add to the monitored count
  32651. * @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.
  32652. */
  32653. addCount(newCount: number, fetchResult: boolean): void;
  32654. /**
  32655. * Start monitoring this performance counter
  32656. */
  32657. beginMonitoring(): void;
  32658. /**
  32659. * Compute the time lapsed since the previous beginMonitoring() call.
  32660. * @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
  32661. */
  32662. endMonitoring(newFrame?: boolean): void;
  32663. private _fetchResult;
  32664. private _startMonitoringTime;
  32665. private _min;
  32666. private _max;
  32667. private _average;
  32668. private _current;
  32669. private _totalValueCount;
  32670. private _totalAccumulated;
  32671. private _lastSecAverage;
  32672. private _lastSecAccumulated;
  32673. private _lastSecTime;
  32674. private _lastSecValueCount;
  32675. }
  32676. /**
  32677. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32678. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32679. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32680. * @param name The name of the class, case should be preserved
  32681. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32682. */
  32683. export function className(name: string, module?: string): (target: Object) => void;
  32684. /**
  32685. * An implementation of a loop for asynchronous functions.
  32686. */
  32687. export class AsyncLoop {
  32688. /**
  32689. * Defines the number of iterations for the loop
  32690. */
  32691. iterations: number;
  32692. /**
  32693. * Defines the current index of the loop.
  32694. */
  32695. index: number;
  32696. private _done;
  32697. private _fn;
  32698. private _successCallback;
  32699. /**
  32700. * Constructor.
  32701. * @param iterations the number of iterations.
  32702. * @param func the function to run each iteration
  32703. * @param successCallback the callback that will be called upon succesful execution
  32704. * @param offset starting offset.
  32705. */
  32706. constructor(
  32707. /**
  32708. * Defines the number of iterations for the loop
  32709. */
  32710. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32711. /**
  32712. * Execute the next iteration. Must be called after the last iteration was finished.
  32713. */
  32714. executeNext(): void;
  32715. /**
  32716. * Break the loop and run the success callback.
  32717. */
  32718. breakLoop(): void;
  32719. /**
  32720. * Create and run an async loop.
  32721. * @param iterations the number of iterations.
  32722. * @param fn the function to run each iteration
  32723. * @param successCallback the callback that will be called upon succesful execution
  32724. * @param offset starting offset.
  32725. * @returns the created async loop object
  32726. */
  32727. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32728. /**
  32729. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32730. * @param iterations total number of iterations
  32731. * @param syncedIterations number of synchronous iterations in each async iteration.
  32732. * @param fn the function to call each iteration.
  32733. * @param callback a success call back that will be called when iterating stops.
  32734. * @param breakFunction a break condition (optional)
  32735. * @param timeout timeout settings for the setTimeout function. default - 0.
  32736. * @returns the created async loop object
  32737. */
  32738. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32739. }
  32740. }
  32741. declare module "babylonjs/Collisions/collisionCoordinator" {
  32742. import { Nullable } from "babylonjs/types";
  32743. import { Scene } from "babylonjs/scene";
  32744. import { Vector3 } from "babylonjs/Maths/math";
  32745. import { Collider } from "babylonjs/Collisions/collider";
  32746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32747. /** @hidden */
  32748. export interface ICollisionCoordinator {
  32749. createCollider(): Collider;
  32750. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32751. init(scene: Scene): void;
  32752. }
  32753. /** @hidden */
  32754. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32755. private _scene;
  32756. private _scaledPosition;
  32757. private _scaledVelocity;
  32758. private _finalPosition;
  32759. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32760. createCollider(): Collider;
  32761. init(scene: Scene): void;
  32762. private _collideWithWorld;
  32763. }
  32764. }
  32765. declare module "babylonjs/Inputs/scene.inputManager" {
  32766. import { Nullable } from "babylonjs/types";
  32767. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32768. import { Vector2 } from "babylonjs/Maths/math";
  32769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32770. import { Scene } from "babylonjs/scene";
  32771. /**
  32772. * Class used to manage all inputs for the scene.
  32773. */
  32774. export class InputManager {
  32775. /** The distance in pixel that you have to move to prevent some events */
  32776. static DragMovementThreshold: number;
  32777. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32778. static LongPressDelay: number;
  32779. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32780. static DoubleClickDelay: number;
  32781. /** If you need to check double click without raising a single click at first click, enable this flag */
  32782. static ExclusiveDoubleClickMode: boolean;
  32783. private _wheelEventName;
  32784. private _onPointerMove;
  32785. private _onPointerDown;
  32786. private _onPointerUp;
  32787. private _initClickEvent;
  32788. private _initActionManager;
  32789. private _delayedSimpleClick;
  32790. private _delayedSimpleClickTimeout;
  32791. private _previousDelayedSimpleClickTimeout;
  32792. private _meshPickProceed;
  32793. private _previousButtonPressed;
  32794. private _currentPickResult;
  32795. private _previousPickResult;
  32796. private _totalPointersPressed;
  32797. private _doubleClickOccured;
  32798. private _pointerOverMesh;
  32799. private _pickedDownMesh;
  32800. private _pickedUpMesh;
  32801. private _pointerX;
  32802. private _pointerY;
  32803. private _unTranslatedPointerX;
  32804. private _unTranslatedPointerY;
  32805. private _startingPointerPosition;
  32806. private _previousStartingPointerPosition;
  32807. private _startingPointerTime;
  32808. private _previousStartingPointerTime;
  32809. private _pointerCaptures;
  32810. private _onKeyDown;
  32811. private _onKeyUp;
  32812. private _onCanvasFocusObserver;
  32813. private _onCanvasBlurObserver;
  32814. private _scene;
  32815. /**
  32816. * Creates a new InputManager
  32817. * @param scene defines the hosting scene
  32818. */
  32819. constructor(scene: Scene);
  32820. /**
  32821. * Gets the mesh that is currently under the pointer
  32822. */
  32823. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32824. /**
  32825. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32826. */
  32827. readonly unTranslatedPointer: Vector2;
  32828. /**
  32829. * Gets or sets the current on-screen X position of the pointer
  32830. */
  32831. pointerX: number;
  32832. /**
  32833. * Gets or sets the current on-screen Y position of the pointer
  32834. */
  32835. pointerY: number;
  32836. private _updatePointerPosition;
  32837. private _processPointerMove;
  32838. private _setRayOnPointerInfo;
  32839. private _checkPrePointerObservable;
  32840. /**
  32841. * Use this method to simulate a pointer move on a mesh
  32842. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32843. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32844. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32845. */
  32846. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32847. /**
  32848. * Use this method to simulate a pointer down on a mesh
  32849. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32850. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32851. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32852. */
  32853. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32854. private _processPointerDown;
  32855. /** @hidden */
  32856. _isPointerSwiping(): boolean;
  32857. /**
  32858. * Use this method to simulate a pointer up on a mesh
  32859. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32860. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32861. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32862. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32863. */
  32864. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32865. private _processPointerUp;
  32866. /**
  32867. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32868. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32869. * @returns true if the pointer was captured
  32870. */
  32871. isPointerCaptured(pointerId?: number): boolean;
  32872. /**
  32873. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32874. * @param attachUp defines if you want to attach events to pointerup
  32875. * @param attachDown defines if you want to attach events to pointerdown
  32876. * @param attachMove defines if you want to attach events to pointermove
  32877. */
  32878. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32879. /**
  32880. * Detaches all event handlers
  32881. */
  32882. detachControl(): void;
  32883. /**
  32884. * Force the value of meshUnderPointer
  32885. * @param mesh defines the mesh to use
  32886. */
  32887. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32888. /**
  32889. * Gets the mesh under the pointer
  32890. * @returns a Mesh or null if no mesh is under the pointer
  32891. */
  32892. getPointerOverMesh(): Nullable<AbstractMesh>;
  32893. }
  32894. }
  32895. declare module "babylonjs/Animations/animationGroup" {
  32896. import { Animatable } from "babylonjs/Animations/animatable";
  32897. import { Animation } from "babylonjs/Animations/animation";
  32898. import { Scene, IDisposable } from "babylonjs/scene";
  32899. import { Observable } from "babylonjs/Misc/observable";
  32900. import { Nullable } from "babylonjs/types";
  32901. import "babylonjs/Animations/animatable";
  32902. /**
  32903. * This class defines the direct association between an animation and a target
  32904. */
  32905. export class TargetedAnimation {
  32906. /**
  32907. * Animation to perform
  32908. */
  32909. animation: Animation;
  32910. /**
  32911. * Target to animate
  32912. */
  32913. target: any;
  32914. /**
  32915. * Serialize the object
  32916. * @returns the JSON object representing the current entity
  32917. */
  32918. serialize(): any;
  32919. }
  32920. /**
  32921. * Use this class to create coordinated animations on multiple targets
  32922. */
  32923. export class AnimationGroup implements IDisposable {
  32924. /** The name of the animation group */
  32925. name: string;
  32926. private _scene;
  32927. private _targetedAnimations;
  32928. private _animatables;
  32929. private _from;
  32930. private _to;
  32931. private _isStarted;
  32932. private _isPaused;
  32933. private _speedRatio;
  32934. private _loopAnimation;
  32935. /**
  32936. * Gets or sets the unique id of the node
  32937. */
  32938. uniqueId: number;
  32939. /**
  32940. * This observable will notify when one animation have ended
  32941. */
  32942. onAnimationEndObservable: Observable<TargetedAnimation>;
  32943. /**
  32944. * Observer raised when one animation loops
  32945. */
  32946. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32947. /**
  32948. * This observable will notify when all animations have ended.
  32949. */
  32950. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32951. /**
  32952. * This observable will notify when all animations have paused.
  32953. */
  32954. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32955. /**
  32956. * This observable will notify when all animations are playing.
  32957. */
  32958. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32959. /**
  32960. * Gets the first frame
  32961. */
  32962. readonly from: number;
  32963. /**
  32964. * Gets the last frame
  32965. */
  32966. readonly to: number;
  32967. /**
  32968. * Define if the animations are started
  32969. */
  32970. readonly isStarted: boolean;
  32971. /**
  32972. * Gets a value indicating that the current group is playing
  32973. */
  32974. readonly isPlaying: boolean;
  32975. /**
  32976. * Gets or sets the speed ratio to use for all animations
  32977. */
  32978. /**
  32979. * Gets or sets the speed ratio to use for all animations
  32980. */
  32981. speedRatio: number;
  32982. /**
  32983. * Gets or sets if all animations should loop or not
  32984. */
  32985. loopAnimation: boolean;
  32986. /**
  32987. * Gets the targeted animations for this animation group
  32988. */
  32989. readonly targetedAnimations: Array<TargetedAnimation>;
  32990. /**
  32991. * returning the list of animatables controlled by this animation group.
  32992. */
  32993. readonly animatables: Array<Animatable>;
  32994. /**
  32995. * Instantiates a new Animation Group.
  32996. * This helps managing several animations at once.
  32997. * @see http://doc.babylonjs.com/how_to/group
  32998. * @param name Defines the name of the group
  32999. * @param scene Defines the scene the group belongs to
  33000. */
  33001. constructor(
  33002. /** The name of the animation group */
  33003. name: string, scene?: Nullable<Scene>);
  33004. /**
  33005. * Add an animation (with its target) in the group
  33006. * @param animation defines the animation we want to add
  33007. * @param target defines the target of the animation
  33008. * @returns the TargetedAnimation object
  33009. */
  33010. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33011. /**
  33012. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33013. * It can add constant keys at begin or end
  33014. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33015. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33016. * @returns the animation group
  33017. */
  33018. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33019. /**
  33020. * Start all animations on given targets
  33021. * @param loop defines if animations must loop
  33022. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33023. * @param from defines the from key (optional)
  33024. * @param to defines the to key (optional)
  33025. * @returns the current animation group
  33026. */
  33027. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33028. /**
  33029. * Pause all animations
  33030. * @returns the animation group
  33031. */
  33032. pause(): AnimationGroup;
  33033. /**
  33034. * Play all animations to initial state
  33035. * This function will start() the animations if they were not started or will restart() them if they were paused
  33036. * @param loop defines if animations must loop
  33037. * @returns the animation group
  33038. */
  33039. play(loop?: boolean): AnimationGroup;
  33040. /**
  33041. * Reset all animations to initial state
  33042. * @returns the animation group
  33043. */
  33044. reset(): AnimationGroup;
  33045. /**
  33046. * Restart animations from key 0
  33047. * @returns the animation group
  33048. */
  33049. restart(): AnimationGroup;
  33050. /**
  33051. * Stop all animations
  33052. * @returns the animation group
  33053. */
  33054. stop(): AnimationGroup;
  33055. /**
  33056. * Set animation weight for all animatables
  33057. * @param weight defines the weight to use
  33058. * @return the animationGroup
  33059. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33060. */
  33061. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33062. /**
  33063. * Synchronize and normalize all animatables with a source animatable
  33064. * @param root defines the root animatable to synchronize with
  33065. * @return the animationGroup
  33066. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33067. */
  33068. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33069. /**
  33070. * Goes to a specific frame in this animation group
  33071. * @param frame the frame number to go to
  33072. * @return the animationGroup
  33073. */
  33074. goToFrame(frame: number): AnimationGroup;
  33075. /**
  33076. * Dispose all associated resources
  33077. */
  33078. dispose(): void;
  33079. private _checkAnimationGroupEnded;
  33080. /**
  33081. * Clone the current animation group and returns a copy
  33082. * @param newName defines the name of the new group
  33083. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33084. * @returns the new aniamtion group
  33085. */
  33086. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33087. /**
  33088. * Serializes the animationGroup to an object
  33089. * @returns Serialized object
  33090. */
  33091. serialize(): any;
  33092. /**
  33093. * Returns a new AnimationGroup object parsed from the source provided.
  33094. * @param parsedAnimationGroup defines the source
  33095. * @param scene defines the scene that will receive the animationGroup
  33096. * @returns a new AnimationGroup
  33097. */
  33098. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33099. /**
  33100. * Returns the string "AnimationGroup"
  33101. * @returns "AnimationGroup"
  33102. */
  33103. getClassName(): string;
  33104. /**
  33105. * Creates a detailled string about the object
  33106. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33107. * @returns a string representing the object
  33108. */
  33109. toString(fullDetails?: boolean): string;
  33110. }
  33111. }
  33112. declare module "babylonjs/scene" {
  33113. import { Nullable } from "babylonjs/types";
  33114. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  33115. import { Observable } from "babylonjs/Misc/observable";
  33116. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33117. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  33118. import { Geometry } from "babylonjs/Meshes/geometry";
  33119. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33120. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33122. import { Mesh } from "babylonjs/Meshes/mesh";
  33123. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33124. import { Bone } from "babylonjs/Bones/bone";
  33125. import { Skeleton } from "babylonjs/Bones/skeleton";
  33126. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33127. import { Camera } from "babylonjs/Cameras/camera";
  33128. import { AbstractScene } from "babylonjs/abstractScene";
  33129. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33130. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33131. import { Material } from "babylonjs/Materials/material";
  33132. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33133. import { Effect } from "babylonjs/Materials/effect";
  33134. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33135. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33136. import { Light } from "babylonjs/Lights/light";
  33137. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33138. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33139. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33140. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33141. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33142. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33143. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33144. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33145. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33146. import { Engine } from "babylonjs/Engines/engine";
  33147. import { Node } from "babylonjs/node";
  33148. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33149. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33150. import { WebRequest } from "babylonjs/Misc/webRequest";
  33151. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33152. import { Ray } from "babylonjs/Culling/ray";
  33153. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33154. import { Animation } from "babylonjs/Animations/animation";
  33155. import { Animatable } from "babylonjs/Animations/animatable";
  33156. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33157. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33158. import { Collider } from "babylonjs/Collisions/collider";
  33159. /**
  33160. * Define an interface for all classes that will hold resources
  33161. */
  33162. export interface IDisposable {
  33163. /**
  33164. * Releases all held resources
  33165. */
  33166. dispose(): void;
  33167. }
  33168. /** Interface defining initialization parameters for Scene class */
  33169. export interface SceneOptions {
  33170. /**
  33171. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33172. * It will improve performance when the number of geometries becomes important.
  33173. */
  33174. useGeometryUniqueIdsMap?: boolean;
  33175. /**
  33176. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33177. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33178. */
  33179. useMaterialMeshMap?: boolean;
  33180. /**
  33181. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33182. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33183. */
  33184. useClonedMeshhMap?: boolean;
  33185. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33186. virtual?: boolean;
  33187. }
  33188. /**
  33189. * Represents a scene to be rendered by the engine.
  33190. * @see http://doc.babylonjs.com/features/scene
  33191. */
  33192. export class Scene extends AbstractScene implements IAnimatable {
  33193. private static _uniqueIdCounter;
  33194. /** The fog is deactivated */
  33195. static readonly FOGMODE_NONE: number;
  33196. /** The fog density is following an exponential function */
  33197. static readonly FOGMODE_EXP: number;
  33198. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33199. static readonly FOGMODE_EXP2: number;
  33200. /** The fog density is following a linear function. */
  33201. static readonly FOGMODE_LINEAR: number;
  33202. /**
  33203. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33204. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33205. */
  33206. static MinDeltaTime: number;
  33207. /**
  33208. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33209. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33210. */
  33211. static MaxDeltaTime: number;
  33212. /**
  33213. * Factory used to create the default material.
  33214. * @param name The name of the material to create
  33215. * @param scene The scene to create the material for
  33216. * @returns The default material
  33217. */
  33218. static DefaultMaterialFactory(scene: Scene): Material;
  33219. /**
  33220. * Factory used to create the a collision coordinator.
  33221. * @returns The collision coordinator
  33222. */
  33223. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33224. /** @hidden */
  33225. _inputManager: InputManager;
  33226. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33227. cameraToUseForPointers: Nullable<Camera>;
  33228. /** @hidden */
  33229. readonly _isScene: boolean;
  33230. /**
  33231. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33232. */
  33233. autoClear: boolean;
  33234. /**
  33235. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33236. */
  33237. autoClearDepthAndStencil: boolean;
  33238. /**
  33239. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33240. */
  33241. clearColor: Color4;
  33242. /**
  33243. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33244. */
  33245. ambientColor: Color3;
  33246. /**
  33247. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33248. * It should only be one of the following (if not the default embedded one):
  33249. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33250. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33251. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33252. * The material properties need to be setup according to the type of texture in use.
  33253. */
  33254. environmentBRDFTexture: BaseTexture;
  33255. /** @hidden */
  33256. protected _environmentTexture: Nullable<BaseTexture>;
  33257. /**
  33258. * Texture used in all pbr material as the reflection texture.
  33259. * As in the majority of the scene they are the same (exception for multi room and so on),
  33260. * this is easier to reference from here than from all the materials.
  33261. */
  33262. /**
  33263. * Texture used in all pbr material as the reflection texture.
  33264. * As in the majority of the scene they are the same (exception for multi room and so on),
  33265. * this is easier to set here than in all the materials.
  33266. */
  33267. environmentTexture: Nullable<BaseTexture>;
  33268. /** @hidden */
  33269. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33270. /**
  33271. * Default image processing configuration used either in the rendering
  33272. * Forward main pass or through the imageProcessingPostProcess if present.
  33273. * As in the majority of the scene they are the same (exception for multi camera),
  33274. * this is easier to reference from here than from all the materials and post process.
  33275. *
  33276. * No setter as we it is a shared configuration, you can set the values instead.
  33277. */
  33278. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33279. private _forceWireframe;
  33280. /**
  33281. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33282. */
  33283. forceWireframe: boolean;
  33284. private _forcePointsCloud;
  33285. /**
  33286. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33287. */
  33288. forcePointsCloud: boolean;
  33289. /**
  33290. * Gets or sets the active clipplane 1
  33291. */
  33292. clipPlane: Nullable<Plane>;
  33293. /**
  33294. * Gets or sets the active clipplane 2
  33295. */
  33296. clipPlane2: Nullable<Plane>;
  33297. /**
  33298. * Gets or sets the active clipplane 3
  33299. */
  33300. clipPlane3: Nullable<Plane>;
  33301. /**
  33302. * Gets or sets the active clipplane 4
  33303. */
  33304. clipPlane4: Nullable<Plane>;
  33305. /**
  33306. * Gets or sets a boolean indicating if animations are enabled
  33307. */
  33308. animationsEnabled: boolean;
  33309. private _animationPropertiesOverride;
  33310. /**
  33311. * Gets or sets the animation properties override
  33312. */
  33313. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33314. /**
  33315. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33316. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33317. */
  33318. useConstantAnimationDeltaTime: boolean;
  33319. /**
  33320. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33321. * Please note that it requires to run a ray cast through the scene on every frame
  33322. */
  33323. constantlyUpdateMeshUnderPointer: boolean;
  33324. /**
  33325. * Defines the HTML cursor to use when hovering over interactive elements
  33326. */
  33327. hoverCursor: string;
  33328. /**
  33329. * Defines the HTML default cursor to use (empty by default)
  33330. */
  33331. defaultCursor: string;
  33332. /**
  33333. * This is used to call preventDefault() on pointer down
  33334. * in order to block unwanted artifacts like system double clicks
  33335. */
  33336. preventDefaultOnPointerDown: boolean;
  33337. /**
  33338. * This is used to call preventDefault() on pointer up
  33339. * in order to block unwanted artifacts like system double clicks
  33340. */
  33341. preventDefaultOnPointerUp: boolean;
  33342. /**
  33343. * Gets or sets user defined metadata
  33344. */
  33345. metadata: any;
  33346. /**
  33347. * For internal use only. Please do not use.
  33348. */
  33349. reservedDataStore: any;
  33350. /**
  33351. * Gets the name of the plugin used to load this scene (null by default)
  33352. */
  33353. loadingPluginName: string;
  33354. /**
  33355. * Use this array to add regular expressions used to disable offline support for specific urls
  33356. */
  33357. disableOfflineSupportExceptionRules: RegExp[];
  33358. /**
  33359. * An event triggered when the scene is disposed.
  33360. */
  33361. onDisposeObservable: Observable<Scene>;
  33362. private _onDisposeObserver;
  33363. /** Sets a function to be executed when this scene is disposed. */
  33364. onDispose: () => void;
  33365. /**
  33366. * An event triggered before rendering the scene (right after animations and physics)
  33367. */
  33368. onBeforeRenderObservable: Observable<Scene>;
  33369. private _onBeforeRenderObserver;
  33370. /** Sets a function to be executed before rendering this scene */
  33371. beforeRender: Nullable<() => void>;
  33372. /**
  33373. * An event triggered after rendering the scene
  33374. */
  33375. onAfterRenderObservable: Observable<Scene>;
  33376. /**
  33377. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33378. */
  33379. onAfterRenderCameraObservable: Observable<Camera>;
  33380. private _onAfterRenderObserver;
  33381. /** Sets a function to be executed after rendering this scene */
  33382. afterRender: Nullable<() => void>;
  33383. /**
  33384. * An event triggered before animating the scene
  33385. */
  33386. onBeforeAnimationsObservable: Observable<Scene>;
  33387. /**
  33388. * An event triggered after animations processing
  33389. */
  33390. onAfterAnimationsObservable: Observable<Scene>;
  33391. /**
  33392. * An event triggered before draw calls are ready to be sent
  33393. */
  33394. onBeforeDrawPhaseObservable: Observable<Scene>;
  33395. /**
  33396. * An event triggered after draw calls have been sent
  33397. */
  33398. onAfterDrawPhaseObservable: Observable<Scene>;
  33399. /**
  33400. * An event triggered when the scene is ready
  33401. */
  33402. onReadyObservable: Observable<Scene>;
  33403. /**
  33404. * An event triggered before rendering a camera
  33405. */
  33406. onBeforeCameraRenderObservable: Observable<Camera>;
  33407. private _onBeforeCameraRenderObserver;
  33408. /** Sets a function to be executed before rendering a camera*/
  33409. beforeCameraRender: () => void;
  33410. /**
  33411. * An event triggered after rendering a camera
  33412. */
  33413. onAfterCameraRenderObservable: Observable<Camera>;
  33414. private _onAfterCameraRenderObserver;
  33415. /** Sets a function to be executed after rendering a camera*/
  33416. afterCameraRender: () => void;
  33417. /**
  33418. * An event triggered when active meshes evaluation is about to start
  33419. */
  33420. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33421. /**
  33422. * An event triggered when active meshes evaluation is done
  33423. */
  33424. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33425. /**
  33426. * An event triggered when particles rendering is about to start
  33427. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33428. */
  33429. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33430. /**
  33431. * An event triggered when particles rendering is done
  33432. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33433. */
  33434. onAfterParticlesRenderingObservable: Observable<Scene>;
  33435. /**
  33436. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33437. */
  33438. onDataLoadedObservable: Observable<Scene>;
  33439. /**
  33440. * An event triggered when a camera is created
  33441. */
  33442. onNewCameraAddedObservable: Observable<Camera>;
  33443. /**
  33444. * An event triggered when a camera is removed
  33445. */
  33446. onCameraRemovedObservable: Observable<Camera>;
  33447. /**
  33448. * An event triggered when a light is created
  33449. */
  33450. onNewLightAddedObservable: Observable<Light>;
  33451. /**
  33452. * An event triggered when a light is removed
  33453. */
  33454. onLightRemovedObservable: Observable<Light>;
  33455. /**
  33456. * An event triggered when a geometry is created
  33457. */
  33458. onNewGeometryAddedObservable: Observable<Geometry>;
  33459. /**
  33460. * An event triggered when a geometry is removed
  33461. */
  33462. onGeometryRemovedObservable: Observable<Geometry>;
  33463. /**
  33464. * An event triggered when a transform node is created
  33465. */
  33466. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33467. /**
  33468. * An event triggered when a transform node is removed
  33469. */
  33470. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33471. /**
  33472. * An event triggered when a mesh is created
  33473. */
  33474. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33475. /**
  33476. * An event triggered when a mesh is removed
  33477. */
  33478. onMeshRemovedObservable: Observable<AbstractMesh>;
  33479. /**
  33480. * An event triggered when a skeleton is created
  33481. */
  33482. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33483. /**
  33484. * An event triggered when a skeleton is removed
  33485. */
  33486. onSkeletonRemovedObservable: Observable<Skeleton>;
  33487. /**
  33488. * An event triggered when a material is created
  33489. */
  33490. onNewMaterialAddedObservable: Observable<Material>;
  33491. /**
  33492. * An event triggered when a material is removed
  33493. */
  33494. onMaterialRemovedObservable: Observable<Material>;
  33495. /**
  33496. * An event triggered when a texture is created
  33497. */
  33498. onNewTextureAddedObservable: Observable<BaseTexture>;
  33499. /**
  33500. * An event triggered when a texture is removed
  33501. */
  33502. onTextureRemovedObservable: Observable<BaseTexture>;
  33503. /**
  33504. * An event triggered when render targets are about to be rendered
  33505. * Can happen multiple times per frame.
  33506. */
  33507. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33508. /**
  33509. * An event triggered when render targets were rendered.
  33510. * Can happen multiple times per frame.
  33511. */
  33512. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33513. /**
  33514. * An event triggered before calculating deterministic simulation step
  33515. */
  33516. onBeforeStepObservable: Observable<Scene>;
  33517. /**
  33518. * An event triggered after calculating deterministic simulation step
  33519. */
  33520. onAfterStepObservable: Observable<Scene>;
  33521. /**
  33522. * An event triggered when the activeCamera property is updated
  33523. */
  33524. onActiveCameraChanged: Observable<Scene>;
  33525. /**
  33526. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33527. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33528. * 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)
  33529. */
  33530. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33531. /**
  33532. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33533. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33534. * 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)
  33535. */
  33536. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33537. /**
  33538. * This Observable will when a mesh has been imported into the scene.
  33539. */
  33540. onMeshImportedObservable: Observable<AbstractMesh>;
  33541. /**
  33542. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33543. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33544. */
  33545. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33546. /** @hidden */
  33547. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33548. /**
  33549. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33550. */
  33551. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33552. /**
  33553. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33554. */
  33555. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33556. /**
  33557. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33558. */
  33559. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33560. /** Callback called when a pointer move is detected */
  33561. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33562. /** Callback called when a pointer down is detected */
  33563. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33564. /** Callback called when a pointer up is detected */
  33565. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33566. /** Callback called when a pointer pick is detected */
  33567. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33568. /**
  33569. * 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).
  33570. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33571. */
  33572. onPrePointerObservable: Observable<PointerInfoPre>;
  33573. /**
  33574. * Observable event triggered each time an input event is received from the rendering canvas
  33575. */
  33576. onPointerObservable: Observable<PointerInfo>;
  33577. /**
  33578. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33579. */
  33580. readonly unTranslatedPointer: Vector2;
  33581. /**
  33582. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33583. */
  33584. static DragMovementThreshold: number;
  33585. /**
  33586. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33587. */
  33588. static LongPressDelay: number;
  33589. /**
  33590. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33591. */
  33592. static DoubleClickDelay: number;
  33593. /** If you need to check double click without raising a single click at first click, enable this flag */
  33594. static ExclusiveDoubleClickMode: boolean;
  33595. /** @hidden */
  33596. _mirroredCameraPosition: Nullable<Vector3>;
  33597. /**
  33598. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33599. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33600. */
  33601. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33602. /**
  33603. * Observable event triggered each time an keyboard event is received from the hosting window
  33604. */
  33605. onKeyboardObservable: Observable<KeyboardInfo>;
  33606. private _useRightHandedSystem;
  33607. /**
  33608. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33609. */
  33610. useRightHandedSystem: boolean;
  33611. private _timeAccumulator;
  33612. private _currentStepId;
  33613. private _currentInternalStep;
  33614. /**
  33615. * Sets the step Id used by deterministic lock step
  33616. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33617. * @param newStepId defines the step Id
  33618. */
  33619. setStepId(newStepId: number): void;
  33620. /**
  33621. * Gets the step Id used by deterministic lock step
  33622. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33623. * @returns the step Id
  33624. */
  33625. getStepId(): number;
  33626. /**
  33627. * Gets the internal step used by deterministic lock step
  33628. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33629. * @returns the internal step
  33630. */
  33631. getInternalStep(): number;
  33632. private _fogEnabled;
  33633. /**
  33634. * Gets or sets a boolean indicating if fog is enabled on this scene
  33635. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33636. * (Default is true)
  33637. */
  33638. fogEnabled: boolean;
  33639. private _fogMode;
  33640. /**
  33641. * Gets or sets the fog mode to use
  33642. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33643. * | mode | value |
  33644. * | --- | --- |
  33645. * | FOGMODE_NONE | 0 |
  33646. * | FOGMODE_EXP | 1 |
  33647. * | FOGMODE_EXP2 | 2 |
  33648. * | FOGMODE_LINEAR | 3 |
  33649. */
  33650. fogMode: number;
  33651. /**
  33652. * Gets or sets the fog color to use
  33653. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33654. * (Default is Color3(0.2, 0.2, 0.3))
  33655. */
  33656. fogColor: Color3;
  33657. /**
  33658. * Gets or sets the fog density to use
  33659. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33660. * (Default is 0.1)
  33661. */
  33662. fogDensity: number;
  33663. /**
  33664. * Gets or sets the fog start distance to use
  33665. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33666. * (Default is 0)
  33667. */
  33668. fogStart: number;
  33669. /**
  33670. * Gets or sets the fog end distance to use
  33671. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33672. * (Default is 1000)
  33673. */
  33674. fogEnd: number;
  33675. private _shadowsEnabled;
  33676. /**
  33677. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33678. */
  33679. shadowsEnabled: boolean;
  33680. private _lightsEnabled;
  33681. /**
  33682. * Gets or sets a boolean indicating if lights are enabled on this scene
  33683. */
  33684. lightsEnabled: boolean;
  33685. /** All of the active cameras added to this scene. */
  33686. activeCameras: Camera[];
  33687. /** @hidden */
  33688. _activeCamera: Nullable<Camera>;
  33689. /** Gets or sets the current active camera */
  33690. activeCamera: Nullable<Camera>;
  33691. private _defaultMaterial;
  33692. /** The default material used on meshes when no material is affected */
  33693. /** The default material used on meshes when no material is affected */
  33694. defaultMaterial: Material;
  33695. private _texturesEnabled;
  33696. /**
  33697. * Gets or sets a boolean indicating if textures are enabled on this scene
  33698. */
  33699. texturesEnabled: boolean;
  33700. /**
  33701. * Gets or sets a boolean indicating if particles are enabled on this scene
  33702. */
  33703. particlesEnabled: boolean;
  33704. /**
  33705. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33706. */
  33707. spritesEnabled: boolean;
  33708. private _skeletonsEnabled;
  33709. /**
  33710. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33711. */
  33712. skeletonsEnabled: boolean;
  33713. /**
  33714. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33715. */
  33716. lensFlaresEnabled: boolean;
  33717. /**
  33718. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33719. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33720. */
  33721. collisionsEnabled: boolean;
  33722. private _collisionCoordinator;
  33723. /** @hidden */
  33724. readonly collisionCoordinator: ICollisionCoordinator;
  33725. /**
  33726. * Defines the gravity applied to this scene (used only for collisions)
  33727. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33728. */
  33729. gravity: Vector3;
  33730. /**
  33731. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33732. */
  33733. postProcessesEnabled: boolean;
  33734. /**
  33735. * The list of postprocesses added to the scene
  33736. */
  33737. postProcesses: PostProcess[];
  33738. /**
  33739. * Gets the current postprocess manager
  33740. */
  33741. postProcessManager: PostProcessManager;
  33742. /**
  33743. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33744. */
  33745. renderTargetsEnabled: boolean;
  33746. /**
  33747. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33748. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33749. */
  33750. dumpNextRenderTargets: boolean;
  33751. /**
  33752. * The list of user defined render targets added to the scene
  33753. */
  33754. customRenderTargets: RenderTargetTexture[];
  33755. /**
  33756. * Defines if texture loading must be delayed
  33757. * If true, textures will only be loaded when they need to be rendered
  33758. */
  33759. useDelayedTextureLoading: boolean;
  33760. /**
  33761. * Gets the list of meshes imported to the scene through SceneLoader
  33762. */
  33763. importedMeshesFiles: String[];
  33764. /**
  33765. * Gets or sets a boolean indicating if probes are enabled on this scene
  33766. */
  33767. probesEnabled: boolean;
  33768. /**
  33769. * Gets or sets the current offline provider to use to store scene data
  33770. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33771. */
  33772. offlineProvider: IOfflineProvider;
  33773. /**
  33774. * Gets or sets the action manager associated with the scene
  33775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33776. */
  33777. actionManager: AbstractActionManager;
  33778. private _meshesForIntersections;
  33779. /**
  33780. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33781. */
  33782. proceduralTexturesEnabled: boolean;
  33783. private _engine;
  33784. private _totalVertices;
  33785. /** @hidden */
  33786. _activeIndices: PerfCounter;
  33787. /** @hidden */
  33788. _activeParticles: PerfCounter;
  33789. /** @hidden */
  33790. _activeBones: PerfCounter;
  33791. private _animationRatio;
  33792. /** @hidden */
  33793. _animationTimeLast: number;
  33794. /** @hidden */
  33795. _animationTime: number;
  33796. /**
  33797. * Gets or sets a general scale for animation speed
  33798. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33799. */
  33800. animationTimeScale: number;
  33801. /** @hidden */
  33802. _cachedMaterial: Nullable<Material>;
  33803. /** @hidden */
  33804. _cachedEffect: Nullable<Effect>;
  33805. /** @hidden */
  33806. _cachedVisibility: Nullable<number>;
  33807. private _renderId;
  33808. private _frameId;
  33809. private _executeWhenReadyTimeoutId;
  33810. private _intermediateRendering;
  33811. private _viewUpdateFlag;
  33812. private _projectionUpdateFlag;
  33813. /** @hidden */
  33814. _toBeDisposed: Nullable<IDisposable>[];
  33815. private _activeRequests;
  33816. /** @hidden */
  33817. _pendingData: any[];
  33818. private _isDisposed;
  33819. /**
  33820. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33821. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33822. */
  33823. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33824. private _activeMeshes;
  33825. private _processedMaterials;
  33826. private _renderTargets;
  33827. /** @hidden */
  33828. _activeParticleSystems: SmartArray<IParticleSystem>;
  33829. private _activeSkeletons;
  33830. private _softwareSkinnedMeshes;
  33831. private _renderingManager;
  33832. /** @hidden */
  33833. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33834. private _transformMatrix;
  33835. private _sceneUbo;
  33836. /** @hidden */
  33837. _viewMatrix: Matrix;
  33838. private _projectionMatrix;
  33839. /** @hidden */
  33840. _forcedViewPosition: Nullable<Vector3>;
  33841. /** @hidden */
  33842. _frustumPlanes: Plane[];
  33843. /**
  33844. * Gets the list of frustum planes (built from the active camera)
  33845. */
  33846. readonly frustumPlanes: Plane[];
  33847. /**
  33848. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33849. * This is useful if there are more lights that the maximum simulteanous authorized
  33850. */
  33851. requireLightSorting: boolean;
  33852. /** @hidden */
  33853. readonly useMaterialMeshMap: boolean;
  33854. /** @hidden */
  33855. readonly useClonedMeshhMap: boolean;
  33856. private _externalData;
  33857. private _uid;
  33858. /**
  33859. * @hidden
  33860. * Backing store of defined scene components.
  33861. */
  33862. _components: ISceneComponent[];
  33863. /**
  33864. * @hidden
  33865. * Backing store of defined scene components.
  33866. */
  33867. _serializableComponents: ISceneSerializableComponent[];
  33868. /**
  33869. * List of components to register on the next registration step.
  33870. */
  33871. private _transientComponents;
  33872. /**
  33873. * Registers the transient components if needed.
  33874. */
  33875. private _registerTransientComponents;
  33876. /**
  33877. * @hidden
  33878. * Add a component to the scene.
  33879. * Note that the ccomponent could be registered on th next frame if this is called after
  33880. * the register component stage.
  33881. * @param component Defines the component to add to the scene
  33882. */
  33883. _addComponent(component: ISceneComponent): void;
  33884. /**
  33885. * @hidden
  33886. * Gets a component from the scene.
  33887. * @param name defines the name of the component to retrieve
  33888. * @returns the component or null if not present
  33889. */
  33890. _getComponent(name: string): Nullable<ISceneComponent>;
  33891. /**
  33892. * @hidden
  33893. * Defines the actions happening before camera updates.
  33894. */
  33895. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33896. /**
  33897. * @hidden
  33898. * Defines the actions happening before clear the canvas.
  33899. */
  33900. _beforeClearStage: Stage<SimpleStageAction>;
  33901. /**
  33902. * @hidden
  33903. * Defines the actions when collecting render targets for the frame.
  33904. */
  33905. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33906. /**
  33907. * @hidden
  33908. * Defines the actions happening for one camera in the frame.
  33909. */
  33910. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33911. /**
  33912. * @hidden
  33913. * Defines the actions happening during the per mesh ready checks.
  33914. */
  33915. _isReadyForMeshStage: Stage<MeshStageAction>;
  33916. /**
  33917. * @hidden
  33918. * Defines the actions happening before evaluate active mesh checks.
  33919. */
  33920. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33921. /**
  33922. * @hidden
  33923. * Defines the actions happening during the evaluate sub mesh checks.
  33924. */
  33925. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33926. /**
  33927. * @hidden
  33928. * Defines the actions happening during the active mesh stage.
  33929. */
  33930. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33931. /**
  33932. * @hidden
  33933. * Defines the actions happening during the per camera render target step.
  33934. */
  33935. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33936. /**
  33937. * @hidden
  33938. * Defines the actions happening just before the active camera is drawing.
  33939. */
  33940. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33941. /**
  33942. * @hidden
  33943. * Defines the actions happening just before a render target is drawing.
  33944. */
  33945. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33946. /**
  33947. * @hidden
  33948. * Defines the actions happening just before a rendering group is drawing.
  33949. */
  33950. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33951. /**
  33952. * @hidden
  33953. * Defines the actions happening just before a mesh is drawing.
  33954. */
  33955. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33956. /**
  33957. * @hidden
  33958. * Defines the actions happening just after a mesh has been drawn.
  33959. */
  33960. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33961. /**
  33962. * @hidden
  33963. * Defines the actions happening just after a rendering group has been drawn.
  33964. */
  33965. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33966. /**
  33967. * @hidden
  33968. * Defines the actions happening just after the active camera has been drawn.
  33969. */
  33970. _afterCameraDrawStage: Stage<CameraStageAction>;
  33971. /**
  33972. * @hidden
  33973. * Defines the actions happening just after a render target has been drawn.
  33974. */
  33975. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33976. /**
  33977. * @hidden
  33978. * Defines the actions happening just after rendering all cameras and computing intersections.
  33979. */
  33980. _afterRenderStage: Stage<SimpleStageAction>;
  33981. /**
  33982. * @hidden
  33983. * Defines the actions happening when a pointer move event happens.
  33984. */
  33985. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33986. /**
  33987. * @hidden
  33988. * Defines the actions happening when a pointer down event happens.
  33989. */
  33990. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33991. /**
  33992. * @hidden
  33993. * Defines the actions happening when a pointer up event happens.
  33994. */
  33995. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33996. /**
  33997. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33998. */
  33999. private geometriesByUniqueId;
  34000. /**
  34001. * Creates a new Scene
  34002. * @param engine defines the engine to use to render this scene
  34003. * @param options defines the scene options
  34004. */
  34005. constructor(engine: Engine, options?: SceneOptions);
  34006. /**
  34007. * Gets a string idenfifying the name of the class
  34008. * @returns "Scene" string
  34009. */
  34010. getClassName(): string;
  34011. private _defaultMeshCandidates;
  34012. /**
  34013. * @hidden
  34014. */
  34015. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34016. private _defaultSubMeshCandidates;
  34017. /**
  34018. * @hidden
  34019. */
  34020. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34021. /**
  34022. * Sets the default candidate providers for the scene.
  34023. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34024. * and getCollidingSubMeshCandidates to their default function
  34025. */
  34026. setDefaultCandidateProviders(): void;
  34027. /**
  34028. * Gets the mesh that is currently under the pointer
  34029. */
  34030. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34031. /**
  34032. * Gets or sets the current on-screen X position of the pointer
  34033. */
  34034. pointerX: number;
  34035. /**
  34036. * Gets or sets the current on-screen Y position of the pointer
  34037. */
  34038. pointerY: number;
  34039. /**
  34040. * Gets the cached material (ie. the latest rendered one)
  34041. * @returns the cached material
  34042. */
  34043. getCachedMaterial(): Nullable<Material>;
  34044. /**
  34045. * Gets the cached effect (ie. the latest rendered one)
  34046. * @returns the cached effect
  34047. */
  34048. getCachedEffect(): Nullable<Effect>;
  34049. /**
  34050. * Gets the cached visibility state (ie. the latest rendered one)
  34051. * @returns the cached visibility state
  34052. */
  34053. getCachedVisibility(): Nullable<number>;
  34054. /**
  34055. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34056. * @param material defines the current material
  34057. * @param effect defines the current effect
  34058. * @param visibility defines the current visibility state
  34059. * @returns true if one parameter is not cached
  34060. */
  34061. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34062. /**
  34063. * Gets the engine associated with the scene
  34064. * @returns an Engine
  34065. */
  34066. getEngine(): Engine;
  34067. /**
  34068. * Gets the total number of vertices rendered per frame
  34069. * @returns the total number of vertices rendered per frame
  34070. */
  34071. getTotalVertices(): number;
  34072. /**
  34073. * Gets the performance counter for total vertices
  34074. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34075. */
  34076. readonly totalVerticesPerfCounter: PerfCounter;
  34077. /**
  34078. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34079. * @returns the total number of active indices rendered per frame
  34080. */
  34081. getActiveIndices(): number;
  34082. /**
  34083. * Gets the performance counter for active indices
  34084. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34085. */
  34086. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34087. /**
  34088. * Gets the total number of active particles rendered per frame
  34089. * @returns the total number of active particles rendered per frame
  34090. */
  34091. getActiveParticles(): number;
  34092. /**
  34093. * Gets the performance counter for active particles
  34094. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34095. */
  34096. readonly activeParticlesPerfCounter: PerfCounter;
  34097. /**
  34098. * Gets the total number of active bones rendered per frame
  34099. * @returns the total number of active bones rendered per frame
  34100. */
  34101. getActiveBones(): number;
  34102. /**
  34103. * Gets the performance counter for active bones
  34104. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34105. */
  34106. readonly activeBonesPerfCounter: PerfCounter;
  34107. /**
  34108. * Gets the array of active meshes
  34109. * @returns an array of AbstractMesh
  34110. */
  34111. getActiveMeshes(): SmartArray<AbstractMesh>;
  34112. /**
  34113. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34114. * @returns a number
  34115. */
  34116. getAnimationRatio(): number;
  34117. /**
  34118. * Gets an unique Id for the current render phase
  34119. * @returns a number
  34120. */
  34121. getRenderId(): number;
  34122. /**
  34123. * Gets an unique Id for the current frame
  34124. * @returns a number
  34125. */
  34126. getFrameId(): number;
  34127. /** Call this function if you want to manually increment the render Id*/
  34128. incrementRenderId(): void;
  34129. private _createUbo;
  34130. /**
  34131. * Use this method to simulate a pointer move on a mesh
  34132. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34133. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34134. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34135. * @returns the current scene
  34136. */
  34137. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34138. /**
  34139. * Use this method to simulate a pointer down on a mesh
  34140. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34141. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34142. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34143. * @returns the current scene
  34144. */
  34145. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34146. /**
  34147. * Use this method to simulate a pointer up on a mesh
  34148. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34149. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34150. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34151. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34152. * @returns the current scene
  34153. */
  34154. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34155. /**
  34156. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34157. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34158. * @returns true if the pointer was captured
  34159. */
  34160. isPointerCaptured(pointerId?: number): boolean;
  34161. /**
  34162. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34163. * @param attachUp defines if you want to attach events to pointerup
  34164. * @param attachDown defines if you want to attach events to pointerdown
  34165. * @param attachMove defines if you want to attach events to pointermove
  34166. */
  34167. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34168. /** Detaches all event handlers*/
  34169. detachControl(): void;
  34170. /**
  34171. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34172. * Delay loaded resources are not taking in account
  34173. * @return true if all required resources are ready
  34174. */
  34175. isReady(): boolean;
  34176. /** Resets all cached information relative to material (including effect and visibility) */
  34177. resetCachedMaterial(): void;
  34178. /**
  34179. * Registers a function to be called before every frame render
  34180. * @param func defines the function to register
  34181. */
  34182. registerBeforeRender(func: () => void): void;
  34183. /**
  34184. * Unregisters a function called before every frame render
  34185. * @param func defines the function to unregister
  34186. */
  34187. unregisterBeforeRender(func: () => void): void;
  34188. /**
  34189. * Registers a function to be called after every frame render
  34190. * @param func defines the function to register
  34191. */
  34192. registerAfterRender(func: () => void): void;
  34193. /**
  34194. * Unregisters a function called after every frame render
  34195. * @param func defines the function to unregister
  34196. */
  34197. unregisterAfterRender(func: () => void): void;
  34198. private _executeOnceBeforeRender;
  34199. /**
  34200. * The provided function will run before render once and will be disposed afterwards.
  34201. * A timeout delay can be provided so that the function will be executed in N ms.
  34202. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34203. * @param func The function to be executed.
  34204. * @param timeout optional delay in ms
  34205. */
  34206. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34207. /** @hidden */
  34208. _addPendingData(data: any): void;
  34209. /** @hidden */
  34210. _removePendingData(data: any): void;
  34211. /**
  34212. * Returns the number of items waiting to be loaded
  34213. * @returns the number of items waiting to be loaded
  34214. */
  34215. getWaitingItemsCount(): number;
  34216. /**
  34217. * Returns a boolean indicating if the scene is still loading data
  34218. */
  34219. readonly isLoading: boolean;
  34220. /**
  34221. * Registers a function to be executed when the scene is ready
  34222. * @param {Function} func - the function to be executed
  34223. */
  34224. executeWhenReady(func: () => void): void;
  34225. /**
  34226. * Returns a promise that resolves when the scene is ready
  34227. * @returns A promise that resolves when the scene is ready
  34228. */
  34229. whenReadyAsync(): Promise<void>;
  34230. /** @hidden */
  34231. _checkIsReady(): void;
  34232. /**
  34233. * Gets all animatable attached to the scene
  34234. */
  34235. readonly animatables: Animatable[];
  34236. /**
  34237. * Resets the last animation time frame.
  34238. * Useful to override when animations start running when loading a scene for the first time.
  34239. */
  34240. resetLastAnimationTimeFrame(): void;
  34241. /**
  34242. * Gets the current view matrix
  34243. * @returns a Matrix
  34244. */
  34245. getViewMatrix(): Matrix;
  34246. /**
  34247. * Gets the current projection matrix
  34248. * @returns a Matrix
  34249. */
  34250. getProjectionMatrix(): Matrix;
  34251. /**
  34252. * Gets the current transform matrix
  34253. * @returns a Matrix made of View * Projection
  34254. */
  34255. getTransformMatrix(): Matrix;
  34256. /**
  34257. * Sets the current transform matrix
  34258. * @param viewL defines the View matrix to use
  34259. * @param projectionL defines the Projection matrix to use
  34260. * @param viewR defines the right View matrix to use (if provided)
  34261. * @param projectionR defines the right Projection matrix to use (if provided)
  34262. */
  34263. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34264. /**
  34265. * Gets the uniform buffer used to store scene data
  34266. * @returns a UniformBuffer
  34267. */
  34268. getSceneUniformBuffer(): UniformBuffer;
  34269. /**
  34270. * Gets an unique (relatively to the current scene) Id
  34271. * @returns an unique number for the scene
  34272. */
  34273. getUniqueId(): number;
  34274. /**
  34275. * Add a mesh to the list of scene's meshes
  34276. * @param newMesh defines the mesh to add
  34277. * @param recursive if all child meshes should also be added to the scene
  34278. */
  34279. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34280. /**
  34281. * Remove a mesh for the list of scene's meshes
  34282. * @param toRemove defines the mesh to remove
  34283. * @param recursive if all child meshes should also be removed from the scene
  34284. * @returns the index where the mesh was in the mesh list
  34285. */
  34286. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34287. /**
  34288. * Add a transform node to the list of scene's transform nodes
  34289. * @param newTransformNode defines the transform node to add
  34290. */
  34291. addTransformNode(newTransformNode: TransformNode): void;
  34292. /**
  34293. * Remove a transform node for the list of scene's transform nodes
  34294. * @param toRemove defines the transform node to remove
  34295. * @returns the index where the transform node was in the transform node list
  34296. */
  34297. removeTransformNode(toRemove: TransformNode): number;
  34298. /**
  34299. * Remove a skeleton for the list of scene's skeletons
  34300. * @param toRemove defines the skeleton to remove
  34301. * @returns the index where the skeleton was in the skeleton list
  34302. */
  34303. removeSkeleton(toRemove: Skeleton): number;
  34304. /**
  34305. * Remove a morph target for the list of scene's morph targets
  34306. * @param toRemove defines the morph target to remove
  34307. * @returns the index where the morph target was in the morph target list
  34308. */
  34309. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34310. /**
  34311. * Remove a light for the list of scene's lights
  34312. * @param toRemove defines the light to remove
  34313. * @returns the index where the light was in the light list
  34314. */
  34315. removeLight(toRemove: Light): number;
  34316. /**
  34317. * Remove a camera for the list of scene's cameras
  34318. * @param toRemove defines the camera to remove
  34319. * @returns the index where the camera was in the camera list
  34320. */
  34321. removeCamera(toRemove: Camera): number;
  34322. /**
  34323. * Remove a particle system for the list of scene's particle systems
  34324. * @param toRemove defines the particle system to remove
  34325. * @returns the index where the particle system was in the particle system list
  34326. */
  34327. removeParticleSystem(toRemove: IParticleSystem): number;
  34328. /**
  34329. * Remove a animation for the list of scene's animations
  34330. * @param toRemove defines the animation to remove
  34331. * @returns the index where the animation was in the animation list
  34332. */
  34333. removeAnimation(toRemove: Animation): number;
  34334. /**
  34335. * Will stop the animation of the given target
  34336. * @param target - the target
  34337. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34338. * @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)
  34339. */
  34340. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34341. /**
  34342. * Removes the given animation group from this scene.
  34343. * @param toRemove The animation group to remove
  34344. * @returns The index of the removed animation group
  34345. */
  34346. removeAnimationGroup(toRemove: AnimationGroup): number;
  34347. /**
  34348. * Removes the given multi-material from this scene.
  34349. * @param toRemove The multi-material to remove
  34350. * @returns The index of the removed multi-material
  34351. */
  34352. removeMultiMaterial(toRemove: MultiMaterial): number;
  34353. /**
  34354. * Removes the given material from this scene.
  34355. * @param toRemove The material to remove
  34356. * @returns The index of the removed material
  34357. */
  34358. removeMaterial(toRemove: Material): number;
  34359. /**
  34360. * Removes the given action manager from this scene.
  34361. * @param toRemove The action manager to remove
  34362. * @returns The index of the removed action manager
  34363. */
  34364. removeActionManager(toRemove: AbstractActionManager): number;
  34365. /**
  34366. * Removes the given texture from this scene.
  34367. * @param toRemove The texture to remove
  34368. * @returns The index of the removed texture
  34369. */
  34370. removeTexture(toRemove: BaseTexture): number;
  34371. /**
  34372. * Adds the given light to this scene
  34373. * @param newLight The light to add
  34374. */
  34375. addLight(newLight: Light): void;
  34376. /**
  34377. * Sorts the list list based on light priorities
  34378. */
  34379. sortLightsByPriority(): void;
  34380. /**
  34381. * Adds the given camera to this scene
  34382. * @param newCamera The camera to add
  34383. */
  34384. addCamera(newCamera: Camera): void;
  34385. /**
  34386. * Adds the given skeleton to this scene
  34387. * @param newSkeleton The skeleton to add
  34388. */
  34389. addSkeleton(newSkeleton: Skeleton): void;
  34390. /**
  34391. * Adds the given particle system to this scene
  34392. * @param newParticleSystem The particle system to add
  34393. */
  34394. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34395. /**
  34396. * Adds the given animation to this scene
  34397. * @param newAnimation The animation to add
  34398. */
  34399. addAnimation(newAnimation: Animation): void;
  34400. /**
  34401. * Adds the given animation group to this scene.
  34402. * @param newAnimationGroup The animation group to add
  34403. */
  34404. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34405. /**
  34406. * Adds the given multi-material to this scene
  34407. * @param newMultiMaterial The multi-material to add
  34408. */
  34409. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34410. /**
  34411. * Adds the given material to this scene
  34412. * @param newMaterial The material to add
  34413. */
  34414. addMaterial(newMaterial: Material): void;
  34415. /**
  34416. * Adds the given morph target to this scene
  34417. * @param newMorphTargetManager The morph target to add
  34418. */
  34419. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34420. /**
  34421. * Adds the given geometry to this scene
  34422. * @param newGeometry The geometry to add
  34423. */
  34424. addGeometry(newGeometry: Geometry): void;
  34425. /**
  34426. * Adds the given action manager to this scene
  34427. * @param newActionManager The action manager to add
  34428. */
  34429. addActionManager(newActionManager: AbstractActionManager): void;
  34430. /**
  34431. * Adds the given texture to this scene.
  34432. * @param newTexture The texture to add
  34433. */
  34434. addTexture(newTexture: BaseTexture): void;
  34435. /**
  34436. * Switch active camera
  34437. * @param newCamera defines the new active camera
  34438. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34439. */
  34440. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34441. /**
  34442. * sets the active camera of the scene using its ID
  34443. * @param id defines the camera's ID
  34444. * @return the new active camera or null if none found.
  34445. */
  34446. setActiveCameraByID(id: string): Nullable<Camera>;
  34447. /**
  34448. * sets the active camera of the scene using its name
  34449. * @param name defines the camera's name
  34450. * @returns the new active camera or null if none found.
  34451. */
  34452. setActiveCameraByName(name: string): Nullable<Camera>;
  34453. /**
  34454. * get an animation group using its name
  34455. * @param name defines the material's name
  34456. * @return the animation group or null if none found.
  34457. */
  34458. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34459. /**
  34460. * Get a material using its unique id
  34461. * @param uniqueId defines the material's unique id
  34462. * @return the material or null if none found.
  34463. */
  34464. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34465. /**
  34466. * get a material using its id
  34467. * @param id defines the material's ID
  34468. * @return the material or null if none found.
  34469. */
  34470. getMaterialByID(id: string): Nullable<Material>;
  34471. /**
  34472. * Gets a the last added material using a given id
  34473. * @param id defines the material's ID
  34474. * @return the last material with the given id or null if none found.
  34475. */
  34476. getLastMaterialByID(id: string): Nullable<Material>;
  34477. /**
  34478. * Gets a material using its name
  34479. * @param name defines the material's name
  34480. * @return the material or null if none found.
  34481. */
  34482. getMaterialByName(name: string): Nullable<Material>;
  34483. /**
  34484. * Gets a camera using its id
  34485. * @param id defines the id to look for
  34486. * @returns the camera or null if not found
  34487. */
  34488. getCameraByID(id: string): Nullable<Camera>;
  34489. /**
  34490. * Gets a camera using its unique id
  34491. * @param uniqueId defines the unique id to look for
  34492. * @returns the camera or null if not found
  34493. */
  34494. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34495. /**
  34496. * Gets a camera using its name
  34497. * @param name defines the camera's name
  34498. * @return the camera or null if none found.
  34499. */
  34500. getCameraByName(name: string): Nullable<Camera>;
  34501. /**
  34502. * Gets a bone using its id
  34503. * @param id defines the bone's id
  34504. * @return the bone or null if not found
  34505. */
  34506. getBoneByID(id: string): Nullable<Bone>;
  34507. /**
  34508. * Gets a bone using its id
  34509. * @param name defines the bone's name
  34510. * @return the bone or null if not found
  34511. */
  34512. getBoneByName(name: string): Nullable<Bone>;
  34513. /**
  34514. * Gets a light node using its name
  34515. * @param name defines the the light's name
  34516. * @return the light or null if none found.
  34517. */
  34518. getLightByName(name: string): Nullable<Light>;
  34519. /**
  34520. * Gets a light node using its id
  34521. * @param id defines the light's id
  34522. * @return the light or null if none found.
  34523. */
  34524. getLightByID(id: string): Nullable<Light>;
  34525. /**
  34526. * Gets a light node using its scene-generated unique ID
  34527. * @param uniqueId defines the light's unique id
  34528. * @return the light or null if none found.
  34529. */
  34530. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34531. /**
  34532. * Gets a particle system by id
  34533. * @param id defines the particle system id
  34534. * @return the corresponding system or null if none found
  34535. */
  34536. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34537. /**
  34538. * Gets a geometry using its ID
  34539. * @param id defines the geometry's id
  34540. * @return the geometry or null if none found.
  34541. */
  34542. getGeometryByID(id: string): Nullable<Geometry>;
  34543. private _getGeometryByUniqueID;
  34544. /**
  34545. * Add a new geometry to this scene
  34546. * @param geometry defines the geometry to be added to the scene.
  34547. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34548. * @return a boolean defining if the geometry was added or not
  34549. */
  34550. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34551. /**
  34552. * Removes an existing geometry
  34553. * @param geometry defines the geometry to be removed from the scene
  34554. * @return a boolean defining if the geometry was removed or not
  34555. */
  34556. removeGeometry(geometry: Geometry): boolean;
  34557. /**
  34558. * Gets the list of geometries attached to the scene
  34559. * @returns an array of Geometry
  34560. */
  34561. getGeometries(): Geometry[];
  34562. /**
  34563. * Gets the first added mesh found of a given ID
  34564. * @param id defines the id to search for
  34565. * @return the mesh found or null if not found at all
  34566. */
  34567. getMeshByID(id: string): Nullable<AbstractMesh>;
  34568. /**
  34569. * Gets a list of meshes using their id
  34570. * @param id defines the id to search for
  34571. * @returns a list of meshes
  34572. */
  34573. getMeshesByID(id: string): Array<AbstractMesh>;
  34574. /**
  34575. * Gets the first added transform node found of a given ID
  34576. * @param id defines the id to search for
  34577. * @return the found transform node or null if not found at all.
  34578. */
  34579. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34580. /**
  34581. * Gets a transform node with its auto-generated unique id
  34582. * @param uniqueId efines the unique id to search for
  34583. * @return the found transform node or null if not found at all.
  34584. */
  34585. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34586. /**
  34587. * Gets a list of transform nodes using their id
  34588. * @param id defines the id to search for
  34589. * @returns a list of transform nodes
  34590. */
  34591. getTransformNodesByID(id: string): Array<TransformNode>;
  34592. /**
  34593. * Gets a mesh with its auto-generated unique id
  34594. * @param uniqueId defines the unique id to search for
  34595. * @return the found mesh or null if not found at all.
  34596. */
  34597. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34598. /**
  34599. * Gets a the last added mesh using a given id
  34600. * @param id defines the id to search for
  34601. * @return the found mesh or null if not found at all.
  34602. */
  34603. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34604. /**
  34605. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34606. * @param id defines the id to search for
  34607. * @return the found node or null if not found at all
  34608. */
  34609. getLastEntryByID(id: string): Nullable<Node>;
  34610. /**
  34611. * Gets a node (Mesh, Camera, Light) using a given id
  34612. * @param id defines the id to search for
  34613. * @return the found node or null if not found at all
  34614. */
  34615. getNodeByID(id: string): Nullable<Node>;
  34616. /**
  34617. * Gets a node (Mesh, Camera, Light) using a given name
  34618. * @param name defines the name to search for
  34619. * @return the found node or null if not found at all.
  34620. */
  34621. getNodeByName(name: string): Nullable<Node>;
  34622. /**
  34623. * Gets a mesh using a given name
  34624. * @param name defines the name to search for
  34625. * @return the found mesh or null if not found at all.
  34626. */
  34627. getMeshByName(name: string): Nullable<AbstractMesh>;
  34628. /**
  34629. * Gets a transform node using a given name
  34630. * @param name defines the name to search for
  34631. * @return the found transform node or null if not found at all.
  34632. */
  34633. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34634. /**
  34635. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34636. * @param id defines the id to search for
  34637. * @return the found skeleton or null if not found at all.
  34638. */
  34639. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34640. /**
  34641. * Gets a skeleton using a given auto generated unique id
  34642. * @param uniqueId defines the unique id to search for
  34643. * @return the found skeleton or null if not found at all.
  34644. */
  34645. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34646. /**
  34647. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34648. * @param id defines the id to search for
  34649. * @return the found skeleton or null if not found at all.
  34650. */
  34651. getSkeletonById(id: string): Nullable<Skeleton>;
  34652. /**
  34653. * Gets a skeleton using a given name
  34654. * @param name defines the name to search for
  34655. * @return the found skeleton or null if not found at all.
  34656. */
  34657. getSkeletonByName(name: string): Nullable<Skeleton>;
  34658. /**
  34659. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34660. * @param id defines the id to search for
  34661. * @return the found morph target manager or null if not found at all.
  34662. */
  34663. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34664. /**
  34665. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34666. * @param id defines the id to search for
  34667. * @return the found morph target or null if not found at all.
  34668. */
  34669. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34670. /**
  34671. * Gets a boolean indicating if the given mesh is active
  34672. * @param mesh defines the mesh to look for
  34673. * @returns true if the mesh is in the active list
  34674. */
  34675. isActiveMesh(mesh: AbstractMesh): boolean;
  34676. /**
  34677. * Return a unique id as a string which can serve as an identifier for the scene
  34678. */
  34679. readonly uid: string;
  34680. /**
  34681. * Add an externaly attached data from its key.
  34682. * This method call will fail and return false, if such key already exists.
  34683. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34684. * @param key the unique key that identifies the data
  34685. * @param data the data object to associate to the key for this Engine instance
  34686. * @return true if no such key were already present and the data was added successfully, false otherwise
  34687. */
  34688. addExternalData<T>(key: string, data: T): boolean;
  34689. /**
  34690. * Get an externaly attached data from its key
  34691. * @param key the unique key that identifies the data
  34692. * @return the associated data, if present (can be null), or undefined if not present
  34693. */
  34694. getExternalData<T>(key: string): Nullable<T>;
  34695. /**
  34696. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34697. * @param key the unique key that identifies the data
  34698. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34699. * @return the associated data, can be null if the factory returned null.
  34700. */
  34701. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34702. /**
  34703. * Remove an externaly attached data from the Engine instance
  34704. * @param key the unique key that identifies the data
  34705. * @return true if the data was successfully removed, false if it doesn't exist
  34706. */
  34707. removeExternalData(key: string): boolean;
  34708. private _evaluateSubMesh;
  34709. /**
  34710. * Clear the processed materials smart array preventing retention point in material dispose.
  34711. */
  34712. freeProcessedMaterials(): void;
  34713. private _preventFreeActiveMeshesAndRenderingGroups;
  34714. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34715. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34716. * when disposing several meshes in a row or a hierarchy of meshes.
  34717. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34718. */
  34719. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34720. /**
  34721. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34722. */
  34723. freeActiveMeshes(): void;
  34724. /**
  34725. * Clear the info related to rendering groups preventing retention points during dispose.
  34726. */
  34727. freeRenderingGroups(): void;
  34728. /** @hidden */
  34729. _isInIntermediateRendering(): boolean;
  34730. /**
  34731. * Lambda returning the list of potentially active meshes.
  34732. */
  34733. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34734. /**
  34735. * Lambda returning the list of potentially active sub meshes.
  34736. */
  34737. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34738. /**
  34739. * Lambda returning the list of potentially intersecting sub meshes.
  34740. */
  34741. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34742. /**
  34743. * Lambda returning the list of potentially colliding sub meshes.
  34744. */
  34745. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34746. private _activeMeshesFrozen;
  34747. /**
  34748. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34749. * @returns the current scene
  34750. */
  34751. freezeActiveMeshes(): Scene;
  34752. /**
  34753. * Use this function to restart evaluating active meshes on every frame
  34754. * @returns the current scene
  34755. */
  34756. unfreezeActiveMeshes(): Scene;
  34757. private _evaluateActiveMeshes;
  34758. private _activeMesh;
  34759. /**
  34760. * Update the transform matrix to update from the current active camera
  34761. * @param force defines a boolean used to force the update even if cache is up to date
  34762. */
  34763. updateTransformMatrix(force?: boolean): void;
  34764. private _bindFrameBuffer;
  34765. /** @hidden */
  34766. _allowPostProcessClearColor: boolean;
  34767. /** @hidden */
  34768. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34769. private _processSubCameras;
  34770. private _checkIntersections;
  34771. /** @hidden */
  34772. _advancePhysicsEngineStep(step: number): void;
  34773. /**
  34774. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34775. */
  34776. getDeterministicFrameTime: () => number;
  34777. /** @hidden */
  34778. _animate(): void;
  34779. /** Execute all animations (for a frame) */
  34780. animate(): void;
  34781. /**
  34782. * Render the scene
  34783. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34784. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34785. */
  34786. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34787. /**
  34788. * Freeze all materials
  34789. * A frozen material will not be updatable but should be faster to render
  34790. */
  34791. freezeMaterials(): void;
  34792. /**
  34793. * Unfreeze all materials
  34794. * A frozen material will not be updatable but should be faster to render
  34795. */
  34796. unfreezeMaterials(): void;
  34797. /**
  34798. * Releases all held ressources
  34799. */
  34800. dispose(): void;
  34801. /**
  34802. * Gets if the scene is already disposed
  34803. */
  34804. readonly isDisposed: boolean;
  34805. /**
  34806. * Call this function to reduce memory footprint of the scene.
  34807. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34808. */
  34809. clearCachedVertexData(): void;
  34810. /**
  34811. * This function will remove the local cached buffer data from texture.
  34812. * It will save memory but will prevent the texture from being rebuilt
  34813. */
  34814. cleanCachedTextureBuffer(): void;
  34815. /**
  34816. * Get the world extend vectors with an optional filter
  34817. *
  34818. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34819. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34820. */
  34821. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34822. min: Vector3;
  34823. max: Vector3;
  34824. };
  34825. /**
  34826. * Creates a ray that can be used to pick in the scene
  34827. * @param x defines the x coordinate of the origin (on-screen)
  34828. * @param y defines the y coordinate of the origin (on-screen)
  34829. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34830. * @param camera defines the camera to use for the picking
  34831. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34832. * @returns a Ray
  34833. */
  34834. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34835. /**
  34836. * Creates a ray that can be used to pick in the scene
  34837. * @param x defines the x coordinate of the origin (on-screen)
  34838. * @param y defines the y coordinate of the origin (on-screen)
  34839. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34840. * @param result defines the ray where to store the picking ray
  34841. * @param camera defines the camera to use for the picking
  34842. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34843. * @returns the current scene
  34844. */
  34845. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34846. /**
  34847. * Creates a ray that can be used to pick in the scene
  34848. * @param x defines the x coordinate of the origin (on-screen)
  34849. * @param y defines the y coordinate of the origin (on-screen)
  34850. * @param camera defines the camera to use for the picking
  34851. * @returns a Ray
  34852. */
  34853. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34854. /**
  34855. * Creates a ray that can be used to pick in the scene
  34856. * @param x defines the x coordinate of the origin (on-screen)
  34857. * @param y defines the y coordinate of the origin (on-screen)
  34858. * @param result defines the ray where to store the picking ray
  34859. * @param camera defines the camera to use for the picking
  34860. * @returns the current scene
  34861. */
  34862. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34863. /** Launch a ray to try to pick a mesh in the scene
  34864. * @param x position on screen
  34865. * @param y position on screen
  34866. * @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
  34867. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34868. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34869. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34870. * @returns a PickingInfo
  34871. */
  34872. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34873. /** Use the given ray to pick a mesh in the scene
  34874. * @param ray The ray to use to pick meshes
  34875. * @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
  34876. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34877. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34878. * @returns a PickingInfo
  34879. */
  34880. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34881. /**
  34882. * Launch a ray to try to pick a mesh in the scene
  34883. * @param x X position on screen
  34884. * @param y Y position on screen
  34885. * @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
  34886. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34887. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34888. * @returns an array of PickingInfo
  34889. */
  34890. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34891. /**
  34892. * Launch a ray to try to pick a mesh in the scene
  34893. * @param ray Ray to use
  34894. * @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
  34895. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34896. * @returns an array of PickingInfo
  34897. */
  34898. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34899. /**
  34900. * Force the value of meshUnderPointer
  34901. * @param mesh defines the mesh to use
  34902. */
  34903. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34904. /**
  34905. * Gets the mesh under the pointer
  34906. * @returns a Mesh or null if no mesh is under the pointer
  34907. */
  34908. getPointerOverMesh(): Nullable<AbstractMesh>;
  34909. /** @hidden */
  34910. _rebuildGeometries(): void;
  34911. /** @hidden */
  34912. _rebuildTextures(): void;
  34913. private _getByTags;
  34914. /**
  34915. * Get a list of meshes by tags
  34916. * @param tagsQuery defines the tags query to use
  34917. * @param forEach defines a predicate used to filter results
  34918. * @returns an array of Mesh
  34919. */
  34920. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34921. /**
  34922. * Get a list of cameras by tags
  34923. * @param tagsQuery defines the tags query to use
  34924. * @param forEach defines a predicate used to filter results
  34925. * @returns an array of Camera
  34926. */
  34927. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34928. /**
  34929. * Get a list of lights by tags
  34930. * @param tagsQuery defines the tags query to use
  34931. * @param forEach defines a predicate used to filter results
  34932. * @returns an array of Light
  34933. */
  34934. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34935. /**
  34936. * Get a list of materials by tags
  34937. * @param tagsQuery defines the tags query to use
  34938. * @param forEach defines a predicate used to filter results
  34939. * @returns an array of Material
  34940. */
  34941. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34942. /**
  34943. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34944. * This allowed control for front to back rendering or reversly depending of the special needs.
  34945. *
  34946. * @param renderingGroupId The rendering group id corresponding to its index
  34947. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34948. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34949. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34950. */
  34951. 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;
  34952. /**
  34953. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34954. *
  34955. * @param renderingGroupId The rendering group id corresponding to its index
  34956. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34957. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34958. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34959. */
  34960. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34961. /**
  34962. * Gets the current auto clear configuration for one rendering group of the rendering
  34963. * manager.
  34964. * @param index the rendering group index to get the information for
  34965. * @returns The auto clear setup for the requested rendering group
  34966. */
  34967. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34968. private _blockMaterialDirtyMechanism;
  34969. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34970. blockMaterialDirtyMechanism: boolean;
  34971. /**
  34972. * Will flag all materials as dirty to trigger new shader compilation
  34973. * @param flag defines the flag used to specify which material part must be marked as dirty
  34974. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34975. */
  34976. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34977. /** @hidden */
  34978. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  34979. /** @hidden */
  34980. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34981. }
  34982. }
  34983. declare module "babylonjs/assetContainer" {
  34984. import { AbstractScene } from "babylonjs/abstractScene";
  34985. import { Scene } from "babylonjs/scene";
  34986. import { Mesh } from "babylonjs/Meshes/mesh";
  34987. /**
  34988. * Set of assets to keep when moving a scene into an asset container.
  34989. */
  34990. export class KeepAssets extends AbstractScene {
  34991. }
  34992. /**
  34993. * Container with a set of assets that can be added or removed from a scene.
  34994. */
  34995. export class AssetContainer extends AbstractScene {
  34996. /**
  34997. * The scene the AssetContainer belongs to.
  34998. */
  34999. scene: Scene;
  35000. /**
  35001. * Instantiates an AssetContainer.
  35002. * @param scene The scene the AssetContainer belongs to.
  35003. */
  35004. constructor(scene: Scene);
  35005. /**
  35006. * Adds all the assets from the container to the scene.
  35007. */
  35008. addAllToScene(): void;
  35009. /**
  35010. * Removes all the assets in the container from the scene
  35011. */
  35012. removeAllFromScene(): void;
  35013. /**
  35014. * Disposes all the assets in the container
  35015. */
  35016. dispose(): void;
  35017. private _moveAssets;
  35018. /**
  35019. * Removes all the assets contained in the scene and adds them to the container.
  35020. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35021. */
  35022. moveAllFromScene(keepAssets?: KeepAssets): void;
  35023. /**
  35024. * 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.
  35025. * @returns the root mesh
  35026. */
  35027. createRootMesh(): Mesh;
  35028. }
  35029. }
  35030. declare module "babylonjs/abstractScene" {
  35031. import { Scene } from "babylonjs/scene";
  35032. import { Nullable } from "babylonjs/types";
  35033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35034. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35035. import { Geometry } from "babylonjs/Meshes/geometry";
  35036. import { Skeleton } from "babylonjs/Bones/skeleton";
  35037. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35038. import { AssetContainer } from "babylonjs/assetContainer";
  35039. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35040. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35041. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35042. import { Material } from "babylonjs/Materials/material";
  35043. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35044. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35045. import { Camera } from "babylonjs/Cameras/camera";
  35046. import { Light } from "babylonjs/Lights/light";
  35047. import { Node } from "babylonjs/node";
  35048. import { Animation } from "babylonjs/Animations/animation";
  35049. /**
  35050. * Defines how the parser contract is defined.
  35051. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35052. */
  35053. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35054. /**
  35055. * Defines how the individual parser contract is defined.
  35056. * These parser can parse an individual asset
  35057. */
  35058. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35059. /**
  35060. * Base class of the scene acting as a container for the different elements composing a scene.
  35061. * This class is dynamically extended by the different components of the scene increasing
  35062. * flexibility and reducing coupling
  35063. */
  35064. export abstract class AbstractScene {
  35065. /**
  35066. * Stores the list of available parsers in the application.
  35067. */
  35068. private static _BabylonFileParsers;
  35069. /**
  35070. * Stores the list of available individual parsers in the application.
  35071. */
  35072. private static _IndividualBabylonFileParsers;
  35073. /**
  35074. * Adds a parser in the list of available ones
  35075. * @param name Defines the name of the parser
  35076. * @param parser Defines the parser to add
  35077. */
  35078. static AddParser(name: string, parser: BabylonFileParser): void;
  35079. /**
  35080. * Gets a general parser from the list of avaialble ones
  35081. * @param name Defines the name of the parser
  35082. * @returns the requested parser or null
  35083. */
  35084. static GetParser(name: string): Nullable<BabylonFileParser>;
  35085. /**
  35086. * Adds n individual parser in the list of available ones
  35087. * @param name Defines the name of the parser
  35088. * @param parser Defines the parser to add
  35089. */
  35090. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35091. /**
  35092. * Gets an individual parser from the list of avaialble ones
  35093. * @param name Defines the name of the parser
  35094. * @returns the requested parser or null
  35095. */
  35096. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35097. /**
  35098. * Parser json data and populate both a scene and its associated container object
  35099. * @param jsonData Defines the data to parse
  35100. * @param scene Defines the scene to parse the data for
  35101. * @param container Defines the container attached to the parsing sequence
  35102. * @param rootUrl Defines the root url of the data
  35103. */
  35104. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35105. /**
  35106. * Gets the list of root nodes (ie. nodes with no parent)
  35107. */
  35108. rootNodes: Node[];
  35109. /** All of the cameras added to this scene
  35110. * @see http://doc.babylonjs.com/babylon101/cameras
  35111. */
  35112. cameras: Camera[];
  35113. /**
  35114. * All of the lights added to this scene
  35115. * @see http://doc.babylonjs.com/babylon101/lights
  35116. */
  35117. lights: Light[];
  35118. /**
  35119. * All of the (abstract) meshes added to this scene
  35120. */
  35121. meshes: AbstractMesh[];
  35122. /**
  35123. * The list of skeletons added to the scene
  35124. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35125. */
  35126. skeletons: Skeleton[];
  35127. /**
  35128. * All of the particle systems added to this scene
  35129. * @see http://doc.babylonjs.com/babylon101/particles
  35130. */
  35131. particleSystems: IParticleSystem[];
  35132. /**
  35133. * Gets a list of Animations associated with the scene
  35134. */
  35135. animations: Animation[];
  35136. /**
  35137. * All of the animation groups added to this scene
  35138. * @see http://doc.babylonjs.com/how_to/group
  35139. */
  35140. animationGroups: AnimationGroup[];
  35141. /**
  35142. * All of the multi-materials added to this scene
  35143. * @see http://doc.babylonjs.com/how_to/multi_materials
  35144. */
  35145. multiMaterials: MultiMaterial[];
  35146. /**
  35147. * All of the materials added to this scene
  35148. * In the context of a Scene, it is not supposed to be modified manually.
  35149. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35150. * Note also that the order of the Material wihin the array is not significant and might change.
  35151. * @see http://doc.babylonjs.com/babylon101/materials
  35152. */
  35153. materials: Material[];
  35154. /**
  35155. * The list of morph target managers added to the scene
  35156. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35157. */
  35158. morphTargetManagers: MorphTargetManager[];
  35159. /**
  35160. * The list of geometries used in the scene.
  35161. */
  35162. geometries: Geometry[];
  35163. /**
  35164. * All of the tranform nodes added to this scene
  35165. * In the context of a Scene, it is not supposed to be modified manually.
  35166. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35167. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35168. * @see http://doc.babylonjs.com/how_to/transformnode
  35169. */
  35170. transformNodes: TransformNode[];
  35171. /**
  35172. * ActionManagers available on the scene.
  35173. */
  35174. actionManagers: AbstractActionManager[];
  35175. /**
  35176. * Textures to keep.
  35177. */
  35178. textures: BaseTexture[];
  35179. /**
  35180. * Environment texture for the scene
  35181. */
  35182. environmentTexture: Nullable<BaseTexture>;
  35183. }
  35184. }
  35185. declare module "babylonjs/Audio/sound" {
  35186. import { Observable } from "babylonjs/Misc/observable";
  35187. import { Vector3 } from "babylonjs/Maths/math";
  35188. import { Nullable } from "babylonjs/types";
  35189. import { Scene } from "babylonjs/scene";
  35190. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35191. /**
  35192. * Interface used to define options for Sound class
  35193. */
  35194. export interface ISoundOptions {
  35195. /**
  35196. * Does the sound autoplay once loaded.
  35197. */
  35198. autoplay?: boolean;
  35199. /**
  35200. * Does the sound loop after it finishes playing once.
  35201. */
  35202. loop?: boolean;
  35203. /**
  35204. * Sound's volume
  35205. */
  35206. volume?: number;
  35207. /**
  35208. * Is it a spatial sound?
  35209. */
  35210. spatialSound?: boolean;
  35211. /**
  35212. * Maximum distance to hear that sound
  35213. */
  35214. maxDistance?: number;
  35215. /**
  35216. * Uses user defined attenuation function
  35217. */
  35218. useCustomAttenuation?: boolean;
  35219. /**
  35220. * Define the roll off factor of spatial sounds.
  35221. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35222. */
  35223. rolloffFactor?: number;
  35224. /**
  35225. * Define the reference distance the sound should be heard perfectly.
  35226. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35227. */
  35228. refDistance?: number;
  35229. /**
  35230. * Define the distance attenuation model the sound will follow.
  35231. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35232. */
  35233. distanceModel?: string;
  35234. /**
  35235. * Defines the playback speed (1 by default)
  35236. */
  35237. playbackRate?: number;
  35238. /**
  35239. * Defines if the sound is from a streaming source
  35240. */
  35241. streaming?: boolean;
  35242. /**
  35243. * Defines an optional length (in seconds) inside the sound file
  35244. */
  35245. length?: number;
  35246. /**
  35247. * Defines an optional offset (in seconds) inside the sound file
  35248. */
  35249. offset?: number;
  35250. /**
  35251. * If true, URLs will not be required to state the audio file codec to use.
  35252. */
  35253. skipCodecCheck?: boolean;
  35254. }
  35255. /**
  35256. * Defines a sound that can be played in the application.
  35257. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35259. */
  35260. export class Sound {
  35261. /**
  35262. * The name of the sound in the scene.
  35263. */
  35264. name: string;
  35265. /**
  35266. * Does the sound autoplay once loaded.
  35267. */
  35268. autoplay: boolean;
  35269. /**
  35270. * Does the sound loop after it finishes playing once.
  35271. */
  35272. loop: boolean;
  35273. /**
  35274. * Does the sound use a custom attenuation curve to simulate the falloff
  35275. * happening when the source gets further away from the camera.
  35276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35277. */
  35278. useCustomAttenuation: boolean;
  35279. /**
  35280. * The sound track id this sound belongs to.
  35281. */
  35282. soundTrackId: number;
  35283. /**
  35284. * Is this sound currently played.
  35285. */
  35286. isPlaying: boolean;
  35287. /**
  35288. * Is this sound currently paused.
  35289. */
  35290. isPaused: boolean;
  35291. /**
  35292. * Does this sound enables spatial sound.
  35293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35294. */
  35295. spatialSound: boolean;
  35296. /**
  35297. * Define the reference distance the sound should be heard perfectly.
  35298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35299. */
  35300. refDistance: number;
  35301. /**
  35302. * Define the roll off factor of spatial sounds.
  35303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35304. */
  35305. rolloffFactor: number;
  35306. /**
  35307. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35308. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35309. */
  35310. maxDistance: number;
  35311. /**
  35312. * Define the distance attenuation model the sound will follow.
  35313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35314. */
  35315. distanceModel: string;
  35316. /**
  35317. * @hidden
  35318. * Back Compat
  35319. **/
  35320. onended: () => any;
  35321. /**
  35322. * Observable event when the current playing sound finishes.
  35323. */
  35324. onEndedObservable: Observable<Sound>;
  35325. private _panningModel;
  35326. private _playbackRate;
  35327. private _streaming;
  35328. private _startTime;
  35329. private _startOffset;
  35330. private _position;
  35331. /** @hidden */
  35332. _positionInEmitterSpace: boolean;
  35333. private _localDirection;
  35334. private _volume;
  35335. private _isReadyToPlay;
  35336. private _isDirectional;
  35337. private _readyToPlayCallback;
  35338. private _audioBuffer;
  35339. private _soundSource;
  35340. private _streamingSource;
  35341. private _soundPanner;
  35342. private _soundGain;
  35343. private _inputAudioNode;
  35344. private _outputAudioNode;
  35345. private _coneInnerAngle;
  35346. private _coneOuterAngle;
  35347. private _coneOuterGain;
  35348. private _scene;
  35349. private _connectedTransformNode;
  35350. private _customAttenuationFunction;
  35351. private _registerFunc;
  35352. private _isOutputConnected;
  35353. private _htmlAudioElement;
  35354. private _urlType;
  35355. private _length?;
  35356. private _offset?;
  35357. /** @hidden */
  35358. static _SceneComponentInitialization: (scene: Scene) => void;
  35359. /**
  35360. * Create a sound and attach it to a scene
  35361. * @param name Name of your sound
  35362. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35363. * @param scene defines the scene the sound belongs to
  35364. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35365. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35366. */
  35367. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35368. /**
  35369. * Release the sound and its associated resources
  35370. */
  35371. dispose(): void;
  35372. /**
  35373. * Gets if the sounds is ready to be played or not.
  35374. * @returns true if ready, otherwise false
  35375. */
  35376. isReady(): boolean;
  35377. private _soundLoaded;
  35378. /**
  35379. * Sets the data of the sound from an audiobuffer
  35380. * @param audioBuffer The audioBuffer containing the data
  35381. */
  35382. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35383. /**
  35384. * Updates the current sounds options such as maxdistance, loop...
  35385. * @param options A JSON object containing values named as the object properties
  35386. */
  35387. updateOptions(options: ISoundOptions): void;
  35388. private _createSpatialParameters;
  35389. private _updateSpatialParameters;
  35390. /**
  35391. * Switch the panning model to HRTF:
  35392. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35393. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35394. */
  35395. switchPanningModelToHRTF(): void;
  35396. /**
  35397. * Switch the panning model to Equal Power:
  35398. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35399. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35400. */
  35401. switchPanningModelToEqualPower(): void;
  35402. private _switchPanningModel;
  35403. /**
  35404. * Connect this sound to a sound track audio node like gain...
  35405. * @param soundTrackAudioNode the sound track audio node to connect to
  35406. */
  35407. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35408. /**
  35409. * Transform this sound into a directional source
  35410. * @param coneInnerAngle Size of the inner cone in degree
  35411. * @param coneOuterAngle Size of the outer cone in degree
  35412. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35413. */
  35414. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35415. /**
  35416. * Gets or sets the inner angle for the directional cone.
  35417. */
  35418. /**
  35419. * Gets or sets the inner angle for the directional cone.
  35420. */
  35421. directionalConeInnerAngle: number;
  35422. /**
  35423. * Gets or sets the outer angle for the directional cone.
  35424. */
  35425. /**
  35426. * Gets or sets the outer angle for the directional cone.
  35427. */
  35428. directionalConeOuterAngle: number;
  35429. /**
  35430. * Sets the position of the emitter if spatial sound is enabled
  35431. * @param newPosition Defines the new posisiton
  35432. */
  35433. setPosition(newPosition: Vector3): void;
  35434. /**
  35435. * Sets the local direction of the emitter if spatial sound is enabled
  35436. * @param newLocalDirection Defines the new local direction
  35437. */
  35438. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35439. private _updateDirection;
  35440. /** @hidden */
  35441. updateDistanceFromListener(): void;
  35442. /**
  35443. * Sets a new custom attenuation function for the sound.
  35444. * @param callback Defines the function used for the attenuation
  35445. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35446. */
  35447. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35448. /**
  35449. * Play the sound
  35450. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35451. * @param offset (optional) Start the sound at a specific time in seconds
  35452. * @param length (optional) Sound duration (in seconds)
  35453. */
  35454. play(time?: number, offset?: number, length?: number): void;
  35455. private _onended;
  35456. /**
  35457. * Stop the sound
  35458. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35459. */
  35460. stop(time?: number): void;
  35461. /**
  35462. * Put the sound in pause
  35463. */
  35464. pause(): void;
  35465. /**
  35466. * Sets a dedicated volume for this sounds
  35467. * @param newVolume Define the new volume of the sound
  35468. * @param time Define time for gradual change to new volume
  35469. */
  35470. setVolume(newVolume: number, time?: number): void;
  35471. /**
  35472. * Set the sound play back rate
  35473. * @param newPlaybackRate Define the playback rate the sound should be played at
  35474. */
  35475. setPlaybackRate(newPlaybackRate: number): void;
  35476. /**
  35477. * Gets the volume of the sound.
  35478. * @returns the volume of the sound
  35479. */
  35480. getVolume(): number;
  35481. /**
  35482. * Attach the sound to a dedicated mesh
  35483. * @param transformNode The transform node to connect the sound with
  35484. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35485. */
  35486. attachToMesh(transformNode: TransformNode): void;
  35487. /**
  35488. * Detach the sound from the previously attached mesh
  35489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35490. */
  35491. detachFromMesh(): void;
  35492. private _onRegisterAfterWorldMatrixUpdate;
  35493. /**
  35494. * Clone the current sound in the scene.
  35495. * @returns the new sound clone
  35496. */
  35497. clone(): Nullable<Sound>;
  35498. /**
  35499. * Gets the current underlying audio buffer containing the data
  35500. * @returns the audio buffer
  35501. */
  35502. getAudioBuffer(): Nullable<AudioBuffer>;
  35503. /**
  35504. * Serializes the Sound in a JSON representation
  35505. * @returns the JSON representation of the sound
  35506. */
  35507. serialize(): any;
  35508. /**
  35509. * Parse a JSON representation of a sound to innstantiate in a given scene
  35510. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35511. * @param scene Define the scene the new parsed sound should be created in
  35512. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35513. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35514. * @returns the newly parsed sound
  35515. */
  35516. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35517. }
  35518. }
  35519. declare module "babylonjs/Actions/directAudioActions" {
  35520. import { Action } from "babylonjs/Actions/action";
  35521. import { Condition } from "babylonjs/Actions/condition";
  35522. import { Sound } from "babylonjs/Audio/sound";
  35523. /**
  35524. * This defines an action helpful to play a defined sound on a triggered action.
  35525. */
  35526. export class PlaySoundAction extends Action {
  35527. private _sound;
  35528. /**
  35529. * Instantiate the action
  35530. * @param triggerOptions defines the trigger options
  35531. * @param sound defines the sound to play
  35532. * @param condition defines the trigger related conditions
  35533. */
  35534. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35535. /** @hidden */
  35536. _prepare(): void;
  35537. /**
  35538. * Execute the action and play the sound.
  35539. */
  35540. execute(): void;
  35541. /**
  35542. * Serializes the actions and its related information.
  35543. * @param parent defines the object to serialize in
  35544. * @returns the serialized object
  35545. */
  35546. serialize(parent: any): any;
  35547. }
  35548. /**
  35549. * This defines an action helpful to stop a defined sound on a triggered action.
  35550. */
  35551. export class StopSoundAction extends Action {
  35552. private _sound;
  35553. /**
  35554. * Instantiate the action
  35555. * @param triggerOptions defines the trigger options
  35556. * @param sound defines the sound to stop
  35557. * @param condition defines the trigger related conditions
  35558. */
  35559. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35560. /** @hidden */
  35561. _prepare(): void;
  35562. /**
  35563. * Execute the action and stop the sound.
  35564. */
  35565. execute(): void;
  35566. /**
  35567. * Serializes the actions and its related information.
  35568. * @param parent defines the object to serialize in
  35569. * @returns the serialized object
  35570. */
  35571. serialize(parent: any): any;
  35572. }
  35573. }
  35574. declare module "babylonjs/Actions/interpolateValueAction" {
  35575. import { Action } from "babylonjs/Actions/action";
  35576. import { Condition } from "babylonjs/Actions/condition";
  35577. import { Observable } from "babylonjs/Misc/observable";
  35578. /**
  35579. * This defines an action responsible to change the value of a property
  35580. * by interpolating between its current value and the newly set one once triggered.
  35581. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35582. */
  35583. export class InterpolateValueAction extends Action {
  35584. /**
  35585. * Defines the path of the property where the value should be interpolated
  35586. */
  35587. propertyPath: string;
  35588. /**
  35589. * Defines the target value at the end of the interpolation.
  35590. */
  35591. value: any;
  35592. /**
  35593. * Defines the time it will take for the property to interpolate to the value.
  35594. */
  35595. duration: number;
  35596. /**
  35597. * Defines if the other scene animations should be stopped when the action has been triggered
  35598. */
  35599. stopOtherAnimations?: boolean;
  35600. /**
  35601. * Defines a callback raised once the interpolation animation has been done.
  35602. */
  35603. onInterpolationDone?: () => void;
  35604. /**
  35605. * Observable triggered once the interpolation animation has been done.
  35606. */
  35607. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35608. private _target;
  35609. private _effectiveTarget;
  35610. private _property;
  35611. /**
  35612. * Instantiate the action
  35613. * @param triggerOptions defines the trigger options
  35614. * @param target defines the object containing the value to interpolate
  35615. * @param propertyPath defines the path to the property in the target object
  35616. * @param value defines the target value at the end of the interpolation
  35617. * @param duration deines the time it will take for the property to interpolate to the value.
  35618. * @param condition defines the trigger related conditions
  35619. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35620. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35621. */
  35622. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35623. /** @hidden */
  35624. _prepare(): void;
  35625. /**
  35626. * Execute the action starts the value interpolation.
  35627. */
  35628. execute(): void;
  35629. /**
  35630. * Serializes the actions and its related information.
  35631. * @param parent defines the object to serialize in
  35632. * @returns the serialized object
  35633. */
  35634. serialize(parent: any): any;
  35635. }
  35636. }
  35637. declare module "babylonjs/Actions/index" {
  35638. export * from "babylonjs/Actions/action";
  35639. export * from "babylonjs/Actions/actionEvent";
  35640. export * from "babylonjs/Actions/actionManager";
  35641. export * from "babylonjs/Actions/condition";
  35642. export * from "babylonjs/Actions/directActions";
  35643. export * from "babylonjs/Actions/directAudioActions";
  35644. export * from "babylonjs/Actions/interpolateValueAction";
  35645. }
  35646. declare module "babylonjs/Animations/index" {
  35647. export * from "babylonjs/Animations/animatable";
  35648. export * from "babylonjs/Animations/animation";
  35649. export * from "babylonjs/Animations/animationGroup";
  35650. export * from "babylonjs/Animations/animationPropertiesOverride";
  35651. export * from "babylonjs/Animations/easing";
  35652. export * from "babylonjs/Animations/runtimeAnimation";
  35653. export * from "babylonjs/Animations/animationEvent";
  35654. export * from "babylonjs/Animations/animationGroup";
  35655. export * from "babylonjs/Animations/animationKey";
  35656. export * from "babylonjs/Animations/animationRange";
  35657. }
  35658. declare module "babylonjs/Audio/soundTrack" {
  35659. import { Sound } from "babylonjs/Audio/sound";
  35660. import { Analyser } from "babylonjs/Audio/analyser";
  35661. import { Scene } from "babylonjs/scene";
  35662. /**
  35663. * Options allowed during the creation of a sound track.
  35664. */
  35665. export interface ISoundTrackOptions {
  35666. /**
  35667. * The volume the sound track should take during creation
  35668. */
  35669. volume?: number;
  35670. /**
  35671. * Define if the sound track is the main sound track of the scene
  35672. */
  35673. mainTrack?: boolean;
  35674. }
  35675. /**
  35676. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35677. * It will be also used in a future release to apply effects on a specific track.
  35678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35679. */
  35680. export class SoundTrack {
  35681. /**
  35682. * The unique identifier of the sound track in the scene.
  35683. */
  35684. id: number;
  35685. /**
  35686. * The list of sounds included in the sound track.
  35687. */
  35688. soundCollection: Array<Sound>;
  35689. private _outputAudioNode;
  35690. private _scene;
  35691. private _isMainTrack;
  35692. private _connectedAnalyser;
  35693. private _options;
  35694. private _isInitialized;
  35695. /**
  35696. * Creates a new sound track.
  35697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35698. * @param scene Define the scene the sound track belongs to
  35699. * @param options
  35700. */
  35701. constructor(scene: Scene, options?: ISoundTrackOptions);
  35702. private _initializeSoundTrackAudioGraph;
  35703. /**
  35704. * Release the sound track and its associated resources
  35705. */
  35706. dispose(): void;
  35707. /**
  35708. * Adds a sound to this sound track
  35709. * @param sound define the cound to add
  35710. * @ignoreNaming
  35711. */
  35712. AddSound(sound: Sound): void;
  35713. /**
  35714. * Removes a sound to this sound track
  35715. * @param sound define the cound to remove
  35716. * @ignoreNaming
  35717. */
  35718. RemoveSound(sound: Sound): void;
  35719. /**
  35720. * Set a global volume for the full sound track.
  35721. * @param newVolume Define the new volume of the sound track
  35722. */
  35723. setVolume(newVolume: number): void;
  35724. /**
  35725. * Switch the panning model to HRTF:
  35726. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35727. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35728. */
  35729. switchPanningModelToHRTF(): void;
  35730. /**
  35731. * Switch the panning model to Equal Power:
  35732. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35733. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35734. */
  35735. switchPanningModelToEqualPower(): void;
  35736. /**
  35737. * Connect the sound track to an audio analyser allowing some amazing
  35738. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35739. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35740. * @param analyser The analyser to connect to the engine
  35741. */
  35742. connectToAnalyser(analyser: Analyser): void;
  35743. }
  35744. }
  35745. declare module "babylonjs/Audio/audioSceneComponent" {
  35746. import { Sound } from "babylonjs/Audio/sound";
  35747. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35748. import { Nullable } from "babylonjs/types";
  35749. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35750. import { Scene } from "babylonjs/scene";
  35751. import { AbstractScene } from "babylonjs/abstractScene";
  35752. module "babylonjs/abstractScene" {
  35753. interface AbstractScene {
  35754. /**
  35755. * The list of sounds used in the scene.
  35756. */
  35757. sounds: Nullable<Array<Sound>>;
  35758. }
  35759. }
  35760. module "babylonjs/scene" {
  35761. interface Scene {
  35762. /**
  35763. * @hidden
  35764. * Backing field
  35765. */
  35766. _mainSoundTrack: SoundTrack;
  35767. /**
  35768. * The main sound track played by the scene.
  35769. * It cotains your primary collection of sounds.
  35770. */
  35771. mainSoundTrack: SoundTrack;
  35772. /**
  35773. * The list of sound tracks added to the scene
  35774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35775. */
  35776. soundTracks: Nullable<Array<SoundTrack>>;
  35777. /**
  35778. * Gets a sound using a given name
  35779. * @param name defines the name to search for
  35780. * @return the found sound or null if not found at all.
  35781. */
  35782. getSoundByName(name: string): Nullable<Sound>;
  35783. /**
  35784. * Gets or sets if audio support is enabled
  35785. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35786. */
  35787. audioEnabled: boolean;
  35788. /**
  35789. * Gets or sets if audio will be output to headphones
  35790. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35791. */
  35792. headphone: boolean;
  35793. }
  35794. }
  35795. /**
  35796. * Defines the sound scene component responsible to manage any sounds
  35797. * in a given scene.
  35798. */
  35799. export class AudioSceneComponent implements ISceneSerializableComponent {
  35800. /**
  35801. * The component name helpfull to identify the component in the list of scene components.
  35802. */
  35803. readonly name: string;
  35804. /**
  35805. * The scene the component belongs to.
  35806. */
  35807. scene: Scene;
  35808. private _audioEnabled;
  35809. /**
  35810. * Gets whether audio is enabled or not.
  35811. * Please use related enable/disable method to switch state.
  35812. */
  35813. readonly audioEnabled: boolean;
  35814. private _headphone;
  35815. /**
  35816. * Gets whether audio is outputing to headphone or not.
  35817. * Please use the according Switch methods to change output.
  35818. */
  35819. readonly headphone: boolean;
  35820. /**
  35821. * Creates a new instance of the component for the given scene
  35822. * @param scene Defines the scene to register the component in
  35823. */
  35824. constructor(scene: Scene);
  35825. /**
  35826. * Registers the component in a given scene
  35827. */
  35828. register(): void;
  35829. /**
  35830. * Rebuilds the elements related to this component in case of
  35831. * context lost for instance.
  35832. */
  35833. rebuild(): void;
  35834. /**
  35835. * Serializes the component data to the specified json object
  35836. * @param serializationObject The object to serialize to
  35837. */
  35838. serialize(serializationObject: any): void;
  35839. /**
  35840. * Adds all the elements from the container to the scene
  35841. * @param container the container holding the elements
  35842. */
  35843. addFromContainer(container: AbstractScene): void;
  35844. /**
  35845. * Removes all the elements in the container from the scene
  35846. * @param container contains the elements to remove
  35847. * @param dispose if the removed element should be disposed (default: false)
  35848. */
  35849. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35850. /**
  35851. * Disposes the component and the associated ressources.
  35852. */
  35853. dispose(): void;
  35854. /**
  35855. * Disables audio in the associated scene.
  35856. */
  35857. disableAudio(): void;
  35858. /**
  35859. * Enables audio in the associated scene.
  35860. */
  35861. enableAudio(): void;
  35862. /**
  35863. * Switch audio to headphone output.
  35864. */
  35865. switchAudioModeForHeadphones(): void;
  35866. /**
  35867. * Switch audio to normal speakers.
  35868. */
  35869. switchAudioModeForNormalSpeakers(): void;
  35870. private _afterRender;
  35871. }
  35872. }
  35873. declare module "babylonjs/Audio/weightedsound" {
  35874. import { Sound } from "babylonjs/Audio/sound";
  35875. /**
  35876. * Wraps one or more Sound objects and selects one with random weight for playback.
  35877. */
  35878. export class WeightedSound {
  35879. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35880. loop: boolean;
  35881. private _coneInnerAngle;
  35882. private _coneOuterAngle;
  35883. private _volume;
  35884. /** A Sound is currently playing. */
  35885. isPlaying: boolean;
  35886. /** A Sound is currently paused. */
  35887. isPaused: boolean;
  35888. private _sounds;
  35889. private _weights;
  35890. private _currentIndex?;
  35891. /**
  35892. * Creates a new WeightedSound from the list of sounds given.
  35893. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35894. * @param sounds Array of Sounds that will be selected from.
  35895. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35896. */
  35897. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35898. /**
  35899. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35900. */
  35901. /**
  35902. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35903. */
  35904. directionalConeInnerAngle: number;
  35905. /**
  35906. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35907. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35908. */
  35909. /**
  35910. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35911. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35912. */
  35913. directionalConeOuterAngle: number;
  35914. /**
  35915. * Playback volume.
  35916. */
  35917. /**
  35918. * Playback volume.
  35919. */
  35920. volume: number;
  35921. private _onended;
  35922. /**
  35923. * Suspend playback
  35924. */
  35925. pause(): void;
  35926. /**
  35927. * Stop playback
  35928. */
  35929. stop(): void;
  35930. /**
  35931. * Start playback.
  35932. * @param startOffset Position the clip head at a specific time in seconds.
  35933. */
  35934. play(startOffset?: number): void;
  35935. }
  35936. }
  35937. declare module "babylonjs/Audio/index" {
  35938. export * from "babylonjs/Audio/analyser";
  35939. export * from "babylonjs/Audio/audioEngine";
  35940. export * from "babylonjs/Audio/audioSceneComponent";
  35941. export * from "babylonjs/Audio/sound";
  35942. export * from "babylonjs/Audio/soundTrack";
  35943. export * from "babylonjs/Audio/weightedsound";
  35944. }
  35945. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35946. import { Behavior } from "babylonjs/Behaviors/behavior";
  35947. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35948. import { BackEase } from "babylonjs/Animations/easing";
  35949. /**
  35950. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35951. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35952. */
  35953. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35954. /**
  35955. * Gets the name of the behavior.
  35956. */
  35957. readonly name: string;
  35958. /**
  35959. * The easing function used by animations
  35960. */
  35961. static EasingFunction: BackEase;
  35962. /**
  35963. * The easing mode used by animations
  35964. */
  35965. static EasingMode: number;
  35966. /**
  35967. * The duration of the animation, in milliseconds
  35968. */
  35969. transitionDuration: number;
  35970. /**
  35971. * Length of the distance animated by the transition when lower radius is reached
  35972. */
  35973. lowerRadiusTransitionRange: number;
  35974. /**
  35975. * Length of the distance animated by the transition when upper radius is reached
  35976. */
  35977. upperRadiusTransitionRange: number;
  35978. private _autoTransitionRange;
  35979. /**
  35980. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35981. */
  35982. /**
  35983. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35984. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35985. */
  35986. autoTransitionRange: boolean;
  35987. private _attachedCamera;
  35988. private _onAfterCheckInputsObserver;
  35989. private _onMeshTargetChangedObserver;
  35990. /**
  35991. * Initializes the behavior.
  35992. */
  35993. init(): void;
  35994. /**
  35995. * Attaches the behavior to its arc rotate camera.
  35996. * @param camera Defines the camera to attach the behavior to
  35997. */
  35998. attach(camera: ArcRotateCamera): void;
  35999. /**
  36000. * Detaches the behavior from its current arc rotate camera.
  36001. */
  36002. detach(): void;
  36003. private _radiusIsAnimating;
  36004. private _radiusBounceTransition;
  36005. private _animatables;
  36006. private _cachedWheelPrecision;
  36007. /**
  36008. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36009. * @param radiusLimit The limit to check against.
  36010. * @return Bool to indicate if at limit.
  36011. */
  36012. private _isRadiusAtLimit;
  36013. /**
  36014. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36015. * @param radiusDelta The delta by which to animate to. Can be negative.
  36016. */
  36017. private _applyBoundRadiusAnimation;
  36018. /**
  36019. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36020. */
  36021. protected _clearAnimationLocks(): void;
  36022. /**
  36023. * Stops and removes all animations that have been applied to the camera
  36024. */
  36025. stopAllAnimations(): void;
  36026. }
  36027. }
  36028. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36029. import { Behavior } from "babylonjs/Behaviors/behavior";
  36030. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36031. import { ExponentialEase } from "babylonjs/Animations/easing";
  36032. import { Nullable } from "babylonjs/types";
  36033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36034. import { Vector3 } from "babylonjs/Maths/math";
  36035. /**
  36036. * 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.
  36037. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36038. */
  36039. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36040. /**
  36041. * Gets the name of the behavior.
  36042. */
  36043. readonly name: string;
  36044. private _mode;
  36045. private _radiusScale;
  36046. private _positionScale;
  36047. private _defaultElevation;
  36048. private _elevationReturnTime;
  36049. private _elevationReturnWaitTime;
  36050. private _zoomStopsAnimation;
  36051. private _framingTime;
  36052. /**
  36053. * The easing function used by animations
  36054. */
  36055. static EasingFunction: ExponentialEase;
  36056. /**
  36057. * The easing mode used by animations
  36058. */
  36059. static EasingMode: number;
  36060. /**
  36061. * Sets the current mode used by the behavior
  36062. */
  36063. /**
  36064. * Gets current mode used by the behavior.
  36065. */
  36066. mode: number;
  36067. /**
  36068. * Sets the scale applied to the radius (1 by default)
  36069. */
  36070. /**
  36071. * Gets the scale applied to the radius
  36072. */
  36073. radiusScale: number;
  36074. /**
  36075. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36076. */
  36077. /**
  36078. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36079. */
  36080. positionScale: number;
  36081. /**
  36082. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36083. * behaviour is triggered, in radians.
  36084. */
  36085. /**
  36086. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36087. * behaviour is triggered, in radians.
  36088. */
  36089. defaultElevation: number;
  36090. /**
  36091. * Sets the time (in milliseconds) taken to return to the default beta position.
  36092. * Negative value indicates camera should not return to default.
  36093. */
  36094. /**
  36095. * Gets the time (in milliseconds) taken to return to the default beta position.
  36096. * Negative value indicates camera should not return to default.
  36097. */
  36098. elevationReturnTime: number;
  36099. /**
  36100. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36101. */
  36102. /**
  36103. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36104. */
  36105. elevationReturnWaitTime: number;
  36106. /**
  36107. * Sets the flag that indicates if user zooming should stop animation.
  36108. */
  36109. /**
  36110. * Gets the flag that indicates if user zooming should stop animation.
  36111. */
  36112. zoomStopsAnimation: boolean;
  36113. /**
  36114. * Sets the transition time when framing the mesh, in milliseconds
  36115. */
  36116. /**
  36117. * Gets the transition time when framing the mesh, in milliseconds
  36118. */
  36119. framingTime: number;
  36120. /**
  36121. * Define if the behavior should automatically change the configured
  36122. * camera limits and sensibilities.
  36123. */
  36124. autoCorrectCameraLimitsAndSensibility: boolean;
  36125. private _onPrePointerObservableObserver;
  36126. private _onAfterCheckInputsObserver;
  36127. private _onMeshTargetChangedObserver;
  36128. private _attachedCamera;
  36129. private _isPointerDown;
  36130. private _lastInteractionTime;
  36131. /**
  36132. * Initializes the behavior.
  36133. */
  36134. init(): void;
  36135. /**
  36136. * Attaches the behavior to its arc rotate camera.
  36137. * @param camera Defines the camera to attach the behavior to
  36138. */
  36139. attach(camera: ArcRotateCamera): void;
  36140. /**
  36141. * Detaches the behavior from its current arc rotate camera.
  36142. */
  36143. detach(): void;
  36144. private _animatables;
  36145. private _betaIsAnimating;
  36146. private _betaTransition;
  36147. private _radiusTransition;
  36148. private _vectorTransition;
  36149. /**
  36150. * Targets the given mesh and updates zoom level accordingly.
  36151. * @param mesh The mesh to target.
  36152. * @param radius Optional. If a cached radius position already exists, overrides default.
  36153. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36154. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36155. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36156. */
  36157. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36158. /**
  36159. * Targets the given mesh with its children and updates zoom level accordingly.
  36160. * @param mesh The mesh to target.
  36161. * @param radius Optional. If a cached radius position already exists, overrides default.
  36162. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36163. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36164. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36165. */
  36166. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36167. /**
  36168. * Targets the given meshes with their children and updates zoom level accordingly.
  36169. * @param meshes The mesh to target.
  36170. * @param radius Optional. If a cached radius position already exists, overrides default.
  36171. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36172. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36173. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36174. */
  36175. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36176. /**
  36177. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36178. * @param minimumWorld Determines the smaller position of the bounding box extend
  36179. * @param maximumWorld Determines the bigger position of the bounding box extend
  36180. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36181. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36182. */
  36183. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36184. /**
  36185. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36186. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36187. * frustum width.
  36188. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36189. * to fully enclose the mesh in the viewing frustum.
  36190. */
  36191. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36192. /**
  36193. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36194. * is automatically returned to its default position (expected to be above ground plane).
  36195. */
  36196. private _maintainCameraAboveGround;
  36197. /**
  36198. * Returns the frustum slope based on the canvas ratio and camera FOV
  36199. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36200. */
  36201. private _getFrustumSlope;
  36202. /**
  36203. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36204. */
  36205. private _clearAnimationLocks;
  36206. /**
  36207. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36208. */
  36209. private _applyUserInteraction;
  36210. /**
  36211. * Stops and removes all animations that have been applied to the camera
  36212. */
  36213. stopAllAnimations(): void;
  36214. /**
  36215. * Gets a value indicating if the user is moving the camera
  36216. */
  36217. readonly isUserIsMoving: boolean;
  36218. /**
  36219. * The camera can move all the way towards the mesh.
  36220. */
  36221. static IgnoreBoundsSizeMode: number;
  36222. /**
  36223. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36224. */
  36225. static FitFrustumSidesMode: number;
  36226. }
  36227. }
  36228. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36229. import { Nullable } from "babylonjs/types";
  36230. import { Camera } from "babylonjs/Cameras/camera";
  36231. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36232. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36233. /**
  36234. * Base class for Camera Pointer Inputs.
  36235. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36236. * for example usage.
  36237. */
  36238. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36239. /**
  36240. * Defines the camera the input is attached to.
  36241. */
  36242. abstract camera: Camera;
  36243. /**
  36244. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36245. */
  36246. protected _altKey: boolean;
  36247. protected _ctrlKey: boolean;
  36248. protected _metaKey: boolean;
  36249. protected _shiftKey: boolean;
  36250. /**
  36251. * Which mouse buttons were pressed at time of last mouse event.
  36252. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36253. */
  36254. protected _buttonsPressed: number;
  36255. /**
  36256. * Defines the buttons associated with the input to handle camera move.
  36257. */
  36258. buttons: number[];
  36259. /**
  36260. * Attach the input controls to a specific dom element to get the input from.
  36261. * @param element Defines the element the controls should be listened from
  36262. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36263. */
  36264. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36265. /**
  36266. * Detach the current controls from the specified dom element.
  36267. * @param element Defines the element to stop listening the inputs from
  36268. */
  36269. detachControl(element: Nullable<HTMLElement>): void;
  36270. /**
  36271. * Gets the class name of the current input.
  36272. * @returns the class name
  36273. */
  36274. getClassName(): string;
  36275. /**
  36276. * Get the friendly name associated with the input class.
  36277. * @returns the input friendly name
  36278. */
  36279. getSimpleName(): string;
  36280. /**
  36281. * Called on pointer POINTERDOUBLETAP event.
  36282. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36283. */
  36284. protected onDoubleTap(type: string): void;
  36285. /**
  36286. * Called on pointer POINTERMOVE event if only a single touch is active.
  36287. * Override this method to provide functionality.
  36288. */
  36289. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36290. /**
  36291. * Called on pointer POINTERMOVE event if multiple touches are active.
  36292. * Override this method to provide functionality.
  36293. */
  36294. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36295. /**
  36296. * Called on JS contextmenu event.
  36297. * Override this method to provide functionality.
  36298. */
  36299. protected onContextMenu(evt: PointerEvent): void;
  36300. /**
  36301. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36302. * press.
  36303. * Override this method to provide functionality.
  36304. */
  36305. protected onButtonDown(evt: PointerEvent): void;
  36306. /**
  36307. * Called each time a new POINTERUP event occurs. Ie, for each button
  36308. * release.
  36309. * Override this method to provide functionality.
  36310. */
  36311. protected onButtonUp(evt: PointerEvent): void;
  36312. /**
  36313. * Called when window becomes inactive.
  36314. * Override this method to provide functionality.
  36315. */
  36316. protected onLostFocus(): void;
  36317. private _pointerInput;
  36318. private _observer;
  36319. private _onLostFocus;
  36320. private pointA;
  36321. private pointB;
  36322. }
  36323. }
  36324. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36325. import { Nullable } from "babylonjs/types";
  36326. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36327. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36328. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36329. /**
  36330. * Manage the pointers inputs to control an arc rotate camera.
  36331. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36332. */
  36333. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36334. /**
  36335. * Defines the camera the input is attached to.
  36336. */
  36337. camera: ArcRotateCamera;
  36338. /**
  36339. * Gets the class name of the current input.
  36340. * @returns the class name
  36341. */
  36342. getClassName(): string;
  36343. /**
  36344. * Defines the buttons associated with the input to handle camera move.
  36345. */
  36346. buttons: number[];
  36347. /**
  36348. * Defines the pointer angular sensibility along the X axis or how fast is
  36349. * the camera rotating.
  36350. */
  36351. angularSensibilityX: number;
  36352. /**
  36353. * Defines the pointer angular sensibility along the Y axis or how fast is
  36354. * the camera rotating.
  36355. */
  36356. angularSensibilityY: number;
  36357. /**
  36358. * Defines the pointer pinch precision or how fast is the camera zooming.
  36359. */
  36360. pinchPrecision: number;
  36361. /**
  36362. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36363. * from 0.
  36364. * It defines the percentage of current camera.radius to use as delta when
  36365. * pinch zoom is used.
  36366. */
  36367. pinchDeltaPercentage: number;
  36368. /**
  36369. * Defines the pointer panning sensibility or how fast is the camera moving.
  36370. */
  36371. panningSensibility: number;
  36372. /**
  36373. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36374. */
  36375. multiTouchPanning: boolean;
  36376. /**
  36377. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36378. * zoom (pinch) through multitouch.
  36379. */
  36380. multiTouchPanAndZoom: boolean;
  36381. /**
  36382. * Revers pinch action direction.
  36383. */
  36384. pinchInwards: boolean;
  36385. private _isPanClick;
  36386. private _twoFingerActivityCount;
  36387. private _isPinching;
  36388. /**
  36389. * Called on pointer POINTERMOVE event if only a single touch is active.
  36390. */
  36391. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36392. /**
  36393. * Called on pointer POINTERDOUBLETAP event.
  36394. */
  36395. protected onDoubleTap(type: string): void;
  36396. /**
  36397. * Called on pointer POINTERMOVE event if multiple touches are active.
  36398. */
  36399. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36400. /**
  36401. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36402. * press.
  36403. */
  36404. protected onButtonDown(evt: PointerEvent): void;
  36405. /**
  36406. * Called each time a new POINTERUP event occurs. Ie, for each button
  36407. * release.
  36408. */
  36409. protected onButtonUp(evt: PointerEvent): void;
  36410. /**
  36411. * Called when window becomes inactive.
  36412. */
  36413. protected onLostFocus(): void;
  36414. }
  36415. }
  36416. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36417. import { Nullable } from "babylonjs/types";
  36418. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36419. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36420. /**
  36421. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36422. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36423. */
  36424. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36425. /**
  36426. * Defines the camera the input is attached to.
  36427. */
  36428. camera: ArcRotateCamera;
  36429. /**
  36430. * Defines the list of key codes associated with the up action (increase alpha)
  36431. */
  36432. keysUp: number[];
  36433. /**
  36434. * Defines the list of key codes associated with the down action (decrease alpha)
  36435. */
  36436. keysDown: number[];
  36437. /**
  36438. * Defines the list of key codes associated with the left action (increase beta)
  36439. */
  36440. keysLeft: number[];
  36441. /**
  36442. * Defines the list of key codes associated with the right action (decrease beta)
  36443. */
  36444. keysRight: number[];
  36445. /**
  36446. * Defines the list of key codes associated with the reset action.
  36447. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36448. */
  36449. keysReset: number[];
  36450. /**
  36451. * Defines the panning sensibility of the inputs.
  36452. * (How fast is the camera paning)
  36453. */
  36454. panningSensibility: number;
  36455. /**
  36456. * Defines the zooming sensibility of the inputs.
  36457. * (How fast is the camera zooming)
  36458. */
  36459. zoomingSensibility: number;
  36460. /**
  36461. * Defines wether maintaining the alt key down switch the movement mode from
  36462. * orientation to zoom.
  36463. */
  36464. useAltToZoom: boolean;
  36465. /**
  36466. * Rotation speed of the camera
  36467. */
  36468. angularSpeed: number;
  36469. private _keys;
  36470. private _ctrlPressed;
  36471. private _altPressed;
  36472. private _onCanvasBlurObserver;
  36473. private _onKeyboardObserver;
  36474. private _engine;
  36475. private _scene;
  36476. /**
  36477. * Attach the input controls to a specific dom element to get the input from.
  36478. * @param element Defines the element the controls should be listened from
  36479. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36480. */
  36481. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36482. /**
  36483. * Detach the current controls from the specified dom element.
  36484. * @param element Defines the element to stop listening the inputs from
  36485. */
  36486. detachControl(element: Nullable<HTMLElement>): void;
  36487. /**
  36488. * Update the current camera state depending on the inputs that have been used this frame.
  36489. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36490. */
  36491. checkInputs(): void;
  36492. /**
  36493. * Gets the class name of the current intput.
  36494. * @returns the class name
  36495. */
  36496. getClassName(): string;
  36497. /**
  36498. * Get the friendly name associated with the input class.
  36499. * @returns the input friendly name
  36500. */
  36501. getSimpleName(): string;
  36502. }
  36503. }
  36504. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36505. import { Nullable } from "babylonjs/types";
  36506. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36507. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36508. /**
  36509. * Manage the mouse wheel inputs to control an arc rotate camera.
  36510. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36511. */
  36512. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36513. /**
  36514. * Defines the camera the input is attached to.
  36515. */
  36516. camera: ArcRotateCamera;
  36517. /**
  36518. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36519. */
  36520. wheelPrecision: number;
  36521. /**
  36522. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36523. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36524. */
  36525. wheelDeltaPercentage: number;
  36526. private _wheel;
  36527. private _observer;
  36528. private computeDeltaFromMouseWheelLegacyEvent;
  36529. /**
  36530. * Attach the input controls to a specific dom element to get the input from.
  36531. * @param element Defines the element the controls should be listened from
  36532. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36533. */
  36534. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36535. /**
  36536. * Detach the current controls from the specified dom element.
  36537. * @param element Defines the element to stop listening the inputs from
  36538. */
  36539. detachControl(element: Nullable<HTMLElement>): void;
  36540. /**
  36541. * Gets the class name of the current intput.
  36542. * @returns the class name
  36543. */
  36544. getClassName(): string;
  36545. /**
  36546. * Get the friendly name associated with the input class.
  36547. * @returns the input friendly name
  36548. */
  36549. getSimpleName(): string;
  36550. }
  36551. }
  36552. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36553. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36554. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36555. /**
  36556. * Default Inputs manager for the ArcRotateCamera.
  36557. * It groups all the default supported inputs for ease of use.
  36558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36559. */
  36560. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36561. /**
  36562. * Instantiates a new ArcRotateCameraInputsManager.
  36563. * @param camera Defines the camera the inputs belong to
  36564. */
  36565. constructor(camera: ArcRotateCamera);
  36566. /**
  36567. * Add mouse wheel input support to the input manager.
  36568. * @returns the current input manager
  36569. */
  36570. addMouseWheel(): ArcRotateCameraInputsManager;
  36571. /**
  36572. * Add pointers input support to the input manager.
  36573. * @returns the current input manager
  36574. */
  36575. addPointers(): ArcRotateCameraInputsManager;
  36576. /**
  36577. * Add keyboard input support to the input manager.
  36578. * @returns the current input manager
  36579. */
  36580. addKeyboard(): ArcRotateCameraInputsManager;
  36581. }
  36582. }
  36583. declare module "babylonjs/Cameras/arcRotateCamera" {
  36584. import { Observable } from "babylonjs/Misc/observable";
  36585. import { Nullable } from "babylonjs/types";
  36586. import { Scene } from "babylonjs/scene";
  36587. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36589. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36590. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36591. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36592. import { Camera } from "babylonjs/Cameras/camera";
  36593. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36594. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36595. import { Collider } from "babylonjs/Collisions/collider";
  36596. /**
  36597. * This represents an orbital type of camera.
  36598. *
  36599. * 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.
  36600. * 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.
  36601. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36602. */
  36603. export class ArcRotateCamera extends TargetCamera {
  36604. /**
  36605. * Defines the rotation angle of the camera along the longitudinal axis.
  36606. */
  36607. alpha: number;
  36608. /**
  36609. * Defines the rotation angle of the camera along the latitudinal axis.
  36610. */
  36611. beta: number;
  36612. /**
  36613. * Defines the radius of the camera from it s target point.
  36614. */
  36615. radius: number;
  36616. protected _target: Vector3;
  36617. protected _targetHost: Nullable<AbstractMesh>;
  36618. /**
  36619. * Defines the target point of the camera.
  36620. * The camera looks towards it form the radius distance.
  36621. */
  36622. target: Vector3;
  36623. /**
  36624. * Define the current local position of the camera in the scene
  36625. */
  36626. position: Vector3;
  36627. protected _upVector: Vector3;
  36628. protected _upToYMatrix: Matrix;
  36629. protected _YToUpMatrix: Matrix;
  36630. /**
  36631. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36632. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36633. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36634. */
  36635. upVector: Vector3;
  36636. /**
  36637. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36638. */
  36639. setMatUp(): void;
  36640. /**
  36641. * Current inertia value on the longitudinal axis.
  36642. * The bigger this number the longer it will take for the camera to stop.
  36643. */
  36644. inertialAlphaOffset: number;
  36645. /**
  36646. * Current inertia value on the latitudinal axis.
  36647. * The bigger this number the longer it will take for the camera to stop.
  36648. */
  36649. inertialBetaOffset: number;
  36650. /**
  36651. * Current inertia value on the radius axis.
  36652. * The bigger this number the longer it will take for the camera to stop.
  36653. */
  36654. inertialRadiusOffset: number;
  36655. /**
  36656. * Minimum allowed angle on the longitudinal axis.
  36657. * This can help limiting how the Camera is able to move in the scene.
  36658. */
  36659. lowerAlphaLimit: Nullable<number>;
  36660. /**
  36661. * Maximum allowed angle on the longitudinal axis.
  36662. * This can help limiting how the Camera is able to move in the scene.
  36663. */
  36664. upperAlphaLimit: Nullable<number>;
  36665. /**
  36666. * Minimum allowed angle on the latitudinal axis.
  36667. * This can help limiting how the Camera is able to move in the scene.
  36668. */
  36669. lowerBetaLimit: number;
  36670. /**
  36671. * Maximum allowed angle on the latitudinal axis.
  36672. * This can help limiting how the Camera is able to move in the scene.
  36673. */
  36674. upperBetaLimit: number;
  36675. /**
  36676. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36677. * This can help limiting how the Camera is able to move in the scene.
  36678. */
  36679. lowerRadiusLimit: Nullable<number>;
  36680. /**
  36681. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36682. * This can help limiting how the Camera is able to move in the scene.
  36683. */
  36684. upperRadiusLimit: Nullable<number>;
  36685. /**
  36686. * Defines the current inertia value used during panning of the camera along the X axis.
  36687. */
  36688. inertialPanningX: number;
  36689. /**
  36690. * Defines the current inertia value used during panning of the camera along the Y axis.
  36691. */
  36692. inertialPanningY: number;
  36693. /**
  36694. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36695. * Basically if your fingers moves away from more than this distance you will be considered
  36696. * in pinch mode.
  36697. */
  36698. pinchToPanMaxDistance: number;
  36699. /**
  36700. * Defines the maximum distance the camera can pan.
  36701. * This could help keeping the cammera always in your scene.
  36702. */
  36703. panningDistanceLimit: Nullable<number>;
  36704. /**
  36705. * Defines the target of the camera before paning.
  36706. */
  36707. panningOriginTarget: Vector3;
  36708. /**
  36709. * Defines the value of the inertia used during panning.
  36710. * 0 would mean stop inertia and one would mean no decelleration at all.
  36711. */
  36712. panningInertia: number;
  36713. /**
  36714. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36715. */
  36716. angularSensibilityX: number;
  36717. /**
  36718. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36719. */
  36720. angularSensibilityY: number;
  36721. /**
  36722. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36723. */
  36724. pinchPrecision: number;
  36725. /**
  36726. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36727. * It will be used instead of pinchDeltaPrecision if different from 0.
  36728. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36729. */
  36730. pinchDeltaPercentage: number;
  36731. /**
  36732. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36733. */
  36734. panningSensibility: number;
  36735. /**
  36736. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36737. */
  36738. keysUp: number[];
  36739. /**
  36740. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36741. */
  36742. keysDown: number[];
  36743. /**
  36744. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36745. */
  36746. keysLeft: number[];
  36747. /**
  36748. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36749. */
  36750. keysRight: number[];
  36751. /**
  36752. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36753. */
  36754. wheelPrecision: number;
  36755. /**
  36756. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36757. * It will be used instead of pinchDeltaPrecision if different from 0.
  36758. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36759. */
  36760. wheelDeltaPercentage: number;
  36761. /**
  36762. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36763. */
  36764. zoomOnFactor: number;
  36765. /**
  36766. * Defines a screen offset for the camera position.
  36767. */
  36768. targetScreenOffset: Vector2;
  36769. /**
  36770. * Allows the camera to be completely reversed.
  36771. * If false the camera can not arrive upside down.
  36772. */
  36773. allowUpsideDown: boolean;
  36774. /**
  36775. * Define if double tap/click is used to restore the previously saved state of the camera.
  36776. */
  36777. useInputToRestoreState: boolean;
  36778. /** @hidden */
  36779. _viewMatrix: Matrix;
  36780. /** @hidden */
  36781. _useCtrlForPanning: boolean;
  36782. /** @hidden */
  36783. _panningMouseButton: number;
  36784. /**
  36785. * Defines the input associated to the camera.
  36786. */
  36787. inputs: ArcRotateCameraInputsManager;
  36788. /** @hidden */
  36789. _reset: () => void;
  36790. /**
  36791. * Defines the allowed panning axis.
  36792. */
  36793. panningAxis: Vector3;
  36794. protected _localDirection: Vector3;
  36795. protected _transformedDirection: Vector3;
  36796. private _bouncingBehavior;
  36797. /**
  36798. * Gets the bouncing behavior of the camera if it has been enabled.
  36799. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36800. */
  36801. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36802. /**
  36803. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36804. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36805. */
  36806. useBouncingBehavior: boolean;
  36807. private _framingBehavior;
  36808. /**
  36809. * Gets the framing behavior of the camera if it has been enabled.
  36810. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36811. */
  36812. readonly framingBehavior: Nullable<FramingBehavior>;
  36813. /**
  36814. * Defines if the framing behavior of the camera is enabled on the camera.
  36815. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36816. */
  36817. useFramingBehavior: boolean;
  36818. private _autoRotationBehavior;
  36819. /**
  36820. * Gets the auto rotation behavior of the camera if it has been enabled.
  36821. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36822. */
  36823. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36824. /**
  36825. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36826. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36827. */
  36828. useAutoRotationBehavior: boolean;
  36829. /**
  36830. * Observable triggered when the mesh target has been changed on the camera.
  36831. */
  36832. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36833. /**
  36834. * Event raised when the camera is colliding with a mesh.
  36835. */
  36836. onCollide: (collidedMesh: AbstractMesh) => void;
  36837. /**
  36838. * Defines whether the camera should check collision with the objects oh the scene.
  36839. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36840. */
  36841. checkCollisions: boolean;
  36842. /**
  36843. * Defines the collision radius of the camera.
  36844. * This simulates a sphere around the camera.
  36845. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36846. */
  36847. collisionRadius: Vector3;
  36848. protected _collider: Collider;
  36849. protected _previousPosition: Vector3;
  36850. protected _collisionVelocity: Vector3;
  36851. protected _newPosition: Vector3;
  36852. protected _previousAlpha: number;
  36853. protected _previousBeta: number;
  36854. protected _previousRadius: number;
  36855. protected _collisionTriggered: boolean;
  36856. protected _targetBoundingCenter: Nullable<Vector3>;
  36857. private _computationVector;
  36858. /**
  36859. * Instantiates a new ArcRotateCamera in a given scene
  36860. * @param name Defines the name of the camera
  36861. * @param alpha Defines the camera rotation along the logitudinal axis
  36862. * @param beta Defines the camera rotation along the latitudinal axis
  36863. * @param radius Defines the camera distance from its target
  36864. * @param target Defines the camera target
  36865. * @param scene Defines the scene the camera belongs to
  36866. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36867. */
  36868. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36869. /** @hidden */
  36870. _initCache(): void;
  36871. /** @hidden */
  36872. _updateCache(ignoreParentClass?: boolean): void;
  36873. protected _getTargetPosition(): Vector3;
  36874. private _storedAlpha;
  36875. private _storedBeta;
  36876. private _storedRadius;
  36877. private _storedTarget;
  36878. /**
  36879. * Stores the current state of the camera (alpha, beta, radius and target)
  36880. * @returns the camera itself
  36881. */
  36882. storeState(): Camera;
  36883. /**
  36884. * @hidden
  36885. * Restored camera state. You must call storeState() first
  36886. */
  36887. _restoreStateValues(): boolean;
  36888. /** @hidden */
  36889. _isSynchronizedViewMatrix(): boolean;
  36890. /**
  36891. * Attached controls to the current camera.
  36892. * @param element Defines the element the controls should be listened from
  36893. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36894. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36895. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36896. */
  36897. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36898. /**
  36899. * Detach the current controls from the camera.
  36900. * The camera will stop reacting to inputs.
  36901. * @param element Defines the element to stop listening the inputs from
  36902. */
  36903. detachControl(element: HTMLElement): void;
  36904. /** @hidden */
  36905. _checkInputs(): void;
  36906. protected _checkLimits(): void;
  36907. /**
  36908. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36909. */
  36910. rebuildAnglesAndRadius(): void;
  36911. /**
  36912. * Use a position to define the current camera related information like aplha, beta and radius
  36913. * @param position Defines the position to set the camera at
  36914. */
  36915. setPosition(position: Vector3): void;
  36916. /**
  36917. * Defines the target the camera should look at.
  36918. * This will automatically adapt alpha beta and radius to fit within the new target.
  36919. * @param target Defines the new target as a Vector or a mesh
  36920. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36921. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36922. */
  36923. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36924. /** @hidden */
  36925. _getViewMatrix(): Matrix;
  36926. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36927. /**
  36928. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36929. * @param meshes Defines the mesh to zoom on
  36930. * @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)
  36931. */
  36932. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36933. /**
  36934. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36935. * The target will be changed but the radius
  36936. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36937. * @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)
  36938. */
  36939. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36940. min: Vector3;
  36941. max: Vector3;
  36942. distance: number;
  36943. }, doNotUpdateMaxZ?: boolean): void;
  36944. /**
  36945. * @override
  36946. * Override Camera.createRigCamera
  36947. */
  36948. createRigCamera(name: string, cameraIndex: number): Camera;
  36949. /**
  36950. * @hidden
  36951. * @override
  36952. * Override Camera._updateRigCameras
  36953. */
  36954. _updateRigCameras(): void;
  36955. /**
  36956. * Destroy the camera and release the current resources hold by it.
  36957. */
  36958. dispose(): void;
  36959. /**
  36960. * Gets the current object class name.
  36961. * @return the class name
  36962. */
  36963. getClassName(): string;
  36964. }
  36965. }
  36966. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36967. import { Behavior } from "babylonjs/Behaviors/behavior";
  36968. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36969. /**
  36970. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36971. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36972. */
  36973. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36974. /**
  36975. * Gets the name of the behavior.
  36976. */
  36977. readonly name: string;
  36978. private _zoomStopsAnimation;
  36979. private _idleRotationSpeed;
  36980. private _idleRotationWaitTime;
  36981. private _idleRotationSpinupTime;
  36982. /**
  36983. * Sets the flag that indicates if user zooming should stop animation.
  36984. */
  36985. /**
  36986. * Gets the flag that indicates if user zooming should stop animation.
  36987. */
  36988. zoomStopsAnimation: boolean;
  36989. /**
  36990. * Sets the default speed at which the camera rotates around the model.
  36991. */
  36992. /**
  36993. * Gets the default speed at which the camera rotates around the model.
  36994. */
  36995. idleRotationSpeed: number;
  36996. /**
  36997. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36998. */
  36999. /**
  37000. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37001. */
  37002. idleRotationWaitTime: number;
  37003. /**
  37004. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37005. */
  37006. /**
  37007. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37008. */
  37009. idleRotationSpinupTime: number;
  37010. /**
  37011. * Gets a value indicating if the camera is currently rotating because of this behavior
  37012. */
  37013. readonly rotationInProgress: boolean;
  37014. private _onPrePointerObservableObserver;
  37015. private _onAfterCheckInputsObserver;
  37016. private _attachedCamera;
  37017. private _isPointerDown;
  37018. private _lastFrameTime;
  37019. private _lastInteractionTime;
  37020. private _cameraRotationSpeed;
  37021. /**
  37022. * Initializes the behavior.
  37023. */
  37024. init(): void;
  37025. /**
  37026. * Attaches the behavior to its arc rotate camera.
  37027. * @param camera Defines the camera to attach the behavior to
  37028. */
  37029. attach(camera: ArcRotateCamera): void;
  37030. /**
  37031. * Detaches the behavior from its current arc rotate camera.
  37032. */
  37033. detach(): void;
  37034. /**
  37035. * Returns true if user is scrolling.
  37036. * @return true if user is scrolling.
  37037. */
  37038. private _userIsZooming;
  37039. private _lastFrameRadius;
  37040. private _shouldAnimationStopForInteraction;
  37041. /**
  37042. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37043. */
  37044. private _applyUserInteraction;
  37045. private _userIsMoving;
  37046. }
  37047. }
  37048. declare module "babylonjs/Behaviors/Cameras/index" {
  37049. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37050. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37051. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37052. }
  37053. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37054. import { Mesh } from "babylonjs/Meshes/mesh";
  37055. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37056. import { Behavior } from "babylonjs/Behaviors/behavior";
  37057. /**
  37058. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37059. */
  37060. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37061. private ui;
  37062. /**
  37063. * The name of the behavior
  37064. */
  37065. name: string;
  37066. /**
  37067. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37068. */
  37069. distanceAwayFromFace: number;
  37070. /**
  37071. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37072. */
  37073. distanceAwayFromBottomOfFace: number;
  37074. private _faceVectors;
  37075. private _target;
  37076. private _scene;
  37077. private _onRenderObserver;
  37078. private _tmpMatrix;
  37079. private _tmpVector;
  37080. /**
  37081. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37082. * @param ui The transform node that should be attched to the mesh
  37083. */
  37084. constructor(ui: TransformNode);
  37085. /**
  37086. * Initializes the behavior
  37087. */
  37088. init(): void;
  37089. private _closestFace;
  37090. private _zeroVector;
  37091. private _lookAtTmpMatrix;
  37092. private _lookAtToRef;
  37093. /**
  37094. * Attaches the AttachToBoxBehavior to the passed in mesh
  37095. * @param target The mesh that the specified node will be attached to
  37096. */
  37097. attach(target: Mesh): void;
  37098. /**
  37099. * Detaches the behavior from the mesh
  37100. */
  37101. detach(): void;
  37102. }
  37103. }
  37104. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37105. import { Behavior } from "babylonjs/Behaviors/behavior";
  37106. import { Mesh } from "babylonjs/Meshes/mesh";
  37107. /**
  37108. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37109. */
  37110. export class FadeInOutBehavior implements Behavior<Mesh> {
  37111. /**
  37112. * Time in milliseconds to delay before fading in (Default: 0)
  37113. */
  37114. delay: number;
  37115. /**
  37116. * Time in milliseconds for the mesh to fade in (Default: 300)
  37117. */
  37118. fadeInTime: number;
  37119. private _millisecondsPerFrame;
  37120. private _hovered;
  37121. private _hoverValue;
  37122. private _ownerNode;
  37123. /**
  37124. * Instatiates the FadeInOutBehavior
  37125. */
  37126. constructor();
  37127. /**
  37128. * The name of the behavior
  37129. */
  37130. readonly name: string;
  37131. /**
  37132. * Initializes the behavior
  37133. */
  37134. init(): void;
  37135. /**
  37136. * Attaches the fade behavior on the passed in mesh
  37137. * @param ownerNode The mesh that will be faded in/out once attached
  37138. */
  37139. attach(ownerNode: Mesh): void;
  37140. /**
  37141. * Detaches the behavior from the mesh
  37142. */
  37143. detach(): void;
  37144. /**
  37145. * Triggers the mesh to begin fading in or out
  37146. * @param value if the object should fade in or out (true to fade in)
  37147. */
  37148. fadeIn(value: boolean): void;
  37149. private _update;
  37150. private _setAllVisibility;
  37151. }
  37152. }
  37153. declare module "babylonjs/Misc/pivotTools" {
  37154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37155. /**
  37156. * Class containing a set of static utilities functions for managing Pivots
  37157. * @hidden
  37158. */
  37159. export class PivotTools {
  37160. private static _PivotCached;
  37161. private static _OldPivotPoint;
  37162. private static _PivotTranslation;
  37163. private static _PivotTmpVector;
  37164. /** @hidden */
  37165. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37166. /** @hidden */
  37167. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37168. }
  37169. }
  37170. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37171. import { Scene } from "babylonjs/scene";
  37172. import { Vector4, Plane } from "babylonjs/Maths/math";
  37173. import { Mesh } from "babylonjs/Meshes/mesh";
  37174. import { Nullable } from "babylonjs/types";
  37175. /**
  37176. * Class containing static functions to help procedurally build meshes
  37177. */
  37178. export class PlaneBuilder {
  37179. /**
  37180. * Creates a plane mesh
  37181. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37182. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37183. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37185. * * 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
  37186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37187. * @param name defines the name of the mesh
  37188. * @param options defines the options used to create the mesh
  37189. * @param scene defines the hosting scene
  37190. * @returns the plane mesh
  37191. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37192. */
  37193. static CreatePlane(name: string, options: {
  37194. size?: number;
  37195. width?: number;
  37196. height?: number;
  37197. sideOrientation?: number;
  37198. frontUVs?: Vector4;
  37199. backUVs?: Vector4;
  37200. updatable?: boolean;
  37201. sourcePlane?: Plane;
  37202. }, scene?: Nullable<Scene>): Mesh;
  37203. }
  37204. }
  37205. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37206. import { Behavior } from "babylonjs/Behaviors/behavior";
  37207. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37208. import { Observable } from "babylonjs/Misc/observable";
  37209. import { Vector3 } from "babylonjs/Maths/math";
  37210. import { Ray } from "babylonjs/Culling/ray";
  37211. import "babylonjs/Meshes/Builders/planeBuilder";
  37212. /**
  37213. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37214. */
  37215. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37216. private static _AnyMouseID;
  37217. /**
  37218. * Abstract mesh the behavior is set on
  37219. */
  37220. attachedNode: AbstractMesh;
  37221. private _dragPlane;
  37222. private _scene;
  37223. private _pointerObserver;
  37224. private _beforeRenderObserver;
  37225. private static _planeScene;
  37226. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37227. /**
  37228. * 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)
  37229. */
  37230. maxDragAngle: number;
  37231. /**
  37232. * @hidden
  37233. */
  37234. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37235. /**
  37236. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37237. */
  37238. currentDraggingPointerID: number;
  37239. /**
  37240. * The last position where the pointer hit the drag plane in world space
  37241. */
  37242. lastDragPosition: Vector3;
  37243. /**
  37244. * If the behavior is currently in a dragging state
  37245. */
  37246. dragging: boolean;
  37247. /**
  37248. * 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)
  37249. */
  37250. dragDeltaRatio: number;
  37251. /**
  37252. * If the drag plane orientation should be updated during the dragging (Default: true)
  37253. */
  37254. updateDragPlane: boolean;
  37255. private _debugMode;
  37256. private _moving;
  37257. /**
  37258. * Fires each time the attached mesh is dragged with the pointer
  37259. * * delta between last drag position and current drag position in world space
  37260. * * dragDistance along the drag axis
  37261. * * dragPlaneNormal normal of the current drag plane used during the drag
  37262. * * dragPlanePoint in world space where the drag intersects the drag plane
  37263. */
  37264. onDragObservable: Observable<{
  37265. delta: Vector3;
  37266. dragPlanePoint: Vector3;
  37267. dragPlaneNormal: Vector3;
  37268. dragDistance: number;
  37269. pointerId: number;
  37270. }>;
  37271. /**
  37272. * Fires each time a drag begins (eg. mouse down on mesh)
  37273. */
  37274. onDragStartObservable: Observable<{
  37275. dragPlanePoint: Vector3;
  37276. pointerId: number;
  37277. }>;
  37278. /**
  37279. * Fires each time a drag ends (eg. mouse release after drag)
  37280. */
  37281. onDragEndObservable: Observable<{
  37282. dragPlanePoint: Vector3;
  37283. pointerId: number;
  37284. }>;
  37285. /**
  37286. * If the attached mesh should be moved when dragged
  37287. */
  37288. moveAttached: boolean;
  37289. /**
  37290. * If the drag behavior will react to drag events (Default: true)
  37291. */
  37292. enabled: boolean;
  37293. /**
  37294. * If pointer events should start and release the drag (Default: true)
  37295. */
  37296. startAndReleaseDragOnPointerEvents: boolean;
  37297. /**
  37298. * If camera controls should be detached during the drag
  37299. */
  37300. detachCameraControls: boolean;
  37301. /**
  37302. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37303. */
  37304. useObjectOrienationForDragging: boolean;
  37305. private _options;
  37306. /**
  37307. * Creates a pointer drag behavior that can be attached to a mesh
  37308. * @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)
  37309. */
  37310. constructor(options?: {
  37311. dragAxis?: Vector3;
  37312. dragPlaneNormal?: Vector3;
  37313. });
  37314. /**
  37315. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37316. */
  37317. validateDrag: (targetPosition: Vector3) => boolean;
  37318. /**
  37319. * The name of the behavior
  37320. */
  37321. readonly name: string;
  37322. /**
  37323. * Initializes the behavior
  37324. */
  37325. init(): void;
  37326. private _tmpVector;
  37327. private _alternatePickedPoint;
  37328. private _worldDragAxis;
  37329. private _targetPosition;
  37330. private _attachedElement;
  37331. /**
  37332. * Attaches the drag behavior the passed in mesh
  37333. * @param ownerNode The mesh that will be dragged around once attached
  37334. */
  37335. attach(ownerNode: AbstractMesh): void;
  37336. /**
  37337. * Force relase the drag action by code.
  37338. */
  37339. releaseDrag(): void;
  37340. private _startDragRay;
  37341. private _lastPointerRay;
  37342. /**
  37343. * Simulates the start of a pointer drag event on the behavior
  37344. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37345. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37346. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37347. */
  37348. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37349. private _startDrag;
  37350. private _dragDelta;
  37351. private _moveDrag;
  37352. private _pickWithRayOnDragPlane;
  37353. private _pointA;
  37354. private _pointB;
  37355. private _pointC;
  37356. private _lineA;
  37357. private _lineB;
  37358. private _localAxis;
  37359. private _lookAt;
  37360. private _updateDragPlanePosition;
  37361. /**
  37362. * Detaches the behavior from the mesh
  37363. */
  37364. detach(): void;
  37365. }
  37366. }
  37367. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37368. import { Mesh } from "babylonjs/Meshes/mesh";
  37369. import { Behavior } from "babylonjs/Behaviors/behavior";
  37370. /**
  37371. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37372. */
  37373. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37374. private _dragBehaviorA;
  37375. private _dragBehaviorB;
  37376. private _startDistance;
  37377. private _initialScale;
  37378. private _targetScale;
  37379. private _ownerNode;
  37380. private _sceneRenderObserver;
  37381. /**
  37382. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37383. */
  37384. constructor();
  37385. /**
  37386. * The name of the behavior
  37387. */
  37388. readonly name: string;
  37389. /**
  37390. * Initializes the behavior
  37391. */
  37392. init(): void;
  37393. private _getCurrentDistance;
  37394. /**
  37395. * Attaches the scale behavior the passed in mesh
  37396. * @param ownerNode The mesh that will be scaled around once attached
  37397. */
  37398. attach(ownerNode: Mesh): void;
  37399. /**
  37400. * Detaches the behavior from the mesh
  37401. */
  37402. detach(): void;
  37403. }
  37404. }
  37405. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37406. import { Behavior } from "babylonjs/Behaviors/behavior";
  37407. import { Mesh } from "babylonjs/Meshes/mesh";
  37408. import { Observable } from "babylonjs/Misc/observable";
  37409. /**
  37410. * 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
  37411. */
  37412. export class SixDofDragBehavior implements Behavior<Mesh> {
  37413. private static _virtualScene;
  37414. private _ownerNode;
  37415. private _sceneRenderObserver;
  37416. private _scene;
  37417. private _targetPosition;
  37418. private _virtualOriginMesh;
  37419. private _virtualDragMesh;
  37420. private _pointerObserver;
  37421. private _moving;
  37422. private _startingOrientation;
  37423. /**
  37424. * 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)
  37425. */
  37426. private zDragFactor;
  37427. /**
  37428. * If the object should rotate to face the drag origin
  37429. */
  37430. rotateDraggedObject: boolean;
  37431. /**
  37432. * If the behavior is currently in a dragging state
  37433. */
  37434. dragging: boolean;
  37435. /**
  37436. * 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)
  37437. */
  37438. dragDeltaRatio: number;
  37439. /**
  37440. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37441. */
  37442. currentDraggingPointerID: number;
  37443. /**
  37444. * If camera controls should be detached during the drag
  37445. */
  37446. detachCameraControls: boolean;
  37447. /**
  37448. * Fires each time a drag starts
  37449. */
  37450. onDragStartObservable: Observable<{}>;
  37451. /**
  37452. * Fires each time a drag ends (eg. mouse release after drag)
  37453. */
  37454. onDragEndObservable: Observable<{}>;
  37455. /**
  37456. * 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
  37457. */
  37458. constructor();
  37459. /**
  37460. * The name of the behavior
  37461. */
  37462. readonly name: string;
  37463. /**
  37464. * Initializes the behavior
  37465. */
  37466. init(): void;
  37467. /**
  37468. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37469. */
  37470. private readonly _pointerCamera;
  37471. /**
  37472. * Attaches the scale behavior the passed in mesh
  37473. * @param ownerNode The mesh that will be scaled around once attached
  37474. */
  37475. attach(ownerNode: Mesh): void;
  37476. /**
  37477. * Detaches the behavior from the mesh
  37478. */
  37479. detach(): void;
  37480. }
  37481. }
  37482. declare module "babylonjs/Behaviors/Meshes/index" {
  37483. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37484. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37485. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37486. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37487. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37488. }
  37489. declare module "babylonjs/Behaviors/index" {
  37490. export * from "babylonjs/Behaviors/behavior";
  37491. export * from "babylonjs/Behaviors/Cameras/index";
  37492. export * from "babylonjs/Behaviors/Meshes/index";
  37493. }
  37494. declare module "babylonjs/Bones/boneIKController" {
  37495. import { Bone } from "babylonjs/Bones/bone";
  37496. import { Vector3 } from "babylonjs/Maths/math";
  37497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37498. import { Nullable } from "babylonjs/types";
  37499. /**
  37500. * Class used to apply inverse kinematics to bones
  37501. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37502. */
  37503. export class BoneIKController {
  37504. private static _tmpVecs;
  37505. private static _tmpQuat;
  37506. private static _tmpMats;
  37507. /**
  37508. * Gets or sets the target mesh
  37509. */
  37510. targetMesh: AbstractMesh;
  37511. /** Gets or sets the mesh used as pole */
  37512. poleTargetMesh: AbstractMesh;
  37513. /**
  37514. * Gets or sets the bone used as pole
  37515. */
  37516. poleTargetBone: Nullable<Bone>;
  37517. /**
  37518. * Gets or sets the target position
  37519. */
  37520. targetPosition: Vector3;
  37521. /**
  37522. * Gets or sets the pole target position
  37523. */
  37524. poleTargetPosition: Vector3;
  37525. /**
  37526. * Gets or sets the pole target local offset
  37527. */
  37528. poleTargetLocalOffset: Vector3;
  37529. /**
  37530. * Gets or sets the pole angle
  37531. */
  37532. poleAngle: number;
  37533. /**
  37534. * Gets or sets the mesh associated with the controller
  37535. */
  37536. mesh: AbstractMesh;
  37537. /**
  37538. * 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)
  37539. */
  37540. slerpAmount: number;
  37541. private _bone1Quat;
  37542. private _bone1Mat;
  37543. private _bone2Ang;
  37544. private _bone1;
  37545. private _bone2;
  37546. private _bone1Length;
  37547. private _bone2Length;
  37548. private _maxAngle;
  37549. private _maxReach;
  37550. private _rightHandedSystem;
  37551. private _bendAxis;
  37552. private _slerping;
  37553. private _adjustRoll;
  37554. /**
  37555. * Gets or sets maximum allowed angle
  37556. */
  37557. maxAngle: number;
  37558. /**
  37559. * Creates a new BoneIKController
  37560. * @param mesh defines the mesh to control
  37561. * @param bone defines the bone to control
  37562. * @param options defines options to set up the controller
  37563. */
  37564. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37565. targetMesh?: AbstractMesh;
  37566. poleTargetMesh?: AbstractMesh;
  37567. poleTargetBone?: Bone;
  37568. poleTargetLocalOffset?: Vector3;
  37569. poleAngle?: number;
  37570. bendAxis?: Vector3;
  37571. maxAngle?: number;
  37572. slerpAmount?: number;
  37573. });
  37574. private _setMaxAngle;
  37575. /**
  37576. * Force the controller to update the bones
  37577. */
  37578. update(): void;
  37579. }
  37580. }
  37581. declare module "babylonjs/Bones/boneLookController" {
  37582. import { Vector3, Space } from "babylonjs/Maths/math";
  37583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37584. import { Bone } from "babylonjs/Bones/bone";
  37585. /**
  37586. * Class used to make a bone look toward a point in space
  37587. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37588. */
  37589. export class BoneLookController {
  37590. private static _tmpVecs;
  37591. private static _tmpQuat;
  37592. private static _tmpMats;
  37593. /**
  37594. * The target Vector3 that the bone will look at
  37595. */
  37596. target: Vector3;
  37597. /**
  37598. * The mesh that the bone is attached to
  37599. */
  37600. mesh: AbstractMesh;
  37601. /**
  37602. * The bone that will be looking to the target
  37603. */
  37604. bone: Bone;
  37605. /**
  37606. * The up axis of the coordinate system that is used when the bone is rotated
  37607. */
  37608. upAxis: Vector3;
  37609. /**
  37610. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37611. */
  37612. upAxisSpace: Space;
  37613. /**
  37614. * Used to make an adjustment to the yaw of the bone
  37615. */
  37616. adjustYaw: number;
  37617. /**
  37618. * Used to make an adjustment to the pitch of the bone
  37619. */
  37620. adjustPitch: number;
  37621. /**
  37622. * Used to make an adjustment to the roll of the bone
  37623. */
  37624. adjustRoll: number;
  37625. /**
  37626. * 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)
  37627. */
  37628. slerpAmount: number;
  37629. private _minYaw;
  37630. private _maxYaw;
  37631. private _minPitch;
  37632. private _maxPitch;
  37633. private _minYawSin;
  37634. private _minYawCos;
  37635. private _maxYawSin;
  37636. private _maxYawCos;
  37637. private _midYawConstraint;
  37638. private _minPitchTan;
  37639. private _maxPitchTan;
  37640. private _boneQuat;
  37641. private _slerping;
  37642. private _transformYawPitch;
  37643. private _transformYawPitchInv;
  37644. private _firstFrameSkipped;
  37645. private _yawRange;
  37646. private _fowardAxis;
  37647. /**
  37648. * Gets or sets the minimum yaw angle that the bone can look to
  37649. */
  37650. minYaw: number;
  37651. /**
  37652. * Gets or sets the maximum yaw angle that the bone can look to
  37653. */
  37654. maxYaw: number;
  37655. /**
  37656. * Gets or sets the minimum pitch angle that the bone can look to
  37657. */
  37658. minPitch: number;
  37659. /**
  37660. * Gets or sets the maximum pitch angle that the bone can look to
  37661. */
  37662. maxPitch: number;
  37663. /**
  37664. * Create a BoneLookController
  37665. * @param mesh the mesh that the bone belongs to
  37666. * @param bone the bone that will be looking to the target
  37667. * @param target the target Vector3 to look at
  37668. * @param options optional settings:
  37669. * * maxYaw: the maximum angle the bone will yaw to
  37670. * * minYaw: the minimum angle the bone will yaw to
  37671. * * maxPitch: the maximum angle the bone will pitch to
  37672. * * minPitch: the minimum angle the bone will yaw to
  37673. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37674. * * upAxis: the up axis of the coordinate system
  37675. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37676. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37677. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37678. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37679. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37680. * * adjustRoll: used to make an adjustment to the roll of the bone
  37681. **/
  37682. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37683. maxYaw?: number;
  37684. minYaw?: number;
  37685. maxPitch?: number;
  37686. minPitch?: number;
  37687. slerpAmount?: number;
  37688. upAxis?: Vector3;
  37689. upAxisSpace?: Space;
  37690. yawAxis?: Vector3;
  37691. pitchAxis?: Vector3;
  37692. adjustYaw?: number;
  37693. adjustPitch?: number;
  37694. adjustRoll?: number;
  37695. });
  37696. /**
  37697. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37698. */
  37699. update(): void;
  37700. private _getAngleDiff;
  37701. private _getAngleBetween;
  37702. private _isAngleBetween;
  37703. }
  37704. }
  37705. declare module "babylonjs/Bones/index" {
  37706. export * from "babylonjs/Bones/bone";
  37707. export * from "babylonjs/Bones/boneIKController";
  37708. export * from "babylonjs/Bones/boneLookController";
  37709. export * from "babylonjs/Bones/skeleton";
  37710. }
  37711. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37712. import { Nullable } from "babylonjs/types";
  37713. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37714. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37715. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37716. /**
  37717. * Manage the gamepad inputs to control an arc rotate camera.
  37718. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37719. */
  37720. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37721. /**
  37722. * Defines the camera the input is attached to.
  37723. */
  37724. camera: ArcRotateCamera;
  37725. /**
  37726. * Defines the gamepad the input is gathering event from.
  37727. */
  37728. gamepad: Nullable<Gamepad>;
  37729. /**
  37730. * Defines the gamepad rotation sensiblity.
  37731. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37732. */
  37733. gamepadRotationSensibility: number;
  37734. /**
  37735. * Defines the gamepad move sensiblity.
  37736. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37737. */
  37738. gamepadMoveSensibility: number;
  37739. private _onGamepadConnectedObserver;
  37740. private _onGamepadDisconnectedObserver;
  37741. /**
  37742. * Attach the input controls to a specific dom element to get the input from.
  37743. * @param element Defines the element the controls should be listened from
  37744. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37745. */
  37746. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37747. /**
  37748. * Detach the current controls from the specified dom element.
  37749. * @param element Defines the element to stop listening the inputs from
  37750. */
  37751. detachControl(element: Nullable<HTMLElement>): void;
  37752. /**
  37753. * Update the current camera state depending on the inputs that have been used this frame.
  37754. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37755. */
  37756. checkInputs(): void;
  37757. /**
  37758. * Gets the class name of the current intput.
  37759. * @returns the class name
  37760. */
  37761. getClassName(): string;
  37762. /**
  37763. * Get the friendly name associated with the input class.
  37764. * @returns the input friendly name
  37765. */
  37766. getSimpleName(): string;
  37767. }
  37768. }
  37769. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37770. import { Nullable } from "babylonjs/types";
  37771. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37772. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37773. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37774. interface ArcRotateCameraInputsManager {
  37775. /**
  37776. * Add orientation input support to the input manager.
  37777. * @returns the current input manager
  37778. */
  37779. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37780. }
  37781. }
  37782. /**
  37783. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37784. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37785. */
  37786. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37787. /**
  37788. * Defines the camera the input is attached to.
  37789. */
  37790. camera: ArcRotateCamera;
  37791. /**
  37792. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37793. */
  37794. alphaCorrection: number;
  37795. /**
  37796. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37797. */
  37798. gammaCorrection: number;
  37799. private _alpha;
  37800. private _gamma;
  37801. private _dirty;
  37802. private _deviceOrientationHandler;
  37803. /**
  37804. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37805. */
  37806. constructor();
  37807. /**
  37808. * Attach the input controls to a specific dom element to get the input from.
  37809. * @param element Defines the element the controls should be listened from
  37810. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37811. */
  37812. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37813. /** @hidden */
  37814. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37815. /**
  37816. * Update the current camera state depending on the inputs that have been used this frame.
  37817. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37818. */
  37819. checkInputs(): void;
  37820. /**
  37821. * Detach the current controls from the specified dom element.
  37822. * @param element Defines the element to stop listening the inputs from
  37823. */
  37824. detachControl(element: Nullable<HTMLElement>): void;
  37825. /**
  37826. * Gets the class name of the current intput.
  37827. * @returns the class name
  37828. */
  37829. getClassName(): string;
  37830. /**
  37831. * Get the friendly name associated with the input class.
  37832. * @returns the input friendly name
  37833. */
  37834. getSimpleName(): string;
  37835. }
  37836. }
  37837. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37838. import { Nullable } from "babylonjs/types";
  37839. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37840. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37841. /**
  37842. * Listen to mouse events to control the camera.
  37843. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37844. */
  37845. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37846. /**
  37847. * Defines the camera the input is attached to.
  37848. */
  37849. camera: FlyCamera;
  37850. /**
  37851. * Defines if touch is enabled. (Default is true.)
  37852. */
  37853. touchEnabled: boolean;
  37854. /**
  37855. * Defines the buttons associated with the input to handle camera rotation.
  37856. */
  37857. buttons: number[];
  37858. /**
  37859. * Assign buttons for Yaw control.
  37860. */
  37861. buttonsYaw: number[];
  37862. /**
  37863. * Assign buttons for Pitch control.
  37864. */
  37865. buttonsPitch: number[];
  37866. /**
  37867. * Assign buttons for Roll control.
  37868. */
  37869. buttonsRoll: number[];
  37870. /**
  37871. * Detect if any button is being pressed while mouse is moved.
  37872. * -1 = Mouse locked.
  37873. * 0 = Left button.
  37874. * 1 = Middle Button.
  37875. * 2 = Right Button.
  37876. */
  37877. activeButton: number;
  37878. /**
  37879. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37880. * Higher values reduce its sensitivity.
  37881. */
  37882. angularSensibility: number;
  37883. private _mousemoveCallback;
  37884. private _observer;
  37885. private _rollObserver;
  37886. private previousPosition;
  37887. private noPreventDefault;
  37888. private element;
  37889. /**
  37890. * Listen to mouse events to control the camera.
  37891. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37892. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37893. */
  37894. constructor(touchEnabled?: boolean);
  37895. /**
  37896. * Attach the mouse control to the HTML DOM element.
  37897. * @param element Defines the element that listens to the input events.
  37898. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37899. */
  37900. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37901. /**
  37902. * Detach the current controls from the specified dom element.
  37903. * @param element Defines the element to stop listening the inputs from
  37904. */
  37905. detachControl(element: Nullable<HTMLElement>): void;
  37906. /**
  37907. * Gets the class name of the current input.
  37908. * @returns the class name.
  37909. */
  37910. getClassName(): string;
  37911. /**
  37912. * Get the friendly name associated with the input class.
  37913. * @returns the input's friendly name.
  37914. */
  37915. getSimpleName(): string;
  37916. private _pointerInput;
  37917. private _onMouseMove;
  37918. /**
  37919. * Rotate camera by mouse offset.
  37920. */
  37921. private rotateCamera;
  37922. }
  37923. }
  37924. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37925. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37926. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37927. /**
  37928. * Default Inputs manager for the FlyCamera.
  37929. * It groups all the default supported inputs for ease of use.
  37930. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37931. */
  37932. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37933. /**
  37934. * Instantiates a new FlyCameraInputsManager.
  37935. * @param camera Defines the camera the inputs belong to.
  37936. */
  37937. constructor(camera: FlyCamera);
  37938. /**
  37939. * Add keyboard input support to the input manager.
  37940. * @returns the new FlyCameraKeyboardMoveInput().
  37941. */
  37942. addKeyboard(): FlyCameraInputsManager;
  37943. /**
  37944. * Add mouse input support to the input manager.
  37945. * @param touchEnabled Enable touch screen support.
  37946. * @returns the new FlyCameraMouseInput().
  37947. */
  37948. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37949. }
  37950. }
  37951. declare module "babylonjs/Cameras/flyCamera" {
  37952. import { Scene } from "babylonjs/scene";
  37953. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37954. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37955. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37956. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37957. /**
  37958. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37959. * such as in a 3D Space Shooter or a Flight Simulator.
  37960. */
  37961. export class FlyCamera extends TargetCamera {
  37962. /**
  37963. * Define the collision ellipsoid of the camera.
  37964. * This is helpful for simulating a camera body, like a player's body.
  37965. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37966. */
  37967. ellipsoid: Vector3;
  37968. /**
  37969. * Define an offset for the position of the ellipsoid around the camera.
  37970. * This can be helpful if the camera is attached away from the player's body center,
  37971. * such as at its head.
  37972. */
  37973. ellipsoidOffset: Vector3;
  37974. /**
  37975. * Enable or disable collisions of the camera with the rest of the scene objects.
  37976. */
  37977. checkCollisions: boolean;
  37978. /**
  37979. * Enable or disable gravity on the camera.
  37980. */
  37981. applyGravity: boolean;
  37982. /**
  37983. * Define the current direction the camera is moving to.
  37984. */
  37985. cameraDirection: Vector3;
  37986. /**
  37987. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37988. * This overrides and empties cameraRotation.
  37989. */
  37990. rotationQuaternion: Quaternion;
  37991. /**
  37992. * Track Roll to maintain the wanted Rolling when looking around.
  37993. */
  37994. _trackRoll: number;
  37995. /**
  37996. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37997. */
  37998. rollCorrect: number;
  37999. /**
  38000. * Mimic a banked turn, Rolling the camera when Yawing.
  38001. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38002. */
  38003. bankedTurn: boolean;
  38004. /**
  38005. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38006. */
  38007. bankedTurnLimit: number;
  38008. /**
  38009. * Value of 0 disables the banked Roll.
  38010. * Value of 1 is equal to the Yaw angle in radians.
  38011. */
  38012. bankedTurnMultiplier: number;
  38013. /**
  38014. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38015. */
  38016. inputs: FlyCameraInputsManager;
  38017. /**
  38018. * Gets the input sensibility for mouse input.
  38019. * Higher values reduce sensitivity.
  38020. */
  38021. /**
  38022. * Sets the input sensibility for a mouse input.
  38023. * Higher values reduce sensitivity.
  38024. */
  38025. angularSensibility: number;
  38026. /**
  38027. * Get the keys for camera movement forward.
  38028. */
  38029. /**
  38030. * Set the keys for camera movement forward.
  38031. */
  38032. keysForward: number[];
  38033. /**
  38034. * Get the keys for camera movement backward.
  38035. */
  38036. keysBackward: number[];
  38037. /**
  38038. * Get the keys for camera movement up.
  38039. */
  38040. /**
  38041. * Set the keys for camera movement up.
  38042. */
  38043. keysUp: number[];
  38044. /**
  38045. * Get the keys for camera movement down.
  38046. */
  38047. /**
  38048. * Set the keys for camera movement down.
  38049. */
  38050. keysDown: number[];
  38051. /**
  38052. * Get the keys for camera movement left.
  38053. */
  38054. /**
  38055. * Set the keys for camera movement left.
  38056. */
  38057. keysLeft: number[];
  38058. /**
  38059. * Set the keys for camera movement right.
  38060. */
  38061. /**
  38062. * Set the keys for camera movement right.
  38063. */
  38064. keysRight: number[];
  38065. /**
  38066. * Event raised when the camera collides with a mesh in the scene.
  38067. */
  38068. onCollide: (collidedMesh: AbstractMesh) => void;
  38069. private _collider;
  38070. private _needMoveForGravity;
  38071. private _oldPosition;
  38072. private _diffPosition;
  38073. private _newPosition;
  38074. /** @hidden */
  38075. _localDirection: Vector3;
  38076. /** @hidden */
  38077. _transformedDirection: Vector3;
  38078. /**
  38079. * Instantiates a FlyCamera.
  38080. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38081. * such as in a 3D Space Shooter or a Flight Simulator.
  38082. * @param name Define the name of the camera in the scene.
  38083. * @param position Define the starting position of the camera in the scene.
  38084. * @param scene Define the scene the camera belongs to.
  38085. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38086. */
  38087. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38088. /**
  38089. * Attach a control to the HTML DOM element.
  38090. * @param element Defines the element that listens to the input events.
  38091. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38092. */
  38093. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38094. /**
  38095. * Detach a control from the HTML DOM element.
  38096. * The camera will stop reacting to that input.
  38097. * @param element Defines the element that listens to the input events.
  38098. */
  38099. detachControl(element: HTMLElement): void;
  38100. private _collisionMask;
  38101. /**
  38102. * Get the mask that the camera ignores in collision events.
  38103. */
  38104. /**
  38105. * Set the mask that the camera ignores in collision events.
  38106. */
  38107. collisionMask: number;
  38108. /** @hidden */
  38109. _collideWithWorld(displacement: Vector3): void;
  38110. /** @hidden */
  38111. private _onCollisionPositionChange;
  38112. /** @hidden */
  38113. _checkInputs(): void;
  38114. /** @hidden */
  38115. _decideIfNeedsToMove(): boolean;
  38116. /** @hidden */
  38117. _updatePosition(): void;
  38118. /**
  38119. * Restore the Roll to its target value at the rate specified.
  38120. * @param rate - Higher means slower restoring.
  38121. * @hidden
  38122. */
  38123. restoreRoll(rate: number): void;
  38124. /**
  38125. * Destroy the camera and release the current resources held by it.
  38126. */
  38127. dispose(): void;
  38128. /**
  38129. * Get the current object class name.
  38130. * @returns the class name.
  38131. */
  38132. getClassName(): string;
  38133. }
  38134. }
  38135. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38136. import { Nullable } from "babylonjs/types";
  38137. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38138. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38139. /**
  38140. * Listen to keyboard events to control the camera.
  38141. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38142. */
  38143. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38144. /**
  38145. * Defines the camera the input is attached to.
  38146. */
  38147. camera: FlyCamera;
  38148. /**
  38149. * The list of keyboard keys used to control the forward move of the camera.
  38150. */
  38151. keysForward: number[];
  38152. /**
  38153. * The list of keyboard keys used to control the backward move of the camera.
  38154. */
  38155. keysBackward: number[];
  38156. /**
  38157. * The list of keyboard keys used to control the forward move of the camera.
  38158. */
  38159. keysUp: number[];
  38160. /**
  38161. * The list of keyboard keys used to control the backward move of the camera.
  38162. */
  38163. keysDown: number[];
  38164. /**
  38165. * The list of keyboard keys used to control the right strafe move of the camera.
  38166. */
  38167. keysRight: number[];
  38168. /**
  38169. * The list of keyboard keys used to control the left strafe move of the camera.
  38170. */
  38171. keysLeft: number[];
  38172. private _keys;
  38173. private _onCanvasBlurObserver;
  38174. private _onKeyboardObserver;
  38175. private _engine;
  38176. private _scene;
  38177. /**
  38178. * Attach the input controls to a specific dom element to get the input from.
  38179. * @param element Defines the element the controls should be listened from
  38180. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38181. */
  38182. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38183. /**
  38184. * Detach the current controls from the specified dom element.
  38185. * @param element Defines the element to stop listening the inputs from
  38186. */
  38187. detachControl(element: Nullable<HTMLElement>): void;
  38188. /**
  38189. * Gets the class name of the current intput.
  38190. * @returns the class name
  38191. */
  38192. getClassName(): string;
  38193. /** @hidden */
  38194. _onLostFocus(e: FocusEvent): void;
  38195. /**
  38196. * Get the friendly name associated with the input class.
  38197. * @returns the input friendly name
  38198. */
  38199. getSimpleName(): string;
  38200. /**
  38201. * Update the current camera state depending on the inputs that have been used this frame.
  38202. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38203. */
  38204. checkInputs(): void;
  38205. }
  38206. }
  38207. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38208. import { Nullable } from "babylonjs/types";
  38209. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38210. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38211. /**
  38212. * Manage the mouse wheel inputs to control a follow camera.
  38213. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38214. */
  38215. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38216. /**
  38217. * Defines the camera the input is attached to.
  38218. */
  38219. camera: FollowCamera;
  38220. /**
  38221. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38222. */
  38223. axisControlRadius: boolean;
  38224. /**
  38225. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38226. */
  38227. axisControlHeight: boolean;
  38228. /**
  38229. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38230. */
  38231. axisControlRotation: boolean;
  38232. /**
  38233. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38234. * relation to mouseWheel events.
  38235. */
  38236. wheelPrecision: number;
  38237. /**
  38238. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38239. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38240. */
  38241. wheelDeltaPercentage: number;
  38242. private _wheel;
  38243. private _observer;
  38244. /**
  38245. * Attach the input controls to a specific dom element to get the input from.
  38246. * @param element Defines the element the controls should be listened from
  38247. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38248. */
  38249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38250. /**
  38251. * Detach the current controls from the specified dom element.
  38252. * @param element Defines the element to stop listening the inputs from
  38253. */
  38254. detachControl(element: Nullable<HTMLElement>): void;
  38255. /**
  38256. * Gets the class name of the current intput.
  38257. * @returns the class name
  38258. */
  38259. getClassName(): string;
  38260. /**
  38261. * Get the friendly name associated with the input class.
  38262. * @returns the input friendly name
  38263. */
  38264. getSimpleName(): string;
  38265. }
  38266. }
  38267. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38268. import { Nullable } from "babylonjs/types";
  38269. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38270. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38271. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38272. /**
  38273. * Manage the pointers inputs to control an follow camera.
  38274. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38275. */
  38276. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38277. /**
  38278. * Defines the camera the input is attached to.
  38279. */
  38280. camera: FollowCamera;
  38281. /**
  38282. * Gets the class name of the current input.
  38283. * @returns the class name
  38284. */
  38285. getClassName(): string;
  38286. /**
  38287. * Defines the pointer angular sensibility along the X axis or how fast is
  38288. * the camera rotating.
  38289. * A negative number will reverse the axis direction.
  38290. */
  38291. angularSensibilityX: number;
  38292. /**
  38293. * Defines the pointer angular sensibility along the Y axis or how fast is
  38294. * the camera rotating.
  38295. * A negative number will reverse the axis direction.
  38296. */
  38297. angularSensibilityY: number;
  38298. /**
  38299. * Defines the pointer pinch precision or how fast is the camera zooming.
  38300. * A negative number will reverse the axis direction.
  38301. */
  38302. pinchPrecision: number;
  38303. /**
  38304. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38305. * from 0.
  38306. * It defines the percentage of current camera.radius to use as delta when
  38307. * pinch zoom is used.
  38308. */
  38309. pinchDeltaPercentage: number;
  38310. /**
  38311. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38312. */
  38313. axisXControlRadius: boolean;
  38314. /**
  38315. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38316. */
  38317. axisXControlHeight: boolean;
  38318. /**
  38319. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38320. */
  38321. axisXControlRotation: boolean;
  38322. /**
  38323. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38324. */
  38325. axisYControlRadius: boolean;
  38326. /**
  38327. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38328. */
  38329. axisYControlHeight: boolean;
  38330. /**
  38331. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38332. */
  38333. axisYControlRotation: boolean;
  38334. /**
  38335. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38336. */
  38337. axisPinchControlRadius: boolean;
  38338. /**
  38339. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38340. */
  38341. axisPinchControlHeight: boolean;
  38342. /**
  38343. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38344. */
  38345. axisPinchControlRotation: boolean;
  38346. /**
  38347. * Log error messages if basic misconfiguration has occurred.
  38348. */
  38349. warningEnable: boolean;
  38350. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38351. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38352. private _warningCounter;
  38353. private _warning;
  38354. }
  38355. }
  38356. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38357. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38358. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38359. /**
  38360. * Default Inputs manager for the FollowCamera.
  38361. * It groups all the default supported inputs for ease of use.
  38362. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38363. */
  38364. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38365. /**
  38366. * Instantiates a new FollowCameraInputsManager.
  38367. * @param camera Defines the camera the inputs belong to
  38368. */
  38369. constructor(camera: FollowCamera);
  38370. /**
  38371. * Add keyboard input support to the input manager.
  38372. * @returns the current input manager
  38373. */
  38374. addKeyboard(): FollowCameraInputsManager;
  38375. /**
  38376. * Add mouse wheel input support to the input manager.
  38377. * @returns the current input manager
  38378. */
  38379. addMouseWheel(): FollowCameraInputsManager;
  38380. /**
  38381. * Add pointers input support to the input manager.
  38382. * @returns the current input manager
  38383. */
  38384. addPointers(): FollowCameraInputsManager;
  38385. /**
  38386. * Add orientation input support to the input manager.
  38387. * @returns the current input manager
  38388. */
  38389. addVRDeviceOrientation(): FollowCameraInputsManager;
  38390. }
  38391. }
  38392. declare module "babylonjs/Cameras/followCamera" {
  38393. import { Nullable } from "babylonjs/types";
  38394. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38395. import { Scene } from "babylonjs/scene";
  38396. import { Vector3 } from "babylonjs/Maths/math";
  38397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38398. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38399. /**
  38400. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38401. * an arc rotate version arcFollowCamera are available.
  38402. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38403. */
  38404. export class FollowCamera extends TargetCamera {
  38405. /**
  38406. * Distance the follow camera should follow an object at
  38407. */
  38408. radius: number;
  38409. /**
  38410. * Minimum allowed distance of the camera to the axis of rotation
  38411. * (The camera can not get closer).
  38412. * This can help limiting how the Camera is able to move in the scene.
  38413. */
  38414. lowerRadiusLimit: Nullable<number>;
  38415. /**
  38416. * Maximum allowed distance of the camera to the axis of rotation
  38417. * (The camera can not get further).
  38418. * This can help limiting how the Camera is able to move in the scene.
  38419. */
  38420. upperRadiusLimit: Nullable<number>;
  38421. /**
  38422. * Define a rotation offset between the camera and the object it follows
  38423. */
  38424. rotationOffset: number;
  38425. /**
  38426. * Minimum allowed angle to camera position relative to target object.
  38427. * This can help limiting how the Camera is able to move in the scene.
  38428. */
  38429. lowerRotationOffsetLimit: Nullable<number>;
  38430. /**
  38431. * Maximum allowed angle to camera position relative to target object.
  38432. * This can help limiting how the Camera is able to move in the scene.
  38433. */
  38434. upperRotationOffsetLimit: Nullable<number>;
  38435. /**
  38436. * Define a height offset between the camera and the object it follows.
  38437. * It can help following an object from the top (like a car chaing a plane)
  38438. */
  38439. heightOffset: number;
  38440. /**
  38441. * Minimum allowed height of camera position relative to target object.
  38442. * This can help limiting how the Camera is able to move in the scene.
  38443. */
  38444. lowerHeightOffsetLimit: Nullable<number>;
  38445. /**
  38446. * Maximum allowed height of camera position relative to target object.
  38447. * This can help limiting how the Camera is able to move in the scene.
  38448. */
  38449. upperHeightOffsetLimit: Nullable<number>;
  38450. /**
  38451. * Define how fast the camera can accelerate to follow it s target.
  38452. */
  38453. cameraAcceleration: number;
  38454. /**
  38455. * Define the speed limit of the camera following an object.
  38456. */
  38457. maxCameraSpeed: number;
  38458. /**
  38459. * Define the target of the camera.
  38460. */
  38461. lockedTarget: Nullable<AbstractMesh>;
  38462. /**
  38463. * Defines the input associated with the camera.
  38464. */
  38465. inputs: FollowCameraInputsManager;
  38466. /**
  38467. * Instantiates the follow camera.
  38468. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38469. * @param name Define the name of the camera in the scene
  38470. * @param position Define the position of the camera
  38471. * @param scene Define the scene the camera belong to
  38472. * @param lockedTarget Define the target of the camera
  38473. */
  38474. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38475. private _follow;
  38476. /**
  38477. * Attached controls to the current camera.
  38478. * @param element Defines the element the controls should be listened from
  38479. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38480. */
  38481. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38482. /**
  38483. * Detach the current controls from the camera.
  38484. * The camera will stop reacting to inputs.
  38485. * @param element Defines the element to stop listening the inputs from
  38486. */
  38487. detachControl(element: HTMLElement): void;
  38488. /** @hidden */
  38489. _checkInputs(): void;
  38490. private _checkLimits;
  38491. /**
  38492. * Gets the camera class name.
  38493. * @returns the class name
  38494. */
  38495. getClassName(): string;
  38496. }
  38497. /**
  38498. * Arc Rotate version of the follow camera.
  38499. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38500. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38501. */
  38502. export class ArcFollowCamera extends TargetCamera {
  38503. /** The longitudinal angle of the camera */
  38504. alpha: number;
  38505. /** The latitudinal angle of the camera */
  38506. beta: number;
  38507. /** The radius of the camera from its target */
  38508. radius: number;
  38509. /** Define the camera target (the messh it should follow) */
  38510. target: Nullable<AbstractMesh>;
  38511. private _cartesianCoordinates;
  38512. /**
  38513. * Instantiates a new ArcFollowCamera
  38514. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38515. * @param name Define the name of the camera
  38516. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38517. * @param beta Define the rotation angle of the camera around the elevation axis
  38518. * @param radius Define the radius of the camera from its target point
  38519. * @param target Define the target of the camera
  38520. * @param scene Define the scene the camera belongs to
  38521. */
  38522. constructor(name: string,
  38523. /** The longitudinal angle of the camera */
  38524. alpha: number,
  38525. /** The latitudinal angle of the camera */
  38526. beta: number,
  38527. /** The radius of the camera from its target */
  38528. radius: number,
  38529. /** Define the camera target (the messh it should follow) */
  38530. target: Nullable<AbstractMesh>, scene: Scene);
  38531. private _follow;
  38532. /** @hidden */
  38533. _checkInputs(): void;
  38534. /**
  38535. * Returns the class name of the object.
  38536. * It is mostly used internally for serialization purposes.
  38537. */
  38538. getClassName(): string;
  38539. }
  38540. }
  38541. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38542. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38543. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38544. import { Nullable } from "babylonjs/types";
  38545. /**
  38546. * Manage the keyboard inputs to control the movement of a follow camera.
  38547. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38548. */
  38549. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38550. /**
  38551. * Defines the camera the input is attached to.
  38552. */
  38553. camera: FollowCamera;
  38554. /**
  38555. * Defines the list of key codes associated with the up action (increase heightOffset)
  38556. */
  38557. keysHeightOffsetIncr: number[];
  38558. /**
  38559. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38560. */
  38561. keysHeightOffsetDecr: number[];
  38562. /**
  38563. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38564. */
  38565. keysHeightOffsetModifierAlt: boolean;
  38566. /**
  38567. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38568. */
  38569. keysHeightOffsetModifierCtrl: boolean;
  38570. /**
  38571. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38572. */
  38573. keysHeightOffsetModifierShift: boolean;
  38574. /**
  38575. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38576. */
  38577. keysRotationOffsetIncr: number[];
  38578. /**
  38579. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38580. */
  38581. keysRotationOffsetDecr: number[];
  38582. /**
  38583. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38584. */
  38585. keysRotationOffsetModifierAlt: boolean;
  38586. /**
  38587. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38588. */
  38589. keysRotationOffsetModifierCtrl: boolean;
  38590. /**
  38591. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38592. */
  38593. keysRotationOffsetModifierShift: boolean;
  38594. /**
  38595. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38596. */
  38597. keysRadiusIncr: number[];
  38598. /**
  38599. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38600. */
  38601. keysRadiusDecr: number[];
  38602. /**
  38603. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38604. */
  38605. keysRadiusModifierAlt: boolean;
  38606. /**
  38607. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38608. */
  38609. keysRadiusModifierCtrl: boolean;
  38610. /**
  38611. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38612. */
  38613. keysRadiusModifierShift: boolean;
  38614. /**
  38615. * Defines the rate of change of heightOffset.
  38616. */
  38617. heightSensibility: number;
  38618. /**
  38619. * Defines the rate of change of rotationOffset.
  38620. */
  38621. rotationSensibility: number;
  38622. /**
  38623. * Defines the rate of change of radius.
  38624. */
  38625. radiusSensibility: number;
  38626. private _keys;
  38627. private _ctrlPressed;
  38628. private _altPressed;
  38629. private _shiftPressed;
  38630. private _onCanvasBlurObserver;
  38631. private _onKeyboardObserver;
  38632. private _engine;
  38633. private _scene;
  38634. /**
  38635. * Attach the input controls to a specific dom element to get the input from.
  38636. * @param element Defines the element the controls should be listened from
  38637. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38638. */
  38639. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38640. /**
  38641. * Detach the current controls from the specified dom element.
  38642. * @param element Defines the element to stop listening the inputs from
  38643. */
  38644. detachControl(element: Nullable<HTMLElement>): void;
  38645. /**
  38646. * Update the current camera state depending on the inputs that have been used this frame.
  38647. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38648. */
  38649. checkInputs(): void;
  38650. /**
  38651. * Gets the class name of the current input.
  38652. * @returns the class name
  38653. */
  38654. getClassName(): string;
  38655. /**
  38656. * Get the friendly name associated with the input class.
  38657. * @returns the input friendly name
  38658. */
  38659. getSimpleName(): string;
  38660. /**
  38661. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38662. * allow modification of the heightOffset value.
  38663. */
  38664. private _modifierHeightOffset;
  38665. /**
  38666. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38667. * allow modification of the rotationOffset value.
  38668. */
  38669. private _modifierRotationOffset;
  38670. /**
  38671. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38672. * allow modification of the radius value.
  38673. */
  38674. private _modifierRadius;
  38675. }
  38676. }
  38677. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38678. import { Nullable } from "babylonjs/types";
  38679. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38680. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38681. import { Observable } from "babylonjs/Misc/observable";
  38682. module "babylonjs/Cameras/freeCameraInputsManager" {
  38683. interface FreeCameraInputsManager {
  38684. /**
  38685. * @hidden
  38686. */
  38687. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38688. /**
  38689. * Add orientation input support to the input manager.
  38690. * @returns the current input manager
  38691. */
  38692. addDeviceOrientation(): FreeCameraInputsManager;
  38693. }
  38694. }
  38695. /**
  38696. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38697. * Screen rotation is taken into account.
  38698. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38699. */
  38700. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38701. private _camera;
  38702. private _screenOrientationAngle;
  38703. private _constantTranform;
  38704. private _screenQuaternion;
  38705. private _alpha;
  38706. private _beta;
  38707. private _gamma;
  38708. /**
  38709. * Can be used to detect if a device orientation sensor is availible on a device
  38710. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38711. * @returns a promise that will resolve on orientation change
  38712. */
  38713. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38714. /**
  38715. * @hidden
  38716. */
  38717. _onDeviceOrientationChangedObservable: Observable<void>;
  38718. /**
  38719. * Instantiates a new input
  38720. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38721. */
  38722. constructor();
  38723. /**
  38724. * Define the camera controlled by the input.
  38725. */
  38726. camera: FreeCamera;
  38727. /**
  38728. * Attach the input controls to a specific dom element to get the input from.
  38729. * @param element Defines the element the controls should be listened from
  38730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38731. */
  38732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38733. private _orientationChanged;
  38734. private _deviceOrientation;
  38735. /**
  38736. * Detach the current controls from the specified dom element.
  38737. * @param element Defines the element to stop listening the inputs from
  38738. */
  38739. detachControl(element: Nullable<HTMLElement>): void;
  38740. /**
  38741. * Update the current camera state depending on the inputs that have been used this frame.
  38742. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38743. */
  38744. checkInputs(): void;
  38745. /**
  38746. * Gets the class name of the current intput.
  38747. * @returns the class name
  38748. */
  38749. getClassName(): string;
  38750. /**
  38751. * Get the friendly name associated with the input class.
  38752. * @returns the input friendly name
  38753. */
  38754. getSimpleName(): string;
  38755. }
  38756. }
  38757. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38758. import { Nullable } from "babylonjs/types";
  38759. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38760. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38761. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38762. /**
  38763. * Manage the gamepad inputs to control a free camera.
  38764. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38765. */
  38766. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38767. /**
  38768. * Define the camera the input is attached to.
  38769. */
  38770. camera: FreeCamera;
  38771. /**
  38772. * Define the Gamepad controlling the input
  38773. */
  38774. gamepad: Nullable<Gamepad>;
  38775. /**
  38776. * Defines the gamepad rotation sensiblity.
  38777. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38778. */
  38779. gamepadAngularSensibility: number;
  38780. /**
  38781. * Defines the gamepad move sensiblity.
  38782. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38783. */
  38784. gamepadMoveSensibility: number;
  38785. private _onGamepadConnectedObserver;
  38786. private _onGamepadDisconnectedObserver;
  38787. private _cameraTransform;
  38788. private _deltaTransform;
  38789. private _vector3;
  38790. private _vector2;
  38791. /**
  38792. * Attach the input controls to a specific dom element to get the input from.
  38793. * @param element Defines the element the controls should be listened from
  38794. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38795. */
  38796. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38797. /**
  38798. * Detach the current controls from the specified dom element.
  38799. * @param element Defines the element to stop listening the inputs from
  38800. */
  38801. detachControl(element: Nullable<HTMLElement>): void;
  38802. /**
  38803. * Update the current camera state depending on the inputs that have been used this frame.
  38804. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38805. */
  38806. checkInputs(): void;
  38807. /**
  38808. * Gets the class name of the current intput.
  38809. * @returns the class name
  38810. */
  38811. getClassName(): string;
  38812. /**
  38813. * Get the friendly name associated with the input class.
  38814. * @returns the input friendly name
  38815. */
  38816. getSimpleName(): string;
  38817. }
  38818. }
  38819. declare module "babylonjs/Misc/virtualJoystick" {
  38820. import { Nullable } from "babylonjs/types";
  38821. import { Vector3 } from "babylonjs/Maths/math";
  38822. /**
  38823. * Defines the potential axis of a Joystick
  38824. */
  38825. export enum JoystickAxis {
  38826. /** X axis */
  38827. X = 0,
  38828. /** Y axis */
  38829. Y = 1,
  38830. /** Z axis */
  38831. Z = 2
  38832. }
  38833. /**
  38834. * Class used to define virtual joystick (used in touch mode)
  38835. */
  38836. export class VirtualJoystick {
  38837. /**
  38838. * Gets or sets a boolean indicating that left and right values must be inverted
  38839. */
  38840. reverseLeftRight: boolean;
  38841. /**
  38842. * Gets or sets a boolean indicating that up and down values must be inverted
  38843. */
  38844. reverseUpDown: boolean;
  38845. /**
  38846. * Gets the offset value for the position (ie. the change of the position value)
  38847. */
  38848. deltaPosition: Vector3;
  38849. /**
  38850. * Gets a boolean indicating if the virtual joystick was pressed
  38851. */
  38852. pressed: boolean;
  38853. /**
  38854. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38855. */
  38856. static Canvas: Nullable<HTMLCanvasElement>;
  38857. private static _globalJoystickIndex;
  38858. private static vjCanvasContext;
  38859. private static vjCanvasWidth;
  38860. private static vjCanvasHeight;
  38861. private static halfWidth;
  38862. private _action;
  38863. private _axisTargetedByLeftAndRight;
  38864. private _axisTargetedByUpAndDown;
  38865. private _joystickSensibility;
  38866. private _inversedSensibility;
  38867. private _joystickPointerID;
  38868. private _joystickColor;
  38869. private _joystickPointerPos;
  38870. private _joystickPreviousPointerPos;
  38871. private _joystickPointerStartPos;
  38872. private _deltaJoystickVector;
  38873. private _leftJoystick;
  38874. private _touches;
  38875. private _onPointerDownHandlerRef;
  38876. private _onPointerMoveHandlerRef;
  38877. private _onPointerUpHandlerRef;
  38878. private _onResize;
  38879. /**
  38880. * Creates a new virtual joystick
  38881. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38882. */
  38883. constructor(leftJoystick?: boolean);
  38884. /**
  38885. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38886. * @param newJoystickSensibility defines the new sensibility
  38887. */
  38888. setJoystickSensibility(newJoystickSensibility: number): void;
  38889. private _onPointerDown;
  38890. private _onPointerMove;
  38891. private _onPointerUp;
  38892. /**
  38893. * Change the color of the virtual joystick
  38894. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38895. */
  38896. setJoystickColor(newColor: string): void;
  38897. /**
  38898. * Defines a callback to call when the joystick is touched
  38899. * @param action defines the callback
  38900. */
  38901. setActionOnTouch(action: () => any): void;
  38902. /**
  38903. * Defines which axis you'd like to control for left & right
  38904. * @param axis defines the axis to use
  38905. */
  38906. setAxisForLeftRight(axis: JoystickAxis): void;
  38907. /**
  38908. * Defines which axis you'd like to control for up & down
  38909. * @param axis defines the axis to use
  38910. */
  38911. setAxisForUpDown(axis: JoystickAxis): void;
  38912. private _drawVirtualJoystick;
  38913. /**
  38914. * Release internal HTML canvas
  38915. */
  38916. releaseCanvas(): void;
  38917. }
  38918. }
  38919. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38920. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38921. import { Nullable } from "babylonjs/types";
  38922. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38923. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38924. module "babylonjs/Cameras/freeCameraInputsManager" {
  38925. interface FreeCameraInputsManager {
  38926. /**
  38927. * Add virtual joystick input support to the input manager.
  38928. * @returns the current input manager
  38929. */
  38930. addVirtualJoystick(): FreeCameraInputsManager;
  38931. }
  38932. }
  38933. /**
  38934. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38935. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38936. */
  38937. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38938. /**
  38939. * Defines the camera the input is attached to.
  38940. */
  38941. camera: FreeCamera;
  38942. private _leftjoystick;
  38943. private _rightjoystick;
  38944. /**
  38945. * Gets the left stick of the virtual joystick.
  38946. * @returns The virtual Joystick
  38947. */
  38948. getLeftJoystick(): VirtualJoystick;
  38949. /**
  38950. * Gets the right stick of the virtual joystick.
  38951. * @returns The virtual Joystick
  38952. */
  38953. getRightJoystick(): VirtualJoystick;
  38954. /**
  38955. * Update the current camera state depending on the inputs that have been used this frame.
  38956. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38957. */
  38958. checkInputs(): void;
  38959. /**
  38960. * Attach the input controls to a specific dom element to get the input from.
  38961. * @param element Defines the element the controls should be listened from
  38962. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38963. */
  38964. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38965. /**
  38966. * Detach the current controls from the specified dom element.
  38967. * @param element Defines the element to stop listening the inputs from
  38968. */
  38969. detachControl(element: Nullable<HTMLElement>): void;
  38970. /**
  38971. * Gets the class name of the current intput.
  38972. * @returns the class name
  38973. */
  38974. getClassName(): string;
  38975. /**
  38976. * Get the friendly name associated with the input class.
  38977. * @returns the input friendly name
  38978. */
  38979. getSimpleName(): string;
  38980. }
  38981. }
  38982. declare module "babylonjs/Cameras/Inputs/index" {
  38983. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38984. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38985. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38986. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38987. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38988. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38989. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38990. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38991. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38992. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38993. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38994. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38995. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38996. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38997. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38998. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38999. }
  39000. declare module "babylonjs/Cameras/touchCamera" {
  39001. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39002. import { Scene } from "babylonjs/scene";
  39003. import { Vector3 } from "babylonjs/Maths/math";
  39004. /**
  39005. * This represents a FPS type of camera controlled by touch.
  39006. * This is like a universal camera minus the Gamepad controls.
  39007. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39008. */
  39009. export class TouchCamera extends FreeCamera {
  39010. /**
  39011. * Defines the touch sensibility for rotation.
  39012. * The higher the faster.
  39013. */
  39014. touchAngularSensibility: number;
  39015. /**
  39016. * Defines the touch sensibility for move.
  39017. * The higher the faster.
  39018. */
  39019. touchMoveSensibility: number;
  39020. /**
  39021. * Instantiates a new touch camera.
  39022. * This represents a FPS type of camera controlled by touch.
  39023. * This is like a universal camera minus the Gamepad controls.
  39024. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39025. * @param name Define the name of the camera in the scene
  39026. * @param position Define the start position of the camera in the scene
  39027. * @param scene Define the scene the camera belongs to
  39028. */
  39029. constructor(name: string, position: Vector3, scene: Scene);
  39030. /**
  39031. * Gets the current object class name.
  39032. * @return the class name
  39033. */
  39034. getClassName(): string;
  39035. /** @hidden */
  39036. _setupInputs(): void;
  39037. }
  39038. }
  39039. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39040. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39041. import { Scene } from "babylonjs/scene";
  39042. import { Vector3, Axis } from "babylonjs/Maths/math";
  39043. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39044. /**
  39045. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39046. * being tilted forward or back and left or right.
  39047. */
  39048. export class DeviceOrientationCamera extends FreeCamera {
  39049. private _initialQuaternion;
  39050. private _quaternionCache;
  39051. private _tmpDragQuaternion;
  39052. /**
  39053. * Creates a new device orientation camera
  39054. * @param name The name of the camera
  39055. * @param position The start position camera
  39056. * @param scene The scene the camera belongs to
  39057. */
  39058. constructor(name: string, position: Vector3, scene: Scene);
  39059. /**
  39060. * @hidden
  39061. * Disabled pointer input on first orientation sensor update (Default: true)
  39062. */
  39063. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  39064. private _dragFactor;
  39065. /**
  39066. * Enabled turning on the y axis when the orientation sensor is active
  39067. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39068. */
  39069. enableHorizontalDragging(dragFactor?: number): void;
  39070. /**
  39071. * Gets the current instance class name ("DeviceOrientationCamera").
  39072. * This helps avoiding instanceof at run time.
  39073. * @returns the class name
  39074. */
  39075. getClassName(): string;
  39076. /**
  39077. * @hidden
  39078. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39079. */
  39080. _checkInputs(): void;
  39081. /**
  39082. * Reset the camera to its default orientation on the specified axis only.
  39083. * @param axis The axis to reset
  39084. */
  39085. resetToCurrentRotation(axis?: Axis): void;
  39086. }
  39087. }
  39088. declare module "babylonjs/Gamepads/xboxGamepad" {
  39089. import { Observable } from "babylonjs/Misc/observable";
  39090. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39091. /**
  39092. * Defines supported buttons for XBox360 compatible gamepads
  39093. */
  39094. export enum Xbox360Button {
  39095. /** A */
  39096. A = 0,
  39097. /** B */
  39098. B = 1,
  39099. /** X */
  39100. X = 2,
  39101. /** Y */
  39102. Y = 3,
  39103. /** Start */
  39104. Start = 4,
  39105. /** Back */
  39106. Back = 5,
  39107. /** Left button */
  39108. LB = 6,
  39109. /** Right button */
  39110. RB = 7,
  39111. /** Left stick */
  39112. LeftStick = 8,
  39113. /** Right stick */
  39114. RightStick = 9
  39115. }
  39116. /** Defines values for XBox360 DPad */
  39117. export enum Xbox360Dpad {
  39118. /** Up */
  39119. Up = 0,
  39120. /** Down */
  39121. Down = 1,
  39122. /** Left */
  39123. Left = 2,
  39124. /** Right */
  39125. Right = 3
  39126. }
  39127. /**
  39128. * Defines a XBox360 gamepad
  39129. */
  39130. export class Xbox360Pad extends Gamepad {
  39131. private _leftTrigger;
  39132. private _rightTrigger;
  39133. private _onlefttriggerchanged;
  39134. private _onrighttriggerchanged;
  39135. private _onbuttondown;
  39136. private _onbuttonup;
  39137. private _ondpaddown;
  39138. private _ondpadup;
  39139. /** Observable raised when a button is pressed */
  39140. onButtonDownObservable: Observable<Xbox360Button>;
  39141. /** Observable raised when a button is released */
  39142. onButtonUpObservable: Observable<Xbox360Button>;
  39143. /** Observable raised when a pad is pressed */
  39144. onPadDownObservable: Observable<Xbox360Dpad>;
  39145. /** Observable raised when a pad is released */
  39146. onPadUpObservable: Observable<Xbox360Dpad>;
  39147. private _buttonA;
  39148. private _buttonB;
  39149. private _buttonX;
  39150. private _buttonY;
  39151. private _buttonBack;
  39152. private _buttonStart;
  39153. private _buttonLB;
  39154. private _buttonRB;
  39155. private _buttonLeftStick;
  39156. private _buttonRightStick;
  39157. private _dPadUp;
  39158. private _dPadDown;
  39159. private _dPadLeft;
  39160. private _dPadRight;
  39161. private _isXboxOnePad;
  39162. /**
  39163. * Creates a new XBox360 gamepad object
  39164. * @param id defines the id of this gamepad
  39165. * @param index defines its index
  39166. * @param gamepad defines the internal HTML gamepad object
  39167. * @param xboxOne defines if it is a XBox One gamepad
  39168. */
  39169. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39170. /**
  39171. * Defines the callback to call when left trigger is pressed
  39172. * @param callback defines the callback to use
  39173. */
  39174. onlefttriggerchanged(callback: (value: number) => void): void;
  39175. /**
  39176. * Defines the callback to call when right trigger is pressed
  39177. * @param callback defines the callback to use
  39178. */
  39179. onrighttriggerchanged(callback: (value: number) => void): void;
  39180. /**
  39181. * Gets the left trigger value
  39182. */
  39183. /**
  39184. * Sets the left trigger value
  39185. */
  39186. leftTrigger: number;
  39187. /**
  39188. * Gets the right trigger value
  39189. */
  39190. /**
  39191. * Sets the right trigger value
  39192. */
  39193. rightTrigger: number;
  39194. /**
  39195. * Defines the callback to call when a button is pressed
  39196. * @param callback defines the callback to use
  39197. */
  39198. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39199. /**
  39200. * Defines the callback to call when a button is released
  39201. * @param callback defines the callback to use
  39202. */
  39203. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39204. /**
  39205. * Defines the callback to call when a pad is pressed
  39206. * @param callback defines the callback to use
  39207. */
  39208. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39209. /**
  39210. * Defines the callback to call when a pad is released
  39211. * @param callback defines the callback to use
  39212. */
  39213. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39214. private _setButtonValue;
  39215. private _setDPadValue;
  39216. /**
  39217. * Gets the value of the `A` button
  39218. */
  39219. /**
  39220. * Sets the value of the `A` button
  39221. */
  39222. buttonA: number;
  39223. /**
  39224. * Gets the value of the `B` button
  39225. */
  39226. /**
  39227. * Sets the value of the `B` button
  39228. */
  39229. buttonB: number;
  39230. /**
  39231. * Gets the value of the `X` button
  39232. */
  39233. /**
  39234. * Sets the value of the `X` button
  39235. */
  39236. buttonX: number;
  39237. /**
  39238. * Gets the value of the `Y` button
  39239. */
  39240. /**
  39241. * Sets the value of the `Y` button
  39242. */
  39243. buttonY: number;
  39244. /**
  39245. * Gets the value of the `Start` button
  39246. */
  39247. /**
  39248. * Sets the value of the `Start` button
  39249. */
  39250. buttonStart: number;
  39251. /**
  39252. * Gets the value of the `Back` button
  39253. */
  39254. /**
  39255. * Sets the value of the `Back` button
  39256. */
  39257. buttonBack: number;
  39258. /**
  39259. * Gets the value of the `Left` button
  39260. */
  39261. /**
  39262. * Sets the value of the `Left` button
  39263. */
  39264. buttonLB: number;
  39265. /**
  39266. * Gets the value of the `Right` button
  39267. */
  39268. /**
  39269. * Sets the value of the `Right` button
  39270. */
  39271. buttonRB: number;
  39272. /**
  39273. * Gets the value of the Left joystick
  39274. */
  39275. /**
  39276. * Sets the value of the Left joystick
  39277. */
  39278. buttonLeftStick: number;
  39279. /**
  39280. * Gets the value of the Right joystick
  39281. */
  39282. /**
  39283. * Sets the value of the Right joystick
  39284. */
  39285. buttonRightStick: number;
  39286. /**
  39287. * Gets the value of D-pad up
  39288. */
  39289. /**
  39290. * Sets the value of D-pad up
  39291. */
  39292. dPadUp: number;
  39293. /**
  39294. * Gets the value of D-pad down
  39295. */
  39296. /**
  39297. * Sets the value of D-pad down
  39298. */
  39299. dPadDown: number;
  39300. /**
  39301. * Gets the value of D-pad left
  39302. */
  39303. /**
  39304. * Sets the value of D-pad left
  39305. */
  39306. dPadLeft: number;
  39307. /**
  39308. * Gets the value of D-pad right
  39309. */
  39310. /**
  39311. * Sets the value of D-pad right
  39312. */
  39313. dPadRight: number;
  39314. /**
  39315. * Force the gamepad to synchronize with device values
  39316. */
  39317. update(): void;
  39318. /**
  39319. * Disposes the gamepad
  39320. */
  39321. dispose(): void;
  39322. }
  39323. }
  39324. declare module "babylonjs/Gamepads/gamepadManager" {
  39325. import { Observable } from "babylonjs/Misc/observable";
  39326. import { Nullable } from "babylonjs/types";
  39327. import { Scene } from "babylonjs/scene";
  39328. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39329. /**
  39330. * Manager for handling gamepads
  39331. */
  39332. export class GamepadManager {
  39333. private _scene?;
  39334. private _babylonGamepads;
  39335. private _oneGamepadConnected;
  39336. /** @hidden */
  39337. _isMonitoring: boolean;
  39338. private _gamepadEventSupported;
  39339. private _gamepadSupport;
  39340. /**
  39341. * observable to be triggered when the gamepad controller has been connected
  39342. */
  39343. onGamepadConnectedObservable: Observable<Gamepad>;
  39344. /**
  39345. * observable to be triggered when the gamepad controller has been disconnected
  39346. */
  39347. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39348. private _onGamepadConnectedEvent;
  39349. private _onGamepadDisconnectedEvent;
  39350. /**
  39351. * Initializes the gamepad manager
  39352. * @param _scene BabylonJS scene
  39353. */
  39354. constructor(_scene?: Scene | undefined);
  39355. /**
  39356. * The gamepads in the game pad manager
  39357. */
  39358. readonly gamepads: Gamepad[];
  39359. /**
  39360. * Get the gamepad controllers based on type
  39361. * @param type The type of gamepad controller
  39362. * @returns Nullable gamepad
  39363. */
  39364. getGamepadByType(type?: number): Nullable<Gamepad>;
  39365. /**
  39366. * Disposes the gamepad manager
  39367. */
  39368. dispose(): void;
  39369. private _addNewGamepad;
  39370. private _startMonitoringGamepads;
  39371. private _stopMonitoringGamepads;
  39372. /** @hidden */
  39373. _checkGamepadsStatus(): void;
  39374. private _updateGamepadObjects;
  39375. }
  39376. }
  39377. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39378. import { Nullable } from "babylonjs/types";
  39379. import { Scene } from "babylonjs/scene";
  39380. import { ISceneComponent } from "babylonjs/sceneComponent";
  39381. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39382. module "babylonjs/scene" {
  39383. interface Scene {
  39384. /** @hidden */
  39385. _gamepadManager: Nullable<GamepadManager>;
  39386. /**
  39387. * Gets the gamepad manager associated with the scene
  39388. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39389. */
  39390. gamepadManager: GamepadManager;
  39391. }
  39392. }
  39393. module "babylonjs/Cameras/freeCameraInputsManager" {
  39394. /**
  39395. * Interface representing a free camera inputs manager
  39396. */
  39397. interface FreeCameraInputsManager {
  39398. /**
  39399. * Adds gamepad input support to the FreeCameraInputsManager.
  39400. * @returns the FreeCameraInputsManager
  39401. */
  39402. addGamepad(): FreeCameraInputsManager;
  39403. }
  39404. }
  39405. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39406. /**
  39407. * Interface representing an arc rotate camera inputs manager
  39408. */
  39409. interface ArcRotateCameraInputsManager {
  39410. /**
  39411. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39412. * @returns the camera inputs manager
  39413. */
  39414. addGamepad(): ArcRotateCameraInputsManager;
  39415. }
  39416. }
  39417. /**
  39418. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39419. */
  39420. export class GamepadSystemSceneComponent implements ISceneComponent {
  39421. /**
  39422. * The component name helpfull to identify the component in the list of scene components.
  39423. */
  39424. readonly name: string;
  39425. /**
  39426. * The scene the component belongs to.
  39427. */
  39428. scene: Scene;
  39429. /**
  39430. * Creates a new instance of the component for the given scene
  39431. * @param scene Defines the scene to register the component in
  39432. */
  39433. constructor(scene: Scene);
  39434. /**
  39435. * Registers the component in a given scene
  39436. */
  39437. register(): void;
  39438. /**
  39439. * Rebuilds the elements related to this component in case of
  39440. * context lost for instance.
  39441. */
  39442. rebuild(): void;
  39443. /**
  39444. * Disposes the component and the associated ressources
  39445. */
  39446. dispose(): void;
  39447. private _beforeCameraUpdate;
  39448. }
  39449. }
  39450. declare module "babylonjs/Cameras/universalCamera" {
  39451. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39452. import { Scene } from "babylonjs/scene";
  39453. import { Vector3 } from "babylonjs/Maths/math";
  39454. import "babylonjs/Gamepads/gamepadSceneComponent";
  39455. /**
  39456. * 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,
  39457. * which still works and will still be found in many Playgrounds.
  39458. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39459. */
  39460. export class UniversalCamera extends TouchCamera {
  39461. /**
  39462. * Defines the gamepad rotation sensiblity.
  39463. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39464. */
  39465. gamepadAngularSensibility: number;
  39466. /**
  39467. * Defines the gamepad move sensiblity.
  39468. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39469. */
  39470. gamepadMoveSensibility: number;
  39471. /**
  39472. * 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,
  39473. * which still works and will still be found in many Playgrounds.
  39474. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39475. * @param name Define the name of the camera in the scene
  39476. * @param position Define the start position of the camera in the scene
  39477. * @param scene Define the scene the camera belongs to
  39478. */
  39479. constructor(name: string, position: Vector3, scene: Scene);
  39480. /**
  39481. * Gets the current object class name.
  39482. * @return the class name
  39483. */
  39484. getClassName(): string;
  39485. }
  39486. }
  39487. declare module "babylonjs/Cameras/gamepadCamera" {
  39488. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39489. import { Scene } from "babylonjs/scene";
  39490. import { Vector3 } from "babylonjs/Maths/math";
  39491. /**
  39492. * This represents a FPS type of camera. This is only here for back compat purpose.
  39493. * Please use the UniversalCamera instead as both are identical.
  39494. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39495. */
  39496. export class GamepadCamera extends UniversalCamera {
  39497. /**
  39498. * Instantiates a new Gamepad Camera
  39499. * This represents a FPS type of camera. This is only here for back compat purpose.
  39500. * Please use the UniversalCamera instead as both are identical.
  39501. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39502. * @param name Define the name of the camera in the scene
  39503. * @param position Define the start position of the camera in the scene
  39504. * @param scene Define the scene the camera belongs to
  39505. */
  39506. constructor(name: string, position: Vector3, scene: Scene);
  39507. /**
  39508. * Gets the current object class name.
  39509. * @return the class name
  39510. */
  39511. getClassName(): string;
  39512. }
  39513. }
  39514. declare module "babylonjs/Shaders/pass.fragment" {
  39515. /** @hidden */
  39516. export var passPixelShader: {
  39517. name: string;
  39518. shader: string;
  39519. };
  39520. }
  39521. declare module "babylonjs/Shaders/passCube.fragment" {
  39522. /** @hidden */
  39523. export var passCubePixelShader: {
  39524. name: string;
  39525. shader: string;
  39526. };
  39527. }
  39528. declare module "babylonjs/PostProcesses/passPostProcess" {
  39529. import { Nullable } from "babylonjs/types";
  39530. import { Camera } from "babylonjs/Cameras/camera";
  39531. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39532. import { Engine } from "babylonjs/Engines/engine";
  39533. import "babylonjs/Shaders/pass.fragment";
  39534. import "babylonjs/Shaders/passCube.fragment";
  39535. /**
  39536. * PassPostProcess which produces an output the same as it's input
  39537. */
  39538. export class PassPostProcess extends PostProcess {
  39539. /**
  39540. * Creates the PassPostProcess
  39541. * @param name The name of the effect.
  39542. * @param options The required width/height ratio to downsize to before computing the render pass.
  39543. * @param camera The camera to apply the render pass to.
  39544. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39545. * @param engine The engine which the post process will be applied. (default: current engine)
  39546. * @param reusable If the post process can be reused on the same frame. (default: false)
  39547. * @param textureType The type of texture to be used when performing the post processing.
  39548. * @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)
  39549. */
  39550. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39551. }
  39552. /**
  39553. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39554. */
  39555. export class PassCubePostProcess extends PostProcess {
  39556. private _face;
  39557. /**
  39558. * Gets or sets the cube face to display.
  39559. * * 0 is +X
  39560. * * 1 is -X
  39561. * * 2 is +Y
  39562. * * 3 is -Y
  39563. * * 4 is +Z
  39564. * * 5 is -Z
  39565. */
  39566. face: number;
  39567. /**
  39568. * Creates the PassCubePostProcess
  39569. * @param name The name of the effect.
  39570. * @param options The required width/height ratio to downsize to before computing the render pass.
  39571. * @param camera The camera to apply the render pass to.
  39572. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39573. * @param engine The engine which the post process will be applied. (default: current engine)
  39574. * @param reusable If the post process can be reused on the same frame. (default: false)
  39575. * @param textureType The type of texture to be used when performing the post processing.
  39576. * @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)
  39577. */
  39578. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39579. }
  39580. }
  39581. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39582. /** @hidden */
  39583. export var anaglyphPixelShader: {
  39584. name: string;
  39585. shader: string;
  39586. };
  39587. }
  39588. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39589. import { Engine } from "babylonjs/Engines/engine";
  39590. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39591. import { Camera } from "babylonjs/Cameras/camera";
  39592. import "babylonjs/Shaders/anaglyph.fragment";
  39593. /**
  39594. * Postprocess used to generate anaglyphic rendering
  39595. */
  39596. export class AnaglyphPostProcess extends PostProcess {
  39597. private _passedProcess;
  39598. /**
  39599. * Creates a new AnaglyphPostProcess
  39600. * @param name defines postprocess name
  39601. * @param options defines creation options or target ratio scale
  39602. * @param rigCameras defines cameras using this postprocess
  39603. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39604. * @param engine defines hosting engine
  39605. * @param reusable defines if the postprocess will be reused multiple times per frame
  39606. */
  39607. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39608. }
  39609. }
  39610. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39611. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39612. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39613. import { Scene } from "babylonjs/scene";
  39614. import { Vector3 } from "babylonjs/Maths/math";
  39615. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39616. /**
  39617. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39618. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39619. */
  39620. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39621. /**
  39622. * Creates a new AnaglyphArcRotateCamera
  39623. * @param name defines camera name
  39624. * @param alpha defines alpha angle (in radians)
  39625. * @param beta defines beta angle (in radians)
  39626. * @param radius defines radius
  39627. * @param target defines camera target
  39628. * @param interaxialDistance defines distance between each color axis
  39629. * @param scene defines the hosting scene
  39630. */
  39631. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39632. /**
  39633. * Gets camera class name
  39634. * @returns AnaglyphArcRotateCamera
  39635. */
  39636. getClassName(): string;
  39637. }
  39638. }
  39639. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39640. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39641. import { Scene } from "babylonjs/scene";
  39642. import { Vector3 } from "babylonjs/Maths/math";
  39643. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39644. /**
  39645. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39646. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39647. */
  39648. export class AnaglyphFreeCamera extends FreeCamera {
  39649. /**
  39650. * Creates a new AnaglyphFreeCamera
  39651. * @param name defines camera name
  39652. * @param position defines initial position
  39653. * @param interaxialDistance defines distance between each color axis
  39654. * @param scene defines the hosting scene
  39655. */
  39656. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39657. /**
  39658. * Gets camera class name
  39659. * @returns AnaglyphFreeCamera
  39660. */
  39661. getClassName(): string;
  39662. }
  39663. }
  39664. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39665. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39666. import { Scene } from "babylonjs/scene";
  39667. import { Vector3 } from "babylonjs/Maths/math";
  39668. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39669. /**
  39670. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39671. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39672. */
  39673. export class AnaglyphGamepadCamera extends GamepadCamera {
  39674. /**
  39675. * Creates a new AnaglyphGamepadCamera
  39676. * @param name defines camera name
  39677. * @param position defines initial position
  39678. * @param interaxialDistance defines distance between each color axis
  39679. * @param scene defines the hosting scene
  39680. */
  39681. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39682. /**
  39683. * Gets camera class name
  39684. * @returns AnaglyphGamepadCamera
  39685. */
  39686. getClassName(): string;
  39687. }
  39688. }
  39689. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39690. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39691. import { Scene } from "babylonjs/scene";
  39692. import { Vector3 } from "babylonjs/Maths/math";
  39693. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39694. /**
  39695. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39696. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39697. */
  39698. export class AnaglyphUniversalCamera extends UniversalCamera {
  39699. /**
  39700. * Creates a new AnaglyphUniversalCamera
  39701. * @param name defines camera name
  39702. * @param position defines initial position
  39703. * @param interaxialDistance defines distance between each color axis
  39704. * @param scene defines the hosting scene
  39705. */
  39706. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39707. /**
  39708. * Gets camera class name
  39709. * @returns AnaglyphUniversalCamera
  39710. */
  39711. getClassName(): string;
  39712. }
  39713. }
  39714. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39715. /** @hidden */
  39716. export var stereoscopicInterlacePixelShader: {
  39717. name: string;
  39718. shader: string;
  39719. };
  39720. }
  39721. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39722. import { Camera } from "babylonjs/Cameras/camera";
  39723. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39724. import { Engine } from "babylonjs/Engines/engine";
  39725. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39726. /**
  39727. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39728. */
  39729. export class StereoscopicInterlacePostProcess extends PostProcess {
  39730. private _stepSize;
  39731. private _passedProcess;
  39732. /**
  39733. * Initializes a StereoscopicInterlacePostProcess
  39734. * @param name The name of the effect.
  39735. * @param rigCameras The rig cameras to be appled to the post process
  39736. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39738. * @param engine The engine which the post process will be applied. (default: current engine)
  39739. * @param reusable If the post process can be reused on the same frame. (default: false)
  39740. */
  39741. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39742. }
  39743. }
  39744. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  39745. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39746. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39747. import { Scene } from "babylonjs/scene";
  39748. import { Vector3 } from "babylonjs/Maths/math";
  39749. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39750. /**
  39751. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39752. * @see http://doc.babylonjs.com/features/cameras
  39753. */
  39754. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39755. /**
  39756. * Creates a new StereoscopicArcRotateCamera
  39757. * @param name defines camera name
  39758. * @param alpha defines alpha angle (in radians)
  39759. * @param beta defines beta angle (in radians)
  39760. * @param radius defines radius
  39761. * @param target defines camera target
  39762. * @param interaxialDistance defines distance between each color axis
  39763. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39764. * @param scene defines the hosting scene
  39765. */
  39766. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39767. /**
  39768. * Gets camera class name
  39769. * @returns StereoscopicArcRotateCamera
  39770. */
  39771. getClassName(): string;
  39772. }
  39773. }
  39774. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39775. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39776. import { Scene } from "babylonjs/scene";
  39777. import { Vector3 } from "babylonjs/Maths/math";
  39778. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39779. /**
  39780. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39781. * @see http://doc.babylonjs.com/features/cameras
  39782. */
  39783. export class StereoscopicFreeCamera extends FreeCamera {
  39784. /**
  39785. * Creates a new StereoscopicFreeCamera
  39786. * @param name defines camera name
  39787. * @param position defines initial position
  39788. * @param interaxialDistance defines distance between each color axis
  39789. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39790. * @param scene defines the hosting scene
  39791. */
  39792. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39793. /**
  39794. * Gets camera class name
  39795. * @returns StereoscopicFreeCamera
  39796. */
  39797. getClassName(): string;
  39798. }
  39799. }
  39800. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39801. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39802. import { Scene } from "babylonjs/scene";
  39803. import { Vector3 } from "babylonjs/Maths/math";
  39804. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39805. /**
  39806. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39807. * @see http://doc.babylonjs.com/features/cameras
  39808. */
  39809. export class StereoscopicGamepadCamera extends GamepadCamera {
  39810. /**
  39811. * Creates a new StereoscopicGamepadCamera
  39812. * @param name defines camera name
  39813. * @param position defines initial position
  39814. * @param interaxialDistance defines distance between each color axis
  39815. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39816. * @param scene defines the hosting scene
  39817. */
  39818. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39819. /**
  39820. * Gets camera class name
  39821. * @returns StereoscopicGamepadCamera
  39822. */
  39823. getClassName(): string;
  39824. }
  39825. }
  39826. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39827. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39828. import { Scene } from "babylonjs/scene";
  39829. import { Vector3 } from "babylonjs/Maths/math";
  39830. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39831. /**
  39832. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39833. * @see http://doc.babylonjs.com/features/cameras
  39834. */
  39835. export class StereoscopicUniversalCamera extends UniversalCamera {
  39836. /**
  39837. * Creates a new StereoscopicUniversalCamera
  39838. * @param name defines camera name
  39839. * @param position defines initial position
  39840. * @param interaxialDistance defines distance between each color axis
  39841. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39842. * @param scene defines the hosting scene
  39843. */
  39844. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39845. /**
  39846. * Gets camera class name
  39847. * @returns StereoscopicUniversalCamera
  39848. */
  39849. getClassName(): string;
  39850. }
  39851. }
  39852. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39853. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39854. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39855. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39856. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39857. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39858. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39859. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39860. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39861. }
  39862. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39863. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39864. import { Scene } from "babylonjs/scene";
  39865. import { Vector3 } from "babylonjs/Maths/math";
  39866. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39867. /**
  39868. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39869. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39870. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39871. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39872. */
  39873. export class VirtualJoysticksCamera extends FreeCamera {
  39874. /**
  39875. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39876. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39877. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39878. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39879. * @param name Define the name of the camera in the scene
  39880. * @param position Define the start position of the camera in the scene
  39881. * @param scene Define the scene the camera belongs to
  39882. */
  39883. constructor(name: string, position: Vector3, scene: Scene);
  39884. /**
  39885. * Gets the current object class name.
  39886. * @return the class name
  39887. */
  39888. getClassName(): string;
  39889. }
  39890. }
  39891. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39892. import { Matrix } from "babylonjs/Maths/math";
  39893. /**
  39894. * This represents all the required metrics to create a VR camera.
  39895. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39896. */
  39897. export class VRCameraMetrics {
  39898. /**
  39899. * Define the horizontal resolution off the screen.
  39900. */
  39901. hResolution: number;
  39902. /**
  39903. * Define the vertical resolution off the screen.
  39904. */
  39905. vResolution: number;
  39906. /**
  39907. * Define the horizontal screen size.
  39908. */
  39909. hScreenSize: number;
  39910. /**
  39911. * Define the vertical screen size.
  39912. */
  39913. vScreenSize: number;
  39914. /**
  39915. * Define the vertical screen center position.
  39916. */
  39917. vScreenCenter: number;
  39918. /**
  39919. * Define the distance of the eyes to the screen.
  39920. */
  39921. eyeToScreenDistance: number;
  39922. /**
  39923. * Define the distance between both lenses
  39924. */
  39925. lensSeparationDistance: number;
  39926. /**
  39927. * Define the distance between both viewer's eyes.
  39928. */
  39929. interpupillaryDistance: number;
  39930. /**
  39931. * Define the distortion factor of the VR postprocess.
  39932. * Please, touch with care.
  39933. */
  39934. distortionK: number[];
  39935. /**
  39936. * Define the chromatic aberration correction factors for the VR post process.
  39937. */
  39938. chromaAbCorrection: number[];
  39939. /**
  39940. * Define the scale factor of the post process.
  39941. * The smaller the better but the slower.
  39942. */
  39943. postProcessScaleFactor: number;
  39944. /**
  39945. * Define an offset for the lens center.
  39946. */
  39947. lensCenterOffset: number;
  39948. /**
  39949. * Define if the current vr camera should compensate the distortion of the lense or not.
  39950. */
  39951. compensateDistortion: boolean;
  39952. /**
  39953. * Defines if multiview should be enabled when rendering (Default: false)
  39954. */
  39955. multiviewEnabled: boolean;
  39956. /**
  39957. * Gets the rendering aspect ratio based on the provided resolutions.
  39958. */
  39959. readonly aspectRatio: number;
  39960. /**
  39961. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39962. */
  39963. readonly aspectRatioFov: number;
  39964. /**
  39965. * @hidden
  39966. */
  39967. readonly leftHMatrix: Matrix;
  39968. /**
  39969. * @hidden
  39970. */
  39971. readonly rightHMatrix: Matrix;
  39972. /**
  39973. * @hidden
  39974. */
  39975. readonly leftPreViewMatrix: Matrix;
  39976. /**
  39977. * @hidden
  39978. */
  39979. readonly rightPreViewMatrix: Matrix;
  39980. /**
  39981. * Get the default VRMetrics based on the most generic setup.
  39982. * @returns the default vr metrics
  39983. */
  39984. static GetDefault(): VRCameraMetrics;
  39985. }
  39986. }
  39987. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39988. /** @hidden */
  39989. export var vrDistortionCorrectionPixelShader: {
  39990. name: string;
  39991. shader: string;
  39992. };
  39993. }
  39994. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39995. import { Camera } from "babylonjs/Cameras/camera";
  39996. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39997. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39998. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39999. /**
  40000. * VRDistortionCorrectionPostProcess used for mobile VR
  40001. */
  40002. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40003. private _isRightEye;
  40004. private _distortionFactors;
  40005. private _postProcessScaleFactor;
  40006. private _lensCenterOffset;
  40007. private _scaleIn;
  40008. private _scaleFactor;
  40009. private _lensCenter;
  40010. /**
  40011. * Initializes the VRDistortionCorrectionPostProcess
  40012. * @param name The name of the effect.
  40013. * @param camera The camera to apply the render pass to.
  40014. * @param isRightEye If this is for the right eye distortion
  40015. * @param vrMetrics All the required metrics for the VR camera
  40016. */
  40017. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40018. }
  40019. }
  40020. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40021. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40022. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40023. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40024. import { Scene } from "babylonjs/scene";
  40025. import { Vector3 } from "babylonjs/Maths/math";
  40026. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40027. import "babylonjs/Cameras/RigModes/vrRigMode";
  40028. /**
  40029. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40030. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40031. */
  40032. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40033. /**
  40034. * Creates a new VRDeviceOrientationArcRotateCamera
  40035. * @param name defines camera name
  40036. * @param alpha defines the camera rotation along the logitudinal axis
  40037. * @param beta defines the camera rotation along the latitudinal axis
  40038. * @param radius defines the camera distance from its target
  40039. * @param target defines the camera target
  40040. * @param scene defines the scene the camera belongs to
  40041. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40042. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40043. */
  40044. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40045. /**
  40046. * Gets camera class name
  40047. * @returns VRDeviceOrientationArcRotateCamera
  40048. */
  40049. getClassName(): string;
  40050. }
  40051. }
  40052. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40053. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40054. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40055. import { Scene } from "babylonjs/scene";
  40056. import { Vector3 } from "babylonjs/Maths/math";
  40057. import "babylonjs/Cameras/RigModes/vrRigMode";
  40058. /**
  40059. * Camera used to simulate VR rendering (based on FreeCamera)
  40060. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40061. */
  40062. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40063. /**
  40064. * Creates a new VRDeviceOrientationFreeCamera
  40065. * @param name defines camera name
  40066. * @param position defines the start position of the camera
  40067. * @param scene defines the scene the camera belongs to
  40068. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40069. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40070. */
  40071. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40072. /**
  40073. * Gets camera class name
  40074. * @returns VRDeviceOrientationFreeCamera
  40075. */
  40076. getClassName(): string;
  40077. }
  40078. }
  40079. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40080. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40081. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40082. import { Scene } from "babylonjs/scene";
  40083. import { Vector3 } from "babylonjs/Maths/math";
  40084. import "babylonjs/Gamepads/gamepadSceneComponent";
  40085. /**
  40086. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40087. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40088. */
  40089. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40090. /**
  40091. * Creates a new VRDeviceOrientationGamepadCamera
  40092. * @param name defines camera name
  40093. * @param position defines the start position of the camera
  40094. * @param scene defines the scene the camera belongs to
  40095. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40096. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40097. */
  40098. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40099. /**
  40100. * Gets camera class name
  40101. * @returns VRDeviceOrientationGamepadCamera
  40102. */
  40103. getClassName(): string;
  40104. }
  40105. }
  40106. declare module "babylonjs/Materials/pushMaterial" {
  40107. import { Nullable } from "babylonjs/types";
  40108. import { Scene } from "babylonjs/scene";
  40109. import { Matrix } from "babylonjs/Maths/math";
  40110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40111. import { Mesh } from "babylonjs/Meshes/mesh";
  40112. import { Material } from "babylonjs/Materials/material";
  40113. import { Effect } from "babylonjs/Materials/effect";
  40114. /**
  40115. * Base class of materials working in push mode in babylon JS
  40116. * @hidden
  40117. */
  40118. export class PushMaterial extends Material {
  40119. protected _activeEffect: Effect;
  40120. protected _normalMatrix: Matrix;
  40121. /**
  40122. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40123. * This means that the material can keep using a previous shader while a new one is being compiled.
  40124. * This is mostly used when shader parallel compilation is supported (true by default)
  40125. */
  40126. allowShaderHotSwapping: boolean;
  40127. constructor(name: string, scene: Scene);
  40128. getEffect(): Effect;
  40129. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40130. /**
  40131. * Binds the given world matrix to the active effect
  40132. *
  40133. * @param world the matrix to bind
  40134. */
  40135. bindOnlyWorldMatrix(world: Matrix): void;
  40136. /**
  40137. * Binds the given normal matrix to the active effect
  40138. *
  40139. * @param normalMatrix the matrix to bind
  40140. */
  40141. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40142. bind(world: Matrix, mesh?: Mesh): void;
  40143. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40144. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40145. }
  40146. }
  40147. declare module "babylonjs/Materials/materialFlags" {
  40148. /**
  40149. * This groups all the flags used to control the materials channel.
  40150. */
  40151. export class MaterialFlags {
  40152. private static _DiffuseTextureEnabled;
  40153. /**
  40154. * Are diffuse textures enabled in the application.
  40155. */
  40156. static DiffuseTextureEnabled: boolean;
  40157. private static _AmbientTextureEnabled;
  40158. /**
  40159. * Are ambient textures enabled in the application.
  40160. */
  40161. static AmbientTextureEnabled: boolean;
  40162. private static _OpacityTextureEnabled;
  40163. /**
  40164. * Are opacity textures enabled in the application.
  40165. */
  40166. static OpacityTextureEnabled: boolean;
  40167. private static _ReflectionTextureEnabled;
  40168. /**
  40169. * Are reflection textures enabled in the application.
  40170. */
  40171. static ReflectionTextureEnabled: boolean;
  40172. private static _EmissiveTextureEnabled;
  40173. /**
  40174. * Are emissive textures enabled in the application.
  40175. */
  40176. static EmissiveTextureEnabled: boolean;
  40177. private static _SpecularTextureEnabled;
  40178. /**
  40179. * Are specular textures enabled in the application.
  40180. */
  40181. static SpecularTextureEnabled: boolean;
  40182. private static _BumpTextureEnabled;
  40183. /**
  40184. * Are bump textures enabled in the application.
  40185. */
  40186. static BumpTextureEnabled: boolean;
  40187. private static _LightmapTextureEnabled;
  40188. /**
  40189. * Are lightmap textures enabled in the application.
  40190. */
  40191. static LightmapTextureEnabled: boolean;
  40192. private static _RefractionTextureEnabled;
  40193. /**
  40194. * Are refraction textures enabled in the application.
  40195. */
  40196. static RefractionTextureEnabled: boolean;
  40197. private static _ColorGradingTextureEnabled;
  40198. /**
  40199. * Are color grading textures enabled in the application.
  40200. */
  40201. static ColorGradingTextureEnabled: boolean;
  40202. private static _FresnelEnabled;
  40203. /**
  40204. * Are fresnels enabled in the application.
  40205. */
  40206. static FresnelEnabled: boolean;
  40207. private static _ClearCoatTextureEnabled;
  40208. /**
  40209. * Are clear coat textures enabled in the application.
  40210. */
  40211. static ClearCoatTextureEnabled: boolean;
  40212. private static _ClearCoatBumpTextureEnabled;
  40213. /**
  40214. * Are clear coat bump textures enabled in the application.
  40215. */
  40216. static ClearCoatBumpTextureEnabled: boolean;
  40217. private static _ClearCoatTintTextureEnabled;
  40218. /**
  40219. * Are clear coat tint textures enabled in the application.
  40220. */
  40221. static ClearCoatTintTextureEnabled: boolean;
  40222. private static _SheenTextureEnabled;
  40223. /**
  40224. * Are sheen textures enabled in the application.
  40225. */
  40226. static SheenTextureEnabled: boolean;
  40227. private static _AnisotropicTextureEnabled;
  40228. /**
  40229. * Are anisotropic textures enabled in the application.
  40230. */
  40231. static AnisotropicTextureEnabled: boolean;
  40232. private static _ThicknessTextureEnabled;
  40233. /**
  40234. * Are thickness textures enabled in the application.
  40235. */
  40236. static ThicknessTextureEnabled: boolean;
  40237. }
  40238. }
  40239. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40240. /** @hidden */
  40241. export var defaultFragmentDeclaration: {
  40242. name: string;
  40243. shader: string;
  40244. };
  40245. }
  40246. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40247. /** @hidden */
  40248. export var defaultUboDeclaration: {
  40249. name: string;
  40250. shader: string;
  40251. };
  40252. }
  40253. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40254. /** @hidden */
  40255. export var lightFragmentDeclaration: {
  40256. name: string;
  40257. shader: string;
  40258. };
  40259. }
  40260. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40261. /** @hidden */
  40262. export var lightUboDeclaration: {
  40263. name: string;
  40264. shader: string;
  40265. };
  40266. }
  40267. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40268. /** @hidden */
  40269. export var lightsFragmentFunctions: {
  40270. name: string;
  40271. shader: string;
  40272. };
  40273. }
  40274. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40275. /** @hidden */
  40276. export var shadowsFragmentFunctions: {
  40277. name: string;
  40278. shader: string;
  40279. };
  40280. }
  40281. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40282. /** @hidden */
  40283. export var fresnelFunction: {
  40284. name: string;
  40285. shader: string;
  40286. };
  40287. }
  40288. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40289. /** @hidden */
  40290. export var reflectionFunction: {
  40291. name: string;
  40292. shader: string;
  40293. };
  40294. }
  40295. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40296. /** @hidden */
  40297. export var bumpFragmentFunctions: {
  40298. name: string;
  40299. shader: string;
  40300. };
  40301. }
  40302. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40303. /** @hidden */
  40304. export var logDepthDeclaration: {
  40305. name: string;
  40306. shader: string;
  40307. };
  40308. }
  40309. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40310. /** @hidden */
  40311. export var bumpFragment: {
  40312. name: string;
  40313. shader: string;
  40314. };
  40315. }
  40316. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40317. /** @hidden */
  40318. export var depthPrePass: {
  40319. name: string;
  40320. shader: string;
  40321. };
  40322. }
  40323. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40324. /** @hidden */
  40325. export var lightFragment: {
  40326. name: string;
  40327. shader: string;
  40328. };
  40329. }
  40330. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40331. /** @hidden */
  40332. export var logDepthFragment: {
  40333. name: string;
  40334. shader: string;
  40335. };
  40336. }
  40337. declare module "babylonjs/Shaders/default.fragment" {
  40338. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40339. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40340. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40341. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40342. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40343. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40344. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40345. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40346. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40347. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40348. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40349. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40350. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40351. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40352. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40353. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40354. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40355. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40356. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40357. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40358. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40359. /** @hidden */
  40360. export var defaultPixelShader: {
  40361. name: string;
  40362. shader: string;
  40363. };
  40364. }
  40365. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40366. /** @hidden */
  40367. export var defaultVertexDeclaration: {
  40368. name: string;
  40369. shader: string;
  40370. };
  40371. }
  40372. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40373. /** @hidden */
  40374. export var bumpVertexDeclaration: {
  40375. name: string;
  40376. shader: string;
  40377. };
  40378. }
  40379. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40380. /** @hidden */
  40381. export var bumpVertex: {
  40382. name: string;
  40383. shader: string;
  40384. };
  40385. }
  40386. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40387. /** @hidden */
  40388. export var fogVertex: {
  40389. name: string;
  40390. shader: string;
  40391. };
  40392. }
  40393. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40394. /** @hidden */
  40395. export var shadowsVertex: {
  40396. name: string;
  40397. shader: string;
  40398. };
  40399. }
  40400. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40401. /** @hidden */
  40402. export var pointCloudVertex: {
  40403. name: string;
  40404. shader: string;
  40405. };
  40406. }
  40407. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40408. /** @hidden */
  40409. export var logDepthVertex: {
  40410. name: string;
  40411. shader: string;
  40412. };
  40413. }
  40414. declare module "babylonjs/Shaders/default.vertex" {
  40415. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40416. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40417. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40418. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40419. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40420. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40421. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40422. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40423. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40424. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40425. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40426. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40427. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40428. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40429. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40430. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40431. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40432. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40433. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40434. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40435. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40436. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40437. /** @hidden */
  40438. export var defaultVertexShader: {
  40439. name: string;
  40440. shader: string;
  40441. };
  40442. }
  40443. declare module "babylonjs/Materials/standardMaterial" {
  40444. import { SmartArray } from "babylonjs/Misc/smartArray";
  40445. import { IAnimatable } from "babylonjs/Misc/tools";
  40446. import { Nullable } from "babylonjs/types";
  40447. import { Scene } from "babylonjs/scene";
  40448. import { Matrix, Color3 } from "babylonjs/Maths/math";
  40449. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40451. import { Mesh } from "babylonjs/Meshes/mesh";
  40452. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40453. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40454. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40455. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40456. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40457. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40458. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40459. import "babylonjs/Shaders/default.fragment";
  40460. import "babylonjs/Shaders/default.vertex";
  40461. /** @hidden */
  40462. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40463. MAINUV1: boolean;
  40464. MAINUV2: boolean;
  40465. DIFFUSE: boolean;
  40466. DIFFUSEDIRECTUV: number;
  40467. AMBIENT: boolean;
  40468. AMBIENTDIRECTUV: number;
  40469. OPACITY: boolean;
  40470. OPACITYDIRECTUV: number;
  40471. OPACITYRGB: boolean;
  40472. REFLECTION: boolean;
  40473. EMISSIVE: boolean;
  40474. EMISSIVEDIRECTUV: number;
  40475. SPECULAR: boolean;
  40476. SPECULARDIRECTUV: number;
  40477. BUMP: boolean;
  40478. BUMPDIRECTUV: number;
  40479. PARALLAX: boolean;
  40480. PARALLAXOCCLUSION: boolean;
  40481. SPECULAROVERALPHA: boolean;
  40482. CLIPPLANE: boolean;
  40483. CLIPPLANE2: boolean;
  40484. CLIPPLANE3: boolean;
  40485. CLIPPLANE4: boolean;
  40486. ALPHATEST: boolean;
  40487. DEPTHPREPASS: boolean;
  40488. ALPHAFROMDIFFUSE: boolean;
  40489. POINTSIZE: boolean;
  40490. FOG: boolean;
  40491. SPECULARTERM: boolean;
  40492. DIFFUSEFRESNEL: boolean;
  40493. OPACITYFRESNEL: boolean;
  40494. REFLECTIONFRESNEL: boolean;
  40495. REFRACTIONFRESNEL: boolean;
  40496. EMISSIVEFRESNEL: boolean;
  40497. FRESNEL: boolean;
  40498. NORMAL: boolean;
  40499. UV1: boolean;
  40500. UV2: boolean;
  40501. VERTEXCOLOR: boolean;
  40502. VERTEXALPHA: boolean;
  40503. NUM_BONE_INFLUENCERS: number;
  40504. BonesPerMesh: number;
  40505. BONETEXTURE: boolean;
  40506. INSTANCES: boolean;
  40507. GLOSSINESS: boolean;
  40508. ROUGHNESS: boolean;
  40509. EMISSIVEASILLUMINATION: boolean;
  40510. LINKEMISSIVEWITHDIFFUSE: boolean;
  40511. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40512. LIGHTMAP: boolean;
  40513. LIGHTMAPDIRECTUV: number;
  40514. OBJECTSPACE_NORMALMAP: boolean;
  40515. USELIGHTMAPASSHADOWMAP: boolean;
  40516. REFLECTIONMAP_3D: boolean;
  40517. REFLECTIONMAP_SPHERICAL: boolean;
  40518. REFLECTIONMAP_PLANAR: boolean;
  40519. REFLECTIONMAP_CUBIC: boolean;
  40520. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40521. REFLECTIONMAP_PROJECTION: boolean;
  40522. REFLECTIONMAP_SKYBOX: boolean;
  40523. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40524. REFLECTIONMAP_EXPLICIT: boolean;
  40525. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40526. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40527. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40528. INVERTCUBICMAP: boolean;
  40529. LOGARITHMICDEPTH: boolean;
  40530. REFRACTION: boolean;
  40531. REFRACTIONMAP_3D: boolean;
  40532. REFLECTIONOVERALPHA: boolean;
  40533. TWOSIDEDLIGHTING: boolean;
  40534. SHADOWFLOAT: boolean;
  40535. MORPHTARGETS: boolean;
  40536. MORPHTARGETS_NORMAL: boolean;
  40537. MORPHTARGETS_TANGENT: boolean;
  40538. MORPHTARGETS_UV: boolean;
  40539. NUM_MORPH_INFLUENCERS: number;
  40540. NONUNIFORMSCALING: boolean;
  40541. PREMULTIPLYALPHA: boolean;
  40542. IMAGEPROCESSING: boolean;
  40543. VIGNETTE: boolean;
  40544. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40545. VIGNETTEBLENDMODEOPAQUE: boolean;
  40546. TONEMAPPING: boolean;
  40547. TONEMAPPING_ACES: boolean;
  40548. CONTRAST: boolean;
  40549. COLORCURVES: boolean;
  40550. COLORGRADING: boolean;
  40551. COLORGRADING3D: boolean;
  40552. SAMPLER3DGREENDEPTH: boolean;
  40553. SAMPLER3DBGRMAP: boolean;
  40554. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40555. MULTIVIEW: boolean;
  40556. /**
  40557. * If the reflection texture on this material is in linear color space
  40558. * @hidden
  40559. */
  40560. IS_REFLECTION_LINEAR: boolean;
  40561. /**
  40562. * If the refraction texture on this material is in linear color space
  40563. * @hidden
  40564. */
  40565. IS_REFRACTION_LINEAR: boolean;
  40566. EXPOSURE: boolean;
  40567. constructor();
  40568. setReflectionMode(modeToEnable: string): void;
  40569. }
  40570. /**
  40571. * This is the default material used in Babylon. It is the best trade off between quality
  40572. * and performances.
  40573. * @see http://doc.babylonjs.com/babylon101/materials
  40574. */
  40575. export class StandardMaterial extends PushMaterial {
  40576. private _diffuseTexture;
  40577. /**
  40578. * The basic texture of the material as viewed under a light.
  40579. */
  40580. diffuseTexture: Nullable<BaseTexture>;
  40581. private _ambientTexture;
  40582. /**
  40583. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40584. */
  40585. ambientTexture: Nullable<BaseTexture>;
  40586. private _opacityTexture;
  40587. /**
  40588. * Define the transparency of the material from a texture.
  40589. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40590. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40591. */
  40592. opacityTexture: Nullable<BaseTexture>;
  40593. private _reflectionTexture;
  40594. /**
  40595. * Define the texture used to display the reflection.
  40596. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40597. */
  40598. reflectionTexture: Nullable<BaseTexture>;
  40599. private _emissiveTexture;
  40600. /**
  40601. * Define texture of the material as if self lit.
  40602. * This will be mixed in the final result even in the absence of light.
  40603. */
  40604. emissiveTexture: Nullable<BaseTexture>;
  40605. private _specularTexture;
  40606. /**
  40607. * Define how the color and intensity of the highlight given by the light in the material.
  40608. */
  40609. specularTexture: Nullable<BaseTexture>;
  40610. private _bumpTexture;
  40611. /**
  40612. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40613. * 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.
  40614. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40615. */
  40616. bumpTexture: Nullable<BaseTexture>;
  40617. private _lightmapTexture;
  40618. /**
  40619. * Complex lighting can be computationally expensive to compute at runtime.
  40620. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40621. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40622. */
  40623. lightmapTexture: Nullable<BaseTexture>;
  40624. private _refractionTexture;
  40625. /**
  40626. * Define the texture used to display the refraction.
  40627. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40628. */
  40629. refractionTexture: Nullable<BaseTexture>;
  40630. /**
  40631. * The color of the material lit by the environmental background lighting.
  40632. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40633. */
  40634. ambientColor: Color3;
  40635. /**
  40636. * The basic color of the material as viewed under a light.
  40637. */
  40638. diffuseColor: Color3;
  40639. /**
  40640. * Define how the color and intensity of the highlight given by the light in the material.
  40641. */
  40642. specularColor: Color3;
  40643. /**
  40644. * Define the color of the material as if self lit.
  40645. * This will be mixed in the final result even in the absence of light.
  40646. */
  40647. emissiveColor: Color3;
  40648. /**
  40649. * Defines how sharp are the highlights in the material.
  40650. * The bigger the value the sharper giving a more glossy feeling to the result.
  40651. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40652. */
  40653. specularPower: number;
  40654. private _useAlphaFromDiffuseTexture;
  40655. /**
  40656. * Does the transparency come from the diffuse texture alpha channel.
  40657. */
  40658. useAlphaFromDiffuseTexture: boolean;
  40659. private _useEmissiveAsIllumination;
  40660. /**
  40661. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40662. */
  40663. useEmissiveAsIllumination: boolean;
  40664. private _linkEmissiveWithDiffuse;
  40665. /**
  40666. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40667. * the emissive level when the final color is close to one.
  40668. */
  40669. linkEmissiveWithDiffuse: boolean;
  40670. private _useSpecularOverAlpha;
  40671. /**
  40672. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40673. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40674. */
  40675. useSpecularOverAlpha: boolean;
  40676. private _useReflectionOverAlpha;
  40677. /**
  40678. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40679. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40680. */
  40681. useReflectionOverAlpha: boolean;
  40682. private _disableLighting;
  40683. /**
  40684. * Does lights from the scene impacts this material.
  40685. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40686. */
  40687. disableLighting: boolean;
  40688. private _useObjectSpaceNormalMap;
  40689. /**
  40690. * Allows using an object space normal map (instead of tangent space).
  40691. */
  40692. useObjectSpaceNormalMap: boolean;
  40693. private _useParallax;
  40694. /**
  40695. * Is parallax enabled or not.
  40696. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40697. */
  40698. useParallax: boolean;
  40699. private _useParallaxOcclusion;
  40700. /**
  40701. * Is parallax occlusion enabled or not.
  40702. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40703. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40704. */
  40705. useParallaxOcclusion: boolean;
  40706. /**
  40707. * 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.
  40708. */
  40709. parallaxScaleBias: number;
  40710. private _roughness;
  40711. /**
  40712. * Helps to define how blurry the reflections should appears in the material.
  40713. */
  40714. roughness: number;
  40715. /**
  40716. * In case of refraction, define the value of the index of refraction.
  40717. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40718. */
  40719. indexOfRefraction: number;
  40720. /**
  40721. * Invert the refraction texture alongside the y axis.
  40722. * It can be useful with procedural textures or probe for instance.
  40723. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40724. */
  40725. invertRefractionY: boolean;
  40726. /**
  40727. * Defines the alpha limits in alpha test mode.
  40728. */
  40729. alphaCutOff: number;
  40730. private _useLightmapAsShadowmap;
  40731. /**
  40732. * In case of light mapping, define whether the map contains light or shadow informations.
  40733. */
  40734. useLightmapAsShadowmap: boolean;
  40735. private _diffuseFresnelParameters;
  40736. /**
  40737. * Define the diffuse fresnel parameters of the material.
  40738. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40739. */
  40740. diffuseFresnelParameters: FresnelParameters;
  40741. private _opacityFresnelParameters;
  40742. /**
  40743. * Define the opacity fresnel parameters of the material.
  40744. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40745. */
  40746. opacityFresnelParameters: FresnelParameters;
  40747. private _reflectionFresnelParameters;
  40748. /**
  40749. * Define the reflection fresnel parameters of the material.
  40750. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40751. */
  40752. reflectionFresnelParameters: FresnelParameters;
  40753. private _refractionFresnelParameters;
  40754. /**
  40755. * Define the refraction fresnel parameters of the material.
  40756. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40757. */
  40758. refractionFresnelParameters: FresnelParameters;
  40759. private _emissiveFresnelParameters;
  40760. /**
  40761. * Define the emissive fresnel parameters of the material.
  40762. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40763. */
  40764. emissiveFresnelParameters: FresnelParameters;
  40765. private _useReflectionFresnelFromSpecular;
  40766. /**
  40767. * If true automatically deducts the fresnels values from the material specularity.
  40768. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40769. */
  40770. useReflectionFresnelFromSpecular: boolean;
  40771. private _useGlossinessFromSpecularMapAlpha;
  40772. /**
  40773. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40774. */
  40775. useGlossinessFromSpecularMapAlpha: boolean;
  40776. private _maxSimultaneousLights;
  40777. /**
  40778. * Defines the maximum number of lights that can be used in the material
  40779. */
  40780. maxSimultaneousLights: number;
  40781. private _invertNormalMapX;
  40782. /**
  40783. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40784. */
  40785. invertNormalMapX: boolean;
  40786. private _invertNormalMapY;
  40787. /**
  40788. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40789. */
  40790. invertNormalMapY: boolean;
  40791. private _twoSidedLighting;
  40792. /**
  40793. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40794. */
  40795. twoSidedLighting: boolean;
  40796. /**
  40797. * Default configuration related to image processing available in the standard Material.
  40798. */
  40799. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40800. /**
  40801. * Gets the image processing configuration used either in this material.
  40802. */
  40803. /**
  40804. * Sets the Default image processing configuration used either in the this material.
  40805. *
  40806. * If sets to null, the scene one is in use.
  40807. */
  40808. imageProcessingConfiguration: ImageProcessingConfiguration;
  40809. /**
  40810. * Keep track of the image processing observer to allow dispose and replace.
  40811. */
  40812. private _imageProcessingObserver;
  40813. /**
  40814. * Attaches a new image processing configuration to the Standard Material.
  40815. * @param configuration
  40816. */
  40817. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40818. /**
  40819. * Gets wether the color curves effect is enabled.
  40820. */
  40821. /**
  40822. * Sets wether the color curves effect is enabled.
  40823. */
  40824. cameraColorCurvesEnabled: boolean;
  40825. /**
  40826. * Gets wether the color grading effect is enabled.
  40827. */
  40828. /**
  40829. * Gets wether the color grading effect is enabled.
  40830. */
  40831. cameraColorGradingEnabled: boolean;
  40832. /**
  40833. * Gets wether tonemapping is enabled or not.
  40834. */
  40835. /**
  40836. * Sets wether tonemapping is enabled or not
  40837. */
  40838. cameraToneMappingEnabled: boolean;
  40839. /**
  40840. * The camera exposure used on this material.
  40841. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40842. * This corresponds to a photographic exposure.
  40843. */
  40844. /**
  40845. * The camera exposure used on this material.
  40846. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40847. * This corresponds to a photographic exposure.
  40848. */
  40849. cameraExposure: number;
  40850. /**
  40851. * Gets The camera contrast used on this material.
  40852. */
  40853. /**
  40854. * Sets The camera contrast used on this material.
  40855. */
  40856. cameraContrast: number;
  40857. /**
  40858. * Gets the Color Grading 2D Lookup Texture.
  40859. */
  40860. /**
  40861. * Sets the Color Grading 2D Lookup Texture.
  40862. */
  40863. cameraColorGradingTexture: Nullable<BaseTexture>;
  40864. /**
  40865. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40866. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40867. * 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;
  40868. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40869. */
  40870. /**
  40871. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40872. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40873. * 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;
  40874. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40875. */
  40876. cameraColorCurves: Nullable<ColorCurves>;
  40877. /**
  40878. * Custom callback helping to override the default shader used in the material.
  40879. */
  40880. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40881. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40882. protected _worldViewProjectionMatrix: Matrix;
  40883. protected _globalAmbientColor: Color3;
  40884. protected _useLogarithmicDepth: boolean;
  40885. /**
  40886. * Instantiates a new standard material.
  40887. * This is the default material used in Babylon. It is the best trade off between quality
  40888. * and performances.
  40889. * @see http://doc.babylonjs.com/babylon101/materials
  40890. * @param name Define the name of the material in the scene
  40891. * @param scene Define the scene the material belong to
  40892. */
  40893. constructor(name: string, scene: Scene);
  40894. /**
  40895. * Gets a boolean indicating that current material needs to register RTT
  40896. */
  40897. readonly hasRenderTargetTextures: boolean;
  40898. /**
  40899. * Gets the current class name of the material e.g. "StandardMaterial"
  40900. * Mainly use in serialization.
  40901. * @returns the class name
  40902. */
  40903. getClassName(): string;
  40904. /**
  40905. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40906. * You can try switching to logarithmic depth.
  40907. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40908. */
  40909. useLogarithmicDepth: boolean;
  40910. /**
  40911. * Specifies if the material will require alpha blending
  40912. * @returns a boolean specifying if alpha blending is needed
  40913. */
  40914. needAlphaBlending(): boolean;
  40915. /**
  40916. * Specifies if this material should be rendered in alpha test mode
  40917. * @returns a boolean specifying if an alpha test is needed.
  40918. */
  40919. needAlphaTesting(): boolean;
  40920. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40921. /**
  40922. * Get the texture used for alpha test purpose.
  40923. * @returns the diffuse texture in case of the standard material.
  40924. */
  40925. getAlphaTestTexture(): Nullable<BaseTexture>;
  40926. /**
  40927. * Get if the submesh is ready to be used and all its information available.
  40928. * Child classes can use it to update shaders
  40929. * @param mesh defines the mesh to check
  40930. * @param subMesh defines which submesh to check
  40931. * @param useInstances specifies that instances should be used
  40932. * @returns a boolean indicating that the submesh is ready or not
  40933. */
  40934. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40935. /**
  40936. * Builds the material UBO layouts.
  40937. * Used internally during the effect preparation.
  40938. */
  40939. buildUniformLayout(): void;
  40940. /**
  40941. * Unbinds the material from the mesh
  40942. */
  40943. unbind(): void;
  40944. /**
  40945. * Binds the submesh to this material by preparing the effect and shader to draw
  40946. * @param world defines the world transformation matrix
  40947. * @param mesh defines the mesh containing the submesh
  40948. * @param subMesh defines the submesh to bind the material to
  40949. */
  40950. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40951. /**
  40952. * Get the list of animatables in the material.
  40953. * @returns the list of animatables object used in the material
  40954. */
  40955. getAnimatables(): IAnimatable[];
  40956. /**
  40957. * Gets the active textures from the material
  40958. * @returns an array of textures
  40959. */
  40960. getActiveTextures(): BaseTexture[];
  40961. /**
  40962. * Specifies if the material uses a texture
  40963. * @param texture defines the texture to check against the material
  40964. * @returns a boolean specifying if the material uses the texture
  40965. */
  40966. hasTexture(texture: BaseTexture): boolean;
  40967. /**
  40968. * Disposes the material
  40969. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40970. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40971. */
  40972. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40973. /**
  40974. * Makes a duplicate of the material, and gives it a new name
  40975. * @param name defines the new name for the duplicated material
  40976. * @returns the cloned material
  40977. */
  40978. clone(name: string): StandardMaterial;
  40979. /**
  40980. * Serializes this material in a JSON representation
  40981. * @returns the serialized material object
  40982. */
  40983. serialize(): any;
  40984. /**
  40985. * Creates a standard material from parsed material data
  40986. * @param source defines the JSON representation of the material
  40987. * @param scene defines the hosting scene
  40988. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40989. * @returns a new standard material
  40990. */
  40991. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40992. /**
  40993. * Are diffuse textures enabled in the application.
  40994. */
  40995. static DiffuseTextureEnabled: boolean;
  40996. /**
  40997. * Are ambient textures enabled in the application.
  40998. */
  40999. static AmbientTextureEnabled: boolean;
  41000. /**
  41001. * Are opacity textures enabled in the application.
  41002. */
  41003. static OpacityTextureEnabled: boolean;
  41004. /**
  41005. * Are reflection textures enabled in the application.
  41006. */
  41007. static ReflectionTextureEnabled: boolean;
  41008. /**
  41009. * Are emissive textures enabled in the application.
  41010. */
  41011. static EmissiveTextureEnabled: boolean;
  41012. /**
  41013. * Are specular textures enabled in the application.
  41014. */
  41015. static SpecularTextureEnabled: boolean;
  41016. /**
  41017. * Are bump textures enabled in the application.
  41018. */
  41019. static BumpTextureEnabled: boolean;
  41020. /**
  41021. * Are lightmap textures enabled in the application.
  41022. */
  41023. static LightmapTextureEnabled: boolean;
  41024. /**
  41025. * Are refraction textures enabled in the application.
  41026. */
  41027. static RefractionTextureEnabled: boolean;
  41028. /**
  41029. * Are color grading textures enabled in the application.
  41030. */
  41031. static ColorGradingTextureEnabled: boolean;
  41032. /**
  41033. * Are fresnels enabled in the application.
  41034. */
  41035. static FresnelEnabled: boolean;
  41036. }
  41037. }
  41038. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41039. import { Scene } from "babylonjs/scene";
  41040. import { Texture } from "babylonjs/Materials/Textures/texture";
  41041. /**
  41042. * A class extending Texture allowing drawing on a texture
  41043. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41044. */
  41045. export class DynamicTexture extends Texture {
  41046. private _generateMipMaps;
  41047. private _canvas;
  41048. private _context;
  41049. private _engine;
  41050. /**
  41051. * Creates a DynamicTexture
  41052. * @param name defines the name of the texture
  41053. * @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
  41054. * @param scene defines the scene where you want the texture
  41055. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41056. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41057. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41058. */
  41059. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41060. /**
  41061. * Get the current class name of the texture useful for serialization or dynamic coding.
  41062. * @returns "DynamicTexture"
  41063. */
  41064. getClassName(): string;
  41065. /**
  41066. * Gets the current state of canRescale
  41067. */
  41068. readonly canRescale: boolean;
  41069. private _recreate;
  41070. /**
  41071. * Scales the texture
  41072. * @param ratio the scale factor to apply to both width and height
  41073. */
  41074. scale(ratio: number): void;
  41075. /**
  41076. * Resizes the texture
  41077. * @param width the new width
  41078. * @param height the new height
  41079. */
  41080. scaleTo(width: number, height: number): void;
  41081. /**
  41082. * Gets the context of the canvas used by the texture
  41083. * @returns the canvas context of the dynamic texture
  41084. */
  41085. getContext(): CanvasRenderingContext2D;
  41086. /**
  41087. * Clears the texture
  41088. */
  41089. clear(): void;
  41090. /**
  41091. * Updates the texture
  41092. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41093. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41094. */
  41095. update(invertY?: boolean, premulAlpha?: boolean): void;
  41096. /**
  41097. * Draws text onto the texture
  41098. * @param text defines the text to be drawn
  41099. * @param x defines the placement of the text from the left
  41100. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41101. * @param font defines the font to be used with font-style, font-size, font-name
  41102. * @param color defines the color used for the text
  41103. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41104. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41105. * @param update defines whether texture is immediately update (default is true)
  41106. */
  41107. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41108. /**
  41109. * Clones the texture
  41110. * @returns the clone of the texture.
  41111. */
  41112. clone(): DynamicTexture;
  41113. /**
  41114. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41115. * @returns a serialized dynamic texture object
  41116. */
  41117. serialize(): any;
  41118. /** @hidden */
  41119. _rebuild(): void;
  41120. }
  41121. }
  41122. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41123. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41124. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41125. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41126. /** @hidden */
  41127. export var imageProcessingPixelShader: {
  41128. name: string;
  41129. shader: string;
  41130. };
  41131. }
  41132. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41133. import { Nullable } from "babylonjs/types";
  41134. import { Color4 } from "babylonjs/Maths/math";
  41135. import { Camera } from "babylonjs/Cameras/camera";
  41136. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41137. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41138. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41139. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41140. import { Engine } from "babylonjs/Engines/engine";
  41141. import "babylonjs/Shaders/imageProcessing.fragment";
  41142. import "babylonjs/Shaders/postprocess.vertex";
  41143. /**
  41144. * ImageProcessingPostProcess
  41145. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41146. */
  41147. export class ImageProcessingPostProcess extends PostProcess {
  41148. /**
  41149. * Default configuration related to image processing available in the PBR Material.
  41150. */
  41151. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41152. /**
  41153. * Gets the image processing configuration used either in this material.
  41154. */
  41155. /**
  41156. * Sets the Default image processing configuration used either in the this material.
  41157. *
  41158. * If sets to null, the scene one is in use.
  41159. */
  41160. imageProcessingConfiguration: ImageProcessingConfiguration;
  41161. /**
  41162. * Keep track of the image processing observer to allow dispose and replace.
  41163. */
  41164. private _imageProcessingObserver;
  41165. /**
  41166. * Attaches a new image processing configuration to the PBR Material.
  41167. * @param configuration
  41168. */
  41169. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41170. /**
  41171. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41172. */
  41173. /**
  41174. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41175. */
  41176. colorCurves: Nullable<ColorCurves>;
  41177. /**
  41178. * Gets wether the color curves effect is enabled.
  41179. */
  41180. /**
  41181. * Sets wether the color curves effect is enabled.
  41182. */
  41183. colorCurvesEnabled: boolean;
  41184. /**
  41185. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41186. */
  41187. /**
  41188. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41189. */
  41190. colorGradingTexture: Nullable<BaseTexture>;
  41191. /**
  41192. * Gets wether the color grading effect is enabled.
  41193. */
  41194. /**
  41195. * Gets wether the color grading effect is enabled.
  41196. */
  41197. colorGradingEnabled: boolean;
  41198. /**
  41199. * Gets exposure used in the effect.
  41200. */
  41201. /**
  41202. * Sets exposure used in the effect.
  41203. */
  41204. exposure: number;
  41205. /**
  41206. * Gets wether tonemapping is enabled or not.
  41207. */
  41208. /**
  41209. * Sets wether tonemapping is enabled or not
  41210. */
  41211. toneMappingEnabled: boolean;
  41212. /**
  41213. * Gets the type of tone mapping effect.
  41214. */
  41215. /**
  41216. * Sets the type of tone mapping effect.
  41217. */
  41218. toneMappingType: number;
  41219. /**
  41220. * Gets contrast used in the effect.
  41221. */
  41222. /**
  41223. * Sets contrast used in the effect.
  41224. */
  41225. contrast: number;
  41226. /**
  41227. * Gets Vignette stretch size.
  41228. */
  41229. /**
  41230. * Sets Vignette stretch size.
  41231. */
  41232. vignetteStretch: number;
  41233. /**
  41234. * Gets Vignette centre X Offset.
  41235. */
  41236. /**
  41237. * Sets Vignette centre X Offset.
  41238. */
  41239. vignetteCentreX: number;
  41240. /**
  41241. * Gets Vignette centre Y Offset.
  41242. */
  41243. /**
  41244. * Sets Vignette centre Y Offset.
  41245. */
  41246. vignetteCentreY: number;
  41247. /**
  41248. * Gets Vignette weight or intensity of the vignette effect.
  41249. */
  41250. /**
  41251. * Sets Vignette weight or intensity of the vignette effect.
  41252. */
  41253. vignetteWeight: number;
  41254. /**
  41255. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41256. * if vignetteEnabled is set to true.
  41257. */
  41258. /**
  41259. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41260. * if vignetteEnabled is set to true.
  41261. */
  41262. vignetteColor: Color4;
  41263. /**
  41264. * Gets Camera field of view used by the Vignette effect.
  41265. */
  41266. /**
  41267. * Sets Camera field of view used by the Vignette effect.
  41268. */
  41269. vignetteCameraFov: number;
  41270. /**
  41271. * Gets the vignette blend mode allowing different kind of effect.
  41272. */
  41273. /**
  41274. * Sets the vignette blend mode allowing different kind of effect.
  41275. */
  41276. vignetteBlendMode: number;
  41277. /**
  41278. * Gets wether the vignette effect is enabled.
  41279. */
  41280. /**
  41281. * Sets wether the vignette effect is enabled.
  41282. */
  41283. vignetteEnabled: boolean;
  41284. private _fromLinearSpace;
  41285. /**
  41286. * Gets wether the input of the processing is in Gamma or Linear Space.
  41287. */
  41288. /**
  41289. * Sets wether the input of the processing is in Gamma or Linear Space.
  41290. */
  41291. fromLinearSpace: boolean;
  41292. /**
  41293. * Defines cache preventing GC.
  41294. */
  41295. private _defines;
  41296. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41297. /**
  41298. * "ImageProcessingPostProcess"
  41299. * @returns "ImageProcessingPostProcess"
  41300. */
  41301. getClassName(): string;
  41302. protected _updateParameters(): void;
  41303. dispose(camera?: Camera): void;
  41304. }
  41305. }
  41306. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41307. import { Scene } from "babylonjs/scene";
  41308. import { Color3 } from "babylonjs/Maths/math";
  41309. import { Mesh } from "babylonjs/Meshes/mesh";
  41310. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41311. import { Nullable } from "babylonjs/types";
  41312. /**
  41313. * Class containing static functions to help procedurally build meshes
  41314. */
  41315. export class GroundBuilder {
  41316. /**
  41317. * Creates a ground mesh
  41318. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41319. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41321. * @param name defines the name of the mesh
  41322. * @param options defines the options used to create the mesh
  41323. * @param scene defines the hosting scene
  41324. * @returns the ground mesh
  41325. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41326. */
  41327. static CreateGround(name: string, options: {
  41328. width?: number;
  41329. height?: number;
  41330. subdivisions?: number;
  41331. subdivisionsX?: number;
  41332. subdivisionsY?: number;
  41333. updatable?: boolean;
  41334. }, scene: any): Mesh;
  41335. /**
  41336. * Creates a tiled ground mesh
  41337. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41338. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41339. * * 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
  41340. * * 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
  41341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41342. * @param name defines the name of the mesh
  41343. * @param options defines the options used to create the mesh
  41344. * @param scene defines the hosting scene
  41345. * @returns the tiled ground mesh
  41346. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41347. */
  41348. static CreateTiledGround(name: string, options: {
  41349. xmin: number;
  41350. zmin: number;
  41351. xmax: number;
  41352. zmax: number;
  41353. subdivisions?: {
  41354. w: number;
  41355. h: number;
  41356. };
  41357. precision?: {
  41358. w: number;
  41359. h: number;
  41360. };
  41361. updatable?: boolean;
  41362. }, scene?: Nullable<Scene>): Mesh;
  41363. /**
  41364. * Creates a ground mesh from a height map
  41365. * * The parameter `url` sets the URL of the height map image resource.
  41366. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41367. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41368. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41369. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41370. * * 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.
  41371. * * 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).
  41372. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41374. * @param name defines the name of the mesh
  41375. * @param url defines the url to the height map
  41376. * @param options defines the options used to create the mesh
  41377. * @param scene defines the hosting scene
  41378. * @returns the ground mesh
  41379. * @see https://doc.babylonjs.com/babylon101/height_map
  41380. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41381. */
  41382. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41383. width?: number;
  41384. height?: number;
  41385. subdivisions?: number;
  41386. minHeight?: number;
  41387. maxHeight?: number;
  41388. colorFilter?: Color3;
  41389. alphaFilter?: number;
  41390. updatable?: boolean;
  41391. onReady?: (mesh: GroundMesh) => void;
  41392. }, scene?: Nullable<Scene>): GroundMesh;
  41393. }
  41394. }
  41395. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41396. import { Vector4 } from "babylonjs/Maths/math";
  41397. import { Mesh } from "babylonjs/Meshes/mesh";
  41398. /**
  41399. * Class containing static functions to help procedurally build meshes
  41400. */
  41401. export class TorusBuilder {
  41402. /**
  41403. * Creates a torus mesh
  41404. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41405. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41406. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41408. * * 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
  41409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41410. * @param name defines the name of the mesh
  41411. * @param options defines the options used to create the mesh
  41412. * @param scene defines the hosting scene
  41413. * @returns the torus mesh
  41414. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41415. */
  41416. static CreateTorus(name: string, options: {
  41417. diameter?: number;
  41418. thickness?: number;
  41419. tessellation?: number;
  41420. updatable?: boolean;
  41421. sideOrientation?: number;
  41422. frontUVs?: Vector4;
  41423. backUVs?: Vector4;
  41424. }, scene: any): Mesh;
  41425. }
  41426. }
  41427. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41428. import { Color4, Vector4 } from "babylonjs/Maths/math";
  41429. import { Mesh } from "babylonjs/Meshes/mesh";
  41430. /**
  41431. * Class containing static functions to help procedurally build meshes
  41432. */
  41433. export class CylinderBuilder {
  41434. /**
  41435. * Creates a cylinder or a cone mesh
  41436. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41437. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41438. * * 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.
  41439. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41440. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41441. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41442. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41443. * * 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).
  41444. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41445. * * 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).
  41446. * * 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
  41447. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41448. * * 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
  41449. * * 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.
  41450. * * If `enclose` is false, a ring surface is one element.
  41451. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41452. * * 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
  41453. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41454. * * 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
  41455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41456. * @param name defines the name of the mesh
  41457. * @param options defines the options used to create the mesh
  41458. * @param scene defines the hosting scene
  41459. * @returns the cylinder mesh
  41460. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41461. */
  41462. static CreateCylinder(name: string, options: {
  41463. height?: number;
  41464. diameterTop?: number;
  41465. diameterBottom?: number;
  41466. diameter?: number;
  41467. tessellation?: number;
  41468. subdivisions?: number;
  41469. arc?: number;
  41470. faceColors?: Color4[];
  41471. faceUV?: Vector4[];
  41472. updatable?: boolean;
  41473. hasRings?: boolean;
  41474. enclose?: boolean;
  41475. cap?: number;
  41476. sideOrientation?: number;
  41477. frontUVs?: Vector4;
  41478. backUVs?: Vector4;
  41479. }, scene: any): Mesh;
  41480. }
  41481. }
  41482. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41483. import { Observable } from "babylonjs/Misc/observable";
  41484. import { Nullable } from "babylonjs/types";
  41485. import { Camera } from "babylonjs/Cameras/camera";
  41486. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41487. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41488. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41489. import { Scene } from "babylonjs/scene";
  41490. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41491. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41493. import { Mesh } from "babylonjs/Meshes/mesh";
  41494. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41495. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41496. import "babylonjs/Meshes/Builders/groundBuilder";
  41497. import "babylonjs/Meshes/Builders/torusBuilder";
  41498. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41499. import "babylonjs/Gamepads/gamepadSceneComponent";
  41500. import "babylonjs/Animations/animatable";
  41501. /**
  41502. * Options to modify the vr teleportation behavior.
  41503. */
  41504. export interface VRTeleportationOptions {
  41505. /**
  41506. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41507. */
  41508. floorMeshName?: string;
  41509. /**
  41510. * A list of meshes to be used as the teleportation floor. (default: empty)
  41511. */
  41512. floorMeshes?: Mesh[];
  41513. }
  41514. /**
  41515. * Options to modify the vr experience helper's behavior.
  41516. */
  41517. export interface VRExperienceHelperOptions extends WebVROptions {
  41518. /**
  41519. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41520. */
  41521. createDeviceOrientationCamera?: boolean;
  41522. /**
  41523. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41524. */
  41525. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41526. /**
  41527. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41528. */
  41529. laserToggle?: boolean;
  41530. /**
  41531. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41532. */
  41533. floorMeshes?: Mesh[];
  41534. /**
  41535. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41536. */
  41537. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41538. }
  41539. /**
  41540. * Event containing information after VR has been entered
  41541. */
  41542. export class OnAfterEnteringVRObservableEvent {
  41543. /**
  41544. * If entering vr was successful
  41545. */
  41546. success: boolean;
  41547. }
  41548. /**
  41549. * Helps to quickly add VR support to an existing scene.
  41550. * See http://doc.babylonjs.com/how_to/webvr_helper
  41551. */
  41552. export class VRExperienceHelper {
  41553. /** Options to modify the vr experience helper's behavior. */
  41554. webVROptions: VRExperienceHelperOptions;
  41555. private _scene;
  41556. private _position;
  41557. private _btnVR;
  41558. private _btnVRDisplayed;
  41559. private _webVRsupported;
  41560. private _webVRready;
  41561. private _webVRrequesting;
  41562. private _webVRpresenting;
  41563. private _hasEnteredVR;
  41564. private _fullscreenVRpresenting;
  41565. private _canvas;
  41566. private _webVRCamera;
  41567. private _vrDeviceOrientationCamera;
  41568. private _deviceOrientationCamera;
  41569. private _existingCamera;
  41570. private _onKeyDown;
  41571. private _onVrDisplayPresentChange;
  41572. private _onVRDisplayChanged;
  41573. private _onVRRequestPresentStart;
  41574. private _onVRRequestPresentComplete;
  41575. /**
  41576. * Observable raised right before entering VR.
  41577. */
  41578. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41579. /**
  41580. * Observable raised when entering VR has completed.
  41581. */
  41582. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41583. /**
  41584. * Observable raised when exiting VR.
  41585. */
  41586. onExitingVRObservable: Observable<VRExperienceHelper>;
  41587. /**
  41588. * Observable raised when controller mesh is loaded.
  41589. */
  41590. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41591. /** Return this.onEnteringVRObservable
  41592. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41593. */
  41594. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41595. /** Return this.onExitingVRObservable
  41596. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41597. */
  41598. readonly onExitingVR: Observable<VRExperienceHelper>;
  41599. /** Return this.onControllerMeshLoadedObservable
  41600. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41601. */
  41602. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41603. private _rayLength;
  41604. private _useCustomVRButton;
  41605. private _teleportationRequested;
  41606. private _teleportActive;
  41607. private _floorMeshName;
  41608. private _floorMeshesCollection;
  41609. private _rotationAllowed;
  41610. private _teleportBackwardsVector;
  41611. private _teleportationTarget;
  41612. private _isDefaultTeleportationTarget;
  41613. private _postProcessMove;
  41614. private _teleportationFillColor;
  41615. private _teleportationBorderColor;
  41616. private _rotationAngle;
  41617. private _haloCenter;
  41618. private _cameraGazer;
  41619. private _padSensibilityUp;
  41620. private _padSensibilityDown;
  41621. private _leftController;
  41622. private _rightController;
  41623. /**
  41624. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41625. */
  41626. onNewMeshSelected: Observable<AbstractMesh>;
  41627. /**
  41628. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41629. */
  41630. onNewMeshPicked: Observable<PickingInfo>;
  41631. private _circleEase;
  41632. /**
  41633. * Observable raised before camera teleportation
  41634. */
  41635. onBeforeCameraTeleport: Observable<Vector3>;
  41636. /**
  41637. * Observable raised after camera teleportation
  41638. */
  41639. onAfterCameraTeleport: Observable<Vector3>;
  41640. /**
  41641. * Observable raised when current selected mesh gets unselected
  41642. */
  41643. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41644. private _raySelectionPredicate;
  41645. /**
  41646. * To be optionaly changed by user to define custom ray selection
  41647. */
  41648. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41649. /**
  41650. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41651. */
  41652. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41653. /**
  41654. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41655. */
  41656. teleportationEnabled: boolean;
  41657. private _defaultHeight;
  41658. private _teleportationInitialized;
  41659. private _interactionsEnabled;
  41660. private _interactionsRequested;
  41661. private _displayGaze;
  41662. private _displayLaserPointer;
  41663. /**
  41664. * The mesh used to display where the user is going to teleport.
  41665. */
  41666. /**
  41667. * Sets the mesh to be used to display where the user is going to teleport.
  41668. */
  41669. teleportationTarget: Mesh;
  41670. /**
  41671. * 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
  41672. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41673. * See http://doc.babylonjs.com/resources/baking_transformations
  41674. */
  41675. gazeTrackerMesh: Mesh;
  41676. /**
  41677. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41678. */
  41679. updateGazeTrackerScale: boolean;
  41680. /**
  41681. * If the gaze trackers color should be updated when selecting meshes
  41682. */
  41683. updateGazeTrackerColor: boolean;
  41684. /**
  41685. * The gaze tracking mesh corresponding to the left controller
  41686. */
  41687. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41688. /**
  41689. * The gaze tracking mesh corresponding to the right controller
  41690. */
  41691. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41692. /**
  41693. * If the ray of the gaze should be displayed.
  41694. */
  41695. /**
  41696. * Sets if the ray of the gaze should be displayed.
  41697. */
  41698. displayGaze: boolean;
  41699. /**
  41700. * If the ray of the LaserPointer should be displayed.
  41701. */
  41702. /**
  41703. * Sets if the ray of the LaserPointer should be displayed.
  41704. */
  41705. displayLaserPointer: boolean;
  41706. /**
  41707. * The deviceOrientationCamera used as the camera when not in VR.
  41708. */
  41709. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41710. /**
  41711. * Based on the current WebVR support, returns the current VR camera used.
  41712. */
  41713. readonly currentVRCamera: Nullable<Camera>;
  41714. /**
  41715. * The webVRCamera which is used when in VR.
  41716. */
  41717. readonly webVRCamera: WebVRFreeCamera;
  41718. /**
  41719. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41720. */
  41721. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41722. private readonly _teleportationRequestInitiated;
  41723. /**
  41724. * Defines wether or not Pointer lock should be requested when switching to
  41725. * full screen.
  41726. */
  41727. requestPointerLockOnFullScreen: boolean;
  41728. /**
  41729. * Instantiates a VRExperienceHelper.
  41730. * Helps to quickly add VR support to an existing scene.
  41731. * @param scene The scene the VRExperienceHelper belongs to.
  41732. * @param webVROptions Options to modify the vr experience helper's behavior.
  41733. */
  41734. constructor(scene: Scene,
  41735. /** Options to modify the vr experience helper's behavior. */
  41736. webVROptions?: VRExperienceHelperOptions);
  41737. private _onDefaultMeshLoaded;
  41738. private _onResize;
  41739. private _onFullscreenChange;
  41740. /**
  41741. * Gets a value indicating if we are currently in VR mode.
  41742. */
  41743. readonly isInVRMode: boolean;
  41744. private onVrDisplayPresentChange;
  41745. private onVRDisplayChanged;
  41746. private moveButtonToBottomRight;
  41747. private displayVRButton;
  41748. private updateButtonVisibility;
  41749. private _cachedAngularSensibility;
  41750. /**
  41751. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41752. * Otherwise, will use the fullscreen API.
  41753. */
  41754. enterVR(): void;
  41755. /**
  41756. * Attempt to exit VR, or fullscreen.
  41757. */
  41758. exitVR(): void;
  41759. /**
  41760. * The position of the vr experience helper.
  41761. */
  41762. /**
  41763. * Sets the position of the vr experience helper.
  41764. */
  41765. position: Vector3;
  41766. /**
  41767. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41768. */
  41769. enableInteractions(): void;
  41770. private readonly _noControllerIsActive;
  41771. private beforeRender;
  41772. private _isTeleportationFloor;
  41773. /**
  41774. * Adds a floor mesh to be used for teleportation.
  41775. * @param floorMesh the mesh to be used for teleportation.
  41776. */
  41777. addFloorMesh(floorMesh: Mesh): void;
  41778. /**
  41779. * Removes a floor mesh from being used for teleportation.
  41780. * @param floorMesh the mesh to be removed.
  41781. */
  41782. removeFloorMesh(floorMesh: Mesh): void;
  41783. /**
  41784. * Enables interactions and teleportation using the VR controllers and gaze.
  41785. * @param vrTeleportationOptions options to modify teleportation behavior.
  41786. */
  41787. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41788. private _onNewGamepadConnected;
  41789. private _tryEnableInteractionOnController;
  41790. private _onNewGamepadDisconnected;
  41791. private _enableInteractionOnController;
  41792. private _checkTeleportWithRay;
  41793. private _checkRotate;
  41794. private _checkTeleportBackwards;
  41795. private _enableTeleportationOnController;
  41796. private _createTeleportationCircles;
  41797. private _displayTeleportationTarget;
  41798. private _hideTeleportationTarget;
  41799. private _rotateCamera;
  41800. private _moveTeleportationSelectorTo;
  41801. private _workingVector;
  41802. private _workingQuaternion;
  41803. private _workingMatrix;
  41804. /**
  41805. * Teleports the users feet to the desired location
  41806. * @param location The location where the user's feet should be placed
  41807. */
  41808. teleportCamera(location: Vector3): void;
  41809. private _convertNormalToDirectionOfRay;
  41810. private _castRayAndSelectObject;
  41811. private _notifySelectedMeshUnselected;
  41812. /**
  41813. * Sets the color of the laser ray from the vr controllers.
  41814. * @param color new color for the ray.
  41815. */
  41816. changeLaserColor(color: Color3): void;
  41817. /**
  41818. * Sets the color of the ray from the vr headsets gaze.
  41819. * @param color new color for the ray.
  41820. */
  41821. changeGazeColor(color: Color3): void;
  41822. /**
  41823. * Exits VR and disposes of the vr experience helper
  41824. */
  41825. dispose(): void;
  41826. /**
  41827. * Gets the name of the VRExperienceHelper class
  41828. * @returns "VRExperienceHelper"
  41829. */
  41830. getClassName(): string;
  41831. }
  41832. }
  41833. declare module "babylonjs/Cameras/VR/index" {
  41834. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41835. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41836. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41837. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41838. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41839. export * from "babylonjs/Cameras/VR/webVRCamera";
  41840. }
  41841. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41842. import { Observable } from "babylonjs/Misc/observable";
  41843. import { Nullable } from "babylonjs/types";
  41844. import { IDisposable, Scene } from "babylonjs/scene";
  41845. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41846. /**
  41847. * Manages an XRSession to work with Babylon's engine
  41848. * @see https://doc.babylonjs.com/how_to/webxr
  41849. */
  41850. export class WebXRSessionManager implements IDisposable {
  41851. private scene;
  41852. /**
  41853. * Fires every time a new xrFrame arrives which can be used to update the camera
  41854. */
  41855. onXRFrameObservable: Observable<any>;
  41856. /**
  41857. * Fires when the xr session is ended either by the device or manually done
  41858. */
  41859. onXRSessionEnded: Observable<any>;
  41860. /**
  41861. * Underlying xr session
  41862. */
  41863. session: XRSession;
  41864. /**
  41865. * Type of reference space used when creating the session
  41866. */
  41867. referenceSpace: XRReferenceSpace;
  41868. /** @hidden */
  41869. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41870. /**
  41871. * Current XR frame
  41872. */
  41873. currentFrame: Nullable<XRFrame>;
  41874. private _xrNavigator;
  41875. private baseLayer;
  41876. /**
  41877. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41878. * @param scene The scene which the session should be created for
  41879. */
  41880. constructor(scene: Scene);
  41881. /**
  41882. * Initializes the manager
  41883. * After initialization enterXR can be called to start an XR session
  41884. * @returns Promise which resolves after it is initialized
  41885. */
  41886. initializeAsync(): Promise<void>;
  41887. /**
  41888. * Initializes an xr session
  41889. * @param xrSessionMode mode to initialize
  41890. * @returns a promise which will resolve once the session has been initialized
  41891. */
  41892. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41893. /**
  41894. * Sets the reference space on the xr session
  41895. * @param referenceSpace space to set
  41896. * @returns a promise that will resolve once the reference space has been set
  41897. */
  41898. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41899. /**
  41900. * Updates the render state of the session
  41901. * @param state state to set
  41902. * @returns a promise that resolves once the render state has been updated
  41903. */
  41904. updateRenderStateAsync(state: any): Promise<void>;
  41905. /**
  41906. * Starts rendering to the xr layer
  41907. * @returns a promise that will resolve once rendering has started
  41908. */
  41909. startRenderingToXRAsync(): Promise<void>;
  41910. /**
  41911. * Stops the xrSession and restores the renderloop
  41912. * @returns Promise which resolves after it exits XR
  41913. */
  41914. exitXRAsync(): Promise<unknown>;
  41915. /**
  41916. * Checks if a session would be supported for the creation options specified
  41917. * @param sessionMode session mode to check if supported eg. immersive-vr
  41918. * @returns true if supported
  41919. */
  41920. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41921. /**
  41922. * @hidden
  41923. * Converts the render layer of xrSession to a render target
  41924. * @param session session to create render target for
  41925. * @param scene scene the new render target should be created for
  41926. */
  41927. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41928. /**
  41929. * Disposes of the session manager
  41930. */
  41931. dispose(): void;
  41932. }
  41933. }
  41934. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41935. import { Scene } from "babylonjs/scene";
  41936. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41937. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41938. /**
  41939. * WebXR Camera which holds the views for the xrSession
  41940. * @see https://doc.babylonjs.com/how_to/webxr
  41941. */
  41942. export class WebXRCamera extends FreeCamera {
  41943. private static _TmpMatrix;
  41944. /**
  41945. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41946. * @param name the name of the camera
  41947. * @param scene the scene to add the camera to
  41948. */
  41949. constructor(name: string, scene: Scene);
  41950. private _updateNumberOfRigCameras;
  41951. /** @hidden */
  41952. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41953. /**
  41954. * Updates the cameras position from the current pose information of the XR session
  41955. * @param xrSessionManager the session containing pose information
  41956. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41957. */
  41958. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41959. }
  41960. }
  41961. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41962. import { Nullable } from "babylonjs/types";
  41963. import { IDisposable } from "babylonjs/scene";
  41964. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41965. /**
  41966. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41967. */
  41968. export class WebXRManagedOutputCanvas implements IDisposable {
  41969. private helper;
  41970. private _canvas;
  41971. /**
  41972. * xrpresent context of the canvas which can be used to display/mirror xr content
  41973. */
  41974. canvasContext: WebGLRenderingContext;
  41975. /**
  41976. * xr layer for the canvas
  41977. */
  41978. xrLayer: Nullable<XRWebGLLayer>;
  41979. /**
  41980. * Initializes the xr layer for the session
  41981. * @param xrSession xr session
  41982. * @returns a promise that will resolve once the XR Layer has been created
  41983. */
  41984. initializeXRLayerAsync(xrSession: any): any;
  41985. /**
  41986. * Initializes the canvas to be added/removed upon entering/exiting xr
  41987. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41988. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41989. */
  41990. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41991. /**
  41992. * Disposes of the object
  41993. */
  41994. dispose(): void;
  41995. private _setManagedOutputCanvas;
  41996. private _addCanvas;
  41997. private _removeCanvas;
  41998. }
  41999. }
  42000. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42001. import { Observable } from "babylonjs/Misc/observable";
  42002. import { IDisposable, Scene } from "babylonjs/scene";
  42003. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  42004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42005. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42006. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42007. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42008. /**
  42009. * States of the webXR experience
  42010. */
  42011. export enum WebXRState {
  42012. /**
  42013. * Transitioning to being in XR mode
  42014. */
  42015. ENTERING_XR = 0,
  42016. /**
  42017. * Transitioning to non XR mode
  42018. */
  42019. EXITING_XR = 1,
  42020. /**
  42021. * In XR mode and presenting
  42022. */
  42023. IN_XR = 2,
  42024. /**
  42025. * Not entered XR mode
  42026. */
  42027. NOT_IN_XR = 3
  42028. }
  42029. /**
  42030. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42031. * @see https://doc.babylonjs.com/how_to/webxr
  42032. */
  42033. export class WebXRExperienceHelper implements IDisposable {
  42034. private scene;
  42035. /**
  42036. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  42037. */
  42038. container: AbstractMesh;
  42039. /**
  42040. * Camera used to render xr content
  42041. */
  42042. camera: WebXRCamera;
  42043. /**
  42044. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42045. */
  42046. state: WebXRState;
  42047. private _setState;
  42048. private static _TmpVector;
  42049. /**
  42050. * Fires when the state of the experience helper has changed
  42051. */
  42052. onStateChangedObservable: Observable<WebXRState>;
  42053. /** Session manager used to keep track of xr session */
  42054. sessionManager: WebXRSessionManager;
  42055. private _nonVRCamera;
  42056. private _originalSceneAutoClear;
  42057. private _supported;
  42058. /**
  42059. * Creates the experience helper
  42060. * @param scene the scene to attach the experience helper to
  42061. * @returns a promise for the experience helper
  42062. */
  42063. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42064. /**
  42065. * Creates a WebXRExperienceHelper
  42066. * @param scene The scene the helper should be created in
  42067. */
  42068. private constructor();
  42069. /**
  42070. * Exits XR mode and returns the scene to its original state
  42071. * @returns promise that resolves after xr mode has exited
  42072. */
  42073. exitXRAsync(): Promise<unknown>;
  42074. /**
  42075. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42076. * @param sessionCreationOptions options for the XR session
  42077. * @param referenceSpaceType frame of reference of the XR session
  42078. * @param outputCanvas the output canvas that will be used to enter XR mode
  42079. * @returns promise that resolves after xr mode has entered
  42080. */
  42081. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42082. /**
  42083. * Updates the global position of the camera by moving the camera's container
  42084. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42085. * @param position The desired global position of the camera
  42086. */
  42087. setPositionOfCameraUsingContainer(position: Vector3): void;
  42088. /**
  42089. * Rotates the xr camera by rotating the camera's container around the camera's position
  42090. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42091. * @param rotation the desired quaternion rotation to apply to the camera
  42092. */
  42093. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42094. /**
  42095. * Disposes of the experience helper
  42096. */
  42097. dispose(): void;
  42098. }
  42099. }
  42100. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42101. import { Nullable } from "babylonjs/types";
  42102. import { Observable } from "babylonjs/Misc/observable";
  42103. import { IDisposable, Scene } from "babylonjs/scene";
  42104. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42105. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42106. /**
  42107. * Button which can be used to enter a different mode of XR
  42108. */
  42109. export class WebXREnterExitUIButton {
  42110. /** button element */
  42111. element: HTMLElement;
  42112. /** XR initialization options for the button */
  42113. sessionMode: XRSessionMode;
  42114. /** Reference space type */
  42115. referenceSpaceType: XRReferenceSpaceType;
  42116. /**
  42117. * Creates a WebXREnterExitUIButton
  42118. * @param element button element
  42119. * @param sessionMode XR initialization session mode
  42120. * @param referenceSpaceType the type of reference space to be used
  42121. */
  42122. constructor(
  42123. /** button element */
  42124. element: HTMLElement,
  42125. /** XR initialization options for the button */
  42126. sessionMode: XRSessionMode,
  42127. /** Reference space type */
  42128. referenceSpaceType: XRReferenceSpaceType);
  42129. /**
  42130. * Overwritable function which can be used to update the button's visuals when the state changes
  42131. * @param activeButton the current active button in the UI
  42132. */
  42133. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42134. }
  42135. /**
  42136. * Options to create the webXR UI
  42137. */
  42138. export class WebXREnterExitUIOptions {
  42139. /**
  42140. * Context to enter xr with
  42141. */
  42142. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42143. /**
  42144. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42145. */
  42146. customButtons?: Array<WebXREnterExitUIButton>;
  42147. }
  42148. /**
  42149. * UI to allow the user to enter/exit XR mode
  42150. */
  42151. export class WebXREnterExitUI implements IDisposable {
  42152. private scene;
  42153. private _overlay;
  42154. private _buttons;
  42155. private _activeButton;
  42156. /**
  42157. * Fired every time the active button is changed.
  42158. *
  42159. * When xr is entered via a button that launches xr that button will be the callback parameter
  42160. *
  42161. * When exiting xr the callback parameter will be null)
  42162. */
  42163. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42164. /**
  42165. * Creates UI to allow the user to enter/exit XR mode
  42166. * @param scene the scene to add the ui to
  42167. * @param helper the xr experience helper to enter/exit xr with
  42168. * @param options options to configure the UI
  42169. * @returns the created ui
  42170. */
  42171. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42172. private constructor();
  42173. private _updateButtons;
  42174. /**
  42175. * Disposes of the object
  42176. */
  42177. dispose(): void;
  42178. }
  42179. }
  42180. declare module "babylonjs/Cameras/XR/webXRController" {
  42181. import { Nullable } from "babylonjs/types";
  42182. import { Observable } from "babylonjs/Misc/observable";
  42183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42184. import { Ray } from "babylonjs/Culling/ray";
  42185. import { Scene } from "babylonjs/scene";
  42186. /**
  42187. * Represents an XR input
  42188. */
  42189. export class WebXRController {
  42190. private scene;
  42191. /** The underlying input source for the controller */
  42192. inputSource: XRInputSource;
  42193. private parentContainer;
  42194. /**
  42195. * 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
  42196. */
  42197. grip?: AbstractMesh;
  42198. /**
  42199. * Pointer which can be used to select objects or attach a visible laser to
  42200. */
  42201. pointer: AbstractMesh;
  42202. /**
  42203. * Event that fires when the controller is removed/disposed
  42204. */
  42205. onDisposeObservable: Observable<{}>;
  42206. private _tmpMatrix;
  42207. private _tmpQuaternion;
  42208. private _tmpVector;
  42209. /**
  42210. * Creates the controller
  42211. * @see https://doc.babylonjs.com/how_to/webxr
  42212. * @param scene the scene which the controller should be associated to
  42213. * @param inputSource the underlying input source for the controller
  42214. * @param parentContainer parent that the controller meshes should be children of
  42215. */
  42216. constructor(scene: Scene,
  42217. /** The underlying input source for the controller */
  42218. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42219. /**
  42220. * Updates the controller pose based on the given XRFrame
  42221. * @param xrFrame xr frame to update the pose with
  42222. * @param referenceSpace reference space to use
  42223. */
  42224. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42225. /**
  42226. * Gets a world space ray coming from the controller
  42227. * @param result the resulting ray
  42228. */
  42229. getWorldPointerRayToRef(result: Ray): void;
  42230. /**
  42231. * Disposes of the object
  42232. */
  42233. dispose(): void;
  42234. }
  42235. }
  42236. declare module "babylonjs/Cameras/XR/webXRInput" {
  42237. import { Observable } from "babylonjs/Misc/observable";
  42238. import { IDisposable } from "babylonjs/scene";
  42239. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42240. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  42241. /**
  42242. * XR input used to track XR inputs such as controllers/rays
  42243. */
  42244. export class WebXRInput implements IDisposable {
  42245. /**
  42246. * Base experience the input listens to
  42247. */
  42248. baseExperience: WebXRExperienceHelper;
  42249. /**
  42250. * XR controllers being tracked
  42251. */
  42252. controllers: Array<WebXRController>;
  42253. private _frameObserver;
  42254. private _stateObserver;
  42255. /**
  42256. * Event when a controller has been connected/added
  42257. */
  42258. onControllerAddedObservable: Observable<WebXRController>;
  42259. /**
  42260. * Event when a controller has been removed/disconnected
  42261. */
  42262. onControllerRemovedObservable: Observable<WebXRController>;
  42263. /**
  42264. * Initializes the WebXRInput
  42265. * @param baseExperience experience helper which the input should be created for
  42266. */
  42267. constructor(
  42268. /**
  42269. * Base experience the input listens to
  42270. */
  42271. baseExperience: WebXRExperienceHelper);
  42272. private _onInputSourcesChange;
  42273. private _addAndRemoveControllers;
  42274. /**
  42275. * Disposes of the object
  42276. */
  42277. dispose(): void;
  42278. }
  42279. }
  42280. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  42281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42282. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42283. /**
  42284. * Enables teleportation
  42285. */
  42286. export class WebXRControllerTeleportation {
  42287. private _teleportationFillColor;
  42288. private _teleportationBorderColor;
  42289. private _tmpRay;
  42290. private _tmpVector;
  42291. /**
  42292. * Creates a WebXRControllerTeleportation
  42293. * @param input input manager to add teleportation to
  42294. * @param floorMeshes floormeshes which can be teleported to
  42295. */
  42296. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  42297. }
  42298. }
  42299. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  42300. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42301. /**
  42302. * Handles pointer input automatically for the pointer of XR controllers
  42303. */
  42304. export class WebXRControllerPointerSelection {
  42305. private static _idCounter;
  42306. private _tmpRay;
  42307. /**
  42308. * Creates a WebXRControllerPointerSelection
  42309. * @param input input manager to setup pointer selection
  42310. */
  42311. constructor(input: WebXRInput);
  42312. private _convertNormalToDirectionOfRay;
  42313. private _updatePointerDistance;
  42314. }
  42315. }
  42316. declare module "babylonjs/Loading/sceneLoader" {
  42317. import { Observable } from "babylonjs/Misc/observable";
  42318. import { Nullable } from "babylonjs/types";
  42319. import { Scene } from "babylonjs/scene";
  42320. import { Engine } from "babylonjs/Engines/engine";
  42321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42322. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42323. import { AssetContainer } from "babylonjs/assetContainer";
  42324. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42325. import { Skeleton } from "babylonjs/Bones/skeleton";
  42326. /**
  42327. * Class used to represent data loading progression
  42328. */
  42329. export class SceneLoaderProgressEvent {
  42330. /** defines if data length to load can be evaluated */
  42331. readonly lengthComputable: boolean;
  42332. /** defines the loaded data length */
  42333. readonly loaded: number;
  42334. /** defines the data length to load */
  42335. readonly total: number;
  42336. /**
  42337. * Create a new progress event
  42338. * @param lengthComputable defines if data length to load can be evaluated
  42339. * @param loaded defines the loaded data length
  42340. * @param total defines the data length to load
  42341. */
  42342. constructor(
  42343. /** defines if data length to load can be evaluated */
  42344. lengthComputable: boolean,
  42345. /** defines the loaded data length */
  42346. loaded: number,
  42347. /** defines the data length to load */
  42348. total: number);
  42349. /**
  42350. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42351. * @param event defines the source event
  42352. * @returns a new SceneLoaderProgressEvent
  42353. */
  42354. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42355. }
  42356. /**
  42357. * Interface used by SceneLoader plugins to define supported file extensions
  42358. */
  42359. export interface ISceneLoaderPluginExtensions {
  42360. /**
  42361. * Defines the list of supported extensions
  42362. */
  42363. [extension: string]: {
  42364. isBinary: boolean;
  42365. };
  42366. }
  42367. /**
  42368. * Interface used by SceneLoader plugin factory
  42369. */
  42370. export interface ISceneLoaderPluginFactory {
  42371. /**
  42372. * Defines the name of the factory
  42373. */
  42374. name: string;
  42375. /**
  42376. * Function called to create a new plugin
  42377. * @return the new plugin
  42378. */
  42379. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42380. /**
  42381. * Boolean indicating if the plugin can direct load specific data
  42382. */
  42383. canDirectLoad?: (data: string) => boolean;
  42384. }
  42385. /**
  42386. * Interface used to define a SceneLoader plugin
  42387. */
  42388. export interface ISceneLoaderPlugin {
  42389. /**
  42390. * The friendly name of this plugin.
  42391. */
  42392. name: string;
  42393. /**
  42394. * The file extensions supported by this plugin.
  42395. */
  42396. extensions: string | ISceneLoaderPluginExtensions;
  42397. /**
  42398. * Import meshes into a scene.
  42399. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42400. * @param scene The scene to import into
  42401. * @param data The data to import
  42402. * @param rootUrl The root url for scene and resources
  42403. * @param meshes The meshes array to import into
  42404. * @param particleSystems The particle systems array to import into
  42405. * @param skeletons The skeletons array to import into
  42406. * @param onError The callback when import fails
  42407. * @returns True if successful or false otherwise
  42408. */
  42409. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42410. /**
  42411. * Load into a scene.
  42412. * @param scene The scene to load into
  42413. * @param data The data to import
  42414. * @param rootUrl The root url for scene and resources
  42415. * @param onError The callback when import fails
  42416. * @returns true if successful or false otherwise
  42417. */
  42418. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42419. /**
  42420. * The callback that returns true if the data can be directly loaded.
  42421. */
  42422. canDirectLoad?: (data: string) => boolean;
  42423. /**
  42424. * The callback that allows custom handling of the root url based on the response url.
  42425. */
  42426. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42427. /**
  42428. * Load into an asset container.
  42429. * @param scene The scene to load into
  42430. * @param data The data to import
  42431. * @param rootUrl The root url for scene and resources
  42432. * @param onError The callback when import fails
  42433. * @returns The loaded asset container
  42434. */
  42435. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42436. }
  42437. /**
  42438. * Interface used to define an async SceneLoader plugin
  42439. */
  42440. export interface ISceneLoaderPluginAsync {
  42441. /**
  42442. * The friendly name of this plugin.
  42443. */
  42444. name: string;
  42445. /**
  42446. * The file extensions supported by this plugin.
  42447. */
  42448. extensions: string | ISceneLoaderPluginExtensions;
  42449. /**
  42450. * Import meshes into a scene.
  42451. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42452. * @param scene The scene to import into
  42453. * @param data The data to import
  42454. * @param rootUrl The root url for scene and resources
  42455. * @param onProgress The callback when the load progresses
  42456. * @param fileName Defines the name of the file to load
  42457. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42458. */
  42459. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42460. meshes: AbstractMesh[];
  42461. particleSystems: IParticleSystem[];
  42462. skeletons: Skeleton[];
  42463. animationGroups: AnimationGroup[];
  42464. }>;
  42465. /**
  42466. * Load into a scene.
  42467. * @param scene The scene to load into
  42468. * @param data The data to import
  42469. * @param rootUrl The root url for scene and resources
  42470. * @param onProgress The callback when the load progresses
  42471. * @param fileName Defines the name of the file to load
  42472. * @returns Nothing
  42473. */
  42474. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42475. /**
  42476. * The callback that returns true if the data can be directly loaded.
  42477. */
  42478. canDirectLoad?: (data: string) => boolean;
  42479. /**
  42480. * The callback that allows custom handling of the root url based on the response url.
  42481. */
  42482. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42483. /**
  42484. * Load into an asset container.
  42485. * @param scene The scene to load into
  42486. * @param data The data to import
  42487. * @param rootUrl The root url for scene and resources
  42488. * @param onProgress The callback when the load progresses
  42489. * @param fileName Defines the name of the file to load
  42490. * @returns The loaded asset container
  42491. */
  42492. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42493. }
  42494. /**
  42495. * Class used to load scene from various file formats using registered plugins
  42496. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42497. */
  42498. export class SceneLoader {
  42499. /**
  42500. * No logging while loading
  42501. */
  42502. static readonly NO_LOGGING: number;
  42503. /**
  42504. * Minimal logging while loading
  42505. */
  42506. static readonly MINIMAL_LOGGING: number;
  42507. /**
  42508. * Summary logging while loading
  42509. */
  42510. static readonly SUMMARY_LOGGING: number;
  42511. /**
  42512. * Detailled logging while loading
  42513. */
  42514. static readonly DETAILED_LOGGING: number;
  42515. /**
  42516. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42517. */
  42518. static ForceFullSceneLoadingForIncremental: boolean;
  42519. /**
  42520. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42521. */
  42522. static ShowLoadingScreen: boolean;
  42523. /**
  42524. * Defines the current logging level (while loading the scene)
  42525. * @ignorenaming
  42526. */
  42527. static loggingLevel: number;
  42528. /**
  42529. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42530. */
  42531. static CleanBoneMatrixWeights: boolean;
  42532. /**
  42533. * Event raised when a plugin is used to load a scene
  42534. */
  42535. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42536. private static _registeredPlugins;
  42537. private static _getDefaultPlugin;
  42538. private static _getPluginForExtension;
  42539. private static _getPluginForDirectLoad;
  42540. private static _getPluginForFilename;
  42541. private static _getDirectLoad;
  42542. private static _loadData;
  42543. private static _getFileInfo;
  42544. /**
  42545. * Gets a plugin that can load the given extension
  42546. * @param extension defines the extension to load
  42547. * @returns a plugin or null if none works
  42548. */
  42549. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42550. /**
  42551. * Gets a boolean indicating that the given extension can be loaded
  42552. * @param extension defines the extension to load
  42553. * @returns true if the extension is supported
  42554. */
  42555. static IsPluginForExtensionAvailable(extension: string): boolean;
  42556. /**
  42557. * Adds a new plugin to the list of registered plugins
  42558. * @param plugin defines the plugin to add
  42559. */
  42560. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42561. /**
  42562. * Import meshes into a scene
  42563. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42564. * @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)
  42565. * @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)
  42566. * @param scene the instance of BABYLON.Scene to append to
  42567. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42568. * @param onProgress a callback with a progress event for each file being loaded
  42569. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42570. * @param pluginExtension the extension used to determine the plugin
  42571. * @returns The loaded plugin
  42572. */
  42573. 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>;
  42574. /**
  42575. * Import meshes into a scene
  42576. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42577. * @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)
  42578. * @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)
  42579. * @param scene the instance of BABYLON.Scene to append to
  42580. * @param onProgress a callback with a progress event for each file being loaded
  42581. * @param pluginExtension the extension used to determine the plugin
  42582. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42583. */
  42584. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42585. meshes: AbstractMesh[];
  42586. particleSystems: IParticleSystem[];
  42587. skeletons: Skeleton[];
  42588. animationGroups: AnimationGroup[];
  42589. }>;
  42590. /**
  42591. * Load a scene
  42592. * @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)
  42593. * @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)
  42594. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42595. * @param onSuccess a callback with the scene when import succeeds
  42596. * @param onProgress a callback with a progress event for each file being loaded
  42597. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42598. * @param pluginExtension the extension used to determine the plugin
  42599. * @returns The loaded plugin
  42600. */
  42601. 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>;
  42602. /**
  42603. * Load a scene
  42604. * @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)
  42605. * @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)
  42606. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42607. * @param onProgress a callback with a progress event for each file being loaded
  42608. * @param pluginExtension the extension used to determine the plugin
  42609. * @returns The loaded scene
  42610. */
  42611. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42612. /**
  42613. * Append a scene
  42614. * @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)
  42615. * @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)
  42616. * @param scene is the instance of BABYLON.Scene to append to
  42617. * @param onSuccess a callback with the scene when import succeeds
  42618. * @param onProgress a callback with a progress event for each file being loaded
  42619. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42620. * @param pluginExtension the extension used to determine the plugin
  42621. * @returns The loaded plugin
  42622. */
  42623. 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>;
  42624. /**
  42625. * Append a scene
  42626. * @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)
  42627. * @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)
  42628. * @param scene is the instance of BABYLON.Scene to append to
  42629. * @param onProgress a callback with a progress event for each file being loaded
  42630. * @param pluginExtension the extension used to determine the plugin
  42631. * @returns The given scene
  42632. */
  42633. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42634. /**
  42635. * Load a scene into an asset container
  42636. * @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)
  42637. * @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)
  42638. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42639. * @param onSuccess a callback with the scene when import succeeds
  42640. * @param onProgress a callback with a progress event for each file being loaded
  42641. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42642. * @param pluginExtension the extension used to determine the plugin
  42643. * @returns The loaded plugin
  42644. */
  42645. 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>;
  42646. /**
  42647. * Load a scene into an asset container
  42648. * @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)
  42649. * @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)
  42650. * @param scene is the instance of Scene to append to
  42651. * @param onProgress a callback with a progress event for each file being loaded
  42652. * @param pluginExtension the extension used to determine the plugin
  42653. * @returns The loaded asset container
  42654. */
  42655. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42656. }
  42657. }
  42658. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42659. import { Scene } from "babylonjs/scene";
  42660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42661. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42662. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42663. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42664. /**
  42665. * Generic Controller
  42666. */
  42667. export class GenericController extends WebVRController {
  42668. /**
  42669. * Base Url for the controller model.
  42670. */
  42671. static readonly MODEL_BASE_URL: string;
  42672. /**
  42673. * File name for the controller model.
  42674. */
  42675. static readonly MODEL_FILENAME: string;
  42676. /**
  42677. * Creates a new GenericController from a gamepad
  42678. * @param vrGamepad the gamepad that the controller should be created from
  42679. */
  42680. constructor(vrGamepad: any);
  42681. /**
  42682. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42683. * @param scene scene in which to add meshes
  42684. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42685. */
  42686. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42687. /**
  42688. * Called once for each button that changed state since the last frame
  42689. * @param buttonIdx Which button index changed
  42690. * @param state New state of the button
  42691. * @param changes Which properties on the state changed since last frame
  42692. */
  42693. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42694. }
  42695. }
  42696. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42697. import { Observable } from "babylonjs/Misc/observable";
  42698. import { Scene } from "babylonjs/scene";
  42699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42700. import { Ray } from "babylonjs/Culling/ray";
  42701. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42702. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42703. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42704. /**
  42705. * Defines the WindowsMotionController object that the state of the windows motion controller
  42706. */
  42707. export class WindowsMotionController extends WebVRController {
  42708. /**
  42709. * The base url used to load the left and right controller models
  42710. */
  42711. static MODEL_BASE_URL: string;
  42712. /**
  42713. * The name of the left controller model file
  42714. */
  42715. static MODEL_LEFT_FILENAME: string;
  42716. /**
  42717. * The name of the right controller model file
  42718. */
  42719. static MODEL_RIGHT_FILENAME: string;
  42720. /**
  42721. * The controller name prefix for this controller type
  42722. */
  42723. static readonly GAMEPAD_ID_PREFIX: string;
  42724. /**
  42725. * The controller id pattern for this controller type
  42726. */
  42727. private static readonly GAMEPAD_ID_PATTERN;
  42728. private _loadedMeshInfo;
  42729. private readonly _mapping;
  42730. /**
  42731. * Fired when the trackpad on this controller is clicked
  42732. */
  42733. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42734. /**
  42735. * Fired when the trackpad on this controller is modified
  42736. */
  42737. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42738. /**
  42739. * The current x and y values of this controller's trackpad
  42740. */
  42741. trackpad: StickValues;
  42742. /**
  42743. * Creates a new WindowsMotionController from a gamepad
  42744. * @param vrGamepad the gamepad that the controller should be created from
  42745. */
  42746. constructor(vrGamepad: any);
  42747. /**
  42748. * Fired when the trigger on this controller is modified
  42749. */
  42750. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42751. /**
  42752. * Fired when the menu button on this controller is modified
  42753. */
  42754. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42755. /**
  42756. * Fired when the grip button on this controller is modified
  42757. */
  42758. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42759. /**
  42760. * Fired when the thumbstick button on this controller is modified
  42761. */
  42762. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42763. /**
  42764. * Fired when the touchpad button on this controller is modified
  42765. */
  42766. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42767. /**
  42768. * Fired when the touchpad values on this controller are modified
  42769. */
  42770. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42771. private _updateTrackpad;
  42772. /**
  42773. * Called once per frame by the engine.
  42774. */
  42775. update(): void;
  42776. /**
  42777. * Called once for each button that changed state since the last frame
  42778. * @param buttonIdx Which button index changed
  42779. * @param state New state of the button
  42780. * @param changes Which properties on the state changed since last frame
  42781. */
  42782. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42783. /**
  42784. * Moves the buttons on the controller mesh based on their current state
  42785. * @param buttonName the name of the button to move
  42786. * @param buttonValue the value of the button which determines the buttons new position
  42787. */
  42788. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42789. /**
  42790. * Moves the axis on the controller mesh based on its current state
  42791. * @param axis the index of the axis
  42792. * @param axisValue the value of the axis which determines the meshes new position
  42793. * @hidden
  42794. */
  42795. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42796. /**
  42797. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42798. * @param scene scene in which to add meshes
  42799. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42800. */
  42801. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42802. /**
  42803. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42804. * can be transformed by button presses and axes values, based on this._mapping.
  42805. *
  42806. * @param scene scene in which the meshes exist
  42807. * @param meshes list of meshes that make up the controller model to process
  42808. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42809. */
  42810. private processModel;
  42811. private createMeshInfo;
  42812. /**
  42813. * Gets the ray of the controller in the direction the controller is pointing
  42814. * @param length the length the resulting ray should be
  42815. * @returns a ray in the direction the controller is pointing
  42816. */
  42817. getForwardRay(length?: number): Ray;
  42818. /**
  42819. * Disposes of the controller
  42820. */
  42821. dispose(): void;
  42822. }
  42823. }
  42824. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42825. import { Observable } from "babylonjs/Misc/observable";
  42826. import { Scene } from "babylonjs/scene";
  42827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42828. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42829. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42830. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42831. /**
  42832. * Oculus Touch Controller
  42833. */
  42834. export class OculusTouchController extends WebVRController {
  42835. /**
  42836. * Base Url for the controller model.
  42837. */
  42838. static MODEL_BASE_URL: string;
  42839. /**
  42840. * File name for the left controller model.
  42841. */
  42842. static MODEL_LEFT_FILENAME: string;
  42843. /**
  42844. * File name for the right controller model.
  42845. */
  42846. static MODEL_RIGHT_FILENAME: string;
  42847. /**
  42848. * Base Url for the Quest controller model.
  42849. */
  42850. static QUEST_MODEL_BASE_URL: string;
  42851. /**
  42852. * @hidden
  42853. * If the controllers are running on a device that needs the updated Quest controller models
  42854. */
  42855. static _IsQuest: boolean;
  42856. /**
  42857. * Fired when the secondary trigger on this controller is modified
  42858. */
  42859. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42860. /**
  42861. * Fired when the thumb rest on this controller is modified
  42862. */
  42863. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42864. /**
  42865. * Creates a new OculusTouchController from a gamepad
  42866. * @param vrGamepad the gamepad that the controller should be created from
  42867. */
  42868. constructor(vrGamepad: any);
  42869. /**
  42870. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42871. * @param scene scene in which to add meshes
  42872. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42873. */
  42874. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42875. /**
  42876. * Fired when the A button on this controller is modified
  42877. */
  42878. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42879. /**
  42880. * Fired when the B button on this controller is modified
  42881. */
  42882. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42883. /**
  42884. * Fired when the X button on this controller is modified
  42885. */
  42886. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42887. /**
  42888. * Fired when the Y button on this controller is modified
  42889. */
  42890. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42891. /**
  42892. * Called once for each button that changed state since the last frame
  42893. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42894. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42895. * 2) secondary trigger (same)
  42896. * 3) A (right) X (left), touch, pressed = value
  42897. * 4) B / Y
  42898. * 5) thumb rest
  42899. * @param buttonIdx Which button index changed
  42900. * @param state New state of the button
  42901. * @param changes Which properties on the state changed since last frame
  42902. */
  42903. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42904. }
  42905. }
  42906. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  42907. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42908. /**
  42909. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42910. */
  42911. export class WebXRControllerModelLoader {
  42912. /**
  42913. * Creates the WebXRControllerModelLoader
  42914. * @param input xr input that creates the controllers
  42915. */
  42916. constructor(input: WebXRInput);
  42917. }
  42918. }
  42919. declare module "babylonjs/Cameras/XR/index" {
  42920. export * from "babylonjs/Cameras/XR/webXRCamera";
  42921. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  42922. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42923. export * from "babylonjs/Cameras/XR/webXRInput";
  42924. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  42925. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  42926. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  42927. export * from "babylonjs/Cameras/XR/webXRController";
  42928. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42929. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  42930. }
  42931. declare module "babylonjs/Cameras/RigModes/index" {
  42932. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42933. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42934. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  42935. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  42936. }
  42937. declare module "babylonjs/Cameras/index" {
  42938. export * from "babylonjs/Cameras/Inputs/index";
  42939. export * from "babylonjs/Cameras/cameraInputsManager";
  42940. export * from "babylonjs/Cameras/camera";
  42941. export * from "babylonjs/Cameras/targetCamera";
  42942. export * from "babylonjs/Cameras/freeCamera";
  42943. export * from "babylonjs/Cameras/freeCameraInputsManager";
  42944. export * from "babylonjs/Cameras/touchCamera";
  42945. export * from "babylonjs/Cameras/arcRotateCamera";
  42946. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  42947. export * from "babylonjs/Cameras/deviceOrientationCamera";
  42948. export * from "babylonjs/Cameras/flyCamera";
  42949. export * from "babylonjs/Cameras/flyCameraInputsManager";
  42950. export * from "babylonjs/Cameras/followCamera";
  42951. export * from "babylonjs/Cameras/gamepadCamera";
  42952. export * from "babylonjs/Cameras/Stereoscopic/index";
  42953. export * from "babylonjs/Cameras/universalCamera";
  42954. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  42955. export * from "babylonjs/Cameras/VR/index";
  42956. export * from "babylonjs/Cameras/XR/index";
  42957. export * from "babylonjs/Cameras/RigModes/index";
  42958. }
  42959. declare module "babylonjs/Collisions/index" {
  42960. export * from "babylonjs/Collisions/collider";
  42961. export * from "babylonjs/Collisions/collisionCoordinator";
  42962. export * from "babylonjs/Collisions/pickingInfo";
  42963. export * from "babylonjs/Collisions/intersectionInfo";
  42964. export * from "babylonjs/Collisions/meshCollisionData";
  42965. }
  42966. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  42967. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  42968. import { Vector3, Plane } from "babylonjs/Maths/math";
  42969. import { Ray } from "babylonjs/Culling/ray";
  42970. /**
  42971. * Contains an array of blocks representing the octree
  42972. */
  42973. export interface IOctreeContainer<T> {
  42974. /**
  42975. * Blocks within the octree
  42976. */
  42977. blocks: Array<OctreeBlock<T>>;
  42978. }
  42979. /**
  42980. * Class used to store a cell in an octree
  42981. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42982. */
  42983. export class OctreeBlock<T> {
  42984. /**
  42985. * Gets the content of the current block
  42986. */
  42987. entries: T[];
  42988. /**
  42989. * Gets the list of block children
  42990. */
  42991. blocks: Array<OctreeBlock<T>>;
  42992. private _depth;
  42993. private _maxDepth;
  42994. private _capacity;
  42995. private _minPoint;
  42996. private _maxPoint;
  42997. private _boundingVectors;
  42998. private _creationFunc;
  42999. /**
  43000. * Creates a new block
  43001. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43002. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43003. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43004. * @param depth defines the current depth of this block in the octree
  43005. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43006. * @param creationFunc defines a callback to call when an element is added to the block
  43007. */
  43008. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43009. /**
  43010. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43011. */
  43012. readonly capacity: number;
  43013. /**
  43014. * Gets the minimum vector (in world space) of the block's bounding box
  43015. */
  43016. readonly minPoint: Vector3;
  43017. /**
  43018. * Gets the maximum vector (in world space) of the block's bounding box
  43019. */
  43020. readonly maxPoint: Vector3;
  43021. /**
  43022. * Add a new element to this block
  43023. * @param entry defines the element to add
  43024. */
  43025. addEntry(entry: T): void;
  43026. /**
  43027. * Remove an element from this block
  43028. * @param entry defines the element to remove
  43029. */
  43030. removeEntry(entry: T): void;
  43031. /**
  43032. * Add an array of elements to this block
  43033. * @param entries defines the array of elements to add
  43034. */
  43035. addEntries(entries: T[]): void;
  43036. /**
  43037. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43038. * @param frustumPlanes defines the frustum planes to test
  43039. * @param selection defines the array to store current content if selection is positive
  43040. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43041. */
  43042. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43043. /**
  43044. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43045. * @param sphereCenter defines the bounding sphere center
  43046. * @param sphereRadius defines the bounding sphere radius
  43047. * @param selection defines the array to store current content if selection is positive
  43048. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43049. */
  43050. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43051. /**
  43052. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43053. * @param ray defines the ray to test with
  43054. * @param selection defines the array to store current content if selection is positive
  43055. */
  43056. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43057. /**
  43058. * Subdivide the content into child blocks (this block will then be empty)
  43059. */
  43060. createInnerBlocks(): void;
  43061. /**
  43062. * @hidden
  43063. */
  43064. 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;
  43065. }
  43066. }
  43067. declare module "babylonjs/Culling/Octrees/octree" {
  43068. import { SmartArray } from "babylonjs/Misc/smartArray";
  43069. import { Vector3, Plane } from "babylonjs/Maths/math";
  43070. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43072. import { Ray } from "babylonjs/Culling/ray";
  43073. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43074. /**
  43075. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43076. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43077. */
  43078. export class Octree<T> {
  43079. /** 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.) */
  43080. maxDepth: number;
  43081. /**
  43082. * Blocks within the octree containing objects
  43083. */
  43084. blocks: Array<OctreeBlock<T>>;
  43085. /**
  43086. * Content stored in the octree
  43087. */
  43088. dynamicContent: T[];
  43089. private _maxBlockCapacity;
  43090. private _selectionContent;
  43091. private _creationFunc;
  43092. /**
  43093. * Creates a octree
  43094. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43095. * @param creationFunc function to be used to instatiate the octree
  43096. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43097. * @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.)
  43098. */
  43099. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43100. /** 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.) */
  43101. maxDepth?: number);
  43102. /**
  43103. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43104. * @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);
  43105. * @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);
  43106. * @param entries meshes to be added to the octree blocks
  43107. */
  43108. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43109. /**
  43110. * Adds a mesh to the octree
  43111. * @param entry Mesh to add to the octree
  43112. */
  43113. addMesh(entry: T): void;
  43114. /**
  43115. * Remove an element from the octree
  43116. * @param entry defines the element to remove
  43117. */
  43118. removeMesh(entry: T): void;
  43119. /**
  43120. * Selects an array of meshes within the frustum
  43121. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43122. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43123. * @returns array of meshes within the frustum
  43124. */
  43125. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43126. /**
  43127. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43128. * @param sphereCenter defines the bounding sphere center
  43129. * @param sphereRadius defines the bounding sphere radius
  43130. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43131. * @returns an array of objects that intersect the sphere
  43132. */
  43133. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43134. /**
  43135. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43136. * @param ray defines the ray to test with
  43137. * @returns array of intersected objects
  43138. */
  43139. intersectsRay(ray: Ray): SmartArray<T>;
  43140. /**
  43141. * Adds a mesh into the octree block if it intersects the block
  43142. */
  43143. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43144. /**
  43145. * Adds a submesh into the octree block if it intersects the block
  43146. */
  43147. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43148. }
  43149. }
  43150. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43151. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43152. import { Scene } from "babylonjs/scene";
  43153. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43155. import { Ray } from "babylonjs/Culling/ray";
  43156. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43157. import { Collider } from "babylonjs/Collisions/collider";
  43158. module "babylonjs/scene" {
  43159. interface Scene {
  43160. /**
  43161. * @hidden
  43162. * Backing Filed
  43163. */
  43164. _selectionOctree: Octree<AbstractMesh>;
  43165. /**
  43166. * Gets the octree used to boost mesh selection (picking)
  43167. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43168. */
  43169. selectionOctree: Octree<AbstractMesh>;
  43170. /**
  43171. * Creates or updates the octree used to boost selection (picking)
  43172. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43173. * @param maxCapacity defines the maximum capacity per leaf
  43174. * @param maxDepth defines the maximum depth of the octree
  43175. * @returns an octree of AbstractMesh
  43176. */
  43177. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43178. }
  43179. }
  43180. module "babylonjs/Meshes/abstractMesh" {
  43181. interface AbstractMesh {
  43182. /**
  43183. * @hidden
  43184. * Backing Field
  43185. */
  43186. _submeshesOctree: Octree<SubMesh>;
  43187. /**
  43188. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43189. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43190. * @param maxCapacity defines the maximum size of each block (64 by default)
  43191. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43192. * @returns the new octree
  43193. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43194. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43195. */
  43196. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43197. }
  43198. }
  43199. /**
  43200. * Defines the octree scene component responsible to manage any octrees
  43201. * in a given scene.
  43202. */
  43203. export class OctreeSceneComponent {
  43204. /**
  43205. * The component name help to identify the component in the list of scene components.
  43206. */
  43207. readonly name: string;
  43208. /**
  43209. * The scene the component belongs to.
  43210. */
  43211. scene: Scene;
  43212. /**
  43213. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43214. */
  43215. readonly checksIsEnabled: boolean;
  43216. /**
  43217. * Creates a new instance of the component for the given scene
  43218. * @param scene Defines the scene to register the component in
  43219. */
  43220. constructor(scene: Scene);
  43221. /**
  43222. * Registers the component in a given scene
  43223. */
  43224. register(): void;
  43225. /**
  43226. * Return the list of active meshes
  43227. * @returns the list of active meshes
  43228. */
  43229. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43230. /**
  43231. * Return the list of active sub meshes
  43232. * @param mesh The mesh to get the candidates sub meshes from
  43233. * @returns the list of active sub meshes
  43234. */
  43235. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43236. private _tempRay;
  43237. /**
  43238. * Return the list of sub meshes intersecting with a given local ray
  43239. * @param mesh defines the mesh to find the submesh for
  43240. * @param localRay defines the ray in local space
  43241. * @returns the list of intersecting sub meshes
  43242. */
  43243. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43244. /**
  43245. * Return the list of sub meshes colliding with a collider
  43246. * @param mesh defines the mesh to find the submesh for
  43247. * @param collider defines the collider to evaluate the collision against
  43248. * @returns the list of colliding sub meshes
  43249. */
  43250. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43251. /**
  43252. * Rebuilds the elements related to this component in case of
  43253. * context lost for instance.
  43254. */
  43255. rebuild(): void;
  43256. /**
  43257. * Disposes the component and the associated ressources.
  43258. */
  43259. dispose(): void;
  43260. }
  43261. }
  43262. declare module "babylonjs/Culling/Octrees/index" {
  43263. export * from "babylonjs/Culling/Octrees/octree";
  43264. export * from "babylonjs/Culling/Octrees/octreeBlock";
  43265. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  43266. }
  43267. declare module "babylonjs/Culling/index" {
  43268. export * from "babylonjs/Culling/boundingBox";
  43269. export * from "babylonjs/Culling/boundingInfo";
  43270. export * from "babylonjs/Culling/boundingSphere";
  43271. export * from "babylonjs/Culling/Octrees/index";
  43272. export * from "babylonjs/Culling/ray";
  43273. }
  43274. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  43275. import { IDisposable, Scene } from "babylonjs/scene";
  43276. import { Nullable } from "babylonjs/types";
  43277. import { Observable } from "babylonjs/Misc/observable";
  43278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43279. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  43280. import { Camera } from "babylonjs/Cameras/camera";
  43281. /**
  43282. * Renders a layer on top of an existing scene
  43283. */
  43284. export class UtilityLayerRenderer implements IDisposable {
  43285. /** the original scene that will be rendered on top of */
  43286. originalScene: Scene;
  43287. private _pointerCaptures;
  43288. private _lastPointerEvents;
  43289. private static _DefaultUtilityLayer;
  43290. private static _DefaultKeepDepthUtilityLayer;
  43291. private _sharedGizmoLight;
  43292. private _renderCamera;
  43293. /**
  43294. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  43295. * @returns the camera that is used when rendering the utility layer
  43296. */
  43297. getRenderCamera(): Nullable<Camera>;
  43298. /**
  43299. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  43300. * @param cam the camera that should be used when rendering the utility layer
  43301. */
  43302. setRenderCamera(cam: Nullable<Camera>): void;
  43303. /**
  43304. * @hidden
  43305. * Light which used by gizmos to get light shading
  43306. */
  43307. _getSharedGizmoLight(): HemisphericLight;
  43308. /**
  43309. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  43310. */
  43311. pickUtilitySceneFirst: boolean;
  43312. /**
  43313. * 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)
  43314. */
  43315. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  43316. /**
  43317. * 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)
  43318. */
  43319. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  43320. /**
  43321. * The scene that is rendered on top of the original scene
  43322. */
  43323. utilityLayerScene: Scene;
  43324. /**
  43325. * If the utility layer should automatically be rendered on top of existing scene
  43326. */
  43327. shouldRender: boolean;
  43328. /**
  43329. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  43330. */
  43331. onlyCheckPointerDownEvents: boolean;
  43332. /**
  43333. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  43334. */
  43335. processAllEvents: boolean;
  43336. /**
  43337. * Observable raised when the pointer move from the utility layer scene to the main scene
  43338. */
  43339. onPointerOutObservable: Observable<number>;
  43340. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  43341. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  43342. private _afterRenderObserver;
  43343. private _sceneDisposeObserver;
  43344. private _originalPointerObserver;
  43345. /**
  43346. * Instantiates a UtilityLayerRenderer
  43347. * @param originalScene the original scene that will be rendered on top of
  43348. * @param handleEvents boolean indicating if the utility layer should handle events
  43349. */
  43350. constructor(
  43351. /** the original scene that will be rendered on top of */
  43352. originalScene: Scene, handleEvents?: boolean);
  43353. private _notifyObservers;
  43354. /**
  43355. * Renders the utility layers scene on top of the original scene
  43356. */
  43357. render(): void;
  43358. /**
  43359. * Disposes of the renderer
  43360. */
  43361. dispose(): void;
  43362. private _updateCamera;
  43363. }
  43364. }
  43365. declare module "babylonjs/Gizmos/gizmo" {
  43366. import { Nullable } from "babylonjs/types";
  43367. import { IDisposable } from "babylonjs/scene";
  43368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43369. import { Mesh } from "babylonjs/Meshes/mesh";
  43370. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43371. /**
  43372. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  43373. */
  43374. export class Gizmo implements IDisposable {
  43375. /** The utility layer the gizmo will be added to */
  43376. gizmoLayer: UtilityLayerRenderer;
  43377. /**
  43378. * The root mesh of the gizmo
  43379. */
  43380. _rootMesh: Mesh;
  43381. private _attachedMesh;
  43382. /**
  43383. * Ratio for the scale of the gizmo (Default: 1)
  43384. */
  43385. scaleRatio: number;
  43386. /**
  43387. * If a custom mesh has been set (Default: false)
  43388. */
  43389. protected _customMeshSet: boolean;
  43390. /**
  43391. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  43392. * * When set, interactions will be enabled
  43393. */
  43394. attachedMesh: Nullable<AbstractMesh>;
  43395. /**
  43396. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43397. * @param mesh The mesh to replace the default mesh of the gizmo
  43398. */
  43399. setCustomMesh(mesh: Mesh): void;
  43400. /**
  43401. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  43402. */
  43403. updateGizmoRotationToMatchAttachedMesh: boolean;
  43404. /**
  43405. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  43406. */
  43407. updateGizmoPositionToMatchAttachedMesh: boolean;
  43408. /**
  43409. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  43410. */
  43411. protected _updateScale: boolean;
  43412. protected _interactionsEnabled: boolean;
  43413. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43414. private _beforeRenderObserver;
  43415. private _tempVector;
  43416. /**
  43417. * Creates a gizmo
  43418. * @param gizmoLayer The utility layer the gizmo will be added to
  43419. */
  43420. constructor(
  43421. /** The utility layer the gizmo will be added to */
  43422. gizmoLayer?: UtilityLayerRenderer);
  43423. /**
  43424. * Updates the gizmo to match the attached mesh's position/rotation
  43425. */
  43426. protected _update(): void;
  43427. /**
  43428. * Disposes of the gizmo
  43429. */
  43430. dispose(): void;
  43431. }
  43432. }
  43433. declare module "babylonjs/Gizmos/planeDragGizmo" {
  43434. import { Observable } from "babylonjs/Misc/observable";
  43435. import { Nullable } from "babylonjs/types";
  43436. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43437. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43439. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43440. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43441. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43442. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  43443. import { Scene } from "babylonjs/scene";
  43444. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43445. /**
  43446. * Single plane drag gizmo
  43447. */
  43448. export class PlaneDragGizmo extends Gizmo {
  43449. /**
  43450. * Drag behavior responsible for the gizmos dragging interactions
  43451. */
  43452. dragBehavior: PointerDragBehavior;
  43453. private _pointerObserver;
  43454. /**
  43455. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43456. */
  43457. snapDistance: number;
  43458. /**
  43459. * Event that fires each time the gizmo snaps to a new location.
  43460. * * snapDistance is the the change in distance
  43461. */
  43462. onSnapObservable: Observable<{
  43463. snapDistance: number;
  43464. }>;
  43465. private _plane;
  43466. private _coloredMaterial;
  43467. private _hoverMaterial;
  43468. private _isEnabled;
  43469. private _parent;
  43470. /** @hidden */
  43471. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  43472. /** @hidden */
  43473. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43474. /**
  43475. * Creates a PlaneDragGizmo
  43476. * @param gizmoLayer The utility layer the gizmo will be added to
  43477. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  43478. * @param color The color of the gizmo
  43479. */
  43480. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43481. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43482. /**
  43483. * If the gizmo is enabled
  43484. */
  43485. isEnabled: boolean;
  43486. /**
  43487. * Disposes of the gizmo
  43488. */
  43489. dispose(): void;
  43490. }
  43491. }
  43492. declare module "babylonjs/Gizmos/positionGizmo" {
  43493. import { Observable } from "babylonjs/Misc/observable";
  43494. import { Nullable } from "babylonjs/types";
  43495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43496. import { Mesh } from "babylonjs/Meshes/mesh";
  43497. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43498. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43499. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  43500. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43501. /**
  43502. * Gizmo that enables dragging a mesh along 3 axis
  43503. */
  43504. export class PositionGizmo extends Gizmo {
  43505. /**
  43506. * Internal gizmo used for interactions on the x axis
  43507. */
  43508. xGizmo: AxisDragGizmo;
  43509. /**
  43510. * Internal gizmo used for interactions on the y axis
  43511. */
  43512. yGizmo: AxisDragGizmo;
  43513. /**
  43514. * Internal gizmo used for interactions on the z axis
  43515. */
  43516. zGizmo: AxisDragGizmo;
  43517. /**
  43518. * Internal gizmo used for interactions on the yz plane
  43519. */
  43520. xPlaneGizmo: PlaneDragGizmo;
  43521. /**
  43522. * Internal gizmo used for interactions on the xz plane
  43523. */
  43524. yPlaneGizmo: PlaneDragGizmo;
  43525. /**
  43526. * Internal gizmo used for interactions on the xy plane
  43527. */
  43528. zPlaneGizmo: PlaneDragGizmo;
  43529. /**
  43530. * private variables
  43531. */
  43532. private _meshAttached;
  43533. private _updateGizmoRotationToMatchAttachedMesh;
  43534. private _snapDistance;
  43535. private _scaleRatio;
  43536. /** Fires an event when any of it's sub gizmos are dragged */
  43537. onDragStartObservable: Observable<unknown>;
  43538. /** Fires an event when any of it's sub gizmos are released from dragging */
  43539. onDragEndObservable: Observable<unknown>;
  43540. /**
  43541. * If set to true, planar drag is enabled
  43542. */
  43543. private _planarGizmoEnabled;
  43544. attachedMesh: Nullable<AbstractMesh>;
  43545. /**
  43546. * Creates a PositionGizmo
  43547. * @param gizmoLayer The utility layer the gizmo will be added to
  43548. */
  43549. constructor(gizmoLayer?: UtilityLayerRenderer);
  43550. /**
  43551. * If the planar drag gizmo is enabled
  43552. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  43553. */
  43554. planarGizmoEnabled: boolean;
  43555. updateGizmoRotationToMatchAttachedMesh: boolean;
  43556. /**
  43557. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43558. */
  43559. snapDistance: number;
  43560. /**
  43561. * Ratio for the scale of the gizmo (Default: 1)
  43562. */
  43563. scaleRatio: number;
  43564. /**
  43565. * Disposes of the gizmo
  43566. */
  43567. dispose(): void;
  43568. /**
  43569. * CustomMeshes are not supported by this gizmo
  43570. * @param mesh The mesh to replace the default mesh of the gizmo
  43571. */
  43572. setCustomMesh(mesh: Mesh): void;
  43573. }
  43574. }
  43575. declare module "babylonjs/Gizmos/axisDragGizmo" {
  43576. import { Observable } from "babylonjs/Misc/observable";
  43577. import { Nullable } from "babylonjs/types";
  43578. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43579. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43581. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43582. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43583. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43584. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  43585. import { Scene } from "babylonjs/scene";
  43586. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43587. /**
  43588. * Single axis drag gizmo
  43589. */
  43590. export class AxisDragGizmo extends Gizmo {
  43591. /**
  43592. * Drag behavior responsible for the gizmos dragging interactions
  43593. */
  43594. dragBehavior: PointerDragBehavior;
  43595. private _pointerObserver;
  43596. /**
  43597. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43598. */
  43599. snapDistance: number;
  43600. /**
  43601. * Event that fires each time the gizmo snaps to a new location.
  43602. * * snapDistance is the the change in distance
  43603. */
  43604. onSnapObservable: Observable<{
  43605. snapDistance: number;
  43606. }>;
  43607. private _isEnabled;
  43608. private _parent;
  43609. private _arrow;
  43610. private _coloredMaterial;
  43611. private _hoverMaterial;
  43612. /** @hidden */
  43613. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  43614. /** @hidden */
  43615. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43616. /**
  43617. * Creates an AxisDragGizmo
  43618. * @param gizmoLayer The utility layer the gizmo will be added to
  43619. * @param dragAxis The axis which the gizmo will be able to drag on
  43620. * @param color The color of the gizmo
  43621. */
  43622. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43623. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43624. /**
  43625. * If the gizmo is enabled
  43626. */
  43627. isEnabled: boolean;
  43628. /**
  43629. * Disposes of the gizmo
  43630. */
  43631. dispose(): void;
  43632. }
  43633. }
  43634. declare module "babylonjs/Debug/axesViewer" {
  43635. import { Vector3 } from "babylonjs/Maths/math";
  43636. import { Nullable } from "babylonjs/types";
  43637. import { Scene } from "babylonjs/scene";
  43638. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43639. /**
  43640. * The Axes viewer will show 3 axes in a specific point in space
  43641. */
  43642. export class AxesViewer {
  43643. private _xAxis;
  43644. private _yAxis;
  43645. private _zAxis;
  43646. private _scaleLinesFactor;
  43647. private _instanced;
  43648. /**
  43649. * Gets the hosting scene
  43650. */
  43651. scene: Scene;
  43652. /**
  43653. * Gets or sets a number used to scale line length
  43654. */
  43655. scaleLines: number;
  43656. /** Gets the node hierarchy used to render x-axis */
  43657. readonly xAxis: TransformNode;
  43658. /** Gets the node hierarchy used to render y-axis */
  43659. readonly yAxis: TransformNode;
  43660. /** Gets the node hierarchy used to render z-axis */
  43661. readonly zAxis: TransformNode;
  43662. /**
  43663. * Creates a new AxesViewer
  43664. * @param scene defines the hosting scene
  43665. * @param scaleLines defines a number used to scale line length (1 by default)
  43666. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  43667. * @param xAxis defines the node hierarchy used to render the x-axis
  43668. * @param yAxis defines the node hierarchy used to render the y-axis
  43669. * @param zAxis defines the node hierarchy used to render the z-axis
  43670. */
  43671. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  43672. /**
  43673. * Force the viewer to update
  43674. * @param position defines the position of the viewer
  43675. * @param xaxis defines the x axis of the viewer
  43676. * @param yaxis defines the y axis of the viewer
  43677. * @param zaxis defines the z axis of the viewer
  43678. */
  43679. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  43680. /**
  43681. * Creates an instance of this axes viewer.
  43682. * @returns a new axes viewer with instanced meshes
  43683. */
  43684. createInstance(): AxesViewer;
  43685. /** Releases resources */
  43686. dispose(): void;
  43687. private static _SetRenderingGroupId;
  43688. }
  43689. }
  43690. declare module "babylonjs/Debug/boneAxesViewer" {
  43691. import { Nullable } from "babylonjs/types";
  43692. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  43693. import { Vector3 } from "babylonjs/Maths/math";
  43694. import { Mesh } from "babylonjs/Meshes/mesh";
  43695. import { Bone } from "babylonjs/Bones/bone";
  43696. import { Scene } from "babylonjs/scene";
  43697. /**
  43698. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  43699. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  43700. */
  43701. export class BoneAxesViewer extends AxesViewer {
  43702. /**
  43703. * Gets or sets the target mesh where to display the axes viewer
  43704. */
  43705. mesh: Nullable<Mesh>;
  43706. /**
  43707. * Gets or sets the target bone where to display the axes viewer
  43708. */
  43709. bone: Nullable<Bone>;
  43710. /** Gets current position */
  43711. pos: Vector3;
  43712. /** Gets direction of X axis */
  43713. xaxis: Vector3;
  43714. /** Gets direction of Y axis */
  43715. yaxis: Vector3;
  43716. /** Gets direction of Z axis */
  43717. zaxis: Vector3;
  43718. /**
  43719. * Creates a new BoneAxesViewer
  43720. * @param scene defines the hosting scene
  43721. * @param bone defines the target bone
  43722. * @param mesh defines the target mesh
  43723. * @param scaleLines defines a scaling factor for line length (1 by default)
  43724. */
  43725. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  43726. /**
  43727. * Force the viewer to update
  43728. */
  43729. update(): void;
  43730. /** Releases resources */
  43731. dispose(): void;
  43732. }
  43733. }
  43734. declare module "babylonjs/Debug/debugLayer" {
  43735. import { Scene } from "babylonjs/scene";
  43736. /**
  43737. * Interface used to define scene explorer extensibility option
  43738. */
  43739. export interface IExplorerExtensibilityOption {
  43740. /**
  43741. * Define the option label
  43742. */
  43743. label: string;
  43744. /**
  43745. * Defines the action to execute on click
  43746. */
  43747. action: (entity: any) => void;
  43748. }
  43749. /**
  43750. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43751. */
  43752. export interface IExplorerExtensibilityGroup {
  43753. /**
  43754. * Defines a predicate to test if a given type mut be extended
  43755. */
  43756. predicate: (entity: any) => boolean;
  43757. /**
  43758. * Gets the list of options added to a type
  43759. */
  43760. entries: IExplorerExtensibilityOption[];
  43761. }
  43762. /**
  43763. * Interface used to define the options to use to create the Inspector
  43764. */
  43765. export interface IInspectorOptions {
  43766. /**
  43767. * Display in overlay mode (default: false)
  43768. */
  43769. overlay?: boolean;
  43770. /**
  43771. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43772. */
  43773. globalRoot?: HTMLElement;
  43774. /**
  43775. * Display the Scene explorer
  43776. */
  43777. showExplorer?: boolean;
  43778. /**
  43779. * Display the property inspector
  43780. */
  43781. showInspector?: boolean;
  43782. /**
  43783. * Display in embed mode (both panes on the right)
  43784. */
  43785. embedMode?: boolean;
  43786. /**
  43787. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43788. */
  43789. handleResize?: boolean;
  43790. /**
  43791. * Allow the panes to popup (default: true)
  43792. */
  43793. enablePopup?: boolean;
  43794. /**
  43795. * Allow the panes to be closed by users (default: true)
  43796. */
  43797. enableClose?: boolean;
  43798. /**
  43799. * Optional list of extensibility entries
  43800. */
  43801. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43802. /**
  43803. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43804. */
  43805. inspectorURL?: string;
  43806. }
  43807. module "babylonjs/scene" {
  43808. interface Scene {
  43809. /**
  43810. * @hidden
  43811. * Backing field
  43812. */
  43813. _debugLayer: DebugLayer;
  43814. /**
  43815. * Gets the debug layer (aka Inspector) associated with the scene
  43816. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43817. */
  43818. debugLayer: DebugLayer;
  43819. }
  43820. }
  43821. /**
  43822. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43823. * what is happening in your scene
  43824. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43825. */
  43826. export class DebugLayer {
  43827. /**
  43828. * Define the url to get the inspector script from.
  43829. * By default it uses the babylonjs CDN.
  43830. * @ignoreNaming
  43831. */
  43832. static InspectorURL: string;
  43833. private _scene;
  43834. private BJSINSPECTOR;
  43835. private _onPropertyChangedObservable?;
  43836. /**
  43837. * Observable triggered when a property is changed through the inspector.
  43838. */
  43839. readonly onPropertyChangedObservable: any;
  43840. /**
  43841. * Instantiates a new debug layer.
  43842. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43843. * what is happening in your scene
  43844. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43845. * @param scene Defines the scene to inspect
  43846. */
  43847. constructor(scene: Scene);
  43848. /** Creates the inspector window. */
  43849. private _createInspector;
  43850. /**
  43851. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43852. * @param entity defines the entity to select
  43853. * @param lineContainerTitle defines the specific block to highlight
  43854. */
  43855. select(entity: any, lineContainerTitle?: string): void;
  43856. /** Get the inspector from bundle or global */
  43857. private _getGlobalInspector;
  43858. /**
  43859. * Get if the inspector is visible or not.
  43860. * @returns true if visible otherwise, false
  43861. */
  43862. isVisible(): boolean;
  43863. /**
  43864. * Hide the inspector and close its window.
  43865. */
  43866. hide(): void;
  43867. /**
  43868. * Launch the debugLayer.
  43869. * @param config Define the configuration of the inspector
  43870. * @return a promise fulfilled when the debug layer is visible
  43871. */
  43872. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43873. }
  43874. }
  43875. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  43876. import { Nullable } from "babylonjs/types";
  43877. import { Scene } from "babylonjs/scene";
  43878. import { Vector4, Color4 } from "babylonjs/Maths/math";
  43879. import { Mesh } from "babylonjs/Meshes/mesh";
  43880. /**
  43881. * Class containing static functions to help procedurally build meshes
  43882. */
  43883. export class BoxBuilder {
  43884. /**
  43885. * Creates a box mesh
  43886. * * The parameter `size` sets the size (float) of each box side (default 1)
  43887. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43888. * * 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)
  43889. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43891. * * 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
  43892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43893. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43894. * @param name defines the name of the mesh
  43895. * @param options defines the options used to create the mesh
  43896. * @param scene defines the hosting scene
  43897. * @returns the box mesh
  43898. */
  43899. static CreateBox(name: string, options: {
  43900. size?: number;
  43901. width?: number;
  43902. height?: number;
  43903. depth?: number;
  43904. faceUV?: Vector4[];
  43905. faceColors?: Color4[];
  43906. sideOrientation?: number;
  43907. frontUVs?: Vector4;
  43908. backUVs?: Vector4;
  43909. wrap?: boolean;
  43910. topBaseAt?: number;
  43911. bottomBaseAt?: number;
  43912. updatable?: boolean;
  43913. }, scene?: Nullable<Scene>): Mesh;
  43914. }
  43915. }
  43916. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  43917. import { Vector4 } from "babylonjs/Maths/math";
  43918. import { Mesh } from "babylonjs/Meshes/mesh";
  43919. /**
  43920. * Class containing static functions to help procedurally build meshes
  43921. */
  43922. export class SphereBuilder {
  43923. /**
  43924. * Creates a sphere mesh
  43925. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43926. * * 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`)
  43927. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43928. * * 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
  43929. * * 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)
  43930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43931. * * 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
  43932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43933. * @param name defines the name of the mesh
  43934. * @param options defines the options used to create the mesh
  43935. * @param scene defines the hosting scene
  43936. * @returns the sphere mesh
  43937. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43938. */
  43939. static CreateSphere(name: string, options: {
  43940. segments?: number;
  43941. diameter?: number;
  43942. diameterX?: number;
  43943. diameterY?: number;
  43944. diameterZ?: number;
  43945. arc?: number;
  43946. slice?: number;
  43947. sideOrientation?: number;
  43948. frontUVs?: Vector4;
  43949. backUVs?: Vector4;
  43950. updatable?: boolean;
  43951. }, scene: any): Mesh;
  43952. }
  43953. }
  43954. declare module "babylonjs/Debug/physicsViewer" {
  43955. import { Nullable } from "babylonjs/types";
  43956. import { Scene } from "babylonjs/scene";
  43957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43958. import { Mesh } from "babylonjs/Meshes/mesh";
  43959. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  43960. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  43961. /**
  43962. * Used to show the physics impostor around the specific mesh
  43963. */
  43964. export class PhysicsViewer {
  43965. /** @hidden */
  43966. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43967. /** @hidden */
  43968. protected _meshes: Array<Nullable<AbstractMesh>>;
  43969. /** @hidden */
  43970. protected _scene: Nullable<Scene>;
  43971. /** @hidden */
  43972. protected _numMeshes: number;
  43973. /** @hidden */
  43974. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43975. private _renderFunction;
  43976. private _utilityLayer;
  43977. private _debugBoxMesh;
  43978. private _debugSphereMesh;
  43979. private _debugCylinderMesh;
  43980. private _debugMaterial;
  43981. private _debugMeshMeshes;
  43982. /**
  43983. * Creates a new PhysicsViewer
  43984. * @param scene defines the hosting scene
  43985. */
  43986. constructor(scene: Scene);
  43987. /** @hidden */
  43988. protected _updateDebugMeshes(): void;
  43989. /**
  43990. * Renders a specified physic impostor
  43991. * @param impostor defines the impostor to render
  43992. * @param targetMesh defines the mesh represented by the impostor
  43993. * @returns the new debug mesh used to render the impostor
  43994. */
  43995. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43996. /**
  43997. * Hides a specified physic impostor
  43998. * @param impostor defines the impostor to hide
  43999. */
  44000. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44001. private _getDebugMaterial;
  44002. private _getDebugBoxMesh;
  44003. private _getDebugSphereMesh;
  44004. private _getDebugCylinderMesh;
  44005. private _getDebugMeshMesh;
  44006. private _getDebugMesh;
  44007. /** Releases all resources */
  44008. dispose(): void;
  44009. }
  44010. }
  44011. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44012. import { Vector3, Color4 } from "babylonjs/Maths/math";
  44013. import { Nullable } from "babylonjs/types";
  44014. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44015. import { Scene } from "babylonjs/scene";
  44016. /**
  44017. * Class containing static functions to help procedurally build meshes
  44018. */
  44019. export class LinesBuilder {
  44020. /**
  44021. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44022. * * 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
  44023. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44024. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44025. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44026. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44027. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44028. * * 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
  44029. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44031. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44032. * @param name defines the name of the new line system
  44033. * @param options defines the options used to create the line system
  44034. * @param scene defines the hosting scene
  44035. * @returns a new line system mesh
  44036. */
  44037. static CreateLineSystem(name: string, options: {
  44038. lines: Vector3[][];
  44039. updatable?: boolean;
  44040. instance?: Nullable<LinesMesh>;
  44041. colors?: Nullable<Color4[][]>;
  44042. useVertexAlpha?: boolean;
  44043. }, scene: Nullable<Scene>): LinesMesh;
  44044. /**
  44045. * Creates a line mesh
  44046. * 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
  44047. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44048. * * The parameter `points` is an array successive Vector3
  44049. * * 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
  44050. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44051. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44052. * * When updating an instance, remember that only point positions can change, not the number of points
  44053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44054. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44055. * @param name defines the name of the new line system
  44056. * @param options defines the options used to create the line system
  44057. * @param scene defines the hosting scene
  44058. * @returns a new line mesh
  44059. */
  44060. static CreateLines(name: string, options: {
  44061. points: Vector3[];
  44062. updatable?: boolean;
  44063. instance?: Nullable<LinesMesh>;
  44064. colors?: Color4[];
  44065. useVertexAlpha?: boolean;
  44066. }, scene?: Nullable<Scene>): LinesMesh;
  44067. /**
  44068. * Creates a dashed line mesh
  44069. * * 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
  44070. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44071. * * The parameter `points` is an array successive Vector3
  44072. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44073. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44074. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44075. * * 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
  44076. * * When updating an instance, remember that only point positions can change, not the number of points
  44077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44078. * @param name defines the name of the mesh
  44079. * @param options defines the options used to create the mesh
  44080. * @param scene defines the hosting scene
  44081. * @returns the dashed line mesh
  44082. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44083. */
  44084. static CreateDashedLines(name: string, options: {
  44085. points: Vector3[];
  44086. dashSize?: number;
  44087. gapSize?: number;
  44088. dashNb?: number;
  44089. updatable?: boolean;
  44090. instance?: LinesMesh;
  44091. }, scene?: Nullable<Scene>): LinesMesh;
  44092. }
  44093. }
  44094. declare module "babylonjs/Debug/rayHelper" {
  44095. import { Nullable } from "babylonjs/types";
  44096. import { Ray } from "babylonjs/Culling/ray";
  44097. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44098. import { Scene } from "babylonjs/scene";
  44099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44100. import "babylonjs/Meshes/Builders/linesBuilder";
  44101. /**
  44102. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44103. * in order to better appreciate the issue one might have.
  44104. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44105. */
  44106. export class RayHelper {
  44107. /**
  44108. * Defines the ray we are currently tryin to visualize.
  44109. */
  44110. ray: Nullable<Ray>;
  44111. private _renderPoints;
  44112. private _renderLine;
  44113. private _renderFunction;
  44114. private _scene;
  44115. private _updateToMeshFunction;
  44116. private _attachedToMesh;
  44117. private _meshSpaceDirection;
  44118. private _meshSpaceOrigin;
  44119. /**
  44120. * Helper function to create a colored helper in a scene in one line.
  44121. * @param ray Defines the ray we are currently tryin to visualize
  44122. * @param scene Defines the scene the ray is used in
  44123. * @param color Defines the color we want to see the ray in
  44124. * @returns The newly created ray helper.
  44125. */
  44126. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44127. /**
  44128. * Instantiate a new ray helper.
  44129. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44130. * in order to better appreciate the issue one might have.
  44131. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44132. * @param ray Defines the ray we are currently tryin to visualize
  44133. */
  44134. constructor(ray: Ray);
  44135. /**
  44136. * Shows the ray we are willing to debug.
  44137. * @param scene Defines the scene the ray needs to be rendered in
  44138. * @param color Defines the color the ray needs to be rendered in
  44139. */
  44140. show(scene: Scene, color?: Color3): void;
  44141. /**
  44142. * Hides the ray we are debugging.
  44143. */
  44144. hide(): void;
  44145. private _render;
  44146. /**
  44147. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44148. * @param mesh Defines the mesh we want the helper attached to
  44149. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44150. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44151. * @param length Defines the length of the ray
  44152. */
  44153. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44154. /**
  44155. * Detach the ray helper from the mesh it has previously been attached to.
  44156. */
  44157. detachFromMesh(): void;
  44158. private _updateToMesh;
  44159. /**
  44160. * Dispose the helper and release its associated resources.
  44161. */
  44162. dispose(): void;
  44163. }
  44164. }
  44165. declare module "babylonjs/Debug/skeletonViewer" {
  44166. import { Color3 } from "babylonjs/Maths/math";
  44167. import { Scene } from "babylonjs/scene";
  44168. import { Nullable } from "babylonjs/types";
  44169. import { Skeleton } from "babylonjs/Bones/skeleton";
  44170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44171. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44172. /**
  44173. * Class used to render a debug view of a given skeleton
  44174. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44175. */
  44176. export class SkeletonViewer {
  44177. /** defines the skeleton to render */
  44178. skeleton: Skeleton;
  44179. /** defines the mesh attached to the skeleton */
  44180. mesh: AbstractMesh;
  44181. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44182. autoUpdateBonesMatrices: boolean;
  44183. /** defines the rendering group id to use with the viewer */
  44184. renderingGroupId: number;
  44185. /** Gets or sets the color used to render the skeleton */
  44186. color: Color3;
  44187. private _scene;
  44188. private _debugLines;
  44189. private _debugMesh;
  44190. private _isEnabled;
  44191. private _renderFunction;
  44192. private _utilityLayer;
  44193. /**
  44194. * Returns the mesh used to render the bones
  44195. */
  44196. readonly debugMesh: Nullable<LinesMesh>;
  44197. /**
  44198. * Creates a new SkeletonViewer
  44199. * @param skeleton defines the skeleton to render
  44200. * @param mesh defines the mesh attached to the skeleton
  44201. * @param scene defines the hosting scene
  44202. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  44203. * @param renderingGroupId defines the rendering group id to use with the viewer
  44204. */
  44205. constructor(
  44206. /** defines the skeleton to render */
  44207. skeleton: Skeleton,
  44208. /** defines the mesh attached to the skeleton */
  44209. mesh: AbstractMesh, scene: Scene,
  44210. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44211. autoUpdateBonesMatrices?: boolean,
  44212. /** defines the rendering group id to use with the viewer */
  44213. renderingGroupId?: number);
  44214. /** Gets or sets a boolean indicating if the viewer is enabled */
  44215. isEnabled: boolean;
  44216. private _getBonePosition;
  44217. private _getLinesForBonesWithLength;
  44218. private _getLinesForBonesNoLength;
  44219. /** Update the viewer to sync with current skeleton state */
  44220. update(): void;
  44221. /** Release associated resources */
  44222. dispose(): void;
  44223. }
  44224. }
  44225. declare module "babylonjs/Debug/index" {
  44226. export * from "babylonjs/Debug/axesViewer";
  44227. export * from "babylonjs/Debug/boneAxesViewer";
  44228. export * from "babylonjs/Debug/debugLayer";
  44229. export * from "babylonjs/Debug/physicsViewer";
  44230. export * from "babylonjs/Debug/rayHelper";
  44231. export * from "babylonjs/Debug/skeletonViewer";
  44232. }
  44233. declare module "babylonjs/Engines/nullEngine" {
  44234. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  44235. import { Scene } from "babylonjs/scene";
  44236. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  44237. import { Engine } from "babylonjs/Engines/engine";
  44238. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  44239. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  44240. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  44241. import { Effect } from "babylonjs/Materials/effect";
  44242. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  44243. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  44244. /**
  44245. * Options to create the null engine
  44246. */
  44247. export class NullEngineOptions {
  44248. /**
  44249. * Render width (Default: 512)
  44250. */
  44251. renderWidth: number;
  44252. /**
  44253. * Render height (Default: 256)
  44254. */
  44255. renderHeight: number;
  44256. /**
  44257. * Texture size (Default: 512)
  44258. */
  44259. textureSize: number;
  44260. /**
  44261. * If delta time between frames should be constant
  44262. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44263. */
  44264. deterministicLockstep: boolean;
  44265. /**
  44266. * Maximum about of steps between frames (Default: 4)
  44267. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44268. */
  44269. lockstepMaxSteps: number;
  44270. }
  44271. /**
  44272. * The null engine class provides support for headless version of babylon.js.
  44273. * This can be used in server side scenario or for testing purposes
  44274. */
  44275. export class NullEngine extends Engine {
  44276. private _options;
  44277. /**
  44278. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44279. */
  44280. isDeterministicLockStep(): boolean;
  44281. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  44282. getLockstepMaxSteps(): number;
  44283. /**
  44284. * Sets hardware scaling, used to save performance if needed
  44285. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  44286. */
  44287. getHardwareScalingLevel(): number;
  44288. constructor(options?: NullEngineOptions);
  44289. createVertexBuffer(vertices: FloatArray): DataBuffer;
  44290. createIndexBuffer(indices: IndicesArray): DataBuffer;
  44291. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44292. getRenderWidth(useScreen?: boolean): number;
  44293. getRenderHeight(useScreen?: boolean): number;
  44294. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44295. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  44296. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  44297. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44298. bindSamplers(effect: Effect): void;
  44299. enableEffect(effect: Effect): void;
  44300. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44301. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44302. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44303. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44304. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44305. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44306. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44307. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44308. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44309. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44310. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44311. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44312. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44313. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44314. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44315. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44316. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44317. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44318. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44319. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44320. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44321. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44322. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44323. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44324. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44325. bindBuffers(vertexBuffers: {
  44326. [key: string]: VertexBuffer;
  44327. }, indexBuffer: DataBuffer, effect: Effect): void;
  44328. wipeCaches(bruteForce?: boolean): void;
  44329. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  44330. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44331. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44332. /** @hidden */
  44333. _createTexture(): WebGLTexture;
  44334. /** @hidden */
  44335. _releaseTexture(texture: InternalTexture): void;
  44336. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  44337. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44338. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44339. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44340. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44341. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  44342. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  44343. areAllEffectsReady(): boolean;
  44344. /**
  44345. * @hidden
  44346. * Get the current error code of the webGL context
  44347. * @returns the error code
  44348. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  44349. */
  44350. getError(): number;
  44351. /** @hidden */
  44352. _getUnpackAlignement(): number;
  44353. /** @hidden */
  44354. _unpackFlipY(value: boolean): void;
  44355. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  44356. /**
  44357. * Updates a dynamic vertex buffer.
  44358. * @param vertexBuffer the vertex buffer to update
  44359. * @param data the data used to update the vertex buffer
  44360. * @param byteOffset the byte offset of the data (optional)
  44361. * @param byteLength the byte length of the data (optional)
  44362. */
  44363. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  44364. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44365. /** @hidden */
  44366. _bindTexture(channel: number, texture: InternalTexture): void;
  44367. /** @hidden */
  44368. _releaseBuffer(buffer: DataBuffer): boolean;
  44369. releaseEffects(): void;
  44370. displayLoadingUI(): void;
  44371. hideLoadingUI(): void;
  44372. /** @hidden */
  44373. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44374. /** @hidden */
  44375. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44376. /** @hidden */
  44377. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44378. /** @hidden */
  44379. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44380. }
  44381. }
  44382. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  44383. import { Nullable, int } from "babylonjs/types";
  44384. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  44385. /** @hidden */
  44386. export class _OcclusionDataStorage {
  44387. /** @hidden */
  44388. occlusionInternalRetryCounter: number;
  44389. /** @hidden */
  44390. isOcclusionQueryInProgress: boolean;
  44391. /** @hidden */
  44392. isOccluded: boolean;
  44393. /** @hidden */
  44394. occlusionRetryCount: number;
  44395. /** @hidden */
  44396. occlusionType: number;
  44397. /** @hidden */
  44398. occlusionQueryAlgorithmType: number;
  44399. }
  44400. module "babylonjs/Engines/engine" {
  44401. interface Engine {
  44402. /**
  44403. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44404. * @return the new query
  44405. */
  44406. createQuery(): WebGLQuery;
  44407. /**
  44408. * Delete and release a webGL query
  44409. * @param query defines the query to delete
  44410. * @return the current engine
  44411. */
  44412. deleteQuery(query: WebGLQuery): Engine;
  44413. /**
  44414. * Check if a given query has resolved and got its value
  44415. * @param query defines the query to check
  44416. * @returns true if the query got its value
  44417. */
  44418. isQueryResultAvailable(query: WebGLQuery): boolean;
  44419. /**
  44420. * Gets the value of a given query
  44421. * @param query defines the query to check
  44422. * @returns the value of the query
  44423. */
  44424. getQueryResult(query: WebGLQuery): number;
  44425. /**
  44426. * Initiates an occlusion query
  44427. * @param algorithmType defines the algorithm to use
  44428. * @param query defines the query to use
  44429. * @returns the current engine
  44430. * @see http://doc.babylonjs.com/features/occlusionquery
  44431. */
  44432. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44433. /**
  44434. * Ends an occlusion query
  44435. * @see http://doc.babylonjs.com/features/occlusionquery
  44436. * @param algorithmType defines the algorithm to use
  44437. * @returns the current engine
  44438. */
  44439. endOcclusionQuery(algorithmType: number): Engine;
  44440. /**
  44441. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44442. * Please note that only one query can be issued at a time
  44443. * @returns a time token used to track the time span
  44444. */
  44445. startTimeQuery(): Nullable<_TimeToken>;
  44446. /**
  44447. * Ends a time query
  44448. * @param token defines the token used to measure the time span
  44449. * @returns the time spent (in ns)
  44450. */
  44451. endTimeQuery(token: _TimeToken): int;
  44452. /** @hidden */
  44453. _currentNonTimestampToken: Nullable<_TimeToken>;
  44454. /** @hidden */
  44455. _createTimeQuery(): WebGLQuery;
  44456. /** @hidden */
  44457. _deleteTimeQuery(query: WebGLQuery): void;
  44458. /** @hidden */
  44459. _getGlAlgorithmType(algorithmType: number): number;
  44460. /** @hidden */
  44461. _getTimeQueryResult(query: WebGLQuery): any;
  44462. /** @hidden */
  44463. _getTimeQueryAvailability(query: WebGLQuery): any;
  44464. }
  44465. }
  44466. module "babylonjs/Meshes/abstractMesh" {
  44467. interface AbstractMesh {
  44468. /**
  44469. * Backing filed
  44470. * @hidden
  44471. */
  44472. __occlusionDataStorage: _OcclusionDataStorage;
  44473. /**
  44474. * Access property
  44475. * @hidden
  44476. */
  44477. _occlusionDataStorage: _OcclusionDataStorage;
  44478. /**
  44479. * 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.
  44480. * The default value is -1 which means don't break the query and wait till the result
  44481. * @see http://doc.babylonjs.com/features/occlusionquery
  44482. */
  44483. occlusionRetryCount: number;
  44484. /**
  44485. * 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:
  44486. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44487. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44488. * * 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.
  44489. * @see http://doc.babylonjs.com/features/occlusionquery
  44490. */
  44491. occlusionType: number;
  44492. /**
  44493. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44494. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44495. * * 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.
  44496. * @see http://doc.babylonjs.com/features/occlusionquery
  44497. */
  44498. occlusionQueryAlgorithmType: number;
  44499. /**
  44500. * 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
  44501. * @see http://doc.babylonjs.com/features/occlusionquery
  44502. */
  44503. isOccluded: boolean;
  44504. /**
  44505. * Flag to check the progress status of the query
  44506. * @see http://doc.babylonjs.com/features/occlusionquery
  44507. */
  44508. isOcclusionQueryInProgress: boolean;
  44509. }
  44510. }
  44511. }
  44512. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  44513. import { Nullable } from "babylonjs/types";
  44514. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  44515. /** @hidden */
  44516. export var _forceTransformFeedbackToBundle: boolean;
  44517. module "babylonjs/Engines/engine" {
  44518. interface Engine {
  44519. /**
  44520. * Creates a webGL transform feedback object
  44521. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44522. * @returns the webGL transform feedback object
  44523. */
  44524. createTransformFeedback(): WebGLTransformFeedback;
  44525. /**
  44526. * Delete a webGL transform feedback object
  44527. * @param value defines the webGL transform feedback object to delete
  44528. */
  44529. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44530. /**
  44531. * Bind a webGL transform feedback object to the webgl context
  44532. * @param value defines the webGL transform feedback object to bind
  44533. */
  44534. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44535. /**
  44536. * Begins a transform feedback operation
  44537. * @param usePoints defines if points or triangles must be used
  44538. */
  44539. beginTransformFeedback(usePoints: boolean): void;
  44540. /**
  44541. * Ends a transform feedback operation
  44542. */
  44543. endTransformFeedback(): void;
  44544. /**
  44545. * Specify the varyings to use with transform feedback
  44546. * @param program defines the associated webGL program
  44547. * @param value defines the list of strings representing the varying names
  44548. */
  44549. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44550. /**
  44551. * Bind a webGL buffer for a transform feedback operation
  44552. * @param value defines the webGL buffer to bind
  44553. */
  44554. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44555. }
  44556. }
  44557. }
  44558. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  44559. import { Scene } from "babylonjs/scene";
  44560. import { Engine } from "babylonjs/Engines/engine";
  44561. import { Texture } from "babylonjs/Materials/Textures/texture";
  44562. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44563. import "babylonjs/Engines/Extensions/engine.multiRender";
  44564. /**
  44565. * Creation options of the multi render target texture.
  44566. */
  44567. export interface IMultiRenderTargetOptions {
  44568. /**
  44569. * Define if the texture needs to create mip maps after render.
  44570. */
  44571. generateMipMaps?: boolean;
  44572. /**
  44573. * Define the types of all the draw buffers we want to create
  44574. */
  44575. types?: number[];
  44576. /**
  44577. * Define the sampling modes of all the draw buffers we want to create
  44578. */
  44579. samplingModes?: number[];
  44580. /**
  44581. * Define if a depth buffer is required
  44582. */
  44583. generateDepthBuffer?: boolean;
  44584. /**
  44585. * Define if a stencil buffer is required
  44586. */
  44587. generateStencilBuffer?: boolean;
  44588. /**
  44589. * Define if a depth texture is required instead of a depth buffer
  44590. */
  44591. generateDepthTexture?: boolean;
  44592. /**
  44593. * Define the number of desired draw buffers
  44594. */
  44595. textureCount?: number;
  44596. /**
  44597. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44598. */
  44599. doNotChangeAspectRatio?: boolean;
  44600. /**
  44601. * Define the default type of the buffers we are creating
  44602. */
  44603. defaultType?: number;
  44604. }
  44605. /**
  44606. * A multi render target, like a render target provides the ability to render to a texture.
  44607. * Unlike the render target, it can render to several draw buffers in one draw.
  44608. * This is specially interesting in deferred rendering or for any effects requiring more than
  44609. * just one color from a single pass.
  44610. */
  44611. export class MultiRenderTarget extends RenderTargetTexture {
  44612. private _internalTextures;
  44613. private _textures;
  44614. private _multiRenderTargetOptions;
  44615. /**
  44616. * Get if draw buffers are currently supported by the used hardware and browser.
  44617. */
  44618. readonly isSupported: boolean;
  44619. /**
  44620. * Get the list of textures generated by the multi render target.
  44621. */
  44622. readonly textures: Texture[];
  44623. /**
  44624. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  44625. */
  44626. readonly depthTexture: Texture;
  44627. /**
  44628. * Set the wrapping mode on U of all the textures we are rendering to.
  44629. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44630. */
  44631. wrapU: number;
  44632. /**
  44633. * Set the wrapping mode on V of all the textures we are rendering to.
  44634. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44635. */
  44636. wrapV: number;
  44637. /**
  44638. * Instantiate a new multi render target texture.
  44639. * A multi render target, like a render target provides the ability to render to a texture.
  44640. * Unlike the render target, it can render to several draw buffers in one draw.
  44641. * This is specially interesting in deferred rendering or for any effects requiring more than
  44642. * just one color from a single pass.
  44643. * @param name Define the name of the texture
  44644. * @param size Define the size of the buffers to render to
  44645. * @param count Define the number of target we are rendering into
  44646. * @param scene Define the scene the texture belongs to
  44647. * @param options Define the options used to create the multi render target
  44648. */
  44649. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  44650. /** @hidden */
  44651. _rebuild(): void;
  44652. private _createInternalTextures;
  44653. private _createTextures;
  44654. /**
  44655. * Define the number of samples used if MSAA is enabled.
  44656. */
  44657. samples: number;
  44658. /**
  44659. * Resize all the textures in the multi render target.
  44660. * Be carrefull as it will recreate all the data in the new texture.
  44661. * @param size Define the new size
  44662. */
  44663. resize(size: any): void;
  44664. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  44665. /**
  44666. * Dispose the render targets and their associated resources
  44667. */
  44668. dispose(): void;
  44669. /**
  44670. * Release all the underlying texture used as draw buffers.
  44671. */
  44672. releaseInternalTextures(): void;
  44673. }
  44674. }
  44675. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  44676. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  44677. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  44678. import { Nullable } from "babylonjs/types";
  44679. module "babylonjs/Engines/engine" {
  44680. interface Engine {
  44681. /**
  44682. * Unbind a list of render target textures from the webGL context
  44683. * This is used only when drawBuffer extension or webGL2 are active
  44684. * @param textures defines the render target textures to unbind
  44685. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44686. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44687. */
  44688. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  44689. /**
  44690. * Create a multi render target texture
  44691. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  44692. * @param size defines the size of the texture
  44693. * @param options defines the creation options
  44694. * @returns the cube texture as an InternalTexture
  44695. */
  44696. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  44697. /**
  44698. * Update the sample count for a given multiple render target texture
  44699. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44700. * @param textures defines the textures to update
  44701. * @param samples defines the sample count to set
  44702. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44703. */
  44704. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  44705. }
  44706. }
  44707. }
  44708. declare module "babylonjs/Engines/Extensions/index" {
  44709. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  44710. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  44711. export * from "babylonjs/Engines/Extensions/engine.multiview";
  44712. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  44713. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  44714. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  44715. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  44716. export * from "babylonjs/Engines/Extensions/engine.webVR";
  44717. }
  44718. declare module "babylonjs/Engines/index" {
  44719. export * from "babylonjs/Engines/constants";
  44720. export * from "babylonjs/Engines/engine";
  44721. export * from "babylonjs/Engines/engineStore";
  44722. export * from "babylonjs/Engines/nullEngine";
  44723. export * from "babylonjs/Engines/Extensions/index";
  44724. export * from "babylonjs/Engines/IPipelineContext";
  44725. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  44726. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  44727. }
  44728. declare module "babylonjs/Events/clipboardEvents" {
  44729. /**
  44730. * Gather the list of clipboard event types as constants.
  44731. */
  44732. export class ClipboardEventTypes {
  44733. /**
  44734. * The clipboard event is fired when a copy command is active (pressed).
  44735. */
  44736. static readonly COPY: number;
  44737. /**
  44738. * The clipboard event is fired when a cut command is active (pressed).
  44739. */
  44740. static readonly CUT: number;
  44741. /**
  44742. * The clipboard event is fired when a paste command is active (pressed).
  44743. */
  44744. static readonly PASTE: number;
  44745. }
  44746. /**
  44747. * This class is used to store clipboard related info for the onClipboardObservable event.
  44748. */
  44749. export class ClipboardInfo {
  44750. /**
  44751. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44752. */
  44753. type: number;
  44754. /**
  44755. * Defines the related dom event
  44756. */
  44757. event: ClipboardEvent;
  44758. /**
  44759. *Creates an instance of ClipboardInfo.
  44760. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44761. * @param event Defines the related dom event
  44762. */
  44763. constructor(
  44764. /**
  44765. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44766. */
  44767. type: number,
  44768. /**
  44769. * Defines the related dom event
  44770. */
  44771. event: ClipboardEvent);
  44772. /**
  44773. * Get the clipboard event's type from the keycode.
  44774. * @param keyCode Defines the keyCode for the current keyboard event.
  44775. * @return {number}
  44776. */
  44777. static GetTypeFromCharacter(keyCode: number): number;
  44778. }
  44779. }
  44780. declare module "babylonjs/Events/index" {
  44781. export * from "babylonjs/Events/keyboardEvents";
  44782. export * from "babylonjs/Events/pointerEvents";
  44783. export * from "babylonjs/Events/clipboardEvents";
  44784. }
  44785. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  44786. import { Scene } from "babylonjs/scene";
  44787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44788. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44789. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44790. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44791. /**
  44792. * Google Daydream controller
  44793. */
  44794. export class DaydreamController extends WebVRController {
  44795. /**
  44796. * Base Url for the controller model.
  44797. */
  44798. static MODEL_BASE_URL: string;
  44799. /**
  44800. * File name for the controller model.
  44801. */
  44802. static MODEL_FILENAME: string;
  44803. /**
  44804. * Gamepad Id prefix used to identify Daydream Controller.
  44805. */
  44806. static readonly GAMEPAD_ID_PREFIX: string;
  44807. /**
  44808. * Creates a new DaydreamController from a gamepad
  44809. * @param vrGamepad the gamepad that the controller should be created from
  44810. */
  44811. constructor(vrGamepad: any);
  44812. /**
  44813. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44814. * @param scene scene in which to add meshes
  44815. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44816. */
  44817. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44818. /**
  44819. * Called once for each button that changed state since the last frame
  44820. * @param buttonIdx Which button index changed
  44821. * @param state New state of the button
  44822. * @param changes Which properties on the state changed since last frame
  44823. */
  44824. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44825. }
  44826. }
  44827. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  44828. import { Scene } from "babylonjs/scene";
  44829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44830. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44831. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44832. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44833. /**
  44834. * Gear VR Controller
  44835. */
  44836. export class GearVRController extends WebVRController {
  44837. /**
  44838. * Base Url for the controller model.
  44839. */
  44840. static MODEL_BASE_URL: string;
  44841. /**
  44842. * File name for the controller model.
  44843. */
  44844. static MODEL_FILENAME: string;
  44845. /**
  44846. * Gamepad Id prefix used to identify this controller.
  44847. */
  44848. static readonly GAMEPAD_ID_PREFIX: string;
  44849. private readonly _buttonIndexToObservableNameMap;
  44850. /**
  44851. * Creates a new GearVRController from a gamepad
  44852. * @param vrGamepad the gamepad that the controller should be created from
  44853. */
  44854. constructor(vrGamepad: any);
  44855. /**
  44856. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44857. * @param scene scene in which to add meshes
  44858. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44859. */
  44860. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44861. /**
  44862. * Called once for each button that changed state since the last frame
  44863. * @param buttonIdx Which button index changed
  44864. * @param state New state of the button
  44865. * @param changes Which properties on the state changed since last frame
  44866. */
  44867. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44868. }
  44869. }
  44870. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44871. import { Scene } from "babylonjs/scene";
  44872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44873. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44874. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44875. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44876. import { Observable } from "babylonjs/Misc/observable";
  44877. /**
  44878. * Vive Controller
  44879. */
  44880. export class ViveController extends WebVRController {
  44881. /**
  44882. * Base Url for the controller model.
  44883. */
  44884. static MODEL_BASE_URL: string;
  44885. /**
  44886. * File name for the controller model.
  44887. */
  44888. static MODEL_FILENAME: string;
  44889. /**
  44890. * Creates a new ViveController from a gamepad
  44891. * @param vrGamepad the gamepad that the controller should be created from
  44892. */
  44893. constructor(vrGamepad: any);
  44894. /**
  44895. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44896. * @param scene scene in which to add meshes
  44897. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44898. */
  44899. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44900. /**
  44901. * Fired when the left button on this controller is modified
  44902. */
  44903. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44904. /**
  44905. * Fired when the right button on this controller is modified
  44906. */
  44907. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44908. /**
  44909. * Fired when the menu button on this controller is modified
  44910. */
  44911. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44912. /**
  44913. * Called once for each button that changed state since the last frame
  44914. * Vive mapping:
  44915. * 0: touchpad
  44916. * 1: trigger
  44917. * 2: left AND right buttons
  44918. * 3: menu button
  44919. * @param buttonIdx Which button index changed
  44920. * @param state New state of the button
  44921. * @param changes Which properties on the state changed since last frame
  44922. */
  44923. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44924. }
  44925. }
  44926. declare module "babylonjs/Gamepads/Controllers/index" {
  44927. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44928. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44929. export * from "babylonjs/Gamepads/Controllers/genericController";
  44930. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44931. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44932. export * from "babylonjs/Gamepads/Controllers/viveController";
  44933. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44934. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44935. }
  44936. declare module "babylonjs/Gamepads/index" {
  44937. export * from "babylonjs/Gamepads/Controllers/index";
  44938. export * from "babylonjs/Gamepads/gamepad";
  44939. export * from "babylonjs/Gamepads/gamepadManager";
  44940. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44941. export * from "babylonjs/Gamepads/xboxGamepad";
  44942. }
  44943. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44944. import { Scene } from "babylonjs/scene";
  44945. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44946. import { Mesh } from "babylonjs/Meshes/mesh";
  44947. import { Nullable } from "babylonjs/types";
  44948. /**
  44949. * Class containing static functions to help procedurally build meshes
  44950. */
  44951. export class PolyhedronBuilder {
  44952. /**
  44953. * Creates a polyhedron mesh
  44954. * * 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
  44955. * * The parameter `size` (positive float, default 1) sets the polygon size
  44956. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44957. * * 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`
  44958. * * 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
  44959. * * 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)`)
  44960. * * 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
  44961. * * 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
  44962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44963. * * 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
  44964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44965. * @param name defines the name of the mesh
  44966. * @param options defines the options used to create the mesh
  44967. * @param scene defines the hosting scene
  44968. * @returns the polyhedron mesh
  44969. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44970. */
  44971. static CreatePolyhedron(name: string, options: {
  44972. type?: number;
  44973. size?: number;
  44974. sizeX?: number;
  44975. sizeY?: number;
  44976. sizeZ?: number;
  44977. custom?: any;
  44978. faceUV?: Vector4[];
  44979. faceColors?: Color4[];
  44980. flat?: boolean;
  44981. updatable?: boolean;
  44982. sideOrientation?: number;
  44983. frontUVs?: Vector4;
  44984. backUVs?: Vector4;
  44985. }, scene?: Nullable<Scene>): Mesh;
  44986. }
  44987. }
  44988. declare module "babylonjs/Gizmos/scaleGizmo" {
  44989. import { Observable } from "babylonjs/Misc/observable";
  44990. import { Nullable } from "babylonjs/types";
  44991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44992. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44993. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44994. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44995. /**
  44996. * Gizmo that enables scaling a mesh along 3 axis
  44997. */
  44998. export class ScaleGizmo extends Gizmo {
  44999. /**
  45000. * Internal gizmo used for interactions on the x axis
  45001. */
  45002. xGizmo: AxisScaleGizmo;
  45003. /**
  45004. * Internal gizmo used for interactions on the y axis
  45005. */
  45006. yGizmo: AxisScaleGizmo;
  45007. /**
  45008. * Internal gizmo used for interactions on the z axis
  45009. */
  45010. zGizmo: AxisScaleGizmo;
  45011. /**
  45012. * Internal gizmo used to scale all axis equally
  45013. */
  45014. uniformScaleGizmo: AxisScaleGizmo;
  45015. private _meshAttached;
  45016. private _updateGizmoRotationToMatchAttachedMesh;
  45017. private _snapDistance;
  45018. private _scaleRatio;
  45019. private _uniformScalingMesh;
  45020. private _octahedron;
  45021. /** Fires an event when any of it's sub gizmos are dragged */
  45022. onDragStartObservable: Observable<unknown>;
  45023. /** Fires an event when any of it's sub gizmos are released from dragging */
  45024. onDragEndObservable: Observable<unknown>;
  45025. attachedMesh: Nullable<AbstractMesh>;
  45026. /**
  45027. * Creates a ScaleGizmo
  45028. * @param gizmoLayer The utility layer the gizmo will be added to
  45029. */
  45030. constructor(gizmoLayer?: UtilityLayerRenderer);
  45031. updateGizmoRotationToMatchAttachedMesh: boolean;
  45032. /**
  45033. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45034. */
  45035. snapDistance: number;
  45036. /**
  45037. * Ratio for the scale of the gizmo (Default: 1)
  45038. */
  45039. scaleRatio: number;
  45040. /**
  45041. * Disposes of the gizmo
  45042. */
  45043. dispose(): void;
  45044. }
  45045. }
  45046. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  45047. import { Observable } from "babylonjs/Misc/observable";
  45048. import { Nullable } from "babylonjs/types";
  45049. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45051. import { Mesh } from "babylonjs/Meshes/mesh";
  45052. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45053. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45054. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45055. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45056. /**
  45057. * Single axis scale gizmo
  45058. */
  45059. export class AxisScaleGizmo extends Gizmo {
  45060. /**
  45061. * Drag behavior responsible for the gizmos dragging interactions
  45062. */
  45063. dragBehavior: PointerDragBehavior;
  45064. private _pointerObserver;
  45065. /**
  45066. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45067. */
  45068. snapDistance: number;
  45069. /**
  45070. * Event that fires each time the gizmo snaps to a new location.
  45071. * * snapDistance is the the change in distance
  45072. */
  45073. onSnapObservable: Observable<{
  45074. snapDistance: number;
  45075. }>;
  45076. /**
  45077. * If the scaling operation should be done on all axis (default: false)
  45078. */
  45079. uniformScaling: boolean;
  45080. private _isEnabled;
  45081. private _parent;
  45082. private _arrow;
  45083. private _coloredMaterial;
  45084. private _hoverMaterial;
  45085. /**
  45086. * Creates an AxisScaleGizmo
  45087. * @param gizmoLayer The utility layer the gizmo will be added to
  45088. * @param dragAxis The axis which the gizmo will be able to scale on
  45089. * @param color The color of the gizmo
  45090. */
  45091. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45092. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45093. /**
  45094. * If the gizmo is enabled
  45095. */
  45096. isEnabled: boolean;
  45097. /**
  45098. * Disposes of the gizmo
  45099. */
  45100. dispose(): void;
  45101. /**
  45102. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45103. * @param mesh The mesh to replace the default mesh of the gizmo
  45104. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45105. */
  45106. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45107. }
  45108. }
  45109. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  45110. import { Observable } from "babylonjs/Misc/observable";
  45111. import { Nullable } from "babylonjs/types";
  45112. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45114. import { Mesh } from "babylonjs/Meshes/mesh";
  45115. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45116. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45117. import "babylonjs/Meshes/Builders/boxBuilder";
  45118. /**
  45119. * Bounding box gizmo
  45120. */
  45121. export class BoundingBoxGizmo extends Gizmo {
  45122. private _lineBoundingBox;
  45123. private _rotateSpheresParent;
  45124. private _scaleBoxesParent;
  45125. private _boundingDimensions;
  45126. private _renderObserver;
  45127. private _pointerObserver;
  45128. private _scaleDragSpeed;
  45129. private _tmpQuaternion;
  45130. private _tmpVector;
  45131. private _tmpRotationMatrix;
  45132. /**
  45133. * 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)
  45134. */
  45135. ignoreChildren: boolean;
  45136. /**
  45137. * 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)
  45138. */
  45139. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45140. /**
  45141. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45142. */
  45143. rotationSphereSize: number;
  45144. /**
  45145. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45146. */
  45147. scaleBoxSize: number;
  45148. /**
  45149. * 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)
  45150. */
  45151. fixedDragMeshScreenSize: boolean;
  45152. /**
  45153. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45154. */
  45155. fixedDragMeshScreenSizeDistanceFactor: number;
  45156. /**
  45157. * Fired when a rotation sphere or scale box is dragged
  45158. */
  45159. onDragStartObservable: Observable<{}>;
  45160. /**
  45161. * Fired when a scale box is dragged
  45162. */
  45163. onScaleBoxDragObservable: Observable<{}>;
  45164. /**
  45165. * Fired when a scale box drag is ended
  45166. */
  45167. onScaleBoxDragEndObservable: Observable<{}>;
  45168. /**
  45169. * Fired when a rotation sphere is dragged
  45170. */
  45171. onRotationSphereDragObservable: Observable<{}>;
  45172. /**
  45173. * Fired when a rotation sphere drag is ended
  45174. */
  45175. onRotationSphereDragEndObservable: Observable<{}>;
  45176. /**
  45177. * 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)
  45178. */
  45179. scalePivot: Nullable<Vector3>;
  45180. /**
  45181. * Mesh used as a pivot to rotate the attached mesh
  45182. */
  45183. private _anchorMesh;
  45184. private _existingMeshScale;
  45185. private _dragMesh;
  45186. private pointerDragBehavior;
  45187. private coloredMaterial;
  45188. private hoverColoredMaterial;
  45189. /**
  45190. * Sets the color of the bounding box gizmo
  45191. * @param color the color to set
  45192. */
  45193. setColor(color: Color3): void;
  45194. /**
  45195. * Creates an BoundingBoxGizmo
  45196. * @param gizmoLayer The utility layer the gizmo will be added to
  45197. * @param color The color of the gizmo
  45198. */
  45199. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45200. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45201. private _selectNode;
  45202. /**
  45203. * Updates the bounding box information for the Gizmo
  45204. */
  45205. updateBoundingBox(): void;
  45206. private _updateRotationSpheres;
  45207. private _updateScaleBoxes;
  45208. /**
  45209. * Enables rotation on the specified axis and disables rotation on the others
  45210. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45211. */
  45212. setEnabledRotationAxis(axis: string): void;
  45213. /**
  45214. * Enables/disables scaling
  45215. * @param enable if scaling should be enabled
  45216. */
  45217. setEnabledScaling(enable: boolean): void;
  45218. private _updateDummy;
  45219. /**
  45220. * Enables a pointer drag behavior on the bounding box of the gizmo
  45221. */
  45222. enableDragBehavior(): void;
  45223. /**
  45224. * Disposes of the gizmo
  45225. */
  45226. dispose(): void;
  45227. /**
  45228. * 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)
  45229. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45230. * @returns the bounding box mesh with the passed in mesh as a child
  45231. */
  45232. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45233. /**
  45234. * CustomMeshes are not supported by this gizmo
  45235. * @param mesh The mesh to replace the default mesh of the gizmo
  45236. */
  45237. setCustomMesh(mesh: Mesh): void;
  45238. }
  45239. }
  45240. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45241. import { Observable } from "babylonjs/Misc/observable";
  45242. import { Nullable } from "babylonjs/types";
  45243. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45245. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45246. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45247. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45248. import "babylonjs/Meshes/Builders/linesBuilder";
  45249. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45250. /**
  45251. * Single plane rotation gizmo
  45252. */
  45253. export class PlaneRotationGizmo extends Gizmo {
  45254. /**
  45255. * Drag behavior responsible for the gizmos dragging interactions
  45256. */
  45257. dragBehavior: PointerDragBehavior;
  45258. private _pointerObserver;
  45259. /**
  45260. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45261. */
  45262. snapDistance: number;
  45263. /**
  45264. * Event that fires each time the gizmo snaps to a new location.
  45265. * * snapDistance is the the change in distance
  45266. */
  45267. onSnapObservable: Observable<{
  45268. snapDistance: number;
  45269. }>;
  45270. private _isEnabled;
  45271. private _parent;
  45272. /**
  45273. * Creates a PlaneRotationGizmo
  45274. * @param gizmoLayer The utility layer the gizmo will be added to
  45275. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45276. * @param color The color of the gizmo
  45277. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45278. */
  45279. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  45280. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45281. /**
  45282. * If the gizmo is enabled
  45283. */
  45284. isEnabled: boolean;
  45285. /**
  45286. * Disposes of the gizmo
  45287. */
  45288. dispose(): void;
  45289. }
  45290. }
  45291. declare module "babylonjs/Gizmos/rotationGizmo" {
  45292. import { Observable } from "babylonjs/Misc/observable";
  45293. import { Nullable } from "babylonjs/types";
  45294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45295. import { Mesh } from "babylonjs/Meshes/mesh";
  45296. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45297. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  45298. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45299. /**
  45300. * Gizmo that enables rotating a mesh along 3 axis
  45301. */
  45302. export class RotationGizmo extends Gizmo {
  45303. /**
  45304. * Internal gizmo used for interactions on the x axis
  45305. */
  45306. xGizmo: PlaneRotationGizmo;
  45307. /**
  45308. * Internal gizmo used for interactions on the y axis
  45309. */
  45310. yGizmo: PlaneRotationGizmo;
  45311. /**
  45312. * Internal gizmo used for interactions on the z axis
  45313. */
  45314. zGizmo: PlaneRotationGizmo;
  45315. /** Fires an event when any of it's sub gizmos are dragged */
  45316. onDragStartObservable: Observable<unknown>;
  45317. /** Fires an event when any of it's sub gizmos are released from dragging */
  45318. onDragEndObservable: Observable<unknown>;
  45319. private _meshAttached;
  45320. attachedMesh: Nullable<AbstractMesh>;
  45321. /**
  45322. * Creates a RotationGizmo
  45323. * @param gizmoLayer The utility layer the gizmo will be added to
  45324. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45325. */
  45326. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  45327. updateGizmoRotationToMatchAttachedMesh: boolean;
  45328. /**
  45329. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45330. */
  45331. snapDistance: number;
  45332. /**
  45333. * Ratio for the scale of the gizmo (Default: 1)
  45334. */
  45335. scaleRatio: number;
  45336. /**
  45337. * Disposes of the gizmo
  45338. */
  45339. dispose(): void;
  45340. /**
  45341. * CustomMeshes are not supported by this gizmo
  45342. * @param mesh The mesh to replace the default mesh of the gizmo
  45343. */
  45344. setCustomMesh(mesh: Mesh): void;
  45345. }
  45346. }
  45347. declare module "babylonjs/Gizmos/gizmoManager" {
  45348. import { Observable } from "babylonjs/Misc/observable";
  45349. import { Nullable } from "babylonjs/types";
  45350. import { Scene, IDisposable } from "babylonjs/scene";
  45351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45352. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45353. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45354. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45355. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45356. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45357. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  45358. /**
  45359. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45360. */
  45361. export class GizmoManager implements IDisposable {
  45362. private scene;
  45363. /**
  45364. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45365. */
  45366. gizmos: {
  45367. positionGizmo: Nullable<PositionGizmo>;
  45368. rotationGizmo: Nullable<RotationGizmo>;
  45369. scaleGizmo: Nullable<ScaleGizmo>;
  45370. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45371. };
  45372. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45373. clearGizmoOnEmptyPointerEvent: boolean;
  45374. /** Fires an event when the manager is attached to a mesh */
  45375. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45376. private _gizmosEnabled;
  45377. private _pointerObserver;
  45378. private _attachedMesh;
  45379. private _boundingBoxColor;
  45380. private _defaultUtilityLayer;
  45381. private _defaultKeepDepthUtilityLayer;
  45382. /**
  45383. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45384. */
  45385. boundingBoxDragBehavior: SixDofDragBehavior;
  45386. /**
  45387. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45388. */
  45389. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45390. /**
  45391. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45392. */
  45393. usePointerToAttachGizmos: boolean;
  45394. /**
  45395. * Utility layer that the bounding box gizmo belongs to
  45396. */
  45397. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45398. /**
  45399. * Utility layer that all gizmos besides bounding box belong to
  45400. */
  45401. readonly utilityLayer: UtilityLayerRenderer;
  45402. /**
  45403. * Instatiates a gizmo manager
  45404. * @param scene the scene to overlay the gizmos on top of
  45405. */
  45406. constructor(scene: Scene);
  45407. /**
  45408. * Attaches a set of gizmos to the specified mesh
  45409. * @param mesh The mesh the gizmo's should be attached to
  45410. */
  45411. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45412. /**
  45413. * If the position gizmo is enabled
  45414. */
  45415. positionGizmoEnabled: boolean;
  45416. /**
  45417. * If the rotation gizmo is enabled
  45418. */
  45419. rotationGizmoEnabled: boolean;
  45420. /**
  45421. * If the scale gizmo is enabled
  45422. */
  45423. scaleGizmoEnabled: boolean;
  45424. /**
  45425. * If the boundingBox gizmo is enabled
  45426. */
  45427. boundingBoxGizmoEnabled: boolean;
  45428. /**
  45429. * Disposes of the gizmo manager
  45430. */
  45431. dispose(): void;
  45432. }
  45433. }
  45434. declare module "babylonjs/Lights/directionalLight" {
  45435. import { Camera } from "babylonjs/Cameras/camera";
  45436. import { Scene } from "babylonjs/scene";
  45437. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45439. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45440. import { Effect } from "babylonjs/Materials/effect";
  45441. /**
  45442. * A directional light is defined by a direction (what a surprise!).
  45443. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45444. * 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.
  45445. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45446. */
  45447. export class DirectionalLight extends ShadowLight {
  45448. private _shadowFrustumSize;
  45449. /**
  45450. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45451. */
  45452. /**
  45453. * Specifies a fix frustum size for the shadow generation.
  45454. */
  45455. shadowFrustumSize: number;
  45456. private _shadowOrthoScale;
  45457. /**
  45458. * Gets the shadow projection scale against the optimal computed one.
  45459. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45460. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45461. */
  45462. /**
  45463. * Sets the shadow projection scale against the optimal computed one.
  45464. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45465. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45466. */
  45467. shadowOrthoScale: number;
  45468. /**
  45469. * Automatically compute the projection matrix to best fit (including all the casters)
  45470. * on each frame.
  45471. */
  45472. autoUpdateExtends: boolean;
  45473. private _orthoLeft;
  45474. private _orthoRight;
  45475. private _orthoTop;
  45476. private _orthoBottom;
  45477. /**
  45478. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45479. * The directional light is emitted from everywhere in the given direction.
  45480. * It can cast shadows.
  45481. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45482. * @param name The friendly name of the light
  45483. * @param direction The direction of the light
  45484. * @param scene The scene the light belongs to
  45485. */
  45486. constructor(name: string, direction: Vector3, scene: Scene);
  45487. /**
  45488. * Returns the string "DirectionalLight".
  45489. * @return The class name
  45490. */
  45491. getClassName(): string;
  45492. /**
  45493. * Returns the integer 1.
  45494. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45495. */
  45496. getTypeID(): number;
  45497. /**
  45498. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45499. * Returns the DirectionalLight Shadow projection matrix.
  45500. */
  45501. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45502. /**
  45503. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45504. * Returns the DirectionalLight Shadow projection matrix.
  45505. */
  45506. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45507. /**
  45508. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45509. * Returns the DirectionalLight Shadow projection matrix.
  45510. */
  45511. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45512. protected _buildUniformLayout(): void;
  45513. /**
  45514. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45515. * @param effect The effect to update
  45516. * @param lightIndex The index of the light in the effect to update
  45517. * @returns The directional light
  45518. */
  45519. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45520. /**
  45521. * Gets the minZ used for shadow according to both the scene and the light.
  45522. *
  45523. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45524. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45525. * @param activeCamera The camera we are returning the min for
  45526. * @returns the depth min z
  45527. */
  45528. getDepthMinZ(activeCamera: Camera): number;
  45529. /**
  45530. * Gets the maxZ used for shadow according to both the scene and the light.
  45531. *
  45532. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45533. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45534. * @param activeCamera The camera we are returning the max for
  45535. * @returns the depth max z
  45536. */
  45537. getDepthMaxZ(activeCamera: Camera): number;
  45538. /**
  45539. * Prepares the list of defines specific to the light type.
  45540. * @param defines the list of defines
  45541. * @param lightIndex defines the index of the light for the effect
  45542. */
  45543. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45544. }
  45545. }
  45546. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45547. import { Mesh } from "babylonjs/Meshes/mesh";
  45548. /**
  45549. * Class containing static functions to help procedurally build meshes
  45550. */
  45551. export class HemisphereBuilder {
  45552. /**
  45553. * Creates a hemisphere mesh
  45554. * @param name defines the name of the mesh
  45555. * @param options defines the options used to create the mesh
  45556. * @param scene defines the hosting scene
  45557. * @returns the hemisphere mesh
  45558. */
  45559. static CreateHemisphere(name: string, options: {
  45560. segments?: number;
  45561. diameter?: number;
  45562. sideOrientation?: number;
  45563. }, scene: any): Mesh;
  45564. }
  45565. }
  45566. declare module "babylonjs/Lights/spotLight" {
  45567. import { Nullable } from "babylonjs/types";
  45568. import { Scene } from "babylonjs/scene";
  45569. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45571. import { Effect } from "babylonjs/Materials/effect";
  45572. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45573. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45574. /**
  45575. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45576. * These values define a cone of light starting from the position, emitting toward the direction.
  45577. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45578. * and the exponent defines the speed of the decay of the light with distance (reach).
  45579. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45580. */
  45581. export class SpotLight extends ShadowLight {
  45582. private _angle;
  45583. private _innerAngle;
  45584. private _cosHalfAngle;
  45585. private _lightAngleScale;
  45586. private _lightAngleOffset;
  45587. /**
  45588. * Gets the cone angle of the spot light in Radians.
  45589. */
  45590. /**
  45591. * Sets the cone angle of the spot light in Radians.
  45592. */
  45593. angle: number;
  45594. /**
  45595. * Only used in gltf falloff mode, this defines the angle where
  45596. * the directional falloff will start before cutting at angle which could be seen
  45597. * as outer angle.
  45598. */
  45599. /**
  45600. * Only used in gltf falloff mode, this defines the angle where
  45601. * the directional falloff will start before cutting at angle which could be seen
  45602. * as outer angle.
  45603. */
  45604. innerAngle: number;
  45605. private _shadowAngleScale;
  45606. /**
  45607. * Allows scaling the angle of the light for shadow generation only.
  45608. */
  45609. /**
  45610. * Allows scaling the angle of the light for shadow generation only.
  45611. */
  45612. shadowAngleScale: number;
  45613. /**
  45614. * The light decay speed with the distance from the emission spot.
  45615. */
  45616. exponent: number;
  45617. private _projectionTextureMatrix;
  45618. /**
  45619. * Allows reading the projecton texture
  45620. */
  45621. readonly projectionTextureMatrix: Matrix;
  45622. protected _projectionTextureLightNear: number;
  45623. /**
  45624. * Gets the near clip of the Spotlight for texture projection.
  45625. */
  45626. /**
  45627. * Sets the near clip of the Spotlight for texture projection.
  45628. */
  45629. projectionTextureLightNear: number;
  45630. protected _projectionTextureLightFar: number;
  45631. /**
  45632. * Gets the far clip of the Spotlight for texture projection.
  45633. */
  45634. /**
  45635. * Sets the far clip of the Spotlight for texture projection.
  45636. */
  45637. projectionTextureLightFar: number;
  45638. protected _projectionTextureUpDirection: Vector3;
  45639. /**
  45640. * Gets the Up vector of the Spotlight for texture projection.
  45641. */
  45642. /**
  45643. * Sets the Up vector of the Spotlight for texture projection.
  45644. */
  45645. projectionTextureUpDirection: Vector3;
  45646. private _projectionTexture;
  45647. /**
  45648. * Gets the projection texture of the light.
  45649. */
  45650. /**
  45651. * Sets the projection texture of the light.
  45652. */
  45653. projectionTexture: Nullable<BaseTexture>;
  45654. private _projectionTextureViewLightDirty;
  45655. private _projectionTextureProjectionLightDirty;
  45656. private _projectionTextureDirty;
  45657. private _projectionTextureViewTargetVector;
  45658. private _projectionTextureViewLightMatrix;
  45659. private _projectionTextureProjectionLightMatrix;
  45660. private _projectionTextureScalingMatrix;
  45661. /**
  45662. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45663. * It can cast shadows.
  45664. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45665. * @param name The light friendly name
  45666. * @param position The position of the spot light in the scene
  45667. * @param direction The direction of the light in the scene
  45668. * @param angle The cone angle of the light in Radians
  45669. * @param exponent The light decay speed with the distance from the emission spot
  45670. * @param scene The scene the lights belongs to
  45671. */
  45672. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45673. /**
  45674. * Returns the string "SpotLight".
  45675. * @returns the class name
  45676. */
  45677. getClassName(): string;
  45678. /**
  45679. * Returns the integer 2.
  45680. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45681. */
  45682. getTypeID(): number;
  45683. /**
  45684. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45685. */
  45686. protected _setDirection(value: Vector3): void;
  45687. /**
  45688. * Overrides the position setter to recompute the projection texture view light Matrix.
  45689. */
  45690. protected _setPosition(value: Vector3): void;
  45691. /**
  45692. * 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.
  45693. * Returns the SpotLight.
  45694. */
  45695. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45696. protected _computeProjectionTextureViewLightMatrix(): void;
  45697. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45698. /**
  45699. * Main function for light texture projection matrix computing.
  45700. */
  45701. protected _computeProjectionTextureMatrix(): void;
  45702. protected _buildUniformLayout(): void;
  45703. private _computeAngleValues;
  45704. /**
  45705. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45706. * @param effect The effect to update
  45707. * @param lightIndex The index of the light in the effect to update
  45708. * @returns The spot light
  45709. */
  45710. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45711. /**
  45712. * Disposes the light and the associated resources.
  45713. */
  45714. dispose(): void;
  45715. /**
  45716. * Prepares the list of defines specific to the light type.
  45717. * @param defines the list of defines
  45718. * @param lightIndex defines the index of the light for the effect
  45719. */
  45720. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45721. }
  45722. }
  45723. declare module "babylonjs/Gizmos/lightGizmo" {
  45724. import { Nullable } from "babylonjs/types";
  45725. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45726. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45727. import { Light } from "babylonjs/Lights/light";
  45728. /**
  45729. * Gizmo that enables viewing a light
  45730. */
  45731. export class LightGizmo extends Gizmo {
  45732. private _lightMesh;
  45733. private _material;
  45734. private cachedPosition;
  45735. private cachedForward;
  45736. /**
  45737. * Creates a LightGizmo
  45738. * @param gizmoLayer The utility layer the gizmo will be added to
  45739. */
  45740. constructor(gizmoLayer?: UtilityLayerRenderer);
  45741. private _light;
  45742. /**
  45743. * The light that the gizmo is attached to
  45744. */
  45745. light: Nullable<Light>;
  45746. /**
  45747. * @hidden
  45748. * Updates the gizmo to match the attached mesh's position/rotation
  45749. */
  45750. protected _update(): void;
  45751. private static _Scale;
  45752. /**
  45753. * Creates the lines for a light mesh
  45754. */
  45755. private static _createLightLines;
  45756. /**
  45757. * Disposes of the light gizmo
  45758. */
  45759. dispose(): void;
  45760. private static _CreateHemisphericLightMesh;
  45761. private static _CreatePointLightMesh;
  45762. private static _CreateSpotLightMesh;
  45763. private static _CreateDirectionalLightMesh;
  45764. }
  45765. }
  45766. declare module "babylonjs/Gizmos/index" {
  45767. export * from "babylonjs/Gizmos/axisDragGizmo";
  45768. export * from "babylonjs/Gizmos/axisScaleGizmo";
  45769. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  45770. export * from "babylonjs/Gizmos/gizmo";
  45771. export * from "babylonjs/Gizmos/gizmoManager";
  45772. export * from "babylonjs/Gizmos/planeRotationGizmo";
  45773. export * from "babylonjs/Gizmos/positionGizmo";
  45774. export * from "babylonjs/Gizmos/rotationGizmo";
  45775. export * from "babylonjs/Gizmos/scaleGizmo";
  45776. export * from "babylonjs/Gizmos/lightGizmo";
  45777. }
  45778. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  45779. /** @hidden */
  45780. export var backgroundFragmentDeclaration: {
  45781. name: string;
  45782. shader: string;
  45783. };
  45784. }
  45785. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  45786. /** @hidden */
  45787. export var backgroundUboDeclaration: {
  45788. name: string;
  45789. shader: string;
  45790. };
  45791. }
  45792. declare module "babylonjs/Shaders/background.fragment" {
  45793. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  45794. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45795. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45796. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45797. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45798. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45799. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45800. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45801. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45802. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45803. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45804. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45805. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45806. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45807. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45808. /** @hidden */
  45809. export var backgroundPixelShader: {
  45810. name: string;
  45811. shader: string;
  45812. };
  45813. }
  45814. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45815. /** @hidden */
  45816. export var backgroundVertexDeclaration: {
  45817. name: string;
  45818. shader: string;
  45819. };
  45820. }
  45821. declare module "babylonjs/Shaders/background.vertex" {
  45822. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45823. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45824. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45825. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45826. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45827. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45828. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45829. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45830. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45831. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45832. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45833. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45834. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45835. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45836. /** @hidden */
  45837. export var backgroundVertexShader: {
  45838. name: string;
  45839. shader: string;
  45840. };
  45841. }
  45842. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45843. import { Nullable, int, float } from "babylonjs/types";
  45844. import { Scene } from "babylonjs/scene";
  45845. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45846. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45847. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45848. import { Mesh } from "babylonjs/Meshes/mesh";
  45849. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45850. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45851. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45852. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45853. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45854. import "babylonjs/Shaders/background.fragment";
  45855. import "babylonjs/Shaders/background.vertex";
  45856. /**
  45857. * Background material used to create an efficient environement around your scene.
  45858. */
  45859. export class BackgroundMaterial extends PushMaterial {
  45860. /**
  45861. * Standard reflectance value at parallel view angle.
  45862. */
  45863. static StandardReflectance0: number;
  45864. /**
  45865. * Standard reflectance value at grazing angle.
  45866. */
  45867. static StandardReflectance90: number;
  45868. protected _primaryColor: Color3;
  45869. /**
  45870. * Key light Color (multiply against the environement texture)
  45871. */
  45872. primaryColor: Color3;
  45873. protected __perceptualColor: Nullable<Color3>;
  45874. /**
  45875. * Experimental Internal Use Only.
  45876. *
  45877. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45878. * This acts as a helper to set the primary color to a more "human friendly" value.
  45879. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45880. * output color as close as possible from the chosen value.
  45881. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45882. * part of lighting setup.)
  45883. */
  45884. _perceptualColor: Nullable<Color3>;
  45885. protected _primaryColorShadowLevel: float;
  45886. /**
  45887. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45888. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45889. */
  45890. primaryColorShadowLevel: float;
  45891. protected _primaryColorHighlightLevel: float;
  45892. /**
  45893. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45894. * The primary color is used at the level chosen to define what the white area would look.
  45895. */
  45896. primaryColorHighlightLevel: float;
  45897. protected _reflectionTexture: Nullable<BaseTexture>;
  45898. /**
  45899. * Reflection Texture used in the material.
  45900. * Should be author in a specific way for the best result (refer to the documentation).
  45901. */
  45902. reflectionTexture: Nullable<BaseTexture>;
  45903. protected _reflectionBlur: float;
  45904. /**
  45905. * Reflection Texture level of blur.
  45906. *
  45907. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45908. * texture twice.
  45909. */
  45910. reflectionBlur: float;
  45911. protected _diffuseTexture: Nullable<BaseTexture>;
  45912. /**
  45913. * Diffuse Texture used in the material.
  45914. * Should be author in a specific way for the best result (refer to the documentation).
  45915. */
  45916. diffuseTexture: Nullable<BaseTexture>;
  45917. protected _shadowLights: Nullable<IShadowLight[]>;
  45918. /**
  45919. * Specify the list of lights casting shadow on the material.
  45920. * All scene shadow lights will be included if null.
  45921. */
  45922. shadowLights: Nullable<IShadowLight[]>;
  45923. protected _shadowLevel: float;
  45924. /**
  45925. * Helps adjusting the shadow to a softer level if required.
  45926. * 0 means black shadows and 1 means no shadows.
  45927. */
  45928. shadowLevel: float;
  45929. protected _sceneCenter: Vector3;
  45930. /**
  45931. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45932. * It is usually zero but might be interesting to modify according to your setup.
  45933. */
  45934. sceneCenter: Vector3;
  45935. protected _opacityFresnel: boolean;
  45936. /**
  45937. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45938. * This helps ensuring a nice transition when the camera goes under the ground.
  45939. */
  45940. opacityFresnel: boolean;
  45941. protected _reflectionFresnel: boolean;
  45942. /**
  45943. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45944. * This helps adding a mirror texture on the ground.
  45945. */
  45946. reflectionFresnel: boolean;
  45947. protected _reflectionFalloffDistance: number;
  45948. /**
  45949. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45950. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45951. */
  45952. reflectionFalloffDistance: number;
  45953. protected _reflectionAmount: number;
  45954. /**
  45955. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45956. */
  45957. reflectionAmount: number;
  45958. protected _reflectionReflectance0: number;
  45959. /**
  45960. * This specifies the weight of the reflection at grazing angle.
  45961. */
  45962. reflectionReflectance0: number;
  45963. protected _reflectionReflectance90: number;
  45964. /**
  45965. * This specifies the weight of the reflection at a perpendicular point of view.
  45966. */
  45967. reflectionReflectance90: number;
  45968. /**
  45969. * Sets the reflection reflectance fresnel values according to the default standard
  45970. * empirically know to work well :-)
  45971. */
  45972. reflectionStandardFresnelWeight: number;
  45973. protected _useRGBColor: boolean;
  45974. /**
  45975. * Helps to directly use the maps channels instead of their level.
  45976. */
  45977. useRGBColor: boolean;
  45978. protected _enableNoise: boolean;
  45979. /**
  45980. * This helps reducing the banding effect that could occur on the background.
  45981. */
  45982. enableNoise: boolean;
  45983. /**
  45984. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45985. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45986. * Recommended to be keep at 1.0 except for special cases.
  45987. */
  45988. fovMultiplier: number;
  45989. private _fovMultiplier;
  45990. /**
  45991. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45992. */
  45993. useEquirectangularFOV: boolean;
  45994. private _maxSimultaneousLights;
  45995. /**
  45996. * Number of Simultaneous lights allowed on the material.
  45997. */
  45998. maxSimultaneousLights: int;
  45999. /**
  46000. * Default configuration related to image processing available in the Background Material.
  46001. */
  46002. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46003. /**
  46004. * Keep track of the image processing observer to allow dispose and replace.
  46005. */
  46006. private _imageProcessingObserver;
  46007. /**
  46008. * Attaches a new image processing configuration to the PBR Material.
  46009. * @param configuration (if null the scene configuration will be use)
  46010. */
  46011. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46012. /**
  46013. * Gets the image processing configuration used either in this material.
  46014. */
  46015. /**
  46016. * Sets the Default image processing configuration used either in the this material.
  46017. *
  46018. * If sets to null, the scene one is in use.
  46019. */
  46020. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46021. /**
  46022. * Gets wether the color curves effect is enabled.
  46023. */
  46024. /**
  46025. * Sets wether the color curves effect is enabled.
  46026. */
  46027. cameraColorCurvesEnabled: boolean;
  46028. /**
  46029. * Gets wether the color grading effect is enabled.
  46030. */
  46031. /**
  46032. * Gets wether the color grading effect is enabled.
  46033. */
  46034. cameraColorGradingEnabled: boolean;
  46035. /**
  46036. * Gets wether tonemapping is enabled or not.
  46037. */
  46038. /**
  46039. * Sets wether tonemapping is enabled or not
  46040. */
  46041. cameraToneMappingEnabled: boolean;
  46042. /**
  46043. * The camera exposure used on this material.
  46044. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46045. * This corresponds to a photographic exposure.
  46046. */
  46047. /**
  46048. * The camera exposure used on this material.
  46049. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46050. * This corresponds to a photographic exposure.
  46051. */
  46052. cameraExposure: float;
  46053. /**
  46054. * Gets The camera contrast used on this material.
  46055. */
  46056. /**
  46057. * Sets The camera contrast used on this material.
  46058. */
  46059. cameraContrast: float;
  46060. /**
  46061. * Gets the Color Grading 2D Lookup Texture.
  46062. */
  46063. /**
  46064. * Sets the Color Grading 2D Lookup Texture.
  46065. */
  46066. cameraColorGradingTexture: Nullable<BaseTexture>;
  46067. /**
  46068. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46069. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46070. * 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;
  46071. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46072. */
  46073. /**
  46074. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46075. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46076. * 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;
  46077. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46078. */
  46079. cameraColorCurves: Nullable<ColorCurves>;
  46080. /**
  46081. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46082. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46083. */
  46084. switchToBGR: boolean;
  46085. private _renderTargets;
  46086. private _reflectionControls;
  46087. private _white;
  46088. private _primaryShadowColor;
  46089. private _primaryHighlightColor;
  46090. /**
  46091. * Instantiates a Background Material in the given scene
  46092. * @param name The friendly name of the material
  46093. * @param scene The scene to add the material to
  46094. */
  46095. constructor(name: string, scene: Scene);
  46096. /**
  46097. * Gets a boolean indicating that current material needs to register RTT
  46098. */
  46099. readonly hasRenderTargetTextures: boolean;
  46100. /**
  46101. * The entire material has been created in order to prevent overdraw.
  46102. * @returns false
  46103. */
  46104. needAlphaTesting(): boolean;
  46105. /**
  46106. * The entire material has been created in order to prevent overdraw.
  46107. * @returns true if blending is enable
  46108. */
  46109. needAlphaBlending(): boolean;
  46110. /**
  46111. * Checks wether the material is ready to be rendered for a given mesh.
  46112. * @param mesh The mesh to render
  46113. * @param subMesh The submesh to check against
  46114. * @param useInstances Specify wether or not the material is used with instances
  46115. * @returns true if all the dependencies are ready (Textures, Effects...)
  46116. */
  46117. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46118. /**
  46119. * Compute the primary color according to the chosen perceptual color.
  46120. */
  46121. private _computePrimaryColorFromPerceptualColor;
  46122. /**
  46123. * Compute the highlights and shadow colors according to their chosen levels.
  46124. */
  46125. private _computePrimaryColors;
  46126. /**
  46127. * Build the uniform buffer used in the material.
  46128. */
  46129. buildUniformLayout(): void;
  46130. /**
  46131. * Unbind the material.
  46132. */
  46133. unbind(): void;
  46134. /**
  46135. * Bind only the world matrix to the material.
  46136. * @param world The world matrix to bind.
  46137. */
  46138. bindOnlyWorldMatrix(world: Matrix): void;
  46139. /**
  46140. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46141. * @param world The world matrix to bind.
  46142. * @param subMesh The submesh to bind for.
  46143. */
  46144. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46145. /**
  46146. * Dispose the material.
  46147. * @param forceDisposeEffect Force disposal of the associated effect.
  46148. * @param forceDisposeTextures Force disposal of the associated textures.
  46149. */
  46150. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46151. /**
  46152. * Clones the material.
  46153. * @param name The cloned name.
  46154. * @returns The cloned material.
  46155. */
  46156. clone(name: string): BackgroundMaterial;
  46157. /**
  46158. * Serializes the current material to its JSON representation.
  46159. * @returns The JSON representation.
  46160. */
  46161. serialize(): any;
  46162. /**
  46163. * Gets the class name of the material
  46164. * @returns "BackgroundMaterial"
  46165. */
  46166. getClassName(): string;
  46167. /**
  46168. * Parse a JSON input to create back a background material.
  46169. * @param source The JSON data to parse
  46170. * @param scene The scene to create the parsed material in
  46171. * @param rootUrl The root url of the assets the material depends upon
  46172. * @returns the instantiated BackgroundMaterial.
  46173. */
  46174. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46175. }
  46176. }
  46177. declare module "babylonjs/Helpers/environmentHelper" {
  46178. import { Observable } from "babylonjs/Misc/observable";
  46179. import { Nullable } from "babylonjs/types";
  46180. import { Scene } from "babylonjs/scene";
  46181. import { Vector3, Color3 } from "babylonjs/Maths/math";
  46182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46183. import { Mesh } from "babylonjs/Meshes/mesh";
  46184. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46185. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46186. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46187. import "babylonjs/Meshes/Builders/planeBuilder";
  46188. import "babylonjs/Meshes/Builders/boxBuilder";
  46189. /**
  46190. * Represents the different options available during the creation of
  46191. * a Environment helper.
  46192. *
  46193. * This can control the default ground, skybox and image processing setup of your scene.
  46194. */
  46195. export interface IEnvironmentHelperOptions {
  46196. /**
  46197. * Specifies wether or not to create a ground.
  46198. * True by default.
  46199. */
  46200. createGround: boolean;
  46201. /**
  46202. * Specifies the ground size.
  46203. * 15 by default.
  46204. */
  46205. groundSize: number;
  46206. /**
  46207. * The texture used on the ground for the main color.
  46208. * Comes from the BabylonJS CDN by default.
  46209. *
  46210. * Remarks: Can be either a texture or a url.
  46211. */
  46212. groundTexture: string | BaseTexture;
  46213. /**
  46214. * The color mixed in the ground texture by default.
  46215. * BabylonJS clearColor by default.
  46216. */
  46217. groundColor: Color3;
  46218. /**
  46219. * Specifies the ground opacity.
  46220. * 1 by default.
  46221. */
  46222. groundOpacity: number;
  46223. /**
  46224. * Enables the ground to receive shadows.
  46225. * True by default.
  46226. */
  46227. enableGroundShadow: boolean;
  46228. /**
  46229. * Helps preventing the shadow to be fully black on the ground.
  46230. * 0.5 by default.
  46231. */
  46232. groundShadowLevel: number;
  46233. /**
  46234. * Creates a mirror texture attach to the ground.
  46235. * false by default.
  46236. */
  46237. enableGroundMirror: boolean;
  46238. /**
  46239. * Specifies the ground mirror size ratio.
  46240. * 0.3 by default as the default kernel is 64.
  46241. */
  46242. groundMirrorSizeRatio: number;
  46243. /**
  46244. * Specifies the ground mirror blur kernel size.
  46245. * 64 by default.
  46246. */
  46247. groundMirrorBlurKernel: number;
  46248. /**
  46249. * Specifies the ground mirror visibility amount.
  46250. * 1 by default
  46251. */
  46252. groundMirrorAmount: number;
  46253. /**
  46254. * Specifies the ground mirror reflectance weight.
  46255. * This uses the standard weight of the background material to setup the fresnel effect
  46256. * of the mirror.
  46257. * 1 by default.
  46258. */
  46259. groundMirrorFresnelWeight: number;
  46260. /**
  46261. * Specifies the ground mirror Falloff distance.
  46262. * This can helps reducing the size of the reflection.
  46263. * 0 by Default.
  46264. */
  46265. groundMirrorFallOffDistance: number;
  46266. /**
  46267. * Specifies the ground mirror texture type.
  46268. * Unsigned Int by Default.
  46269. */
  46270. groundMirrorTextureType: number;
  46271. /**
  46272. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46273. * the shown objects.
  46274. */
  46275. groundYBias: number;
  46276. /**
  46277. * Specifies wether or not to create a skybox.
  46278. * True by default.
  46279. */
  46280. createSkybox: boolean;
  46281. /**
  46282. * Specifies the skybox size.
  46283. * 20 by default.
  46284. */
  46285. skyboxSize: number;
  46286. /**
  46287. * The texture used on the skybox for the main color.
  46288. * Comes from the BabylonJS CDN by default.
  46289. *
  46290. * Remarks: Can be either a texture or a url.
  46291. */
  46292. skyboxTexture: string | BaseTexture;
  46293. /**
  46294. * The color mixed in the skybox texture by default.
  46295. * BabylonJS clearColor by default.
  46296. */
  46297. skyboxColor: Color3;
  46298. /**
  46299. * The background rotation around the Y axis of the scene.
  46300. * This helps aligning the key lights of your scene with the background.
  46301. * 0 by default.
  46302. */
  46303. backgroundYRotation: number;
  46304. /**
  46305. * Compute automatically the size of the elements to best fit with the scene.
  46306. */
  46307. sizeAuto: boolean;
  46308. /**
  46309. * Default position of the rootMesh if autoSize is not true.
  46310. */
  46311. rootPosition: Vector3;
  46312. /**
  46313. * Sets up the image processing in the scene.
  46314. * true by default.
  46315. */
  46316. setupImageProcessing: boolean;
  46317. /**
  46318. * The texture used as your environment texture in the scene.
  46319. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46320. *
  46321. * Remarks: Can be either a texture or a url.
  46322. */
  46323. environmentTexture: string | BaseTexture;
  46324. /**
  46325. * The value of the exposure to apply to the scene.
  46326. * 0.6 by default if setupImageProcessing is true.
  46327. */
  46328. cameraExposure: number;
  46329. /**
  46330. * The value of the contrast to apply to the scene.
  46331. * 1.6 by default if setupImageProcessing is true.
  46332. */
  46333. cameraContrast: number;
  46334. /**
  46335. * Specifies wether or not tonemapping should be enabled in the scene.
  46336. * true by default if setupImageProcessing is true.
  46337. */
  46338. toneMappingEnabled: boolean;
  46339. }
  46340. /**
  46341. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46342. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46343. * It also helps with the default setup of your imageProcessing configuration.
  46344. */
  46345. export class EnvironmentHelper {
  46346. /**
  46347. * Default ground texture URL.
  46348. */
  46349. private static _groundTextureCDNUrl;
  46350. /**
  46351. * Default skybox texture URL.
  46352. */
  46353. private static _skyboxTextureCDNUrl;
  46354. /**
  46355. * Default environment texture URL.
  46356. */
  46357. private static _environmentTextureCDNUrl;
  46358. /**
  46359. * Creates the default options for the helper.
  46360. */
  46361. private static _getDefaultOptions;
  46362. private _rootMesh;
  46363. /**
  46364. * Gets the root mesh created by the helper.
  46365. */
  46366. readonly rootMesh: Mesh;
  46367. private _skybox;
  46368. /**
  46369. * Gets the skybox created by the helper.
  46370. */
  46371. readonly skybox: Nullable<Mesh>;
  46372. private _skyboxTexture;
  46373. /**
  46374. * Gets the skybox texture created by the helper.
  46375. */
  46376. readonly skyboxTexture: Nullable<BaseTexture>;
  46377. private _skyboxMaterial;
  46378. /**
  46379. * Gets the skybox material created by the helper.
  46380. */
  46381. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46382. private _ground;
  46383. /**
  46384. * Gets the ground mesh created by the helper.
  46385. */
  46386. readonly ground: Nullable<Mesh>;
  46387. private _groundTexture;
  46388. /**
  46389. * Gets the ground texture created by the helper.
  46390. */
  46391. readonly groundTexture: Nullable<BaseTexture>;
  46392. private _groundMirror;
  46393. /**
  46394. * Gets the ground mirror created by the helper.
  46395. */
  46396. readonly groundMirror: Nullable<MirrorTexture>;
  46397. /**
  46398. * Gets the ground mirror render list to helps pushing the meshes
  46399. * you wish in the ground reflection.
  46400. */
  46401. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46402. private _groundMaterial;
  46403. /**
  46404. * Gets the ground material created by the helper.
  46405. */
  46406. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46407. /**
  46408. * Stores the creation options.
  46409. */
  46410. private readonly _scene;
  46411. private _options;
  46412. /**
  46413. * This observable will be notified with any error during the creation of the environment,
  46414. * mainly texture creation errors.
  46415. */
  46416. onErrorObservable: Observable<{
  46417. message?: string;
  46418. exception?: any;
  46419. }>;
  46420. /**
  46421. * constructor
  46422. * @param options Defines the options we want to customize the helper
  46423. * @param scene The scene to add the material to
  46424. */
  46425. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46426. /**
  46427. * Updates the background according to the new options
  46428. * @param options
  46429. */
  46430. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46431. /**
  46432. * Sets the primary color of all the available elements.
  46433. * @param color the main color to affect to the ground and the background
  46434. */
  46435. setMainColor(color: Color3): void;
  46436. /**
  46437. * Setup the image processing according to the specified options.
  46438. */
  46439. private _setupImageProcessing;
  46440. /**
  46441. * Setup the environment texture according to the specified options.
  46442. */
  46443. private _setupEnvironmentTexture;
  46444. /**
  46445. * Setup the background according to the specified options.
  46446. */
  46447. private _setupBackground;
  46448. /**
  46449. * Get the scene sizes according to the setup.
  46450. */
  46451. private _getSceneSize;
  46452. /**
  46453. * Setup the ground according to the specified options.
  46454. */
  46455. private _setupGround;
  46456. /**
  46457. * Setup the ground material according to the specified options.
  46458. */
  46459. private _setupGroundMaterial;
  46460. /**
  46461. * Setup the ground diffuse texture according to the specified options.
  46462. */
  46463. private _setupGroundDiffuseTexture;
  46464. /**
  46465. * Setup the ground mirror texture according to the specified options.
  46466. */
  46467. private _setupGroundMirrorTexture;
  46468. /**
  46469. * Setup the ground to receive the mirror texture.
  46470. */
  46471. private _setupMirrorInGroundMaterial;
  46472. /**
  46473. * Setup the skybox according to the specified options.
  46474. */
  46475. private _setupSkybox;
  46476. /**
  46477. * Setup the skybox material according to the specified options.
  46478. */
  46479. private _setupSkyboxMaterial;
  46480. /**
  46481. * Setup the skybox reflection texture according to the specified options.
  46482. */
  46483. private _setupSkyboxReflectionTexture;
  46484. private _errorHandler;
  46485. /**
  46486. * Dispose all the elements created by the Helper.
  46487. */
  46488. dispose(): void;
  46489. }
  46490. }
  46491. declare module "babylonjs/Helpers/photoDome" {
  46492. import { Observable } from "babylonjs/Misc/observable";
  46493. import { Nullable } from "babylonjs/types";
  46494. import { Scene } from "babylonjs/scene";
  46495. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46496. import { Mesh } from "babylonjs/Meshes/mesh";
  46497. import { Texture } from "babylonjs/Materials/Textures/texture";
  46498. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46499. import "babylonjs/Meshes/Builders/sphereBuilder";
  46500. /**
  46501. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46502. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46503. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46504. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46505. */
  46506. export class PhotoDome extends TransformNode {
  46507. /**
  46508. * Define the image as a Monoscopic panoramic 360 image.
  46509. */
  46510. static readonly MODE_MONOSCOPIC: number;
  46511. /**
  46512. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46513. */
  46514. static readonly MODE_TOPBOTTOM: number;
  46515. /**
  46516. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46517. */
  46518. static readonly MODE_SIDEBYSIDE: number;
  46519. private _useDirectMapping;
  46520. /**
  46521. * The texture being displayed on the sphere
  46522. */
  46523. protected _photoTexture: Texture;
  46524. /**
  46525. * Gets or sets the texture being displayed on the sphere
  46526. */
  46527. photoTexture: Texture;
  46528. /**
  46529. * Observable raised when an error occured while loading the 360 image
  46530. */
  46531. onLoadErrorObservable: Observable<string>;
  46532. /**
  46533. * The skybox material
  46534. */
  46535. protected _material: BackgroundMaterial;
  46536. /**
  46537. * The surface used for the skybox
  46538. */
  46539. protected _mesh: Mesh;
  46540. /**
  46541. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46542. * Also see the options.resolution property.
  46543. */
  46544. fovMultiplier: number;
  46545. private _imageMode;
  46546. /**
  46547. * Gets or set the current video mode for the video. It can be:
  46548. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46549. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46550. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46551. */
  46552. imageMode: number;
  46553. /**
  46554. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46555. * @param name Element's name, child elements will append suffixes for their own names.
  46556. * @param urlsOfPhoto defines the url of the photo to display
  46557. * @param options defines an object containing optional or exposed sub element properties
  46558. * @param onError defines a callback called when an error occured while loading the texture
  46559. */
  46560. constructor(name: string, urlOfPhoto: string, options: {
  46561. resolution?: number;
  46562. size?: number;
  46563. useDirectMapping?: boolean;
  46564. faceForward?: boolean;
  46565. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46566. private _onBeforeCameraRenderObserver;
  46567. private _changeImageMode;
  46568. /**
  46569. * Releases resources associated with this node.
  46570. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46571. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46572. */
  46573. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46574. }
  46575. }
  46576. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46577. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46578. /** @hidden */
  46579. export var rgbdDecodePixelShader: {
  46580. name: string;
  46581. shader: string;
  46582. };
  46583. }
  46584. declare module "babylonjs/Misc/brdfTextureTools" {
  46585. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46586. import { Scene } from "babylonjs/scene";
  46587. import "babylonjs/Shaders/rgbdDecode.fragment";
  46588. /**
  46589. * Class used to host texture specific utilities
  46590. */
  46591. export class BRDFTextureTools {
  46592. /**
  46593. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46594. * @param texture the texture to expand.
  46595. */
  46596. private static _ExpandDefaultBRDFTexture;
  46597. /**
  46598. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46599. * @param scene defines the hosting scene
  46600. * @returns the environment BRDF texture
  46601. */
  46602. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46603. private static _environmentBRDFBase64Texture;
  46604. }
  46605. }
  46606. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  46607. import { Nullable } from "babylonjs/types";
  46608. import { IAnimatable } from "babylonjs/Misc/tools";
  46609. import { Color3 } from "babylonjs/Maths/math";
  46610. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46611. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46612. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46613. import { Engine } from "babylonjs/Engines/engine";
  46614. import { Scene } from "babylonjs/scene";
  46615. /**
  46616. * @hidden
  46617. */
  46618. export interface IMaterialClearCoatDefines {
  46619. CLEARCOAT: boolean;
  46620. CLEARCOAT_DEFAULTIOR: boolean;
  46621. CLEARCOAT_TEXTURE: boolean;
  46622. CLEARCOAT_TEXTUREDIRECTUV: number;
  46623. CLEARCOAT_BUMP: boolean;
  46624. CLEARCOAT_BUMPDIRECTUV: number;
  46625. CLEARCOAT_TINT: boolean;
  46626. CLEARCOAT_TINT_TEXTURE: boolean;
  46627. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46628. /** @hidden */
  46629. _areTexturesDirty: boolean;
  46630. }
  46631. /**
  46632. * Define the code related to the clear coat parameters of the pbr material.
  46633. */
  46634. export class PBRClearCoatConfiguration {
  46635. /**
  46636. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46637. * The default fits with a polyurethane material.
  46638. */
  46639. private static readonly _DefaultIndexOfRefraction;
  46640. private _isEnabled;
  46641. /**
  46642. * Defines if the clear coat is enabled in the material.
  46643. */
  46644. isEnabled: boolean;
  46645. /**
  46646. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46647. */
  46648. intensity: number;
  46649. /**
  46650. * Defines the clear coat layer roughness.
  46651. */
  46652. roughness: number;
  46653. private _indexOfRefraction;
  46654. /**
  46655. * Defines the index of refraction of the clear coat.
  46656. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46657. * The default fits with a polyurethane material.
  46658. * Changing the default value is more performance intensive.
  46659. */
  46660. indexOfRefraction: number;
  46661. private _texture;
  46662. /**
  46663. * Stores the clear coat values in a texture.
  46664. */
  46665. texture: Nullable<BaseTexture>;
  46666. private _bumpTexture;
  46667. /**
  46668. * Define the clear coat specific bump texture.
  46669. */
  46670. bumpTexture: Nullable<BaseTexture>;
  46671. private _isTintEnabled;
  46672. /**
  46673. * Defines if the clear coat tint is enabled in the material.
  46674. */
  46675. isTintEnabled: boolean;
  46676. /**
  46677. * Defines the clear coat tint of the material.
  46678. * This is only use if tint is enabled
  46679. */
  46680. tintColor: Color3;
  46681. /**
  46682. * Defines the distance at which the tint color should be found in the
  46683. * clear coat media.
  46684. * This is only use if tint is enabled
  46685. */
  46686. tintColorAtDistance: number;
  46687. /**
  46688. * Defines the clear coat layer thickness.
  46689. * This is only use if tint is enabled
  46690. */
  46691. tintThickness: number;
  46692. private _tintTexture;
  46693. /**
  46694. * Stores the clear tint values in a texture.
  46695. * rgb is tint
  46696. * a is a thickness factor
  46697. */
  46698. tintTexture: Nullable<BaseTexture>;
  46699. /** @hidden */
  46700. private _internalMarkAllSubMeshesAsTexturesDirty;
  46701. /** @hidden */
  46702. _markAllSubMeshesAsTexturesDirty(): void;
  46703. /**
  46704. * Instantiate a new istance of clear coat configuration.
  46705. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46706. */
  46707. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46708. /**
  46709. * Gets wehter the submesh is ready to be used or not.
  46710. * @param defines the list of "defines" to update.
  46711. * @param scene defines the scene the material belongs to.
  46712. * @param engine defines the engine the material belongs to.
  46713. * @param disableBumpMap defines wether the material disables bump or not.
  46714. * @returns - boolean indicating that the submesh is ready or not.
  46715. */
  46716. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46717. /**
  46718. * Checks to see if a texture is used in the material.
  46719. * @param defines the list of "defines" to update.
  46720. * @param scene defines the scene to the material belongs to.
  46721. */
  46722. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46723. /**
  46724. * Binds the material data.
  46725. * @param uniformBuffer defines the Uniform buffer to fill in.
  46726. * @param scene defines the scene the material belongs to.
  46727. * @param engine defines the engine the material belongs to.
  46728. * @param disableBumpMap defines wether the material disables bump or not.
  46729. * @param isFrozen defines wether the material is frozen or not.
  46730. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46731. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46732. */
  46733. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46734. /**
  46735. * Checks to see if a texture is used in the material.
  46736. * @param texture - Base texture to use.
  46737. * @returns - Boolean specifying if a texture is used in the material.
  46738. */
  46739. hasTexture(texture: BaseTexture): boolean;
  46740. /**
  46741. * Returns an array of the actively used textures.
  46742. * @param activeTextures Array of BaseTextures
  46743. */
  46744. getActiveTextures(activeTextures: BaseTexture[]): void;
  46745. /**
  46746. * Returns the animatable textures.
  46747. * @param animatables Array of animatable textures.
  46748. */
  46749. getAnimatables(animatables: IAnimatable[]): void;
  46750. /**
  46751. * Disposes the resources of the material.
  46752. * @param forceDisposeTextures - Forces the disposal of all textures.
  46753. */
  46754. dispose(forceDisposeTextures?: boolean): void;
  46755. /**
  46756. * Get the current class name of the texture useful for serialization or dynamic coding.
  46757. * @returns "PBRClearCoatConfiguration"
  46758. */
  46759. getClassName(): string;
  46760. /**
  46761. * Add fallbacks to the effect fallbacks list.
  46762. * @param defines defines the Base texture to use.
  46763. * @param fallbacks defines the current fallback list.
  46764. * @param currentRank defines the current fallback rank.
  46765. * @returns the new fallback rank.
  46766. */
  46767. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46768. /**
  46769. * Add the required uniforms to the current list.
  46770. * @param uniforms defines the current uniform list.
  46771. */
  46772. static AddUniforms(uniforms: string[]): void;
  46773. /**
  46774. * Add the required samplers to the current list.
  46775. * @param samplers defines the current sampler list.
  46776. */
  46777. static AddSamplers(samplers: string[]): void;
  46778. /**
  46779. * Add the required uniforms to the current buffer.
  46780. * @param uniformBuffer defines the current uniform buffer.
  46781. */
  46782. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46783. /**
  46784. * Makes a duplicate of the current configuration into another one.
  46785. * @param clearCoatConfiguration define the config where to copy the info
  46786. */
  46787. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46788. /**
  46789. * Serializes this clear coat configuration.
  46790. * @returns - An object with the serialized config.
  46791. */
  46792. serialize(): any;
  46793. /**
  46794. * Parses a anisotropy Configuration from a serialized object.
  46795. * @param source - Serialized object.
  46796. * @param scene Defines the scene we are parsing for
  46797. * @param rootUrl Defines the rootUrl to load from
  46798. */
  46799. parse(source: any, scene: Scene, rootUrl: string): void;
  46800. }
  46801. }
  46802. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  46803. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46804. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46806. import { Vector2 } from "babylonjs/Maths/math";
  46807. import { Scene } from "babylonjs/scene";
  46808. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46809. import { IAnimatable } from "babylonjs/Misc/tools";
  46810. import { Nullable } from "babylonjs/types";
  46811. /**
  46812. * @hidden
  46813. */
  46814. export interface IMaterialAnisotropicDefines {
  46815. ANISOTROPIC: boolean;
  46816. ANISOTROPIC_TEXTURE: boolean;
  46817. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46818. MAINUV1: boolean;
  46819. _areTexturesDirty: boolean;
  46820. _needUVs: boolean;
  46821. }
  46822. /**
  46823. * Define the code related to the anisotropic parameters of the pbr material.
  46824. */
  46825. export class PBRAnisotropicConfiguration {
  46826. private _isEnabled;
  46827. /**
  46828. * Defines if the anisotropy is enabled in the material.
  46829. */
  46830. isEnabled: boolean;
  46831. /**
  46832. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46833. */
  46834. intensity: number;
  46835. /**
  46836. * Defines if the effect is along the tangents, bitangents or in between.
  46837. * By default, the effect is "strectching" the highlights along the tangents.
  46838. */
  46839. direction: Vector2;
  46840. private _texture;
  46841. /**
  46842. * Stores the anisotropy values in a texture.
  46843. * rg is direction (like normal from -1 to 1)
  46844. * b is a intensity
  46845. */
  46846. texture: Nullable<BaseTexture>;
  46847. /** @hidden */
  46848. private _internalMarkAllSubMeshesAsTexturesDirty;
  46849. /** @hidden */
  46850. _markAllSubMeshesAsTexturesDirty(): void;
  46851. /**
  46852. * Instantiate a new istance of anisotropy configuration.
  46853. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46854. */
  46855. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46856. /**
  46857. * Specifies that the submesh is ready to be used.
  46858. * @param defines the list of "defines" to update.
  46859. * @param scene defines the scene the material belongs to.
  46860. * @returns - boolean indicating that the submesh is ready or not.
  46861. */
  46862. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46863. /**
  46864. * Checks to see if a texture is used in the material.
  46865. * @param defines the list of "defines" to update.
  46866. * @param mesh the mesh we are preparing the defines for.
  46867. * @param scene defines the scene the material belongs to.
  46868. */
  46869. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46870. /**
  46871. * Binds the material data.
  46872. * @param uniformBuffer defines the Uniform buffer to fill in.
  46873. * @param scene defines the scene the material belongs to.
  46874. * @param isFrozen defines wether the material is frozen or not.
  46875. */
  46876. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46877. /**
  46878. * Checks to see if a texture is used in the material.
  46879. * @param texture - Base texture to use.
  46880. * @returns - Boolean specifying if a texture is used in the material.
  46881. */
  46882. hasTexture(texture: BaseTexture): boolean;
  46883. /**
  46884. * Returns an array of the actively used textures.
  46885. * @param activeTextures Array of BaseTextures
  46886. */
  46887. getActiveTextures(activeTextures: BaseTexture[]): void;
  46888. /**
  46889. * Returns the animatable textures.
  46890. * @param animatables Array of animatable textures.
  46891. */
  46892. getAnimatables(animatables: IAnimatable[]): void;
  46893. /**
  46894. * Disposes the resources of the material.
  46895. * @param forceDisposeTextures - Forces the disposal of all textures.
  46896. */
  46897. dispose(forceDisposeTextures?: boolean): void;
  46898. /**
  46899. * Get the current class name of the texture useful for serialization or dynamic coding.
  46900. * @returns "PBRAnisotropicConfiguration"
  46901. */
  46902. getClassName(): string;
  46903. /**
  46904. * Add fallbacks to the effect fallbacks list.
  46905. * @param defines defines the Base texture to use.
  46906. * @param fallbacks defines the current fallback list.
  46907. * @param currentRank defines the current fallback rank.
  46908. * @returns the new fallback rank.
  46909. */
  46910. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46911. /**
  46912. * Add the required uniforms to the current list.
  46913. * @param uniforms defines the current uniform list.
  46914. */
  46915. static AddUniforms(uniforms: string[]): void;
  46916. /**
  46917. * Add the required uniforms to the current buffer.
  46918. * @param uniformBuffer defines the current uniform buffer.
  46919. */
  46920. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46921. /**
  46922. * Add the required samplers to the current list.
  46923. * @param samplers defines the current sampler list.
  46924. */
  46925. static AddSamplers(samplers: string[]): void;
  46926. /**
  46927. * Makes a duplicate of the current configuration into another one.
  46928. * @param anisotropicConfiguration define the config where to copy the info
  46929. */
  46930. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46931. /**
  46932. * Serializes this anisotropy configuration.
  46933. * @returns - An object with the serialized config.
  46934. */
  46935. serialize(): any;
  46936. /**
  46937. * Parses a anisotropy Configuration from a serialized object.
  46938. * @param source - Serialized object.
  46939. * @param scene Defines the scene we are parsing for
  46940. * @param rootUrl Defines the rootUrl to load from
  46941. */
  46942. parse(source: any, scene: Scene, rootUrl: string): void;
  46943. }
  46944. }
  46945. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46946. import { Scene } from "babylonjs/scene";
  46947. /**
  46948. * @hidden
  46949. */
  46950. export interface IMaterialBRDFDefines {
  46951. BRDF_V_HEIGHT_CORRELATED: boolean;
  46952. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46953. SPHERICAL_HARMONICS: boolean;
  46954. /** @hidden */
  46955. _areMiscDirty: boolean;
  46956. }
  46957. /**
  46958. * Define the code related to the BRDF parameters of the pbr material.
  46959. */
  46960. export class PBRBRDFConfiguration {
  46961. /**
  46962. * Default value used for the energy conservation.
  46963. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46964. */
  46965. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46966. /**
  46967. * Default value used for the Smith Visibility Height Correlated mode.
  46968. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46969. */
  46970. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46971. /**
  46972. * Default value used for the IBL diffuse part.
  46973. * This can help switching back to the polynomials mode globally which is a tiny bit
  46974. * less GPU intensive at the drawback of a lower quality.
  46975. */
  46976. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46977. private _useEnergyConservation;
  46978. /**
  46979. * Defines if the material uses energy conservation.
  46980. */
  46981. useEnergyConservation: boolean;
  46982. private _useSmithVisibilityHeightCorrelated;
  46983. /**
  46984. * LEGACY Mode set to false
  46985. * Defines if the material uses height smith correlated visibility term.
  46986. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46987. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46988. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46989. * Not relying on height correlated will also disable energy conservation.
  46990. */
  46991. useSmithVisibilityHeightCorrelated: boolean;
  46992. private _useSphericalHarmonics;
  46993. /**
  46994. * LEGACY Mode set to false
  46995. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46996. * diffuse part of the IBL.
  46997. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46998. * to the ground truth.
  46999. */
  47000. useSphericalHarmonics: boolean;
  47001. /** @hidden */
  47002. private _internalMarkAllSubMeshesAsMiscDirty;
  47003. /** @hidden */
  47004. _markAllSubMeshesAsMiscDirty(): void;
  47005. /**
  47006. * Instantiate a new istance of clear coat configuration.
  47007. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47008. */
  47009. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47010. /**
  47011. * Checks to see if a texture is used in the material.
  47012. * @param defines the list of "defines" to update.
  47013. */
  47014. prepareDefines(defines: IMaterialBRDFDefines): void;
  47015. /**
  47016. * Get the current class name of the texture useful for serialization or dynamic coding.
  47017. * @returns "PBRClearCoatConfiguration"
  47018. */
  47019. getClassName(): string;
  47020. /**
  47021. * Makes a duplicate of the current configuration into another one.
  47022. * @param brdfConfiguration define the config where to copy the info
  47023. */
  47024. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47025. /**
  47026. * Serializes this BRDF configuration.
  47027. * @returns - An object with the serialized config.
  47028. */
  47029. serialize(): any;
  47030. /**
  47031. * Parses a anisotropy Configuration from a serialized object.
  47032. * @param source - Serialized object.
  47033. * @param scene Defines the scene we are parsing for
  47034. * @param rootUrl Defines the rootUrl to load from
  47035. */
  47036. parse(source: any, scene: Scene, rootUrl: string): void;
  47037. }
  47038. }
  47039. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  47040. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47041. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47042. import { Color3 } from "babylonjs/Maths/math";
  47043. import { Scene } from "babylonjs/scene";
  47044. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47045. import { IAnimatable } from "babylonjs/Misc/tools";
  47046. import { Nullable } from "babylonjs/types";
  47047. /**
  47048. * @hidden
  47049. */
  47050. export interface IMaterialSheenDefines {
  47051. SHEEN: boolean;
  47052. SHEEN_TEXTURE: boolean;
  47053. SHEEN_TEXTUREDIRECTUV: number;
  47054. SHEEN_LINKWITHALBEDO: boolean;
  47055. /** @hidden */
  47056. _areTexturesDirty: boolean;
  47057. }
  47058. /**
  47059. * Define the code related to the Sheen parameters of the pbr material.
  47060. */
  47061. export class PBRSheenConfiguration {
  47062. private _isEnabled;
  47063. /**
  47064. * Defines if the material uses sheen.
  47065. */
  47066. isEnabled: boolean;
  47067. private _linkSheenWithAlbedo;
  47068. /**
  47069. * Defines if the sheen is linked to the sheen color.
  47070. */
  47071. linkSheenWithAlbedo: boolean;
  47072. /**
  47073. * Defines the sheen intensity.
  47074. */
  47075. intensity: number;
  47076. /**
  47077. * Defines the sheen color.
  47078. */
  47079. color: Color3;
  47080. private _texture;
  47081. /**
  47082. * Stores the sheen tint values in a texture.
  47083. * rgb is tint
  47084. * a is a intensity
  47085. */
  47086. texture: Nullable<BaseTexture>;
  47087. /** @hidden */
  47088. private _internalMarkAllSubMeshesAsTexturesDirty;
  47089. /** @hidden */
  47090. _markAllSubMeshesAsTexturesDirty(): void;
  47091. /**
  47092. * Instantiate a new istance of clear coat configuration.
  47093. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47094. */
  47095. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47096. /**
  47097. * Specifies that the submesh is ready to be used.
  47098. * @param defines the list of "defines" to update.
  47099. * @param scene defines the scene the material belongs to.
  47100. * @returns - boolean indicating that the submesh is ready or not.
  47101. */
  47102. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47103. /**
  47104. * Checks to see if a texture is used in the material.
  47105. * @param defines the list of "defines" to update.
  47106. * @param scene defines the scene the material belongs to.
  47107. */
  47108. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47109. /**
  47110. * Binds the material data.
  47111. * @param uniformBuffer defines the Uniform buffer to fill in.
  47112. * @param scene defines the scene the material belongs to.
  47113. * @param isFrozen defines wether the material is frozen or not.
  47114. */
  47115. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47116. /**
  47117. * Checks to see if a texture is used in the material.
  47118. * @param texture - Base texture to use.
  47119. * @returns - Boolean specifying if a texture is used in the material.
  47120. */
  47121. hasTexture(texture: BaseTexture): boolean;
  47122. /**
  47123. * Returns an array of the actively used textures.
  47124. * @param activeTextures Array of BaseTextures
  47125. */
  47126. getActiveTextures(activeTextures: BaseTexture[]): void;
  47127. /**
  47128. * Returns the animatable textures.
  47129. * @param animatables Array of animatable textures.
  47130. */
  47131. getAnimatables(animatables: IAnimatable[]): void;
  47132. /**
  47133. * Disposes the resources of the material.
  47134. * @param forceDisposeTextures - Forces the disposal of all textures.
  47135. */
  47136. dispose(forceDisposeTextures?: boolean): void;
  47137. /**
  47138. * Get the current class name of the texture useful for serialization or dynamic coding.
  47139. * @returns "PBRSheenConfiguration"
  47140. */
  47141. getClassName(): string;
  47142. /**
  47143. * Add fallbacks to the effect fallbacks list.
  47144. * @param defines defines the Base texture to use.
  47145. * @param fallbacks defines the current fallback list.
  47146. * @param currentRank defines the current fallback rank.
  47147. * @returns the new fallback rank.
  47148. */
  47149. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47150. /**
  47151. * Add the required uniforms to the current list.
  47152. * @param uniforms defines the current uniform list.
  47153. */
  47154. static AddUniforms(uniforms: string[]): void;
  47155. /**
  47156. * Add the required uniforms to the current buffer.
  47157. * @param uniformBuffer defines the current uniform buffer.
  47158. */
  47159. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47160. /**
  47161. * Add the required samplers to the current list.
  47162. * @param samplers defines the current sampler list.
  47163. */
  47164. static AddSamplers(samplers: string[]): void;
  47165. /**
  47166. * Makes a duplicate of the current configuration into another one.
  47167. * @param sheenConfiguration define the config where to copy the info
  47168. */
  47169. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47170. /**
  47171. * Serializes this BRDF configuration.
  47172. * @returns - An object with the serialized config.
  47173. */
  47174. serialize(): any;
  47175. /**
  47176. * Parses a anisotropy Configuration from a serialized object.
  47177. * @param source - Serialized object.
  47178. * @param scene Defines the scene we are parsing for
  47179. * @param rootUrl Defines the rootUrl to load from
  47180. */
  47181. parse(source: any, scene: Scene, rootUrl: string): void;
  47182. }
  47183. }
  47184. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47185. import { Nullable } from "babylonjs/types";
  47186. import { IAnimatable } from "babylonjs/Misc/tools";
  47187. import { Color3 } from "babylonjs/Maths/math";
  47188. import { SmartArray } from "babylonjs/Misc/smartArray";
  47189. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47190. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47191. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47192. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47193. import { Engine } from "babylonjs/Engines/engine";
  47194. import { Scene } from "babylonjs/scene";
  47195. /**
  47196. * @hidden
  47197. */
  47198. export interface IMaterialSubSurfaceDefines {
  47199. SUBSURFACE: boolean;
  47200. SS_REFRACTION: boolean;
  47201. SS_TRANSLUCENCY: boolean;
  47202. SS_SCATERRING: boolean;
  47203. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47204. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47205. SS_REFRACTIONMAP_3D: boolean;
  47206. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47207. SS_LODINREFRACTIONALPHA: boolean;
  47208. SS_GAMMAREFRACTION: boolean;
  47209. SS_RGBDREFRACTION: boolean;
  47210. SS_LINEARSPECULARREFRACTION: boolean;
  47211. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47212. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47213. /** @hidden */
  47214. _areTexturesDirty: boolean;
  47215. }
  47216. /**
  47217. * Define the code related to the sub surface parameters of the pbr material.
  47218. */
  47219. export class PBRSubSurfaceConfiguration {
  47220. private _isRefractionEnabled;
  47221. /**
  47222. * Defines if the refraction is enabled in the material.
  47223. */
  47224. isRefractionEnabled: boolean;
  47225. private _isTranslucencyEnabled;
  47226. /**
  47227. * Defines if the translucency is enabled in the material.
  47228. */
  47229. isTranslucencyEnabled: boolean;
  47230. private _isScatteringEnabled;
  47231. /**
  47232. * Defines the refraction intensity of the material.
  47233. * The refraction when enabled replaces the Diffuse part of the material.
  47234. * The intensity helps transitionning between diffuse and refraction.
  47235. */
  47236. refractionIntensity: number;
  47237. /**
  47238. * Defines the translucency intensity of the material.
  47239. * When translucency has been enabled, this defines how much of the "translucency"
  47240. * is addded to the diffuse part of the material.
  47241. */
  47242. translucencyIntensity: number;
  47243. /**
  47244. * Defines the scattering intensity of the material.
  47245. * When scattering has been enabled, this defines how much of the "scattered light"
  47246. * is addded to the diffuse part of the material.
  47247. */
  47248. scatteringIntensity: number;
  47249. private _thicknessTexture;
  47250. /**
  47251. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47252. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47253. * 0 would mean minimumThickness
  47254. * 1 would mean maximumThickness
  47255. * The other channels might be use as a mask to vary the different effects intensity.
  47256. */
  47257. thicknessTexture: Nullable<BaseTexture>;
  47258. private _refractionTexture;
  47259. /**
  47260. * Defines the texture to use for refraction.
  47261. */
  47262. refractionTexture: Nullable<BaseTexture>;
  47263. private _indexOfRefraction;
  47264. /**
  47265. * Defines the index of refraction used in the material.
  47266. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47267. */
  47268. indexOfRefraction: number;
  47269. private _invertRefractionY;
  47270. /**
  47271. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47272. */
  47273. invertRefractionY: boolean;
  47274. private _linkRefractionWithTransparency;
  47275. /**
  47276. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47277. * Materials half opaque for instance using refraction could benefit from this control.
  47278. */
  47279. linkRefractionWithTransparency: boolean;
  47280. /**
  47281. * Defines the minimum thickness stored in the thickness map.
  47282. * If no thickness map is defined, this value will be used to simulate thickness.
  47283. */
  47284. minimumThickness: number;
  47285. /**
  47286. * Defines the maximum thickness stored in the thickness map.
  47287. */
  47288. maximumThickness: number;
  47289. /**
  47290. * Defines the volume tint of the material.
  47291. * This is used for both translucency and scattering.
  47292. */
  47293. tintColor: Color3;
  47294. /**
  47295. * Defines the distance at which the tint color should be found in the media.
  47296. * This is used for refraction only.
  47297. */
  47298. tintColorAtDistance: number;
  47299. /**
  47300. * Defines how far each channel transmit through the media.
  47301. * It is defined as a color to simplify it selection.
  47302. */
  47303. diffusionDistance: Color3;
  47304. private _useMaskFromThicknessTexture;
  47305. /**
  47306. * Stores the intensity of the different subsurface effects in the thickness texture.
  47307. * * the green channel is the translucency intensity.
  47308. * * the blue channel is the scattering intensity.
  47309. * * the alpha channel is the refraction intensity.
  47310. */
  47311. useMaskFromThicknessTexture: boolean;
  47312. /** @hidden */
  47313. private _internalMarkAllSubMeshesAsTexturesDirty;
  47314. /** @hidden */
  47315. _markAllSubMeshesAsTexturesDirty(): void;
  47316. /**
  47317. * Instantiate a new istance of sub surface configuration.
  47318. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47319. */
  47320. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47321. /**
  47322. * Gets wehter the submesh is ready to be used or not.
  47323. * @param defines the list of "defines" to update.
  47324. * @param scene defines the scene the material belongs to.
  47325. * @returns - boolean indicating that the submesh is ready or not.
  47326. */
  47327. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47328. /**
  47329. * Checks to see if a texture is used in the material.
  47330. * @param defines the list of "defines" to update.
  47331. * @param scene defines the scene to the material belongs to.
  47332. */
  47333. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47334. /**
  47335. * Binds the material data.
  47336. * @param uniformBuffer defines the Uniform buffer to fill in.
  47337. * @param scene defines the scene the material belongs to.
  47338. * @param engine defines the engine the material belongs to.
  47339. * @param isFrozen defines wether the material is frozen or not.
  47340. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47341. */
  47342. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47343. /**
  47344. * Unbinds the material from the mesh.
  47345. * @param activeEffect defines the effect that should be unbound from.
  47346. * @returns true if unbound, otherwise false
  47347. */
  47348. unbind(activeEffect: Effect): boolean;
  47349. /**
  47350. * Returns the texture used for refraction or null if none is used.
  47351. * @param scene defines the scene the material belongs to.
  47352. * @returns - Refraction texture if present. If no refraction texture and refraction
  47353. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47354. */
  47355. private _getRefractionTexture;
  47356. /**
  47357. * Returns true if alpha blending should be disabled.
  47358. */
  47359. readonly disableAlphaBlending: boolean;
  47360. /**
  47361. * Fills the list of render target textures.
  47362. * @param renderTargets the list of render targets to update
  47363. */
  47364. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47365. /**
  47366. * Checks to see if a texture is used in the material.
  47367. * @param texture - Base texture to use.
  47368. * @returns - Boolean specifying if a texture is used in the material.
  47369. */
  47370. hasTexture(texture: BaseTexture): boolean;
  47371. /**
  47372. * Gets a boolean indicating that current material needs to register RTT
  47373. * @returns true if this uses a render target otherwise false.
  47374. */
  47375. hasRenderTargetTextures(): boolean;
  47376. /**
  47377. * Returns an array of the actively used textures.
  47378. * @param activeTextures Array of BaseTextures
  47379. */
  47380. getActiveTextures(activeTextures: BaseTexture[]): void;
  47381. /**
  47382. * Returns the animatable textures.
  47383. * @param animatables Array of animatable textures.
  47384. */
  47385. getAnimatables(animatables: IAnimatable[]): void;
  47386. /**
  47387. * Disposes the resources of the material.
  47388. * @param forceDisposeTextures - Forces the disposal of all textures.
  47389. */
  47390. dispose(forceDisposeTextures?: boolean): void;
  47391. /**
  47392. * Get the current class name of the texture useful for serialization or dynamic coding.
  47393. * @returns "PBRSubSurfaceConfiguration"
  47394. */
  47395. getClassName(): string;
  47396. /**
  47397. * Add fallbacks to the effect fallbacks list.
  47398. * @param defines defines the Base texture to use.
  47399. * @param fallbacks defines the current fallback list.
  47400. * @param currentRank defines the current fallback rank.
  47401. * @returns the new fallback rank.
  47402. */
  47403. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47404. /**
  47405. * Add the required uniforms to the current list.
  47406. * @param uniforms defines the current uniform list.
  47407. */
  47408. static AddUniforms(uniforms: string[]): void;
  47409. /**
  47410. * Add the required samplers to the current list.
  47411. * @param samplers defines the current sampler list.
  47412. */
  47413. static AddSamplers(samplers: string[]): void;
  47414. /**
  47415. * Add the required uniforms to the current buffer.
  47416. * @param uniformBuffer defines the current uniform buffer.
  47417. */
  47418. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47419. /**
  47420. * Makes a duplicate of the current configuration into another one.
  47421. * @param configuration define the config where to copy the info
  47422. */
  47423. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47424. /**
  47425. * Serializes this Sub Surface configuration.
  47426. * @returns - An object with the serialized config.
  47427. */
  47428. serialize(): any;
  47429. /**
  47430. * Parses a anisotropy Configuration from a serialized object.
  47431. * @param source - Serialized object.
  47432. * @param scene Defines the scene we are parsing for
  47433. * @param rootUrl Defines the rootUrl to load from
  47434. */
  47435. parse(source: any, scene: Scene, rootUrl: string): void;
  47436. }
  47437. }
  47438. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  47439. /** @hidden */
  47440. export var pbrFragmentDeclaration: {
  47441. name: string;
  47442. shader: string;
  47443. };
  47444. }
  47445. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47446. /** @hidden */
  47447. export var pbrUboDeclaration: {
  47448. name: string;
  47449. shader: string;
  47450. };
  47451. }
  47452. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47453. /** @hidden */
  47454. export var pbrFragmentExtraDeclaration: {
  47455. name: string;
  47456. shader: string;
  47457. };
  47458. }
  47459. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47460. /** @hidden */
  47461. export var pbrFragmentSamplersDeclaration: {
  47462. name: string;
  47463. shader: string;
  47464. };
  47465. }
  47466. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47467. /** @hidden */
  47468. export var pbrHelperFunctions: {
  47469. name: string;
  47470. shader: string;
  47471. };
  47472. }
  47473. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47474. /** @hidden */
  47475. export var harmonicsFunctions: {
  47476. name: string;
  47477. shader: string;
  47478. };
  47479. }
  47480. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47481. /** @hidden */
  47482. export var pbrDirectLightingSetupFunctions: {
  47483. name: string;
  47484. shader: string;
  47485. };
  47486. }
  47487. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47488. /** @hidden */
  47489. export var pbrDirectLightingFalloffFunctions: {
  47490. name: string;
  47491. shader: string;
  47492. };
  47493. }
  47494. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47495. /** @hidden */
  47496. export var pbrBRDFFunctions: {
  47497. name: string;
  47498. shader: string;
  47499. };
  47500. }
  47501. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47502. /** @hidden */
  47503. export var pbrDirectLightingFunctions: {
  47504. name: string;
  47505. shader: string;
  47506. };
  47507. }
  47508. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47509. /** @hidden */
  47510. export var pbrIBLFunctions: {
  47511. name: string;
  47512. shader: string;
  47513. };
  47514. }
  47515. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47516. /** @hidden */
  47517. export var pbrDebug: {
  47518. name: string;
  47519. shader: string;
  47520. };
  47521. }
  47522. declare module "babylonjs/Shaders/pbr.fragment" {
  47523. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47524. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47525. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47526. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47527. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47528. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47529. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47530. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47531. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47532. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47533. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47534. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47535. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47536. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47537. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47538. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47539. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47540. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47541. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47542. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47543. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47544. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47545. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47546. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47547. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47548. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47549. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47550. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47551. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47552. /** @hidden */
  47553. export var pbrPixelShader: {
  47554. name: string;
  47555. shader: string;
  47556. };
  47557. }
  47558. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47559. /** @hidden */
  47560. export var pbrVertexDeclaration: {
  47561. name: string;
  47562. shader: string;
  47563. };
  47564. }
  47565. declare module "babylonjs/Shaders/pbr.vertex" {
  47566. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47567. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47568. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47569. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47570. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47571. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47572. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47573. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47574. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47575. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47576. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47577. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47578. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47579. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47580. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47581. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47582. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47583. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47584. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47585. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47586. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47587. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47588. /** @hidden */
  47589. export var pbrVertexShader: {
  47590. name: string;
  47591. shader: string;
  47592. };
  47593. }
  47594. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47595. import { IAnimatable } from "babylonjs/Misc/tools";
  47596. import { Nullable } from "babylonjs/types";
  47597. import { Scene } from "babylonjs/scene";
  47598. import { Matrix, Color3 } from "babylonjs/Maths/math";
  47599. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47601. import { Mesh } from "babylonjs/Meshes/mesh";
  47602. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47603. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47604. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47605. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47606. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47607. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  47608. import { Material } from "babylonjs/Materials/material";
  47609. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  47610. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47611. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47612. import "babylonjs/Shaders/pbr.fragment";
  47613. import "babylonjs/Shaders/pbr.vertex";
  47614. /**
  47615. * Manages the defines for the PBR Material.
  47616. * @hidden
  47617. */
  47618. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47619. PBR: boolean;
  47620. MAINUV1: boolean;
  47621. MAINUV2: boolean;
  47622. UV1: boolean;
  47623. UV2: boolean;
  47624. ALBEDO: boolean;
  47625. ALBEDODIRECTUV: number;
  47626. VERTEXCOLOR: boolean;
  47627. AMBIENT: boolean;
  47628. AMBIENTDIRECTUV: number;
  47629. AMBIENTINGRAYSCALE: boolean;
  47630. OPACITY: boolean;
  47631. VERTEXALPHA: boolean;
  47632. OPACITYDIRECTUV: number;
  47633. OPACITYRGB: boolean;
  47634. ALPHATEST: boolean;
  47635. DEPTHPREPASS: boolean;
  47636. ALPHABLEND: boolean;
  47637. ALPHAFROMALBEDO: boolean;
  47638. ALPHATESTVALUE: string;
  47639. SPECULAROVERALPHA: boolean;
  47640. RADIANCEOVERALPHA: boolean;
  47641. ALPHAFRESNEL: boolean;
  47642. LINEARALPHAFRESNEL: boolean;
  47643. PREMULTIPLYALPHA: boolean;
  47644. EMISSIVE: boolean;
  47645. EMISSIVEDIRECTUV: number;
  47646. REFLECTIVITY: boolean;
  47647. REFLECTIVITYDIRECTUV: number;
  47648. SPECULARTERM: boolean;
  47649. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47650. MICROSURFACEAUTOMATIC: boolean;
  47651. LODBASEDMICROSFURACE: boolean;
  47652. MICROSURFACEMAP: boolean;
  47653. MICROSURFACEMAPDIRECTUV: number;
  47654. METALLICWORKFLOW: boolean;
  47655. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47656. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47657. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47658. AOSTOREINMETALMAPRED: boolean;
  47659. ENVIRONMENTBRDF: boolean;
  47660. ENVIRONMENTBRDF_RGBD: boolean;
  47661. NORMAL: boolean;
  47662. TANGENT: boolean;
  47663. BUMP: boolean;
  47664. BUMPDIRECTUV: number;
  47665. OBJECTSPACE_NORMALMAP: boolean;
  47666. PARALLAX: boolean;
  47667. PARALLAXOCCLUSION: boolean;
  47668. NORMALXYSCALE: boolean;
  47669. LIGHTMAP: boolean;
  47670. LIGHTMAPDIRECTUV: number;
  47671. USELIGHTMAPASSHADOWMAP: boolean;
  47672. GAMMALIGHTMAP: boolean;
  47673. REFLECTION: boolean;
  47674. REFLECTIONMAP_3D: boolean;
  47675. REFLECTIONMAP_SPHERICAL: boolean;
  47676. REFLECTIONMAP_PLANAR: boolean;
  47677. REFLECTIONMAP_CUBIC: boolean;
  47678. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47679. REFLECTIONMAP_PROJECTION: boolean;
  47680. REFLECTIONMAP_SKYBOX: boolean;
  47681. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47682. REFLECTIONMAP_EXPLICIT: boolean;
  47683. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47684. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47685. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47686. INVERTCUBICMAP: boolean;
  47687. USESPHERICALFROMREFLECTIONMAP: boolean;
  47688. USEIRRADIANCEMAP: boolean;
  47689. SPHERICAL_HARMONICS: boolean;
  47690. USESPHERICALINVERTEX: boolean;
  47691. REFLECTIONMAP_OPPOSITEZ: boolean;
  47692. LODINREFLECTIONALPHA: boolean;
  47693. GAMMAREFLECTION: boolean;
  47694. RGBDREFLECTION: boolean;
  47695. LINEARSPECULARREFLECTION: boolean;
  47696. RADIANCEOCCLUSION: boolean;
  47697. HORIZONOCCLUSION: boolean;
  47698. INSTANCES: boolean;
  47699. NUM_BONE_INFLUENCERS: number;
  47700. BonesPerMesh: number;
  47701. BONETEXTURE: boolean;
  47702. NONUNIFORMSCALING: boolean;
  47703. MORPHTARGETS: boolean;
  47704. MORPHTARGETS_NORMAL: boolean;
  47705. MORPHTARGETS_TANGENT: boolean;
  47706. MORPHTARGETS_UV: boolean;
  47707. NUM_MORPH_INFLUENCERS: number;
  47708. IMAGEPROCESSING: boolean;
  47709. VIGNETTE: boolean;
  47710. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47711. VIGNETTEBLENDMODEOPAQUE: boolean;
  47712. TONEMAPPING: boolean;
  47713. TONEMAPPING_ACES: boolean;
  47714. CONTRAST: boolean;
  47715. COLORCURVES: boolean;
  47716. COLORGRADING: boolean;
  47717. COLORGRADING3D: boolean;
  47718. SAMPLER3DGREENDEPTH: boolean;
  47719. SAMPLER3DBGRMAP: boolean;
  47720. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47721. EXPOSURE: boolean;
  47722. MULTIVIEW: boolean;
  47723. USEPHYSICALLIGHTFALLOFF: boolean;
  47724. USEGLTFLIGHTFALLOFF: boolean;
  47725. TWOSIDEDLIGHTING: boolean;
  47726. SHADOWFLOAT: boolean;
  47727. CLIPPLANE: boolean;
  47728. CLIPPLANE2: boolean;
  47729. CLIPPLANE3: boolean;
  47730. CLIPPLANE4: boolean;
  47731. POINTSIZE: boolean;
  47732. FOG: boolean;
  47733. LOGARITHMICDEPTH: boolean;
  47734. FORCENORMALFORWARD: boolean;
  47735. SPECULARAA: boolean;
  47736. CLEARCOAT: boolean;
  47737. CLEARCOAT_DEFAULTIOR: boolean;
  47738. CLEARCOAT_TEXTURE: boolean;
  47739. CLEARCOAT_TEXTUREDIRECTUV: number;
  47740. CLEARCOAT_BUMP: boolean;
  47741. CLEARCOAT_BUMPDIRECTUV: number;
  47742. CLEARCOAT_TINT: boolean;
  47743. CLEARCOAT_TINT_TEXTURE: boolean;
  47744. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47745. ANISOTROPIC: boolean;
  47746. ANISOTROPIC_TEXTURE: boolean;
  47747. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47748. BRDF_V_HEIGHT_CORRELATED: boolean;
  47749. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47750. SHEEN: boolean;
  47751. SHEEN_TEXTURE: boolean;
  47752. SHEEN_TEXTUREDIRECTUV: number;
  47753. SHEEN_LINKWITHALBEDO: boolean;
  47754. SUBSURFACE: boolean;
  47755. SS_REFRACTION: boolean;
  47756. SS_TRANSLUCENCY: boolean;
  47757. SS_SCATERRING: boolean;
  47758. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47759. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47760. SS_REFRACTIONMAP_3D: boolean;
  47761. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47762. SS_LODINREFRACTIONALPHA: boolean;
  47763. SS_GAMMAREFRACTION: boolean;
  47764. SS_RGBDREFRACTION: boolean;
  47765. SS_LINEARSPECULARREFRACTION: boolean;
  47766. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47767. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47768. UNLIT: boolean;
  47769. DEBUGMODE: number;
  47770. /**
  47771. * Initializes the PBR Material defines.
  47772. */
  47773. constructor();
  47774. /**
  47775. * Resets the PBR Material defines.
  47776. */
  47777. reset(): void;
  47778. }
  47779. /**
  47780. * The Physically based material base class of BJS.
  47781. *
  47782. * This offers the main features of a standard PBR material.
  47783. * For more information, please refer to the documentation :
  47784. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47785. */
  47786. export abstract class PBRBaseMaterial extends PushMaterial {
  47787. /**
  47788. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47789. */
  47790. static readonly PBRMATERIAL_OPAQUE: number;
  47791. /**
  47792. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47793. */
  47794. static readonly PBRMATERIAL_ALPHATEST: number;
  47795. /**
  47796. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47797. */
  47798. static readonly PBRMATERIAL_ALPHABLEND: number;
  47799. /**
  47800. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47801. * They are also discarded below the alpha cutoff threshold to improve performances.
  47802. */
  47803. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47804. /**
  47805. * Defines the default value of how much AO map is occluding the analytical lights
  47806. * (point spot...).
  47807. */
  47808. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47809. /**
  47810. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47811. */
  47812. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47813. /**
  47814. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47815. * to enhance interoperability with other engines.
  47816. */
  47817. static readonly LIGHTFALLOFF_GLTF: number;
  47818. /**
  47819. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47820. * to enhance interoperability with other materials.
  47821. */
  47822. static readonly LIGHTFALLOFF_STANDARD: number;
  47823. /**
  47824. * Intensity of the direct lights e.g. the four lights available in your scene.
  47825. * This impacts both the direct diffuse and specular highlights.
  47826. */
  47827. protected _directIntensity: number;
  47828. /**
  47829. * Intensity of the emissive part of the material.
  47830. * This helps controlling the emissive effect without modifying the emissive color.
  47831. */
  47832. protected _emissiveIntensity: number;
  47833. /**
  47834. * Intensity of the environment e.g. how much the environment will light the object
  47835. * either through harmonics for rough material or through the refelction for shiny ones.
  47836. */
  47837. protected _environmentIntensity: number;
  47838. /**
  47839. * This is a special control allowing the reduction of the specular highlights coming from the
  47840. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47841. */
  47842. protected _specularIntensity: number;
  47843. /**
  47844. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47845. */
  47846. private _lightingInfos;
  47847. /**
  47848. * Debug Control allowing disabling the bump map on this material.
  47849. */
  47850. protected _disableBumpMap: boolean;
  47851. /**
  47852. * AKA Diffuse Texture in standard nomenclature.
  47853. */
  47854. protected _albedoTexture: Nullable<BaseTexture>;
  47855. /**
  47856. * AKA Occlusion Texture in other nomenclature.
  47857. */
  47858. protected _ambientTexture: Nullable<BaseTexture>;
  47859. /**
  47860. * AKA Occlusion Texture Intensity in other nomenclature.
  47861. */
  47862. protected _ambientTextureStrength: number;
  47863. /**
  47864. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47865. * 1 means it completely occludes it
  47866. * 0 mean it has no impact
  47867. */
  47868. protected _ambientTextureImpactOnAnalyticalLights: number;
  47869. /**
  47870. * Stores the alpha values in a texture.
  47871. */
  47872. protected _opacityTexture: Nullable<BaseTexture>;
  47873. /**
  47874. * Stores the reflection values in a texture.
  47875. */
  47876. protected _reflectionTexture: Nullable<BaseTexture>;
  47877. /**
  47878. * Stores the emissive values in a texture.
  47879. */
  47880. protected _emissiveTexture: Nullable<BaseTexture>;
  47881. /**
  47882. * AKA Specular texture in other nomenclature.
  47883. */
  47884. protected _reflectivityTexture: Nullable<BaseTexture>;
  47885. /**
  47886. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47887. */
  47888. protected _metallicTexture: Nullable<BaseTexture>;
  47889. /**
  47890. * Specifies the metallic scalar of the metallic/roughness workflow.
  47891. * Can also be used to scale the metalness values of the metallic texture.
  47892. */
  47893. protected _metallic: Nullable<number>;
  47894. /**
  47895. * Specifies the roughness scalar of the metallic/roughness workflow.
  47896. * Can also be used to scale the roughness values of the metallic texture.
  47897. */
  47898. protected _roughness: Nullable<number>;
  47899. /**
  47900. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47901. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47902. */
  47903. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47904. /**
  47905. * Stores surface normal data used to displace a mesh in a texture.
  47906. */
  47907. protected _bumpTexture: Nullable<BaseTexture>;
  47908. /**
  47909. * Stores the pre-calculated light information of a mesh in a texture.
  47910. */
  47911. protected _lightmapTexture: Nullable<BaseTexture>;
  47912. /**
  47913. * The color of a material in ambient lighting.
  47914. */
  47915. protected _ambientColor: Color3;
  47916. /**
  47917. * AKA Diffuse Color in other nomenclature.
  47918. */
  47919. protected _albedoColor: Color3;
  47920. /**
  47921. * AKA Specular Color in other nomenclature.
  47922. */
  47923. protected _reflectivityColor: Color3;
  47924. /**
  47925. * The color applied when light is reflected from a material.
  47926. */
  47927. protected _reflectionColor: Color3;
  47928. /**
  47929. * The color applied when light is emitted from a material.
  47930. */
  47931. protected _emissiveColor: Color3;
  47932. /**
  47933. * AKA Glossiness in other nomenclature.
  47934. */
  47935. protected _microSurface: number;
  47936. /**
  47937. * Specifies that the material will use the light map as a show map.
  47938. */
  47939. protected _useLightmapAsShadowmap: boolean;
  47940. /**
  47941. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47942. * makes the reflect vector face the model (under horizon).
  47943. */
  47944. protected _useHorizonOcclusion: boolean;
  47945. /**
  47946. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47947. * too much the area relying on ambient texture to define their ambient occlusion.
  47948. */
  47949. protected _useRadianceOcclusion: boolean;
  47950. /**
  47951. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47952. */
  47953. protected _useAlphaFromAlbedoTexture: boolean;
  47954. /**
  47955. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47956. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47957. */
  47958. protected _useSpecularOverAlpha: boolean;
  47959. /**
  47960. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47961. */
  47962. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47963. /**
  47964. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47965. */
  47966. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47967. /**
  47968. * Specifies if the metallic texture contains the roughness information in its green channel.
  47969. */
  47970. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47971. /**
  47972. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47973. */
  47974. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47975. /**
  47976. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47977. */
  47978. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47979. /**
  47980. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47981. */
  47982. protected _useAmbientInGrayScale: boolean;
  47983. /**
  47984. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47985. * The material will try to infer what glossiness each pixel should be.
  47986. */
  47987. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47988. /**
  47989. * Defines the falloff type used in this material.
  47990. * It by default is Physical.
  47991. */
  47992. protected _lightFalloff: number;
  47993. /**
  47994. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47995. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47996. */
  47997. protected _useRadianceOverAlpha: boolean;
  47998. /**
  47999. * Allows using an object space normal map (instead of tangent space).
  48000. */
  48001. protected _useObjectSpaceNormalMap: boolean;
  48002. /**
  48003. * Allows using the bump map in parallax mode.
  48004. */
  48005. protected _useParallax: boolean;
  48006. /**
  48007. * Allows using the bump map in parallax occlusion mode.
  48008. */
  48009. protected _useParallaxOcclusion: boolean;
  48010. /**
  48011. * Controls the scale bias of the parallax mode.
  48012. */
  48013. protected _parallaxScaleBias: number;
  48014. /**
  48015. * If sets to true, disables all the lights affecting the material.
  48016. */
  48017. protected _disableLighting: boolean;
  48018. /**
  48019. * Number of Simultaneous lights allowed on the material.
  48020. */
  48021. protected _maxSimultaneousLights: number;
  48022. /**
  48023. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48024. */
  48025. protected _invertNormalMapX: boolean;
  48026. /**
  48027. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48028. */
  48029. protected _invertNormalMapY: boolean;
  48030. /**
  48031. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48032. */
  48033. protected _twoSidedLighting: boolean;
  48034. /**
  48035. * Defines the alpha limits in alpha test mode.
  48036. */
  48037. protected _alphaCutOff: number;
  48038. /**
  48039. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48040. */
  48041. protected _forceAlphaTest: boolean;
  48042. /**
  48043. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48044. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48045. */
  48046. protected _useAlphaFresnel: boolean;
  48047. /**
  48048. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48049. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48050. */
  48051. protected _useLinearAlphaFresnel: boolean;
  48052. /**
  48053. * The transparency mode of the material.
  48054. */
  48055. protected _transparencyMode: Nullable<number>;
  48056. /**
  48057. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48058. * from cos thetav and roughness:
  48059. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48060. */
  48061. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48062. /**
  48063. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48064. */
  48065. protected _forceIrradianceInFragment: boolean;
  48066. /**
  48067. * Force normal to face away from face.
  48068. */
  48069. protected _forceNormalForward: boolean;
  48070. /**
  48071. * Enables specular anti aliasing in the PBR shader.
  48072. * It will both interacts on the Geometry for analytical and IBL lighting.
  48073. * It also prefilter the roughness map based on the bump values.
  48074. */
  48075. protected _enableSpecularAntiAliasing: boolean;
  48076. /**
  48077. * Default configuration related to image processing available in the PBR Material.
  48078. */
  48079. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48080. /**
  48081. * Keep track of the image processing observer to allow dispose and replace.
  48082. */
  48083. private _imageProcessingObserver;
  48084. /**
  48085. * Attaches a new image processing configuration to the PBR Material.
  48086. * @param configuration
  48087. */
  48088. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48089. /**
  48090. * Stores the available render targets.
  48091. */
  48092. private _renderTargets;
  48093. /**
  48094. * Sets the global ambient color for the material used in lighting calculations.
  48095. */
  48096. private _globalAmbientColor;
  48097. /**
  48098. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48099. */
  48100. private _useLogarithmicDepth;
  48101. /**
  48102. * If set to true, no lighting calculations will be applied.
  48103. */
  48104. private _unlit;
  48105. private _debugMode;
  48106. /**
  48107. * @hidden
  48108. * This is reserved for the inspector.
  48109. * Defines the material debug mode.
  48110. * It helps seeing only some components of the material while troubleshooting.
  48111. */
  48112. debugMode: number;
  48113. /**
  48114. * @hidden
  48115. * This is reserved for the inspector.
  48116. * Specify from where on screen the debug mode should start.
  48117. * The value goes from -1 (full screen) to 1 (not visible)
  48118. * It helps with side by side comparison against the final render
  48119. * This defaults to -1
  48120. */
  48121. private debugLimit;
  48122. /**
  48123. * @hidden
  48124. * This is reserved for the inspector.
  48125. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48126. * You can use the factor to better multiply the final value.
  48127. */
  48128. private debugFactor;
  48129. /**
  48130. * Defines the clear coat layer parameters for the material.
  48131. */
  48132. readonly clearCoat: PBRClearCoatConfiguration;
  48133. /**
  48134. * Defines the anisotropic parameters for the material.
  48135. */
  48136. readonly anisotropy: PBRAnisotropicConfiguration;
  48137. /**
  48138. * Defines the BRDF parameters for the material.
  48139. */
  48140. readonly brdf: PBRBRDFConfiguration;
  48141. /**
  48142. * Defines the Sheen parameters for the material.
  48143. */
  48144. readonly sheen: PBRSheenConfiguration;
  48145. /**
  48146. * Defines the SubSurface parameters for the material.
  48147. */
  48148. readonly subSurface: PBRSubSurfaceConfiguration;
  48149. /**
  48150. * Custom callback helping to override the default shader used in the material.
  48151. */
  48152. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48153. /**
  48154. * Instantiates a new PBRMaterial instance.
  48155. *
  48156. * @param name The material name
  48157. * @param scene The scene the material will be use in.
  48158. */
  48159. constructor(name: string, scene: Scene);
  48160. /**
  48161. * Gets a boolean indicating that current material needs to register RTT
  48162. */
  48163. readonly hasRenderTargetTextures: boolean;
  48164. /**
  48165. * Gets the name of the material class.
  48166. */
  48167. getClassName(): string;
  48168. /**
  48169. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48170. */
  48171. /**
  48172. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48173. */
  48174. useLogarithmicDepth: boolean;
  48175. /**
  48176. * Gets the current transparency mode.
  48177. */
  48178. /**
  48179. * Sets the transparency mode of the material.
  48180. *
  48181. * | Value | Type | Description |
  48182. * | ----- | ----------------------------------- | ----------- |
  48183. * | 0 | OPAQUE | |
  48184. * | 1 | ALPHATEST | |
  48185. * | 2 | ALPHABLEND | |
  48186. * | 3 | ALPHATESTANDBLEND | |
  48187. *
  48188. */
  48189. transparencyMode: Nullable<number>;
  48190. /**
  48191. * Returns true if alpha blending should be disabled.
  48192. */
  48193. private readonly _disableAlphaBlending;
  48194. /**
  48195. * Specifies whether or not this material should be rendered in alpha blend mode.
  48196. */
  48197. needAlphaBlending(): boolean;
  48198. /**
  48199. * Specifies if the mesh will require alpha blending.
  48200. * @param mesh - BJS mesh.
  48201. */
  48202. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48203. /**
  48204. * Specifies whether or not this material should be rendered in alpha test mode.
  48205. */
  48206. needAlphaTesting(): boolean;
  48207. /**
  48208. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48209. */
  48210. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48211. /**
  48212. * Gets the texture used for the alpha test.
  48213. */
  48214. getAlphaTestTexture(): Nullable<BaseTexture>;
  48215. /**
  48216. * Specifies that the submesh is ready to be used.
  48217. * @param mesh - BJS mesh.
  48218. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48219. * @param useInstances - Specifies that instances should be used.
  48220. * @returns - boolean indicating that the submesh is ready or not.
  48221. */
  48222. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48223. /**
  48224. * Specifies if the material uses metallic roughness workflow.
  48225. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48226. */
  48227. isMetallicWorkflow(): boolean;
  48228. private _prepareEffect;
  48229. private _prepareDefines;
  48230. /**
  48231. * Force shader compilation
  48232. */
  48233. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48234. clipPlane: boolean;
  48235. }>): void;
  48236. /**
  48237. * Initializes the uniform buffer layout for the shader.
  48238. */
  48239. buildUniformLayout(): void;
  48240. /**
  48241. * Unbinds the material from the mesh
  48242. */
  48243. unbind(): void;
  48244. /**
  48245. * Binds the submesh data.
  48246. * @param world - The world matrix.
  48247. * @param mesh - The BJS mesh.
  48248. * @param subMesh - A submesh of the BJS mesh.
  48249. */
  48250. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48251. /**
  48252. * Returns the animatable textures.
  48253. * @returns - Array of animatable textures.
  48254. */
  48255. getAnimatables(): IAnimatable[];
  48256. /**
  48257. * Returns the texture used for reflections.
  48258. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48259. */
  48260. private _getReflectionTexture;
  48261. /**
  48262. * Returns an array of the actively used textures.
  48263. * @returns - Array of BaseTextures
  48264. */
  48265. getActiveTextures(): BaseTexture[];
  48266. /**
  48267. * Checks to see if a texture is used in the material.
  48268. * @param texture - Base texture to use.
  48269. * @returns - Boolean specifying if a texture is used in the material.
  48270. */
  48271. hasTexture(texture: BaseTexture): boolean;
  48272. /**
  48273. * Disposes the resources of the material.
  48274. * @param forceDisposeEffect - Forces the disposal of effects.
  48275. * @param forceDisposeTextures - Forces the disposal of all textures.
  48276. */
  48277. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48278. }
  48279. }
  48280. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  48281. import { Nullable } from "babylonjs/types";
  48282. import { Scene } from "babylonjs/scene";
  48283. import { Color3 } from "babylonjs/Maths/math";
  48284. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48285. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48286. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48287. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48288. /**
  48289. * The Physically based material of BJS.
  48290. *
  48291. * This offers the main features of a standard PBR material.
  48292. * For more information, please refer to the documentation :
  48293. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48294. */
  48295. export class PBRMaterial extends PBRBaseMaterial {
  48296. /**
  48297. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48298. */
  48299. static readonly PBRMATERIAL_OPAQUE: number;
  48300. /**
  48301. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48302. */
  48303. static readonly PBRMATERIAL_ALPHATEST: number;
  48304. /**
  48305. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48306. */
  48307. static readonly PBRMATERIAL_ALPHABLEND: number;
  48308. /**
  48309. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48310. * They are also discarded below the alpha cutoff threshold to improve performances.
  48311. */
  48312. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48313. /**
  48314. * Defines the default value of how much AO map is occluding the analytical lights
  48315. * (point spot...).
  48316. */
  48317. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48318. /**
  48319. * Intensity of the direct lights e.g. the four lights available in your scene.
  48320. * This impacts both the direct diffuse and specular highlights.
  48321. */
  48322. directIntensity: number;
  48323. /**
  48324. * Intensity of the emissive part of the material.
  48325. * This helps controlling the emissive effect without modifying the emissive color.
  48326. */
  48327. emissiveIntensity: number;
  48328. /**
  48329. * Intensity of the environment e.g. how much the environment will light the object
  48330. * either through harmonics for rough material or through the refelction for shiny ones.
  48331. */
  48332. environmentIntensity: number;
  48333. /**
  48334. * This is a special control allowing the reduction of the specular highlights coming from the
  48335. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48336. */
  48337. specularIntensity: number;
  48338. /**
  48339. * Debug Control allowing disabling the bump map on this material.
  48340. */
  48341. disableBumpMap: boolean;
  48342. /**
  48343. * AKA Diffuse Texture in standard nomenclature.
  48344. */
  48345. albedoTexture: BaseTexture;
  48346. /**
  48347. * AKA Occlusion Texture in other nomenclature.
  48348. */
  48349. ambientTexture: BaseTexture;
  48350. /**
  48351. * AKA Occlusion Texture Intensity in other nomenclature.
  48352. */
  48353. ambientTextureStrength: number;
  48354. /**
  48355. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48356. * 1 means it completely occludes it
  48357. * 0 mean it has no impact
  48358. */
  48359. ambientTextureImpactOnAnalyticalLights: number;
  48360. /**
  48361. * Stores the alpha values in a texture.
  48362. */
  48363. opacityTexture: BaseTexture;
  48364. /**
  48365. * Stores the reflection values in a texture.
  48366. */
  48367. reflectionTexture: Nullable<BaseTexture>;
  48368. /**
  48369. * Stores the emissive values in a texture.
  48370. */
  48371. emissiveTexture: BaseTexture;
  48372. /**
  48373. * AKA Specular texture in other nomenclature.
  48374. */
  48375. reflectivityTexture: BaseTexture;
  48376. /**
  48377. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48378. */
  48379. metallicTexture: BaseTexture;
  48380. /**
  48381. * Specifies the metallic scalar of the metallic/roughness workflow.
  48382. * Can also be used to scale the metalness values of the metallic texture.
  48383. */
  48384. metallic: Nullable<number>;
  48385. /**
  48386. * Specifies the roughness scalar of the metallic/roughness workflow.
  48387. * Can also be used to scale the roughness values of the metallic texture.
  48388. */
  48389. roughness: Nullable<number>;
  48390. /**
  48391. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48392. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48393. */
  48394. microSurfaceTexture: BaseTexture;
  48395. /**
  48396. * Stores surface normal data used to displace a mesh in a texture.
  48397. */
  48398. bumpTexture: BaseTexture;
  48399. /**
  48400. * Stores the pre-calculated light information of a mesh in a texture.
  48401. */
  48402. lightmapTexture: BaseTexture;
  48403. /**
  48404. * Stores the refracted light information in a texture.
  48405. */
  48406. refractionTexture: Nullable<BaseTexture>;
  48407. /**
  48408. * The color of a material in ambient lighting.
  48409. */
  48410. ambientColor: Color3;
  48411. /**
  48412. * AKA Diffuse Color in other nomenclature.
  48413. */
  48414. albedoColor: Color3;
  48415. /**
  48416. * AKA Specular Color in other nomenclature.
  48417. */
  48418. reflectivityColor: Color3;
  48419. /**
  48420. * The color reflected from the material.
  48421. */
  48422. reflectionColor: Color3;
  48423. /**
  48424. * The color emitted from the material.
  48425. */
  48426. emissiveColor: Color3;
  48427. /**
  48428. * AKA Glossiness in other nomenclature.
  48429. */
  48430. microSurface: number;
  48431. /**
  48432. * source material index of refraction (IOR)' / 'destination material IOR.
  48433. */
  48434. indexOfRefraction: number;
  48435. /**
  48436. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48437. */
  48438. invertRefractionY: boolean;
  48439. /**
  48440. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48441. * Materials half opaque for instance using refraction could benefit from this control.
  48442. */
  48443. linkRefractionWithTransparency: boolean;
  48444. /**
  48445. * If true, the light map contains occlusion information instead of lighting info.
  48446. */
  48447. useLightmapAsShadowmap: boolean;
  48448. /**
  48449. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48450. */
  48451. useAlphaFromAlbedoTexture: boolean;
  48452. /**
  48453. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48454. */
  48455. forceAlphaTest: boolean;
  48456. /**
  48457. * Defines the alpha limits in alpha test mode.
  48458. */
  48459. alphaCutOff: number;
  48460. /**
  48461. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48462. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48463. */
  48464. useSpecularOverAlpha: boolean;
  48465. /**
  48466. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48467. */
  48468. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48469. /**
  48470. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48471. */
  48472. useRoughnessFromMetallicTextureAlpha: boolean;
  48473. /**
  48474. * Specifies if the metallic texture contains the roughness information in its green channel.
  48475. */
  48476. useRoughnessFromMetallicTextureGreen: boolean;
  48477. /**
  48478. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48479. */
  48480. useMetallnessFromMetallicTextureBlue: boolean;
  48481. /**
  48482. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48483. */
  48484. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48485. /**
  48486. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48487. */
  48488. useAmbientInGrayScale: boolean;
  48489. /**
  48490. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48491. * The material will try to infer what glossiness each pixel should be.
  48492. */
  48493. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48494. /**
  48495. * BJS is using an harcoded light falloff based on a manually sets up range.
  48496. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48497. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48498. */
  48499. /**
  48500. * BJS is using an harcoded light falloff based on a manually sets up range.
  48501. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48502. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48503. */
  48504. usePhysicalLightFalloff: boolean;
  48505. /**
  48506. * In order to support the falloff compatibility with gltf, a special mode has been added
  48507. * to reproduce the gltf light falloff.
  48508. */
  48509. /**
  48510. * In order to support the falloff compatibility with gltf, a special mode has been added
  48511. * to reproduce the gltf light falloff.
  48512. */
  48513. useGLTFLightFalloff: boolean;
  48514. /**
  48515. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48516. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48517. */
  48518. useRadianceOverAlpha: boolean;
  48519. /**
  48520. * Allows using an object space normal map (instead of tangent space).
  48521. */
  48522. useObjectSpaceNormalMap: boolean;
  48523. /**
  48524. * Allows using the bump map in parallax mode.
  48525. */
  48526. useParallax: boolean;
  48527. /**
  48528. * Allows using the bump map in parallax occlusion mode.
  48529. */
  48530. useParallaxOcclusion: boolean;
  48531. /**
  48532. * Controls the scale bias of the parallax mode.
  48533. */
  48534. parallaxScaleBias: number;
  48535. /**
  48536. * If sets to true, disables all the lights affecting the material.
  48537. */
  48538. disableLighting: boolean;
  48539. /**
  48540. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48541. */
  48542. forceIrradianceInFragment: boolean;
  48543. /**
  48544. * Number of Simultaneous lights allowed on the material.
  48545. */
  48546. maxSimultaneousLights: number;
  48547. /**
  48548. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48549. */
  48550. invertNormalMapX: boolean;
  48551. /**
  48552. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48553. */
  48554. invertNormalMapY: boolean;
  48555. /**
  48556. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48557. */
  48558. twoSidedLighting: boolean;
  48559. /**
  48560. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48561. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48562. */
  48563. useAlphaFresnel: boolean;
  48564. /**
  48565. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48566. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48567. */
  48568. useLinearAlphaFresnel: boolean;
  48569. /**
  48570. * Let user defines the brdf lookup texture used for IBL.
  48571. * A default 8bit version is embedded but you could point at :
  48572. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48573. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48574. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48575. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48576. */
  48577. environmentBRDFTexture: Nullable<BaseTexture>;
  48578. /**
  48579. * Force normal to face away from face.
  48580. */
  48581. forceNormalForward: boolean;
  48582. /**
  48583. * Enables specular anti aliasing in the PBR shader.
  48584. * It will both interacts on the Geometry for analytical and IBL lighting.
  48585. * It also prefilter the roughness map based on the bump values.
  48586. */
  48587. enableSpecularAntiAliasing: boolean;
  48588. /**
  48589. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48590. * makes the reflect vector face the model (under horizon).
  48591. */
  48592. useHorizonOcclusion: boolean;
  48593. /**
  48594. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48595. * too much the area relying on ambient texture to define their ambient occlusion.
  48596. */
  48597. useRadianceOcclusion: boolean;
  48598. /**
  48599. * If set to true, no lighting calculations will be applied.
  48600. */
  48601. unlit: boolean;
  48602. /**
  48603. * Gets the image processing configuration used either in this material.
  48604. */
  48605. /**
  48606. * Sets the Default image processing configuration used either in the this material.
  48607. *
  48608. * If sets to null, the scene one is in use.
  48609. */
  48610. imageProcessingConfiguration: ImageProcessingConfiguration;
  48611. /**
  48612. * Gets wether the color curves effect is enabled.
  48613. */
  48614. /**
  48615. * Sets wether the color curves effect is enabled.
  48616. */
  48617. cameraColorCurvesEnabled: boolean;
  48618. /**
  48619. * Gets wether the color grading effect is enabled.
  48620. */
  48621. /**
  48622. * Gets wether the color grading effect is enabled.
  48623. */
  48624. cameraColorGradingEnabled: boolean;
  48625. /**
  48626. * Gets wether tonemapping is enabled or not.
  48627. */
  48628. /**
  48629. * Sets wether tonemapping is enabled or not
  48630. */
  48631. cameraToneMappingEnabled: boolean;
  48632. /**
  48633. * The camera exposure used on this material.
  48634. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48635. * This corresponds to a photographic exposure.
  48636. */
  48637. /**
  48638. * The camera exposure used on this material.
  48639. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48640. * This corresponds to a photographic exposure.
  48641. */
  48642. cameraExposure: number;
  48643. /**
  48644. * Gets The camera contrast used on this material.
  48645. */
  48646. /**
  48647. * Sets The camera contrast used on this material.
  48648. */
  48649. cameraContrast: number;
  48650. /**
  48651. * Gets the Color Grading 2D Lookup Texture.
  48652. */
  48653. /**
  48654. * Sets the Color Grading 2D Lookup Texture.
  48655. */
  48656. cameraColorGradingTexture: Nullable<BaseTexture>;
  48657. /**
  48658. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48659. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48660. * 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;
  48661. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48662. */
  48663. /**
  48664. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48665. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48666. * 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;
  48667. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48668. */
  48669. cameraColorCurves: Nullable<ColorCurves>;
  48670. /**
  48671. * Instantiates a new PBRMaterial instance.
  48672. *
  48673. * @param name The material name
  48674. * @param scene The scene the material will be use in.
  48675. */
  48676. constructor(name: string, scene: Scene);
  48677. /**
  48678. * Returns the name of this material class.
  48679. */
  48680. getClassName(): string;
  48681. /**
  48682. * Makes a duplicate of the current material.
  48683. * @param name - name to use for the new material.
  48684. */
  48685. clone(name: string): PBRMaterial;
  48686. /**
  48687. * Serializes this PBR Material.
  48688. * @returns - An object with the serialized material.
  48689. */
  48690. serialize(): any;
  48691. /**
  48692. * Parses a PBR Material from a serialized object.
  48693. * @param source - Serialized object.
  48694. * @param scene - BJS scene instance.
  48695. * @param rootUrl - url for the scene object
  48696. * @returns - PBRMaterial
  48697. */
  48698. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48699. }
  48700. }
  48701. declare module "babylonjs/Misc/dds" {
  48702. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48703. import { Engine } from "babylonjs/Engines/engine";
  48704. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48705. import { Nullable } from "babylonjs/types";
  48706. import { Scene } from "babylonjs/scene";
  48707. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  48708. /**
  48709. * Direct draw surface info
  48710. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48711. */
  48712. export interface DDSInfo {
  48713. /**
  48714. * Width of the texture
  48715. */
  48716. width: number;
  48717. /**
  48718. * Width of the texture
  48719. */
  48720. height: number;
  48721. /**
  48722. * Number of Mipmaps for the texture
  48723. * @see https://en.wikipedia.org/wiki/Mipmap
  48724. */
  48725. mipmapCount: number;
  48726. /**
  48727. * If the textures format is a known fourCC format
  48728. * @see https://www.fourcc.org/
  48729. */
  48730. isFourCC: boolean;
  48731. /**
  48732. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48733. */
  48734. isRGB: boolean;
  48735. /**
  48736. * If the texture is a lumincance format
  48737. */
  48738. isLuminance: boolean;
  48739. /**
  48740. * If this is a cube texture
  48741. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48742. */
  48743. isCube: boolean;
  48744. /**
  48745. * If the texture is a compressed format eg. FOURCC_DXT1
  48746. */
  48747. isCompressed: boolean;
  48748. /**
  48749. * The dxgiFormat of the texture
  48750. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48751. */
  48752. dxgiFormat: number;
  48753. /**
  48754. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48755. */
  48756. textureType: number;
  48757. /**
  48758. * Sphericle polynomial created for the dds texture
  48759. */
  48760. sphericalPolynomial?: SphericalPolynomial;
  48761. }
  48762. /**
  48763. * Class used to provide DDS decompression tools
  48764. */
  48765. export class DDSTools {
  48766. /**
  48767. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48768. */
  48769. static StoreLODInAlphaChannel: boolean;
  48770. /**
  48771. * Gets DDS information from an array buffer
  48772. * @param arrayBuffer defines the array buffer to read data from
  48773. * @returns the DDS information
  48774. */
  48775. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48776. private static _FloatView;
  48777. private static _Int32View;
  48778. private static _ToHalfFloat;
  48779. private static _FromHalfFloat;
  48780. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48781. private static _GetHalfFloatRGBAArrayBuffer;
  48782. private static _GetFloatRGBAArrayBuffer;
  48783. private static _GetFloatAsUIntRGBAArrayBuffer;
  48784. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48785. private static _GetRGBAArrayBuffer;
  48786. private static _ExtractLongWordOrder;
  48787. private static _GetRGBArrayBuffer;
  48788. private static _GetLuminanceArrayBuffer;
  48789. /**
  48790. * Uploads DDS Levels to a Babylon Texture
  48791. * @hidden
  48792. */
  48793. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48794. }
  48795. module "babylonjs/Engines/engine" {
  48796. interface Engine {
  48797. /**
  48798. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48799. * @param rootUrl defines the url where the file to load is located
  48800. * @param scene defines the current scene
  48801. * @param lodScale defines scale to apply to the mip map selection
  48802. * @param lodOffset defines offset to apply to the mip map selection
  48803. * @param onLoad defines an optional callback raised when the texture is loaded
  48804. * @param onError defines an optional callback raised if there is an issue to load the texture
  48805. * @param format defines the format of the data
  48806. * @param forcedExtension defines the extension to use to pick the right loader
  48807. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48808. * @returns the cube texture as an InternalTexture
  48809. */
  48810. 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;
  48811. }
  48812. }
  48813. }
  48814. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48815. import { Nullable } from "babylonjs/types";
  48816. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48817. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48818. /**
  48819. * Implementation of the DDS Texture Loader.
  48820. * @hidden
  48821. */
  48822. export class _DDSTextureLoader implements IInternalTextureLoader {
  48823. /**
  48824. * Defines wether the loader supports cascade loading the different faces.
  48825. */
  48826. readonly supportCascades: boolean;
  48827. /**
  48828. * This returns if the loader support the current file information.
  48829. * @param extension defines the file extension of the file being loaded
  48830. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48831. * @param fallback defines the fallback internal texture if any
  48832. * @param isBase64 defines whether the texture is encoded as a base64
  48833. * @param isBuffer defines whether the texture data are stored as a buffer
  48834. * @returns true if the loader can load the specified file
  48835. */
  48836. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48837. /**
  48838. * Transform the url before loading if required.
  48839. * @param rootUrl the url of the texture
  48840. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48841. * @returns the transformed texture
  48842. */
  48843. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48844. /**
  48845. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48846. * @param rootUrl the url of the texture
  48847. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48848. * @returns the fallback texture
  48849. */
  48850. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48851. /**
  48852. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48853. * @param data contains the texture data
  48854. * @param texture defines the BabylonJS internal texture
  48855. * @param createPolynomials will be true if polynomials have been requested
  48856. * @param onLoad defines the callback to trigger once the texture is ready
  48857. * @param onError defines the callback to trigger in case of error
  48858. */
  48859. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48860. /**
  48861. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48862. * @param data contains the texture data
  48863. * @param texture defines the BabylonJS internal texture
  48864. * @param callback defines the method to call once ready to upload
  48865. */
  48866. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48867. }
  48868. }
  48869. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48870. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48871. /** @hidden */
  48872. export var rgbdEncodePixelShader: {
  48873. name: string;
  48874. shader: string;
  48875. };
  48876. }
  48877. declare module "babylonjs/Misc/environmentTextureTools" {
  48878. import { Nullable } from "babylonjs/types";
  48879. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48880. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48881. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48882. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48883. import "babylonjs/Shaders/rgbdEncode.fragment";
  48884. import "babylonjs/Shaders/rgbdDecode.fragment";
  48885. /**
  48886. * Raw texture data and descriptor sufficient for WebGL texture upload
  48887. */
  48888. export interface EnvironmentTextureInfo {
  48889. /**
  48890. * Version of the environment map
  48891. */
  48892. version: number;
  48893. /**
  48894. * Width of image
  48895. */
  48896. width: number;
  48897. /**
  48898. * Irradiance information stored in the file.
  48899. */
  48900. irradiance: any;
  48901. /**
  48902. * Specular information stored in the file.
  48903. */
  48904. specular: any;
  48905. }
  48906. /**
  48907. * Sets of helpers addressing the serialization and deserialization of environment texture
  48908. * stored in a BabylonJS env file.
  48909. * Those files are usually stored as .env files.
  48910. */
  48911. export class EnvironmentTextureTools {
  48912. /**
  48913. * Magic number identifying the env file.
  48914. */
  48915. private static _MagicBytes;
  48916. /**
  48917. * Gets the environment info from an env file.
  48918. * @param data The array buffer containing the .env bytes.
  48919. * @returns the environment file info (the json header) if successfully parsed.
  48920. */
  48921. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48922. /**
  48923. * Creates an environment texture from a loaded cube texture.
  48924. * @param texture defines the cube texture to convert in env file
  48925. * @return a promise containing the environment data if succesfull.
  48926. */
  48927. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48928. /**
  48929. * Creates a JSON representation of the spherical data.
  48930. * @param texture defines the texture containing the polynomials
  48931. * @return the JSON representation of the spherical info
  48932. */
  48933. private static _CreateEnvTextureIrradiance;
  48934. /**
  48935. * Uploads the texture info contained in the env file to the GPU.
  48936. * @param texture defines the internal texture to upload to
  48937. * @param arrayBuffer defines the buffer cotaining the data to load
  48938. * @param info defines the texture info retrieved through the GetEnvInfo method
  48939. * @returns a promise
  48940. */
  48941. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48942. /**
  48943. * Uploads the levels of image data to the GPU.
  48944. * @param texture defines the internal texture to upload to
  48945. * @param imageData defines the array buffer views of image data [mipmap][face]
  48946. * @returns a promise
  48947. */
  48948. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48949. /**
  48950. * Uploads spherical polynomials information to the texture.
  48951. * @param texture defines the texture we are trying to upload the information to
  48952. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48953. */
  48954. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48955. /** @hidden */
  48956. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48957. }
  48958. }
  48959. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48960. import { Nullable } from "babylonjs/types";
  48961. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48962. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48963. /**
  48964. * Implementation of the ENV Texture Loader.
  48965. * @hidden
  48966. */
  48967. export class _ENVTextureLoader implements IInternalTextureLoader {
  48968. /**
  48969. * Defines wether the loader supports cascade loading the different faces.
  48970. */
  48971. readonly supportCascades: boolean;
  48972. /**
  48973. * This returns if the loader support the current file information.
  48974. * @param extension defines the file extension of the file being loaded
  48975. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48976. * @param fallback defines the fallback internal texture if any
  48977. * @param isBase64 defines whether the texture is encoded as a base64
  48978. * @param isBuffer defines whether the texture data are stored as a buffer
  48979. * @returns true if the loader can load the specified file
  48980. */
  48981. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48982. /**
  48983. * Transform the url before loading if required.
  48984. * @param rootUrl the url of the texture
  48985. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48986. * @returns the transformed texture
  48987. */
  48988. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48989. /**
  48990. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48991. * @param rootUrl the url of the texture
  48992. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48993. * @returns the fallback texture
  48994. */
  48995. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48996. /**
  48997. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48998. * @param data contains the texture data
  48999. * @param texture defines the BabylonJS internal texture
  49000. * @param createPolynomials will be true if polynomials have been requested
  49001. * @param onLoad defines the callback to trigger once the texture is ready
  49002. * @param onError defines the callback to trigger in case of error
  49003. */
  49004. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49005. /**
  49006. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49007. * @param data contains the texture data
  49008. * @param texture defines the BabylonJS internal texture
  49009. * @param callback defines the method to call once ready to upload
  49010. */
  49011. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49012. }
  49013. }
  49014. declare module "babylonjs/Misc/khronosTextureContainer" {
  49015. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49016. /**
  49017. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49018. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49019. */
  49020. export class KhronosTextureContainer {
  49021. /** contents of the KTX container file */
  49022. arrayBuffer: any;
  49023. private static HEADER_LEN;
  49024. private static COMPRESSED_2D;
  49025. private static COMPRESSED_3D;
  49026. private static TEX_2D;
  49027. private static TEX_3D;
  49028. /**
  49029. * Gets the openGL type
  49030. */
  49031. glType: number;
  49032. /**
  49033. * Gets the openGL type size
  49034. */
  49035. glTypeSize: number;
  49036. /**
  49037. * Gets the openGL format
  49038. */
  49039. glFormat: number;
  49040. /**
  49041. * Gets the openGL internal format
  49042. */
  49043. glInternalFormat: number;
  49044. /**
  49045. * Gets the base internal format
  49046. */
  49047. glBaseInternalFormat: number;
  49048. /**
  49049. * Gets image width in pixel
  49050. */
  49051. pixelWidth: number;
  49052. /**
  49053. * Gets image height in pixel
  49054. */
  49055. pixelHeight: number;
  49056. /**
  49057. * Gets image depth in pixels
  49058. */
  49059. pixelDepth: number;
  49060. /**
  49061. * Gets the number of array elements
  49062. */
  49063. numberOfArrayElements: number;
  49064. /**
  49065. * Gets the number of faces
  49066. */
  49067. numberOfFaces: number;
  49068. /**
  49069. * Gets the number of mipmap levels
  49070. */
  49071. numberOfMipmapLevels: number;
  49072. /**
  49073. * Gets the bytes of key value data
  49074. */
  49075. bytesOfKeyValueData: number;
  49076. /**
  49077. * Gets the load type
  49078. */
  49079. loadType: number;
  49080. /**
  49081. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49082. */
  49083. isInvalid: boolean;
  49084. /**
  49085. * Creates a new KhronosTextureContainer
  49086. * @param arrayBuffer contents of the KTX container file
  49087. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49088. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49089. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49090. */
  49091. constructor(
  49092. /** contents of the KTX container file */
  49093. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49094. /**
  49095. * Uploads KTX content to a Babylon Texture.
  49096. * It is assumed that the texture has already been created & is currently bound
  49097. * @hidden
  49098. */
  49099. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49100. private _upload2DCompressedLevels;
  49101. }
  49102. }
  49103. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  49104. import { Nullable } from "babylonjs/types";
  49105. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49106. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49107. /**
  49108. * Implementation of the KTX Texture Loader.
  49109. * @hidden
  49110. */
  49111. export class _KTXTextureLoader implements IInternalTextureLoader {
  49112. /**
  49113. * Defines wether the loader supports cascade loading the different faces.
  49114. */
  49115. readonly supportCascades: boolean;
  49116. /**
  49117. * This returns if the loader support the current file information.
  49118. * @param extension defines the file extension of the file being loaded
  49119. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49120. * @param fallback defines the fallback internal texture if any
  49121. * @param isBase64 defines whether the texture is encoded as a base64
  49122. * @param isBuffer defines whether the texture data are stored as a buffer
  49123. * @returns true if the loader can load the specified file
  49124. */
  49125. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49126. /**
  49127. * Transform the url before loading if required.
  49128. * @param rootUrl the url of the texture
  49129. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49130. * @returns the transformed texture
  49131. */
  49132. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49133. /**
  49134. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49135. * @param rootUrl the url of the texture
  49136. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49137. * @returns the fallback texture
  49138. */
  49139. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49140. /**
  49141. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49142. * @param data contains the texture data
  49143. * @param texture defines the BabylonJS internal texture
  49144. * @param createPolynomials will be true if polynomials have been requested
  49145. * @param onLoad defines the callback to trigger once the texture is ready
  49146. * @param onError defines the callback to trigger in case of error
  49147. */
  49148. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49149. /**
  49150. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49151. * @param data contains the texture data
  49152. * @param texture defines the BabylonJS internal texture
  49153. * @param callback defines the method to call once ready to upload
  49154. */
  49155. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49156. }
  49157. }
  49158. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  49159. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49160. import { Scene } from "babylonjs/scene";
  49161. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  49162. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  49163. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  49164. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  49165. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  49166. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  49167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49168. /**
  49169. * Options for the default xr helper
  49170. */
  49171. export class WebXRDefaultExperienceOptions {
  49172. /**
  49173. * Floor meshes that should be used for teleporting
  49174. */
  49175. floorMeshes: Array<AbstractMesh>;
  49176. }
  49177. /**
  49178. * Default experience which provides a similar setup to the previous webVRExperience
  49179. */
  49180. export class WebXRDefaultExperience {
  49181. /**
  49182. * Base experience
  49183. */
  49184. baseExperience: WebXRExperienceHelper;
  49185. /**
  49186. * Input experience extension
  49187. */
  49188. input: WebXRInput;
  49189. /**
  49190. * Loads the controller models
  49191. */
  49192. controllerModelLoader: WebXRControllerModelLoader;
  49193. /**
  49194. * Enables laser pointer and selection
  49195. */
  49196. pointerSelection: WebXRControllerPointerSelection;
  49197. /**
  49198. * Enables teleportation
  49199. */
  49200. teleportation: WebXRControllerTeleportation;
  49201. /**
  49202. * Enables ui for enetering/exiting xr
  49203. */
  49204. enterExitUI: WebXREnterExitUI;
  49205. /**
  49206. * Default output canvas xr should render to
  49207. */
  49208. outputCanvas: WebXRManagedOutputCanvas;
  49209. /**
  49210. * Creates the default xr experience
  49211. * @param scene scene
  49212. * @param options options for basic configuration
  49213. * @returns resulting WebXRDefaultExperience
  49214. */
  49215. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49216. private constructor();
  49217. /**
  49218. * DIsposes of the experience helper
  49219. */
  49220. dispose(): void;
  49221. }
  49222. }
  49223. declare module "babylonjs/Helpers/sceneHelpers" {
  49224. import { Nullable } from "babylonjs/types";
  49225. import { Mesh } from "babylonjs/Meshes/mesh";
  49226. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49227. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  49228. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  49229. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49230. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49231. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49232. import "babylonjs/Meshes/Builders/boxBuilder";
  49233. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  49234. /** @hidden */
  49235. export var _forceSceneHelpersToBundle: boolean;
  49236. module "babylonjs/scene" {
  49237. interface Scene {
  49238. /**
  49239. * Creates a default light for the scene.
  49240. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49241. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49242. */
  49243. createDefaultLight(replace?: boolean): void;
  49244. /**
  49245. * Creates a default camera for the scene.
  49246. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49247. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49248. * @param replace has default false, when true replaces the active camera in the scene
  49249. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49250. */
  49251. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49252. /**
  49253. * Creates a default camera and a default light.
  49254. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49255. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49256. * @param replace has the default false, when true replaces the active camera/light in the scene
  49257. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49258. */
  49259. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49260. /**
  49261. * Creates a new sky box
  49262. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49263. * @param environmentTexture defines the texture to use as environment texture
  49264. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49265. * @param scale defines the overall scale of the skybox
  49266. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49267. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49268. * @returns a new mesh holding the sky box
  49269. */
  49270. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49271. /**
  49272. * Creates a new environment
  49273. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49274. * @param options defines the options you can use to configure the environment
  49275. * @returns the new EnvironmentHelper
  49276. */
  49277. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49278. /**
  49279. * Creates a new VREXperienceHelper
  49280. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49281. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49282. * @returns a new VREXperienceHelper
  49283. */
  49284. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49285. /**
  49286. * Creates a new WebXRDefaultExperience
  49287. * @see http://doc.babylonjs.com/how_to/webxr
  49288. * @param options experience options
  49289. * @returns a promise for a new WebXRDefaultExperience
  49290. */
  49291. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49292. }
  49293. }
  49294. }
  49295. declare module "babylonjs/Helpers/videoDome" {
  49296. import { Scene } from "babylonjs/scene";
  49297. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49298. import { Mesh } from "babylonjs/Meshes/mesh";
  49299. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  49300. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49301. import "babylonjs/Meshes/Builders/sphereBuilder";
  49302. /**
  49303. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49304. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49305. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49306. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49307. */
  49308. export class VideoDome extends TransformNode {
  49309. /**
  49310. * Define the video source as a Monoscopic panoramic 360 video.
  49311. */
  49312. static readonly MODE_MONOSCOPIC: number;
  49313. /**
  49314. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49315. */
  49316. static readonly MODE_TOPBOTTOM: number;
  49317. /**
  49318. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49319. */
  49320. static readonly MODE_SIDEBYSIDE: number;
  49321. private _useDirectMapping;
  49322. /**
  49323. * The video texture being displayed on the sphere
  49324. */
  49325. protected _videoTexture: VideoTexture;
  49326. /**
  49327. * Gets the video texture being displayed on the sphere
  49328. */
  49329. readonly videoTexture: VideoTexture;
  49330. /**
  49331. * The skybox material
  49332. */
  49333. protected _material: BackgroundMaterial;
  49334. /**
  49335. * The surface used for the skybox
  49336. */
  49337. protected _mesh: Mesh;
  49338. /**
  49339. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49340. * Also see the options.resolution property.
  49341. */
  49342. fovMultiplier: number;
  49343. private _videoMode;
  49344. /**
  49345. * Gets or set the current video mode for the video. It can be:
  49346. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49347. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49348. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49349. */
  49350. videoMode: number;
  49351. /**
  49352. * Oberserver used in Stereoscopic VR Mode.
  49353. */
  49354. private _onBeforeCameraRenderObserver;
  49355. /**
  49356. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49357. * @param name Element's name, child elements will append suffixes for their own names.
  49358. * @param urlsOrVideo defines the url(s) or the video element to use
  49359. * @param options An object containing optional or exposed sub element properties
  49360. */
  49361. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49362. resolution?: number;
  49363. clickToPlay?: boolean;
  49364. autoPlay?: boolean;
  49365. loop?: boolean;
  49366. size?: number;
  49367. poster?: string;
  49368. faceForward?: boolean;
  49369. useDirectMapping?: boolean;
  49370. }, scene: Scene);
  49371. private _changeVideoMode;
  49372. /**
  49373. * Releases resources associated with this node.
  49374. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49375. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49376. */
  49377. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49378. }
  49379. }
  49380. declare module "babylonjs/Helpers/index" {
  49381. export * from "babylonjs/Helpers/environmentHelper";
  49382. export * from "babylonjs/Helpers/photoDome";
  49383. export * from "babylonjs/Helpers/sceneHelpers";
  49384. export * from "babylonjs/Helpers/videoDome";
  49385. }
  49386. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  49387. import { PerfCounter } from "babylonjs/Misc/tools";
  49388. import { IDisposable } from "babylonjs/scene";
  49389. import { Engine } from "babylonjs/Engines/engine";
  49390. /**
  49391. * This class can be used to get instrumentation data from a Babylon engine
  49392. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49393. */
  49394. export class EngineInstrumentation implements IDisposable {
  49395. /**
  49396. * Define the instrumented engine.
  49397. */
  49398. engine: Engine;
  49399. private _captureGPUFrameTime;
  49400. private _gpuFrameTimeToken;
  49401. private _gpuFrameTime;
  49402. private _captureShaderCompilationTime;
  49403. private _shaderCompilationTime;
  49404. private _onBeginFrameObserver;
  49405. private _onEndFrameObserver;
  49406. private _onBeforeShaderCompilationObserver;
  49407. private _onAfterShaderCompilationObserver;
  49408. /**
  49409. * Gets the perf counter used for GPU frame time
  49410. */
  49411. readonly gpuFrameTimeCounter: PerfCounter;
  49412. /**
  49413. * Gets the GPU frame time capture status
  49414. */
  49415. /**
  49416. * Enable or disable the GPU frame time capture
  49417. */
  49418. captureGPUFrameTime: boolean;
  49419. /**
  49420. * Gets the perf counter used for shader compilation time
  49421. */
  49422. readonly shaderCompilationTimeCounter: PerfCounter;
  49423. /**
  49424. * Gets the shader compilation time capture status
  49425. */
  49426. /**
  49427. * Enable or disable the shader compilation time capture
  49428. */
  49429. captureShaderCompilationTime: boolean;
  49430. /**
  49431. * Instantiates a new engine instrumentation.
  49432. * This class can be used to get instrumentation data from a Babylon engine
  49433. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49434. * @param engine Defines the engine to instrument
  49435. */
  49436. constructor(
  49437. /**
  49438. * Define the instrumented engine.
  49439. */
  49440. engine: Engine);
  49441. /**
  49442. * Dispose and release associated resources.
  49443. */
  49444. dispose(): void;
  49445. }
  49446. }
  49447. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  49448. import { PerfCounter } from "babylonjs/Misc/tools";
  49449. import { Scene, IDisposable } from "babylonjs/scene";
  49450. /**
  49451. * This class can be used to get instrumentation data from a Babylon engine
  49452. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49453. */
  49454. export class SceneInstrumentation implements IDisposable {
  49455. /**
  49456. * Defines the scene to instrument
  49457. */
  49458. scene: Scene;
  49459. private _captureActiveMeshesEvaluationTime;
  49460. private _activeMeshesEvaluationTime;
  49461. private _captureRenderTargetsRenderTime;
  49462. private _renderTargetsRenderTime;
  49463. private _captureFrameTime;
  49464. private _frameTime;
  49465. private _captureRenderTime;
  49466. private _renderTime;
  49467. private _captureInterFrameTime;
  49468. private _interFrameTime;
  49469. private _captureParticlesRenderTime;
  49470. private _particlesRenderTime;
  49471. private _captureSpritesRenderTime;
  49472. private _spritesRenderTime;
  49473. private _capturePhysicsTime;
  49474. private _physicsTime;
  49475. private _captureAnimationsTime;
  49476. private _animationsTime;
  49477. private _captureCameraRenderTime;
  49478. private _cameraRenderTime;
  49479. private _onBeforeActiveMeshesEvaluationObserver;
  49480. private _onAfterActiveMeshesEvaluationObserver;
  49481. private _onBeforeRenderTargetsRenderObserver;
  49482. private _onAfterRenderTargetsRenderObserver;
  49483. private _onAfterRenderObserver;
  49484. private _onBeforeDrawPhaseObserver;
  49485. private _onAfterDrawPhaseObserver;
  49486. private _onBeforeAnimationsObserver;
  49487. private _onBeforeParticlesRenderingObserver;
  49488. private _onAfterParticlesRenderingObserver;
  49489. private _onBeforeSpritesRenderingObserver;
  49490. private _onAfterSpritesRenderingObserver;
  49491. private _onBeforePhysicsObserver;
  49492. private _onAfterPhysicsObserver;
  49493. private _onAfterAnimationsObserver;
  49494. private _onBeforeCameraRenderObserver;
  49495. private _onAfterCameraRenderObserver;
  49496. /**
  49497. * Gets the perf counter used for active meshes evaluation time
  49498. */
  49499. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49500. /**
  49501. * Gets the active meshes evaluation time capture status
  49502. */
  49503. /**
  49504. * Enable or disable the active meshes evaluation time capture
  49505. */
  49506. captureActiveMeshesEvaluationTime: boolean;
  49507. /**
  49508. * Gets the perf counter used for render targets render time
  49509. */
  49510. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49511. /**
  49512. * Gets the render targets render time capture status
  49513. */
  49514. /**
  49515. * Enable or disable the render targets render time capture
  49516. */
  49517. captureRenderTargetsRenderTime: boolean;
  49518. /**
  49519. * Gets the perf counter used for particles render time
  49520. */
  49521. readonly particlesRenderTimeCounter: PerfCounter;
  49522. /**
  49523. * Gets the particles render time capture status
  49524. */
  49525. /**
  49526. * Enable or disable the particles render time capture
  49527. */
  49528. captureParticlesRenderTime: boolean;
  49529. /**
  49530. * Gets the perf counter used for sprites render time
  49531. */
  49532. readonly spritesRenderTimeCounter: PerfCounter;
  49533. /**
  49534. * Gets the sprites render time capture status
  49535. */
  49536. /**
  49537. * Enable or disable the sprites render time capture
  49538. */
  49539. captureSpritesRenderTime: boolean;
  49540. /**
  49541. * Gets the perf counter used for physics time
  49542. */
  49543. readonly physicsTimeCounter: PerfCounter;
  49544. /**
  49545. * Gets the physics time capture status
  49546. */
  49547. /**
  49548. * Enable or disable the physics time capture
  49549. */
  49550. capturePhysicsTime: boolean;
  49551. /**
  49552. * Gets the perf counter used for animations time
  49553. */
  49554. readonly animationsTimeCounter: PerfCounter;
  49555. /**
  49556. * Gets the animations time capture status
  49557. */
  49558. /**
  49559. * Enable or disable the animations time capture
  49560. */
  49561. captureAnimationsTime: boolean;
  49562. /**
  49563. * Gets the perf counter used for frame time capture
  49564. */
  49565. readonly frameTimeCounter: PerfCounter;
  49566. /**
  49567. * Gets the frame time capture status
  49568. */
  49569. /**
  49570. * Enable or disable the frame time capture
  49571. */
  49572. captureFrameTime: boolean;
  49573. /**
  49574. * Gets the perf counter used for inter-frames time capture
  49575. */
  49576. readonly interFrameTimeCounter: PerfCounter;
  49577. /**
  49578. * Gets the inter-frames time capture status
  49579. */
  49580. /**
  49581. * Enable or disable the inter-frames time capture
  49582. */
  49583. captureInterFrameTime: boolean;
  49584. /**
  49585. * Gets the perf counter used for render time capture
  49586. */
  49587. readonly renderTimeCounter: PerfCounter;
  49588. /**
  49589. * Gets the render time capture status
  49590. */
  49591. /**
  49592. * Enable or disable the render time capture
  49593. */
  49594. captureRenderTime: boolean;
  49595. /**
  49596. * Gets the perf counter used for camera render time capture
  49597. */
  49598. readonly cameraRenderTimeCounter: PerfCounter;
  49599. /**
  49600. * Gets the camera render time capture status
  49601. */
  49602. /**
  49603. * Enable or disable the camera render time capture
  49604. */
  49605. captureCameraRenderTime: boolean;
  49606. /**
  49607. * Gets the perf counter used for draw calls
  49608. */
  49609. readonly drawCallsCounter: PerfCounter;
  49610. /**
  49611. * Instantiates a new scene instrumentation.
  49612. * This class can be used to get instrumentation data from a Babylon engine
  49613. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49614. * @param scene Defines the scene to instrument
  49615. */
  49616. constructor(
  49617. /**
  49618. * Defines the scene to instrument
  49619. */
  49620. scene: Scene);
  49621. /**
  49622. * Dispose and release associated resources.
  49623. */
  49624. dispose(): void;
  49625. }
  49626. }
  49627. declare module "babylonjs/Instrumentation/index" {
  49628. export * from "babylonjs/Instrumentation/engineInstrumentation";
  49629. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  49630. export * from "babylonjs/Instrumentation/timeToken";
  49631. }
  49632. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  49633. /** @hidden */
  49634. export var glowMapGenerationPixelShader: {
  49635. name: string;
  49636. shader: string;
  49637. };
  49638. }
  49639. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  49640. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49641. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49642. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49643. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49644. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49645. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49646. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49647. /** @hidden */
  49648. export var glowMapGenerationVertexShader: {
  49649. name: string;
  49650. shader: string;
  49651. };
  49652. }
  49653. declare module "babylonjs/Layers/effectLayer" {
  49654. import { Observable } from "babylonjs/Misc/observable";
  49655. import { Nullable } from "babylonjs/types";
  49656. import { Camera } from "babylonjs/Cameras/camera";
  49657. import { Scene } from "babylonjs/scene";
  49658. import { Color4, ISize } from "babylonjs/Maths/math";
  49659. import { Engine } from "babylonjs/Engines/engine";
  49660. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49662. import { Mesh } from "babylonjs/Meshes/mesh";
  49663. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  49664. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49665. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49666. import { Effect } from "babylonjs/Materials/effect";
  49667. import { Material } from "babylonjs/Materials/material";
  49668. import "babylonjs/Shaders/glowMapGeneration.fragment";
  49669. import "babylonjs/Shaders/glowMapGeneration.vertex";
  49670. /**
  49671. * Effect layer options. This helps customizing the behaviour
  49672. * of the effect layer.
  49673. */
  49674. export interface IEffectLayerOptions {
  49675. /**
  49676. * Multiplication factor apply to the canvas size to compute the render target size
  49677. * used to generated the objects (the smaller the faster).
  49678. */
  49679. mainTextureRatio: number;
  49680. /**
  49681. * Enforces a fixed size texture to ensure effect stability across devices.
  49682. */
  49683. mainTextureFixedSize?: number;
  49684. /**
  49685. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49686. */
  49687. alphaBlendingMode: number;
  49688. /**
  49689. * The camera attached to the layer.
  49690. */
  49691. camera: Nullable<Camera>;
  49692. /**
  49693. * The rendering group to draw the layer in.
  49694. */
  49695. renderingGroupId: number;
  49696. }
  49697. /**
  49698. * The effect layer Helps adding post process effect blended with the main pass.
  49699. *
  49700. * This can be for instance use to generate glow or higlight effects on the scene.
  49701. *
  49702. * The effect layer class can not be used directly and is intented to inherited from to be
  49703. * customized per effects.
  49704. */
  49705. export abstract class EffectLayer {
  49706. private _vertexBuffers;
  49707. private _indexBuffer;
  49708. private _cachedDefines;
  49709. private _effectLayerMapGenerationEffect;
  49710. private _effectLayerOptions;
  49711. private _mergeEffect;
  49712. protected _scene: Scene;
  49713. protected _engine: Engine;
  49714. protected _maxSize: number;
  49715. protected _mainTextureDesiredSize: ISize;
  49716. protected _mainTexture: RenderTargetTexture;
  49717. protected _shouldRender: boolean;
  49718. protected _postProcesses: PostProcess[];
  49719. protected _textures: BaseTexture[];
  49720. protected _emissiveTextureAndColor: {
  49721. texture: Nullable<BaseTexture>;
  49722. color: Color4;
  49723. };
  49724. /**
  49725. * The name of the layer
  49726. */
  49727. name: string;
  49728. /**
  49729. * The clear color of the texture used to generate the glow map.
  49730. */
  49731. neutralColor: Color4;
  49732. /**
  49733. * Specifies wether the highlight layer is enabled or not.
  49734. */
  49735. isEnabled: boolean;
  49736. /**
  49737. * Gets the camera attached to the layer.
  49738. */
  49739. readonly camera: Nullable<Camera>;
  49740. /**
  49741. * Gets the rendering group id the layer should render in.
  49742. */
  49743. renderingGroupId: number;
  49744. /**
  49745. * An event triggered when the effect layer has been disposed.
  49746. */
  49747. onDisposeObservable: Observable<EffectLayer>;
  49748. /**
  49749. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49750. */
  49751. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49752. /**
  49753. * An event triggered when the generated texture is being merged in the scene.
  49754. */
  49755. onBeforeComposeObservable: Observable<EffectLayer>;
  49756. /**
  49757. * An event triggered when the generated texture has been merged in the scene.
  49758. */
  49759. onAfterComposeObservable: Observable<EffectLayer>;
  49760. /**
  49761. * An event triggered when the efffect layer changes its size.
  49762. */
  49763. onSizeChangedObservable: Observable<EffectLayer>;
  49764. /** @hidden */
  49765. static _SceneComponentInitialization: (scene: Scene) => void;
  49766. /**
  49767. * Instantiates a new effect Layer and references it in the scene.
  49768. * @param name The name of the layer
  49769. * @param scene The scene to use the layer in
  49770. */
  49771. constructor(
  49772. /** The Friendly of the effect in the scene */
  49773. name: string, scene: Scene);
  49774. /**
  49775. * Get the effect name of the layer.
  49776. * @return The effect name
  49777. */
  49778. abstract getEffectName(): string;
  49779. /**
  49780. * Checks for the readiness of the element composing the layer.
  49781. * @param subMesh the mesh to check for
  49782. * @param useInstances specify wether or not to use instances to render the mesh
  49783. * @return true if ready otherwise, false
  49784. */
  49785. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49786. /**
  49787. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49788. * @returns true if the effect requires stencil during the main canvas render pass.
  49789. */
  49790. abstract needStencil(): boolean;
  49791. /**
  49792. * Create the merge effect. This is the shader use to blit the information back
  49793. * to the main canvas at the end of the scene rendering.
  49794. * @returns The effect containing the shader used to merge the effect on the main canvas
  49795. */
  49796. protected abstract _createMergeEffect(): Effect;
  49797. /**
  49798. * Creates the render target textures and post processes used in the effect layer.
  49799. */
  49800. protected abstract _createTextureAndPostProcesses(): void;
  49801. /**
  49802. * Implementation specific of rendering the generating effect on the main canvas.
  49803. * @param effect The effect used to render through
  49804. */
  49805. protected abstract _internalRender(effect: Effect): void;
  49806. /**
  49807. * Sets the required values for both the emissive texture and and the main color.
  49808. */
  49809. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49810. /**
  49811. * Free any resources and references associated to a mesh.
  49812. * Internal use
  49813. * @param mesh The mesh to free.
  49814. */
  49815. abstract _disposeMesh(mesh: Mesh): void;
  49816. /**
  49817. * Serializes this layer (Glow or Highlight for example)
  49818. * @returns a serialized layer object
  49819. */
  49820. abstract serialize?(): any;
  49821. /**
  49822. * Initializes the effect layer with the required options.
  49823. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49824. */
  49825. protected _init(options: Partial<IEffectLayerOptions>): void;
  49826. /**
  49827. * Generates the index buffer of the full screen quad blending to the main canvas.
  49828. */
  49829. private _generateIndexBuffer;
  49830. /**
  49831. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49832. */
  49833. private _generateVertexBuffer;
  49834. /**
  49835. * Sets the main texture desired size which is the closest power of two
  49836. * of the engine canvas size.
  49837. */
  49838. private _setMainTextureSize;
  49839. /**
  49840. * Creates the main texture for the effect layer.
  49841. */
  49842. protected _createMainTexture(): void;
  49843. /**
  49844. * Adds specific effects defines.
  49845. * @param defines The defines to add specifics to.
  49846. */
  49847. protected _addCustomEffectDefines(defines: string[]): void;
  49848. /**
  49849. * Checks for the readiness of the element composing the layer.
  49850. * @param subMesh the mesh to check for
  49851. * @param useInstances specify wether or not to use instances to render the mesh
  49852. * @param emissiveTexture the associated emissive texture used to generate the glow
  49853. * @return true if ready otherwise, false
  49854. */
  49855. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49856. /**
  49857. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49858. */
  49859. render(): void;
  49860. /**
  49861. * Determine if a given mesh will be used in the current effect.
  49862. * @param mesh mesh to test
  49863. * @returns true if the mesh will be used
  49864. */
  49865. hasMesh(mesh: AbstractMesh): boolean;
  49866. /**
  49867. * Returns true if the layer contains information to display, otherwise false.
  49868. * @returns true if the glow layer should be rendered
  49869. */
  49870. shouldRender(): boolean;
  49871. /**
  49872. * Returns true if the mesh should render, otherwise false.
  49873. * @param mesh The mesh to render
  49874. * @returns true if it should render otherwise false
  49875. */
  49876. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49877. /**
  49878. * Returns true if the mesh can be rendered, otherwise false.
  49879. * @param mesh The mesh to render
  49880. * @param material The material used on the mesh
  49881. * @returns true if it can be rendered otherwise false
  49882. */
  49883. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49884. /**
  49885. * Returns true if the mesh should render, otherwise false.
  49886. * @param mesh The mesh to render
  49887. * @returns true if it should render otherwise false
  49888. */
  49889. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49890. /**
  49891. * Renders the submesh passed in parameter to the generation map.
  49892. */
  49893. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49894. /**
  49895. * Rebuild the required buffers.
  49896. * @hidden Internal use only.
  49897. */
  49898. _rebuild(): void;
  49899. /**
  49900. * Dispose only the render target textures and post process.
  49901. */
  49902. private _disposeTextureAndPostProcesses;
  49903. /**
  49904. * Dispose the highlight layer and free resources.
  49905. */
  49906. dispose(): void;
  49907. /**
  49908. * Gets the class name of the effect layer
  49909. * @returns the string with the class name of the effect layer
  49910. */
  49911. getClassName(): string;
  49912. /**
  49913. * Creates an effect layer from parsed effect layer data
  49914. * @param parsedEffectLayer defines effect layer data
  49915. * @param scene defines the current scene
  49916. * @param rootUrl defines the root URL containing the effect layer information
  49917. * @returns a parsed effect Layer
  49918. */
  49919. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49920. }
  49921. }
  49922. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49923. import { Scene } from "babylonjs/scene";
  49924. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49925. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49926. import { AbstractScene } from "babylonjs/abstractScene";
  49927. module "babylonjs/abstractScene" {
  49928. interface AbstractScene {
  49929. /**
  49930. * The list of effect layers (highlights/glow) added to the scene
  49931. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49932. * @see http://doc.babylonjs.com/how_to/glow_layer
  49933. */
  49934. effectLayers: Array<EffectLayer>;
  49935. /**
  49936. * Removes the given effect layer from this scene.
  49937. * @param toRemove defines the effect layer to remove
  49938. * @returns the index of the removed effect layer
  49939. */
  49940. removeEffectLayer(toRemove: EffectLayer): number;
  49941. /**
  49942. * Adds the given effect layer to this scene
  49943. * @param newEffectLayer defines the effect layer to add
  49944. */
  49945. addEffectLayer(newEffectLayer: EffectLayer): void;
  49946. }
  49947. }
  49948. /**
  49949. * Defines the layer scene component responsible to manage any effect layers
  49950. * in a given scene.
  49951. */
  49952. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49953. /**
  49954. * The component name helpfull to identify the component in the list of scene components.
  49955. */
  49956. readonly name: string;
  49957. /**
  49958. * The scene the component belongs to.
  49959. */
  49960. scene: Scene;
  49961. private _engine;
  49962. private _renderEffects;
  49963. private _needStencil;
  49964. private _previousStencilState;
  49965. /**
  49966. * Creates a new instance of the component for the given scene
  49967. * @param scene Defines the scene to register the component in
  49968. */
  49969. constructor(scene: Scene);
  49970. /**
  49971. * Registers the component in a given scene
  49972. */
  49973. register(): void;
  49974. /**
  49975. * Rebuilds the elements related to this component in case of
  49976. * context lost for instance.
  49977. */
  49978. rebuild(): void;
  49979. /**
  49980. * Serializes the component data to the specified json object
  49981. * @param serializationObject The object to serialize to
  49982. */
  49983. serialize(serializationObject: any): void;
  49984. /**
  49985. * Adds all the elements from the container to the scene
  49986. * @param container the container holding the elements
  49987. */
  49988. addFromContainer(container: AbstractScene): void;
  49989. /**
  49990. * Removes all the elements in the container from the scene
  49991. * @param container contains the elements to remove
  49992. * @param dispose if the removed element should be disposed (default: false)
  49993. */
  49994. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49995. /**
  49996. * Disposes the component and the associated ressources.
  49997. */
  49998. dispose(): void;
  49999. private _isReadyForMesh;
  50000. private _renderMainTexture;
  50001. private _setStencil;
  50002. private _setStencilBack;
  50003. private _draw;
  50004. private _drawCamera;
  50005. private _drawRenderingGroup;
  50006. }
  50007. }
  50008. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  50009. /** @hidden */
  50010. export var glowMapMergePixelShader: {
  50011. name: string;
  50012. shader: string;
  50013. };
  50014. }
  50015. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  50016. /** @hidden */
  50017. export var glowMapMergeVertexShader: {
  50018. name: string;
  50019. shader: string;
  50020. };
  50021. }
  50022. declare module "babylonjs/Layers/glowLayer" {
  50023. import { Nullable } from "babylonjs/types";
  50024. import { Camera } from "babylonjs/Cameras/camera";
  50025. import { Scene } from "babylonjs/scene";
  50026. import { Color4 } from "babylonjs/Maths/math";
  50027. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50029. import { Mesh } from "babylonjs/Meshes/mesh";
  50030. import { Texture } from "babylonjs/Materials/Textures/texture";
  50031. import { Effect } from "babylonjs/Materials/effect";
  50032. import { Material } from "babylonjs/Materials/material";
  50033. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50034. import "babylonjs/Shaders/glowMapMerge.fragment";
  50035. import "babylonjs/Shaders/glowMapMerge.vertex";
  50036. import "babylonjs/Layers/effectLayerSceneComponent";
  50037. module "babylonjs/abstractScene" {
  50038. interface AbstractScene {
  50039. /**
  50040. * Return a the first highlight layer of the scene with a given name.
  50041. * @param name The name of the highlight layer to look for.
  50042. * @return The highlight layer if found otherwise null.
  50043. */
  50044. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50045. }
  50046. }
  50047. /**
  50048. * Glow layer options. This helps customizing the behaviour
  50049. * of the glow layer.
  50050. */
  50051. export interface IGlowLayerOptions {
  50052. /**
  50053. * Multiplication factor apply to the canvas size to compute the render target size
  50054. * used to generated the glowing objects (the smaller the faster).
  50055. */
  50056. mainTextureRatio: number;
  50057. /**
  50058. * Enforces a fixed size texture to ensure resize independant blur.
  50059. */
  50060. mainTextureFixedSize?: number;
  50061. /**
  50062. * How big is the kernel of the blur texture.
  50063. */
  50064. blurKernelSize: number;
  50065. /**
  50066. * The camera attached to the layer.
  50067. */
  50068. camera: Nullable<Camera>;
  50069. /**
  50070. * Enable MSAA by chosing the number of samples.
  50071. */
  50072. mainTextureSamples?: number;
  50073. /**
  50074. * The rendering group to draw the layer in.
  50075. */
  50076. renderingGroupId: number;
  50077. }
  50078. /**
  50079. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50080. *
  50081. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50082. * glowy meshes to your scene.
  50083. *
  50084. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50085. */
  50086. export class GlowLayer extends EffectLayer {
  50087. /**
  50088. * Effect Name of the layer.
  50089. */
  50090. static readonly EffectName: string;
  50091. /**
  50092. * The default blur kernel size used for the glow.
  50093. */
  50094. static DefaultBlurKernelSize: number;
  50095. /**
  50096. * The default texture size ratio used for the glow.
  50097. */
  50098. static DefaultTextureRatio: number;
  50099. /**
  50100. * Sets the kernel size of the blur.
  50101. */
  50102. /**
  50103. * Gets the kernel size of the blur.
  50104. */
  50105. blurKernelSize: number;
  50106. /**
  50107. * Sets the glow intensity.
  50108. */
  50109. /**
  50110. * Gets the glow intensity.
  50111. */
  50112. intensity: number;
  50113. private _options;
  50114. private _intensity;
  50115. private _horizontalBlurPostprocess1;
  50116. private _verticalBlurPostprocess1;
  50117. private _horizontalBlurPostprocess2;
  50118. private _verticalBlurPostprocess2;
  50119. private _blurTexture1;
  50120. private _blurTexture2;
  50121. private _postProcesses1;
  50122. private _postProcesses2;
  50123. private _includedOnlyMeshes;
  50124. private _excludedMeshes;
  50125. /**
  50126. * Callback used to let the user override the color selection on a per mesh basis
  50127. */
  50128. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50129. /**
  50130. * Callback used to let the user override the texture selection on a per mesh basis
  50131. */
  50132. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50133. /**
  50134. * Instantiates a new glow Layer and references it to the scene.
  50135. * @param name The name of the layer
  50136. * @param scene The scene to use the layer in
  50137. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50138. */
  50139. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50140. /**
  50141. * Get the effect name of the layer.
  50142. * @return The effect name
  50143. */
  50144. getEffectName(): string;
  50145. /**
  50146. * Create the merge effect. This is the shader use to blit the information back
  50147. * to the main canvas at the end of the scene rendering.
  50148. */
  50149. protected _createMergeEffect(): Effect;
  50150. /**
  50151. * Creates the render target textures and post processes used in the glow layer.
  50152. */
  50153. protected _createTextureAndPostProcesses(): void;
  50154. /**
  50155. * Checks for the readiness of the element composing the layer.
  50156. * @param subMesh the mesh to check for
  50157. * @param useInstances specify wether or not to use instances to render the mesh
  50158. * @param emissiveTexture the associated emissive texture used to generate the glow
  50159. * @return true if ready otherwise, false
  50160. */
  50161. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50162. /**
  50163. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50164. */
  50165. needStencil(): boolean;
  50166. /**
  50167. * Returns true if the mesh can be rendered, otherwise false.
  50168. * @param mesh The mesh to render
  50169. * @param material The material used on the mesh
  50170. * @returns true if it can be rendered otherwise false
  50171. */
  50172. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50173. /**
  50174. * Implementation specific of rendering the generating effect on the main canvas.
  50175. * @param effect The effect used to render through
  50176. */
  50177. protected _internalRender(effect: Effect): void;
  50178. /**
  50179. * Sets the required values for both the emissive texture and and the main color.
  50180. */
  50181. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50182. /**
  50183. * Returns true if the mesh should render, otherwise false.
  50184. * @param mesh The mesh to render
  50185. * @returns true if it should render otherwise false
  50186. */
  50187. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50188. /**
  50189. * Adds specific effects defines.
  50190. * @param defines The defines to add specifics to.
  50191. */
  50192. protected _addCustomEffectDefines(defines: string[]): void;
  50193. /**
  50194. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50195. * @param mesh The mesh to exclude from the glow layer
  50196. */
  50197. addExcludedMesh(mesh: Mesh): void;
  50198. /**
  50199. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50200. * @param mesh The mesh to remove
  50201. */
  50202. removeExcludedMesh(mesh: Mesh): void;
  50203. /**
  50204. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50205. * @param mesh The mesh to include in the glow layer
  50206. */
  50207. addIncludedOnlyMesh(mesh: Mesh): void;
  50208. /**
  50209. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50210. * @param mesh The mesh to remove
  50211. */
  50212. removeIncludedOnlyMesh(mesh: Mesh): void;
  50213. /**
  50214. * Determine if a given mesh will be used in the glow layer
  50215. * @param mesh The mesh to test
  50216. * @returns true if the mesh will be highlighted by the current glow layer
  50217. */
  50218. hasMesh(mesh: AbstractMesh): boolean;
  50219. /**
  50220. * Free any resources and references associated to a mesh.
  50221. * Internal use
  50222. * @param mesh The mesh to free.
  50223. * @hidden
  50224. */
  50225. _disposeMesh(mesh: Mesh): void;
  50226. /**
  50227. * Gets the class name of the effect layer
  50228. * @returns the string with the class name of the effect layer
  50229. */
  50230. getClassName(): string;
  50231. /**
  50232. * Serializes this glow layer
  50233. * @returns a serialized glow layer object
  50234. */
  50235. serialize(): any;
  50236. /**
  50237. * Creates a Glow Layer from parsed glow layer data
  50238. * @param parsedGlowLayer defines glow layer data
  50239. * @param scene defines the current scene
  50240. * @param rootUrl defines the root URL containing the glow layer information
  50241. * @returns a parsed Glow Layer
  50242. */
  50243. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50244. }
  50245. }
  50246. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  50247. /** @hidden */
  50248. export var glowBlurPostProcessPixelShader: {
  50249. name: string;
  50250. shader: string;
  50251. };
  50252. }
  50253. declare module "babylonjs/Layers/highlightLayer" {
  50254. import { Observable } from "babylonjs/Misc/observable";
  50255. import { Nullable } from "babylonjs/types";
  50256. import { Camera } from "babylonjs/Cameras/camera";
  50257. import { Scene } from "babylonjs/scene";
  50258. import { Color3, Color4 } from "babylonjs/Maths/math";
  50259. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50260. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50261. import { Mesh } from "babylonjs/Meshes/mesh";
  50262. import { Effect } from "babylonjs/Materials/effect";
  50263. import { Material } from "babylonjs/Materials/material";
  50264. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50265. import "babylonjs/Shaders/glowMapMerge.fragment";
  50266. import "babylonjs/Shaders/glowMapMerge.vertex";
  50267. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  50268. module "babylonjs/abstractScene" {
  50269. interface AbstractScene {
  50270. /**
  50271. * Return a the first highlight layer of the scene with a given name.
  50272. * @param name The name of the highlight layer to look for.
  50273. * @return The highlight layer if found otherwise null.
  50274. */
  50275. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50276. }
  50277. }
  50278. /**
  50279. * Highlight layer options. This helps customizing the behaviour
  50280. * of the highlight layer.
  50281. */
  50282. export interface IHighlightLayerOptions {
  50283. /**
  50284. * Multiplication factor apply to the canvas size to compute the render target size
  50285. * used to generated the glowing objects (the smaller the faster).
  50286. */
  50287. mainTextureRatio: number;
  50288. /**
  50289. * Enforces a fixed size texture to ensure resize independant blur.
  50290. */
  50291. mainTextureFixedSize?: number;
  50292. /**
  50293. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50294. * of the picture to blur (the smaller the faster).
  50295. */
  50296. blurTextureSizeRatio: number;
  50297. /**
  50298. * How big in texel of the blur texture is the vertical blur.
  50299. */
  50300. blurVerticalSize: number;
  50301. /**
  50302. * How big in texel of the blur texture is the horizontal blur.
  50303. */
  50304. blurHorizontalSize: number;
  50305. /**
  50306. * Alpha blending mode used to apply the blur. Default is combine.
  50307. */
  50308. alphaBlendingMode: number;
  50309. /**
  50310. * The camera attached to the layer.
  50311. */
  50312. camera: Nullable<Camera>;
  50313. /**
  50314. * Should we display highlight as a solid stroke?
  50315. */
  50316. isStroke?: boolean;
  50317. /**
  50318. * The rendering group to draw the layer in.
  50319. */
  50320. renderingGroupId: number;
  50321. }
  50322. /**
  50323. * The highlight layer Helps adding a glow effect around a mesh.
  50324. *
  50325. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50326. * glowy meshes to your scene.
  50327. *
  50328. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50329. */
  50330. export class HighlightLayer extends EffectLayer {
  50331. name: string;
  50332. /**
  50333. * Effect Name of the highlight layer.
  50334. */
  50335. static readonly EffectName: string;
  50336. /**
  50337. * The neutral color used during the preparation of the glow effect.
  50338. * This is black by default as the blend operation is a blend operation.
  50339. */
  50340. static NeutralColor: Color4;
  50341. /**
  50342. * Stencil value used for glowing meshes.
  50343. */
  50344. static GlowingMeshStencilReference: number;
  50345. /**
  50346. * Stencil value used for the other meshes in the scene.
  50347. */
  50348. static NormalMeshStencilReference: number;
  50349. /**
  50350. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50351. */
  50352. innerGlow: boolean;
  50353. /**
  50354. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50355. */
  50356. outerGlow: boolean;
  50357. /**
  50358. * Specifies the horizontal size of the blur.
  50359. */
  50360. /**
  50361. * Gets the horizontal size of the blur.
  50362. */
  50363. blurHorizontalSize: number;
  50364. /**
  50365. * Specifies the vertical size of the blur.
  50366. */
  50367. /**
  50368. * Gets the vertical size of the blur.
  50369. */
  50370. blurVerticalSize: number;
  50371. /**
  50372. * An event triggered when the highlight layer is being blurred.
  50373. */
  50374. onBeforeBlurObservable: Observable<HighlightLayer>;
  50375. /**
  50376. * An event triggered when the highlight layer has been blurred.
  50377. */
  50378. onAfterBlurObservable: Observable<HighlightLayer>;
  50379. private _instanceGlowingMeshStencilReference;
  50380. private _options;
  50381. private _downSamplePostprocess;
  50382. private _horizontalBlurPostprocess;
  50383. private _verticalBlurPostprocess;
  50384. private _blurTexture;
  50385. private _meshes;
  50386. private _excludedMeshes;
  50387. /**
  50388. * Instantiates a new highlight Layer and references it to the scene..
  50389. * @param name The name of the layer
  50390. * @param scene The scene to use the layer in
  50391. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50392. */
  50393. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50394. /**
  50395. * Get the effect name of the layer.
  50396. * @return The effect name
  50397. */
  50398. getEffectName(): string;
  50399. /**
  50400. * Create the merge effect. This is the shader use to blit the information back
  50401. * to the main canvas at the end of the scene rendering.
  50402. */
  50403. protected _createMergeEffect(): Effect;
  50404. /**
  50405. * Creates the render target textures and post processes used in the highlight layer.
  50406. */
  50407. protected _createTextureAndPostProcesses(): void;
  50408. /**
  50409. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50410. */
  50411. needStencil(): boolean;
  50412. /**
  50413. * Checks for the readiness of the element composing the layer.
  50414. * @param subMesh the mesh to check for
  50415. * @param useInstances specify wether or not to use instances to render the mesh
  50416. * @param emissiveTexture the associated emissive texture used to generate the glow
  50417. * @return true if ready otherwise, false
  50418. */
  50419. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50420. /**
  50421. * Implementation specific of rendering the generating effect on the main canvas.
  50422. * @param effect The effect used to render through
  50423. */
  50424. protected _internalRender(effect: Effect): void;
  50425. /**
  50426. * Returns true if the layer contains information to display, otherwise false.
  50427. */
  50428. shouldRender(): boolean;
  50429. /**
  50430. * Returns true if the mesh should render, otherwise false.
  50431. * @param mesh The mesh to render
  50432. * @returns true if it should render otherwise false
  50433. */
  50434. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50435. /**
  50436. * Sets the required values for both the emissive texture and and the main color.
  50437. */
  50438. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50439. /**
  50440. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50441. * @param mesh The mesh to exclude from the highlight layer
  50442. */
  50443. addExcludedMesh(mesh: Mesh): void;
  50444. /**
  50445. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50446. * @param mesh The mesh to highlight
  50447. */
  50448. removeExcludedMesh(mesh: Mesh): void;
  50449. /**
  50450. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50451. * @param mesh mesh to test
  50452. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50453. */
  50454. hasMesh(mesh: AbstractMesh): boolean;
  50455. /**
  50456. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50457. * @param mesh The mesh to highlight
  50458. * @param color The color of the highlight
  50459. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50460. */
  50461. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50462. /**
  50463. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50464. * @param mesh The mesh to highlight
  50465. */
  50466. removeMesh(mesh: Mesh): void;
  50467. /**
  50468. * Force the stencil to the normal expected value for none glowing parts
  50469. */
  50470. private _defaultStencilReference;
  50471. /**
  50472. * Free any resources and references associated to a mesh.
  50473. * Internal use
  50474. * @param mesh The mesh to free.
  50475. * @hidden
  50476. */
  50477. _disposeMesh(mesh: Mesh): void;
  50478. /**
  50479. * Dispose the highlight layer and free resources.
  50480. */
  50481. dispose(): void;
  50482. /**
  50483. * Gets the class name of the effect layer
  50484. * @returns the string with the class name of the effect layer
  50485. */
  50486. getClassName(): string;
  50487. /**
  50488. * Serializes this Highlight layer
  50489. * @returns a serialized Highlight layer object
  50490. */
  50491. serialize(): any;
  50492. /**
  50493. * Creates a Highlight layer from parsed Highlight layer data
  50494. * @param parsedHightlightLayer defines the Highlight layer data
  50495. * @param scene defines the current scene
  50496. * @param rootUrl defines the root URL containing the Highlight layer information
  50497. * @returns a parsed Highlight layer
  50498. */
  50499. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50500. }
  50501. }
  50502. declare module "babylonjs/Layers/layerSceneComponent" {
  50503. import { Scene } from "babylonjs/scene";
  50504. import { ISceneComponent } from "babylonjs/sceneComponent";
  50505. import { Layer } from "babylonjs/Layers/layer";
  50506. import { AbstractScene } from "babylonjs/abstractScene";
  50507. module "babylonjs/abstractScene" {
  50508. interface AbstractScene {
  50509. /**
  50510. * The list of layers (background and foreground) of the scene
  50511. */
  50512. layers: Array<Layer>;
  50513. }
  50514. }
  50515. /**
  50516. * Defines the layer scene component responsible to manage any layers
  50517. * in a given scene.
  50518. */
  50519. export class LayerSceneComponent implements ISceneComponent {
  50520. /**
  50521. * The component name helpfull to identify the component in the list of scene components.
  50522. */
  50523. readonly name: string;
  50524. /**
  50525. * The scene the component belongs to.
  50526. */
  50527. scene: Scene;
  50528. private _engine;
  50529. /**
  50530. * Creates a new instance of the component for the given scene
  50531. * @param scene Defines the scene to register the component in
  50532. */
  50533. constructor(scene: Scene);
  50534. /**
  50535. * Registers the component in a given scene
  50536. */
  50537. register(): void;
  50538. /**
  50539. * Rebuilds the elements related to this component in case of
  50540. * context lost for instance.
  50541. */
  50542. rebuild(): void;
  50543. /**
  50544. * Disposes the component and the associated ressources.
  50545. */
  50546. dispose(): void;
  50547. private _draw;
  50548. private _drawCameraPredicate;
  50549. private _drawCameraBackground;
  50550. private _drawCameraForeground;
  50551. private _drawRenderTargetPredicate;
  50552. private _drawRenderTargetBackground;
  50553. private _drawRenderTargetForeground;
  50554. /**
  50555. * Adds all the elements from the container to the scene
  50556. * @param container the container holding the elements
  50557. */
  50558. addFromContainer(container: AbstractScene): void;
  50559. /**
  50560. * Removes all the elements in the container from the scene
  50561. * @param container contains the elements to remove
  50562. * @param dispose if the removed element should be disposed (default: false)
  50563. */
  50564. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50565. }
  50566. }
  50567. declare module "babylonjs/Shaders/layer.fragment" {
  50568. /** @hidden */
  50569. export var layerPixelShader: {
  50570. name: string;
  50571. shader: string;
  50572. };
  50573. }
  50574. declare module "babylonjs/Shaders/layer.vertex" {
  50575. /** @hidden */
  50576. export var layerVertexShader: {
  50577. name: string;
  50578. shader: string;
  50579. };
  50580. }
  50581. declare module "babylonjs/Layers/layer" {
  50582. import { Observable } from "babylonjs/Misc/observable";
  50583. import { Nullable } from "babylonjs/types";
  50584. import { Scene } from "babylonjs/scene";
  50585. import { Vector2, Color4 } from "babylonjs/Maths/math";
  50586. import { Texture } from "babylonjs/Materials/Textures/texture";
  50587. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50588. import "babylonjs/Shaders/layer.fragment";
  50589. import "babylonjs/Shaders/layer.vertex";
  50590. /**
  50591. * This represents a full screen 2d layer.
  50592. * This can be useful to display a picture in the background of your scene for instance.
  50593. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50594. */
  50595. export class Layer {
  50596. /**
  50597. * Define the name of the layer.
  50598. */
  50599. name: string;
  50600. /**
  50601. * Define the texture the layer should display.
  50602. */
  50603. texture: Nullable<Texture>;
  50604. /**
  50605. * Is the layer in background or foreground.
  50606. */
  50607. isBackground: boolean;
  50608. /**
  50609. * Define the color of the layer (instead of texture).
  50610. */
  50611. color: Color4;
  50612. /**
  50613. * Define the scale of the layer in order to zoom in out of the texture.
  50614. */
  50615. scale: Vector2;
  50616. /**
  50617. * Define an offset for the layer in order to shift the texture.
  50618. */
  50619. offset: Vector2;
  50620. /**
  50621. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50622. */
  50623. alphaBlendingMode: number;
  50624. /**
  50625. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50626. * Alpha test will not mix with the background color in case of transparency.
  50627. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50628. */
  50629. alphaTest: boolean;
  50630. /**
  50631. * Define a mask to restrict the layer to only some of the scene cameras.
  50632. */
  50633. layerMask: number;
  50634. /**
  50635. * Define the list of render target the layer is visible into.
  50636. */
  50637. renderTargetTextures: RenderTargetTexture[];
  50638. /**
  50639. * Define if the layer is only used in renderTarget or if it also
  50640. * renders in the main frame buffer of the canvas.
  50641. */
  50642. renderOnlyInRenderTargetTextures: boolean;
  50643. private _scene;
  50644. private _vertexBuffers;
  50645. private _indexBuffer;
  50646. private _effect;
  50647. private _alphaTestEffect;
  50648. /**
  50649. * An event triggered when the layer is disposed.
  50650. */
  50651. onDisposeObservable: Observable<Layer>;
  50652. private _onDisposeObserver;
  50653. /**
  50654. * Back compatibility with callback before the onDisposeObservable existed.
  50655. * The set callback will be triggered when the layer has been disposed.
  50656. */
  50657. onDispose: () => void;
  50658. /**
  50659. * An event triggered before rendering the scene
  50660. */
  50661. onBeforeRenderObservable: Observable<Layer>;
  50662. private _onBeforeRenderObserver;
  50663. /**
  50664. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50665. * The set callback will be triggered just before rendering the layer.
  50666. */
  50667. onBeforeRender: () => void;
  50668. /**
  50669. * An event triggered after rendering the scene
  50670. */
  50671. onAfterRenderObservable: Observable<Layer>;
  50672. private _onAfterRenderObserver;
  50673. /**
  50674. * Back compatibility with callback before the onAfterRenderObservable existed.
  50675. * The set callback will be triggered just after rendering the layer.
  50676. */
  50677. onAfterRender: () => void;
  50678. /**
  50679. * Instantiates a new layer.
  50680. * This represents a full screen 2d layer.
  50681. * This can be useful to display a picture in the background of your scene for instance.
  50682. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50683. * @param name Define the name of the layer in the scene
  50684. * @param imgUrl Define the url of the texture to display in the layer
  50685. * @param scene Define the scene the layer belongs to
  50686. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50687. * @param color Defines a color for the layer
  50688. */
  50689. constructor(
  50690. /**
  50691. * Define the name of the layer.
  50692. */
  50693. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50694. private _createIndexBuffer;
  50695. /** @hidden */
  50696. _rebuild(): void;
  50697. /**
  50698. * Renders the layer in the scene.
  50699. */
  50700. render(): void;
  50701. /**
  50702. * Disposes and releases the associated ressources.
  50703. */
  50704. dispose(): void;
  50705. }
  50706. }
  50707. declare module "babylonjs/Layers/index" {
  50708. export * from "babylonjs/Layers/effectLayer";
  50709. export * from "babylonjs/Layers/effectLayerSceneComponent";
  50710. export * from "babylonjs/Layers/glowLayer";
  50711. export * from "babylonjs/Layers/highlightLayer";
  50712. export * from "babylonjs/Layers/layer";
  50713. export * from "babylonjs/Layers/layerSceneComponent";
  50714. }
  50715. declare module "babylonjs/Shaders/lensFlare.fragment" {
  50716. /** @hidden */
  50717. export var lensFlarePixelShader: {
  50718. name: string;
  50719. shader: string;
  50720. };
  50721. }
  50722. declare module "babylonjs/Shaders/lensFlare.vertex" {
  50723. /** @hidden */
  50724. export var lensFlareVertexShader: {
  50725. name: string;
  50726. shader: string;
  50727. };
  50728. }
  50729. declare module "babylonjs/LensFlares/lensFlareSystem" {
  50730. import { Scene } from "babylonjs/scene";
  50731. import { Vector3, Viewport } from "babylonjs/Maths/math";
  50732. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50733. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  50734. import "babylonjs/Shaders/lensFlare.fragment";
  50735. import "babylonjs/Shaders/lensFlare.vertex";
  50736. /**
  50737. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50738. * It is usually composed of several `lensFlare`.
  50739. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50740. */
  50741. export class LensFlareSystem {
  50742. /**
  50743. * Define the name of the lens flare system
  50744. */
  50745. name: string;
  50746. /**
  50747. * List of lens flares used in this system.
  50748. */
  50749. lensFlares: LensFlare[];
  50750. /**
  50751. * Define a limit from the border the lens flare can be visible.
  50752. */
  50753. borderLimit: number;
  50754. /**
  50755. * Define a viewport border we do not want to see the lens flare in.
  50756. */
  50757. viewportBorder: number;
  50758. /**
  50759. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50760. */
  50761. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50762. /**
  50763. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50764. */
  50765. layerMask: number;
  50766. /**
  50767. * Define the id of the lens flare system in the scene.
  50768. * (equal to name by default)
  50769. */
  50770. id: string;
  50771. private _scene;
  50772. private _emitter;
  50773. private _vertexBuffers;
  50774. private _indexBuffer;
  50775. private _effect;
  50776. private _positionX;
  50777. private _positionY;
  50778. private _isEnabled;
  50779. /** @hidden */
  50780. static _SceneComponentInitialization: (scene: Scene) => void;
  50781. /**
  50782. * Instantiates a lens flare system.
  50783. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50784. * It is usually composed of several `lensFlare`.
  50785. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50786. * @param name Define the name of the lens flare system in the scene
  50787. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50788. * @param scene Define the scene the lens flare system belongs to
  50789. */
  50790. constructor(
  50791. /**
  50792. * Define the name of the lens flare system
  50793. */
  50794. name: string, emitter: any, scene: Scene);
  50795. /**
  50796. * Define if the lens flare system is enabled.
  50797. */
  50798. isEnabled: boolean;
  50799. /**
  50800. * Get the scene the effects belongs to.
  50801. * @returns the scene holding the lens flare system
  50802. */
  50803. getScene(): Scene;
  50804. /**
  50805. * Get the emitter of the lens flare system.
  50806. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50807. * @returns the emitter of the lens flare system
  50808. */
  50809. getEmitter(): any;
  50810. /**
  50811. * Set the emitter of the lens flare system.
  50812. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50813. * @param newEmitter Define the new emitter of the system
  50814. */
  50815. setEmitter(newEmitter: any): void;
  50816. /**
  50817. * Get the lens flare system emitter position.
  50818. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50819. * @returns the position
  50820. */
  50821. getEmitterPosition(): Vector3;
  50822. /**
  50823. * @hidden
  50824. */
  50825. computeEffectivePosition(globalViewport: Viewport): boolean;
  50826. /** @hidden */
  50827. _isVisible(): boolean;
  50828. /**
  50829. * @hidden
  50830. */
  50831. render(): boolean;
  50832. /**
  50833. * Dispose and release the lens flare with its associated resources.
  50834. */
  50835. dispose(): void;
  50836. /**
  50837. * Parse a lens flare system from a JSON repressentation
  50838. * @param parsedLensFlareSystem Define the JSON to parse
  50839. * @param scene Define the scene the parsed system should be instantiated in
  50840. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50841. * @returns the parsed system
  50842. */
  50843. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50844. /**
  50845. * Serialize the current Lens Flare System into a JSON representation.
  50846. * @returns the serialized JSON
  50847. */
  50848. serialize(): any;
  50849. }
  50850. }
  50851. declare module "babylonjs/LensFlares/lensFlare" {
  50852. import { Nullable } from "babylonjs/types";
  50853. import { Color3 } from "babylonjs/Maths/math";
  50854. import { Texture } from "babylonjs/Materials/Textures/texture";
  50855. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50856. /**
  50857. * This represents one of the lens effect in a `lensFlareSystem`.
  50858. * It controls one of the indiviual texture used in the effect.
  50859. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50860. */
  50861. export class LensFlare {
  50862. /**
  50863. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50864. */
  50865. size: number;
  50866. /**
  50867. * 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.
  50868. */
  50869. position: number;
  50870. /**
  50871. * Define the lens color.
  50872. */
  50873. color: Color3;
  50874. /**
  50875. * Define the lens texture.
  50876. */
  50877. texture: Nullable<Texture>;
  50878. /**
  50879. * Define the alpha mode to render this particular lens.
  50880. */
  50881. alphaMode: number;
  50882. private _system;
  50883. /**
  50884. * Creates a new Lens Flare.
  50885. * This represents one of the lens effect in a `lensFlareSystem`.
  50886. * It controls one of the indiviual texture used in the effect.
  50887. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50888. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50889. * @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.
  50890. * @param color Define the lens color
  50891. * @param imgUrl Define the lens texture url
  50892. * @param system Define the `lensFlareSystem` this flare is part of
  50893. * @returns The newly created Lens Flare
  50894. */
  50895. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50896. /**
  50897. * Instantiates a new Lens Flare.
  50898. * This represents one of the lens effect in a `lensFlareSystem`.
  50899. * It controls one of the indiviual texture used in the effect.
  50900. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50901. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50902. * @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.
  50903. * @param color Define the lens color
  50904. * @param imgUrl Define the lens texture url
  50905. * @param system Define the `lensFlareSystem` this flare is part of
  50906. */
  50907. constructor(
  50908. /**
  50909. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50910. */
  50911. size: number,
  50912. /**
  50913. * 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.
  50914. */
  50915. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50916. /**
  50917. * Dispose and release the lens flare with its associated resources.
  50918. */
  50919. dispose(): void;
  50920. }
  50921. }
  50922. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  50923. import { Nullable } from "babylonjs/types";
  50924. import { Scene } from "babylonjs/scene";
  50925. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50926. import { AbstractScene } from "babylonjs/abstractScene";
  50927. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50928. module "babylonjs/abstractScene" {
  50929. interface AbstractScene {
  50930. /**
  50931. * The list of lens flare system added to the scene
  50932. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50933. */
  50934. lensFlareSystems: Array<LensFlareSystem>;
  50935. /**
  50936. * Removes the given lens flare system from this scene.
  50937. * @param toRemove The lens flare system to remove
  50938. * @returns The index of the removed lens flare system
  50939. */
  50940. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50941. /**
  50942. * Adds the given lens flare system to this scene
  50943. * @param newLensFlareSystem The lens flare system to add
  50944. */
  50945. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50946. /**
  50947. * Gets a lens flare system using its name
  50948. * @param name defines the name to look for
  50949. * @returns the lens flare system or null if not found
  50950. */
  50951. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50952. /**
  50953. * Gets a lens flare system using its id
  50954. * @param id defines the id to look for
  50955. * @returns the lens flare system or null if not found
  50956. */
  50957. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50958. }
  50959. }
  50960. /**
  50961. * Defines the lens flare scene component responsible to manage any lens flares
  50962. * in a given scene.
  50963. */
  50964. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50965. /**
  50966. * The component name helpfull to identify the component in the list of scene components.
  50967. */
  50968. readonly name: string;
  50969. /**
  50970. * The scene the component belongs to.
  50971. */
  50972. scene: Scene;
  50973. /**
  50974. * Creates a new instance of the component for the given scene
  50975. * @param scene Defines the scene to register the component in
  50976. */
  50977. constructor(scene: Scene);
  50978. /**
  50979. * Registers the component in a given scene
  50980. */
  50981. register(): void;
  50982. /**
  50983. * Rebuilds the elements related to this component in case of
  50984. * context lost for instance.
  50985. */
  50986. rebuild(): void;
  50987. /**
  50988. * Adds all the elements from the container to the scene
  50989. * @param container the container holding the elements
  50990. */
  50991. addFromContainer(container: AbstractScene): void;
  50992. /**
  50993. * Removes all the elements in the container from the scene
  50994. * @param container contains the elements to remove
  50995. * @param dispose if the removed element should be disposed (default: false)
  50996. */
  50997. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50998. /**
  50999. * Serializes the component data to the specified json object
  51000. * @param serializationObject The object to serialize to
  51001. */
  51002. serialize(serializationObject: any): void;
  51003. /**
  51004. * Disposes the component and the associated ressources.
  51005. */
  51006. dispose(): void;
  51007. private _draw;
  51008. }
  51009. }
  51010. declare module "babylonjs/LensFlares/index" {
  51011. export * from "babylonjs/LensFlares/lensFlare";
  51012. export * from "babylonjs/LensFlares/lensFlareSystem";
  51013. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  51014. }
  51015. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  51016. import { Scene } from "babylonjs/scene";
  51017. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51018. import { AbstractScene } from "babylonjs/abstractScene";
  51019. /**
  51020. * Defines the shadow generator component responsible to manage any shadow generators
  51021. * in a given scene.
  51022. */
  51023. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51024. /**
  51025. * The component name helpfull to identify the component in the list of scene components.
  51026. */
  51027. readonly name: string;
  51028. /**
  51029. * The scene the component belongs to.
  51030. */
  51031. scene: Scene;
  51032. /**
  51033. * Creates a new instance of the component for the given scene
  51034. * @param scene Defines the scene to register the component in
  51035. */
  51036. constructor(scene: Scene);
  51037. /**
  51038. * Registers the component in a given scene
  51039. */
  51040. register(): void;
  51041. /**
  51042. * Rebuilds the elements related to this component in case of
  51043. * context lost for instance.
  51044. */
  51045. rebuild(): void;
  51046. /**
  51047. * Serializes the component data to the specified json object
  51048. * @param serializationObject The object to serialize to
  51049. */
  51050. serialize(serializationObject: any): void;
  51051. /**
  51052. * Adds all the elements from the container to the scene
  51053. * @param container the container holding the elements
  51054. */
  51055. addFromContainer(container: AbstractScene): void;
  51056. /**
  51057. * Removes all the elements in the container from the scene
  51058. * @param container contains the elements to remove
  51059. * @param dispose if the removed element should be disposed (default: false)
  51060. */
  51061. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51062. /**
  51063. * Rebuilds the elements related to this component in case of
  51064. * context lost for instance.
  51065. */
  51066. dispose(): void;
  51067. private _gatherRenderTargets;
  51068. }
  51069. }
  51070. declare module "babylonjs/Lights/Shadows/index" {
  51071. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  51072. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  51073. }
  51074. declare module "babylonjs/Lights/pointLight" {
  51075. import { Scene } from "babylonjs/scene";
  51076. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  51077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51078. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51079. import { Effect } from "babylonjs/Materials/effect";
  51080. /**
  51081. * A point light is a light defined by an unique point in world space.
  51082. * The light is emitted in every direction from this point.
  51083. * A good example of a point light is a standard light bulb.
  51084. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51085. */
  51086. export class PointLight extends ShadowLight {
  51087. private _shadowAngle;
  51088. /**
  51089. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51090. * This specifies what angle the shadow will use to be created.
  51091. *
  51092. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51093. */
  51094. /**
  51095. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51096. * This specifies what angle the shadow will use to be created.
  51097. *
  51098. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51099. */
  51100. shadowAngle: number;
  51101. /**
  51102. * Gets the direction if it has been set.
  51103. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51104. */
  51105. /**
  51106. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51107. */
  51108. direction: Vector3;
  51109. /**
  51110. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51111. * A PointLight emits the light in every direction.
  51112. * It can cast shadows.
  51113. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51114. * ```javascript
  51115. * var pointLight = new PointLight("pl", camera.position, scene);
  51116. * ```
  51117. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51118. * @param name The light friendly name
  51119. * @param position The position of the point light in the scene
  51120. * @param scene The scene the lights belongs to
  51121. */
  51122. constructor(name: string, position: Vector3, scene: Scene);
  51123. /**
  51124. * Returns the string "PointLight"
  51125. * @returns the class name
  51126. */
  51127. getClassName(): string;
  51128. /**
  51129. * Returns the integer 0.
  51130. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51131. */
  51132. getTypeID(): number;
  51133. /**
  51134. * Specifies wether or not the shadowmap should be a cube texture.
  51135. * @returns true if the shadowmap needs to be a cube texture.
  51136. */
  51137. needCube(): boolean;
  51138. /**
  51139. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51140. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51141. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51142. */
  51143. getShadowDirection(faceIndex?: number): Vector3;
  51144. /**
  51145. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51146. * - fov = PI / 2
  51147. * - aspect ratio : 1.0
  51148. * - z-near and far equal to the active camera minZ and maxZ.
  51149. * Returns the PointLight.
  51150. */
  51151. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51152. protected _buildUniformLayout(): void;
  51153. /**
  51154. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51155. * @param effect The effect to update
  51156. * @param lightIndex The index of the light in the effect to update
  51157. * @returns The point light
  51158. */
  51159. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51160. /**
  51161. * Prepares the list of defines specific to the light type.
  51162. * @param defines the list of defines
  51163. * @param lightIndex defines the index of the light for the effect
  51164. */
  51165. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51166. }
  51167. }
  51168. declare module "babylonjs/Lights/index" {
  51169. export * from "babylonjs/Lights/light";
  51170. export * from "babylonjs/Lights/shadowLight";
  51171. export * from "babylonjs/Lights/Shadows/index";
  51172. export * from "babylonjs/Lights/directionalLight";
  51173. export * from "babylonjs/Lights/hemisphericLight";
  51174. export * from "babylonjs/Lights/pointLight";
  51175. export * from "babylonjs/Lights/spotLight";
  51176. }
  51177. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  51178. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  51179. /**
  51180. * Header information of HDR texture files.
  51181. */
  51182. export interface HDRInfo {
  51183. /**
  51184. * The height of the texture in pixels.
  51185. */
  51186. height: number;
  51187. /**
  51188. * The width of the texture in pixels.
  51189. */
  51190. width: number;
  51191. /**
  51192. * The index of the beginning of the data in the binary file.
  51193. */
  51194. dataPosition: number;
  51195. }
  51196. /**
  51197. * This groups tools to convert HDR texture to native colors array.
  51198. */
  51199. export class HDRTools {
  51200. private static Ldexp;
  51201. private static Rgbe2float;
  51202. private static readStringLine;
  51203. /**
  51204. * Reads header information from an RGBE texture stored in a native array.
  51205. * More information on this format are available here:
  51206. * https://en.wikipedia.org/wiki/RGBE_image_format
  51207. *
  51208. * @param uint8array The binary file stored in native array.
  51209. * @return The header information.
  51210. */
  51211. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51212. /**
  51213. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51214. * This RGBE texture needs to store the information as a panorama.
  51215. *
  51216. * More information on this format are available here:
  51217. * https://en.wikipedia.org/wiki/RGBE_image_format
  51218. *
  51219. * @param buffer The binary file stored in an array buffer.
  51220. * @param size The expected size of the extracted cubemap.
  51221. * @return The Cube Map information.
  51222. */
  51223. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51224. /**
  51225. * Returns the pixels data extracted from an RGBE texture.
  51226. * This pixels will be stored left to right up to down in the R G B order in one array.
  51227. *
  51228. * More information on this format are available here:
  51229. * https://en.wikipedia.org/wiki/RGBE_image_format
  51230. *
  51231. * @param uint8array The binary file stored in an array buffer.
  51232. * @param hdrInfo The header information of the file.
  51233. * @return The pixels data in RGB right to left up to down order.
  51234. */
  51235. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51236. private static RGBE_ReadPixels_RLE;
  51237. }
  51238. }
  51239. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  51240. import { Nullable } from "babylonjs/types";
  51241. import { Scene } from "babylonjs/scene";
  51242. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  51243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51244. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51245. /**
  51246. * This represents a texture coming from an HDR input.
  51247. *
  51248. * The only supported format is currently panorama picture stored in RGBE format.
  51249. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51250. */
  51251. export class HDRCubeTexture extends BaseTexture {
  51252. private static _facesMapping;
  51253. private _generateHarmonics;
  51254. private _noMipmap;
  51255. private _textureMatrix;
  51256. private _size;
  51257. private _onLoad;
  51258. private _onError;
  51259. /**
  51260. * The texture URL.
  51261. */
  51262. url: string;
  51263. /**
  51264. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51265. */
  51266. coordinatesMode: number;
  51267. protected _isBlocking: boolean;
  51268. /**
  51269. * Sets wether or not the texture is blocking during loading.
  51270. */
  51271. /**
  51272. * Gets wether or not the texture is blocking during loading.
  51273. */
  51274. isBlocking: boolean;
  51275. protected _rotationY: number;
  51276. /**
  51277. * Sets texture matrix rotation angle around Y axis in radians.
  51278. */
  51279. /**
  51280. * Gets texture matrix rotation angle around Y axis radians.
  51281. */
  51282. rotationY: number;
  51283. /**
  51284. * Gets or sets the center of the bounding box associated with the cube texture
  51285. * It must define where the camera used to render the texture was set
  51286. */
  51287. boundingBoxPosition: Vector3;
  51288. private _boundingBoxSize;
  51289. /**
  51290. * Gets or sets the size of the bounding box associated with the cube texture
  51291. * When defined, the cubemap will switch to local mode
  51292. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51293. * @example https://www.babylonjs-playground.com/#RNASML
  51294. */
  51295. boundingBoxSize: Vector3;
  51296. /**
  51297. * Instantiates an HDRTexture from the following parameters.
  51298. *
  51299. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51300. * @param scene The scene the texture will be used in
  51301. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51302. * @param noMipmap Forces to not generate the mipmap if true
  51303. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51304. * @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)
  51305. * @param reserved Reserved flag for internal use.
  51306. */
  51307. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51308. /**
  51309. * Get the current class name of the texture useful for serialization or dynamic coding.
  51310. * @returns "HDRCubeTexture"
  51311. */
  51312. getClassName(): string;
  51313. /**
  51314. * Occurs when the file is raw .hdr file.
  51315. */
  51316. private loadTexture;
  51317. clone(): HDRCubeTexture;
  51318. delayLoad(): void;
  51319. /**
  51320. * Get the texture reflection matrix used to rotate/transform the reflection.
  51321. * @returns the reflection matrix
  51322. */
  51323. getReflectionTextureMatrix(): Matrix;
  51324. /**
  51325. * Set the texture reflection matrix used to rotate/transform the reflection.
  51326. * @param value Define the reflection matrix to set
  51327. */
  51328. setReflectionTextureMatrix(value: Matrix): void;
  51329. /**
  51330. * Parses a JSON representation of an HDR Texture in order to create the texture
  51331. * @param parsedTexture Define the JSON representation
  51332. * @param scene Define the scene the texture should be created in
  51333. * @param rootUrl Define the root url in case we need to load relative dependencies
  51334. * @returns the newly created texture after parsing
  51335. */
  51336. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51337. serialize(): any;
  51338. }
  51339. }
  51340. declare module "babylonjs/Physics/physicsEngine" {
  51341. import { Nullable } from "babylonjs/types";
  51342. import { Vector3 } from "babylonjs/Maths/math";
  51343. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51344. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  51345. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  51346. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51347. /**
  51348. * Class used to control physics engine
  51349. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51350. */
  51351. export class PhysicsEngine implements IPhysicsEngine {
  51352. private _physicsPlugin;
  51353. /**
  51354. * Global value used to control the smallest number supported by the simulation
  51355. */
  51356. static Epsilon: number;
  51357. private _impostors;
  51358. private _joints;
  51359. /**
  51360. * Gets the gravity vector used by the simulation
  51361. */
  51362. gravity: Vector3;
  51363. /**
  51364. * Factory used to create the default physics plugin.
  51365. * @returns The default physics plugin
  51366. */
  51367. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51368. /**
  51369. * Creates a new Physics Engine
  51370. * @param gravity defines the gravity vector used by the simulation
  51371. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51372. */
  51373. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51374. /**
  51375. * Sets the gravity vector used by the simulation
  51376. * @param gravity defines the gravity vector to use
  51377. */
  51378. setGravity(gravity: Vector3): void;
  51379. /**
  51380. * Set the time step of the physics engine.
  51381. * Default is 1/60.
  51382. * To slow it down, enter 1/600 for example.
  51383. * To speed it up, 1/30
  51384. * @param newTimeStep defines the new timestep to apply to this world.
  51385. */
  51386. setTimeStep(newTimeStep?: number): void;
  51387. /**
  51388. * Get the time step of the physics engine.
  51389. * @returns the current time step
  51390. */
  51391. getTimeStep(): number;
  51392. /**
  51393. * Release all resources
  51394. */
  51395. dispose(): void;
  51396. /**
  51397. * Gets the name of the current physics plugin
  51398. * @returns the name of the plugin
  51399. */
  51400. getPhysicsPluginName(): string;
  51401. /**
  51402. * Adding a new impostor for the impostor tracking.
  51403. * This will be done by the impostor itself.
  51404. * @param impostor the impostor to add
  51405. */
  51406. addImpostor(impostor: PhysicsImpostor): void;
  51407. /**
  51408. * Remove an impostor from the engine.
  51409. * This impostor and its mesh will not longer be updated by the physics engine.
  51410. * @param impostor the impostor to remove
  51411. */
  51412. removeImpostor(impostor: PhysicsImpostor): void;
  51413. /**
  51414. * Add a joint to the physics engine
  51415. * @param mainImpostor defines the main impostor to which the joint is added.
  51416. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51417. * @param joint defines the joint that will connect both impostors.
  51418. */
  51419. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51420. /**
  51421. * Removes a joint from the simulation
  51422. * @param mainImpostor defines the impostor used with the joint
  51423. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51424. * @param joint defines the joint to remove
  51425. */
  51426. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51427. /**
  51428. * Called by the scene. No need to call it.
  51429. * @param delta defines the timespam between frames
  51430. */
  51431. _step(delta: number): void;
  51432. /**
  51433. * Gets the current plugin used to run the simulation
  51434. * @returns current plugin
  51435. */
  51436. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51437. /**
  51438. * Gets the list of physic impostors
  51439. * @returns an array of PhysicsImpostor
  51440. */
  51441. getImpostors(): Array<PhysicsImpostor>;
  51442. /**
  51443. * Gets the impostor for a physics enabled object
  51444. * @param object defines the object impersonated by the impostor
  51445. * @returns the PhysicsImpostor or null if not found
  51446. */
  51447. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51448. /**
  51449. * Gets the impostor for a physics body object
  51450. * @param body defines physics body used by the impostor
  51451. * @returns the PhysicsImpostor or null if not found
  51452. */
  51453. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51454. /**
  51455. * Does a raycast in the physics world
  51456. * @param from when should the ray start?
  51457. * @param to when should the ray end?
  51458. * @returns PhysicsRaycastResult
  51459. */
  51460. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51461. }
  51462. }
  51463. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  51464. import { Nullable } from "babylonjs/types";
  51465. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51467. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51468. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51469. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51470. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51471. /** @hidden */
  51472. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51473. private _useDeltaForWorldStep;
  51474. world: any;
  51475. name: string;
  51476. private _physicsMaterials;
  51477. private _fixedTimeStep;
  51478. private _cannonRaycastResult;
  51479. private _raycastResult;
  51480. private _physicsBodysToRemoveAfterStep;
  51481. BJSCANNON: any;
  51482. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51483. setGravity(gravity: Vector3): void;
  51484. setTimeStep(timeStep: number): void;
  51485. getTimeStep(): number;
  51486. executeStep(delta: number): void;
  51487. private _removeMarkedPhysicsBodiesFromWorld;
  51488. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51489. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51490. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51491. private _processChildMeshes;
  51492. removePhysicsBody(impostor: PhysicsImpostor): void;
  51493. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51494. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51495. private _addMaterial;
  51496. private _checkWithEpsilon;
  51497. private _createShape;
  51498. private _createHeightmap;
  51499. private _minus90X;
  51500. private _plus90X;
  51501. private _tmpPosition;
  51502. private _tmpDeltaPosition;
  51503. private _tmpUnityRotation;
  51504. private _updatePhysicsBodyTransformation;
  51505. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51506. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51507. isSupported(): boolean;
  51508. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51509. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51510. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51511. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51512. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51513. getBodyMass(impostor: PhysicsImpostor): number;
  51514. getBodyFriction(impostor: PhysicsImpostor): number;
  51515. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51516. getBodyRestitution(impostor: PhysicsImpostor): number;
  51517. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51518. sleepBody(impostor: PhysicsImpostor): void;
  51519. wakeUpBody(impostor: PhysicsImpostor): void;
  51520. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51521. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51522. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51523. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51524. getRadius(impostor: PhysicsImpostor): number;
  51525. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51526. dispose(): void;
  51527. private _extendNamespace;
  51528. /**
  51529. * Does a raycast in the physics world
  51530. * @param from when should the ray start?
  51531. * @param to when should the ray end?
  51532. * @returns PhysicsRaycastResult
  51533. */
  51534. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51535. }
  51536. }
  51537. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51538. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51539. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51540. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51542. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51543. import { Nullable } from "babylonjs/types";
  51544. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51545. /** @hidden */
  51546. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51547. world: any;
  51548. name: string;
  51549. BJSOIMO: any;
  51550. private _raycastResult;
  51551. constructor(iterations?: number, oimoInjection?: any);
  51552. setGravity(gravity: Vector3): void;
  51553. setTimeStep(timeStep: number): void;
  51554. getTimeStep(): number;
  51555. private _tmpImpostorsArray;
  51556. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51557. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51558. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51559. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51560. private _tmpPositionVector;
  51561. removePhysicsBody(impostor: PhysicsImpostor): void;
  51562. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51563. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51564. isSupported(): boolean;
  51565. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51566. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51567. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51568. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51569. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51570. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51571. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51572. getBodyMass(impostor: PhysicsImpostor): number;
  51573. getBodyFriction(impostor: PhysicsImpostor): number;
  51574. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51575. getBodyRestitution(impostor: PhysicsImpostor): number;
  51576. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51577. sleepBody(impostor: PhysicsImpostor): void;
  51578. wakeUpBody(impostor: PhysicsImpostor): void;
  51579. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51580. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51581. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51582. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51583. getRadius(impostor: PhysicsImpostor): number;
  51584. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51585. dispose(): void;
  51586. /**
  51587. * Does a raycast in the physics world
  51588. * @param from when should the ray start?
  51589. * @param to when should the ray end?
  51590. * @returns PhysicsRaycastResult
  51591. */
  51592. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51593. }
  51594. }
  51595. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51596. import { Nullable } from "babylonjs/types";
  51597. import { Scene } from "babylonjs/scene";
  51598. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  51599. import { Mesh } from "babylonjs/Meshes/mesh";
  51600. /**
  51601. * Class containing static functions to help procedurally build meshes
  51602. */
  51603. export class RibbonBuilder {
  51604. /**
  51605. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51606. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51607. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51608. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51609. * * 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
  51610. * * 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
  51611. * * 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
  51612. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51613. * * 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
  51614. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51615. * * 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
  51616. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51617. * * 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
  51618. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51620. * @param name defines the name of the mesh
  51621. * @param options defines the options used to create the mesh
  51622. * @param scene defines the hosting scene
  51623. * @returns the ribbon mesh
  51624. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51625. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51626. */
  51627. static CreateRibbon(name: string, options: {
  51628. pathArray: Vector3[][];
  51629. closeArray?: boolean;
  51630. closePath?: boolean;
  51631. offset?: number;
  51632. updatable?: boolean;
  51633. sideOrientation?: number;
  51634. frontUVs?: Vector4;
  51635. backUVs?: Vector4;
  51636. instance?: Mesh;
  51637. invertUV?: boolean;
  51638. uvs?: Vector2[];
  51639. colors?: Color4[];
  51640. }, scene?: Nullable<Scene>): Mesh;
  51641. }
  51642. }
  51643. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  51644. import { Nullable } from "babylonjs/types";
  51645. import { Scene } from "babylonjs/scene";
  51646. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51647. import { Mesh } from "babylonjs/Meshes/mesh";
  51648. /**
  51649. * Class containing static functions to help procedurally build meshes
  51650. */
  51651. export class ShapeBuilder {
  51652. /**
  51653. * 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.
  51654. * * 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.
  51655. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51656. * * 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.
  51657. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51658. * * 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
  51659. * * 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
  51660. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51662. * * 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
  51663. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51665. * @param name defines the name of the mesh
  51666. * @param options defines the options used to create the mesh
  51667. * @param scene defines the hosting scene
  51668. * @returns the extruded shape mesh
  51669. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51670. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51671. */
  51672. static ExtrudeShape(name: string, options: {
  51673. shape: Vector3[];
  51674. path: Vector3[];
  51675. scale?: number;
  51676. rotation?: number;
  51677. cap?: number;
  51678. updatable?: boolean;
  51679. sideOrientation?: number;
  51680. frontUVs?: Vector4;
  51681. backUVs?: Vector4;
  51682. instance?: Mesh;
  51683. invertUV?: boolean;
  51684. }, scene?: Nullable<Scene>): Mesh;
  51685. /**
  51686. * Creates an custom extruded shape mesh.
  51687. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51688. * * 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.
  51689. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51690. * * 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
  51691. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51692. * * 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
  51693. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51694. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51695. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51696. * * 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
  51697. * * 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
  51698. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51700. * * 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
  51701. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51703. * @param name defines the name of the mesh
  51704. * @param options defines the options used to create the mesh
  51705. * @param scene defines the hosting scene
  51706. * @returns the custom extruded shape mesh
  51707. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51708. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51709. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51710. */
  51711. static ExtrudeShapeCustom(name: string, options: {
  51712. shape: Vector3[];
  51713. path: Vector3[];
  51714. scaleFunction?: any;
  51715. rotationFunction?: any;
  51716. ribbonCloseArray?: boolean;
  51717. ribbonClosePath?: boolean;
  51718. cap?: number;
  51719. updatable?: boolean;
  51720. sideOrientation?: number;
  51721. frontUVs?: Vector4;
  51722. backUVs?: Vector4;
  51723. instance?: Mesh;
  51724. invertUV?: boolean;
  51725. }, scene?: Nullable<Scene>): Mesh;
  51726. private static _ExtrudeShapeGeneric;
  51727. }
  51728. }
  51729. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51730. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51731. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51732. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51733. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51734. import { Nullable } from "babylonjs/types";
  51735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51736. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51737. /**
  51738. * AmmoJS Physics plugin
  51739. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51740. * @see https://github.com/kripken/ammo.js/
  51741. */
  51742. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51743. private _useDeltaForWorldStep;
  51744. /**
  51745. * Reference to the Ammo library
  51746. */
  51747. bjsAMMO: any;
  51748. /**
  51749. * Created ammoJS world which physics bodies are added to
  51750. */
  51751. world: any;
  51752. /**
  51753. * Name of the plugin
  51754. */
  51755. name: string;
  51756. private _timeStep;
  51757. private _fixedTimeStep;
  51758. private _maxSteps;
  51759. private _tmpQuaternion;
  51760. private _tmpAmmoTransform;
  51761. private _tmpAmmoQuaternion;
  51762. private _tmpAmmoConcreteContactResultCallback;
  51763. private _collisionConfiguration;
  51764. private _dispatcher;
  51765. private _overlappingPairCache;
  51766. private _solver;
  51767. private _softBodySolver;
  51768. private _tmpAmmoVectorA;
  51769. private _tmpAmmoVectorB;
  51770. private _tmpAmmoVectorC;
  51771. private _tmpAmmoVectorD;
  51772. private _tmpContactCallbackResult;
  51773. private _tmpAmmoVectorRCA;
  51774. private _tmpAmmoVectorRCB;
  51775. private _raycastResult;
  51776. private static readonly DISABLE_COLLISION_FLAG;
  51777. private static readonly KINEMATIC_FLAG;
  51778. private static readonly DISABLE_DEACTIVATION_FLAG;
  51779. /**
  51780. * Initializes the ammoJS plugin
  51781. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51782. * @param ammoInjection can be used to inject your own ammo reference
  51783. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51784. */
  51785. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51786. /**
  51787. * Sets the gravity of the physics world (m/(s^2))
  51788. * @param gravity Gravity to set
  51789. */
  51790. setGravity(gravity: Vector3): void;
  51791. /**
  51792. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51793. * @param timeStep timestep to use in seconds
  51794. */
  51795. setTimeStep(timeStep: number): void;
  51796. /**
  51797. * 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)
  51798. * @param fixedTimeStep fixedTimeStep to use in seconds
  51799. */
  51800. setFixedTimeStep(fixedTimeStep: number): void;
  51801. /**
  51802. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51803. * @param maxSteps the maximum number of steps by the physics engine per frame
  51804. */
  51805. setMaxSteps(maxSteps: number): void;
  51806. /**
  51807. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51808. * @returns the current timestep in seconds
  51809. */
  51810. getTimeStep(): number;
  51811. private _isImpostorInContact;
  51812. private _isImpostorPairInContact;
  51813. private _stepSimulation;
  51814. /**
  51815. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51816. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51817. * After the step the babylon meshes are set to the position of the physics imposters
  51818. * @param delta amount of time to step forward
  51819. * @param impostors array of imposters to update before/after the step
  51820. */
  51821. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51822. /**
  51823. * Update babylon mesh to match physics world object
  51824. * @param impostor imposter to match
  51825. */
  51826. private _afterSoftStep;
  51827. /**
  51828. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51829. * @param impostor imposter to match
  51830. */
  51831. private _ropeStep;
  51832. /**
  51833. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51834. * @param impostor imposter to match
  51835. */
  51836. private _softbodyOrClothStep;
  51837. private _tmpVector;
  51838. private _tmpMatrix;
  51839. /**
  51840. * Applies an impulse on the imposter
  51841. * @param impostor imposter to apply impulse to
  51842. * @param force amount of force to be applied to the imposter
  51843. * @param contactPoint the location to apply the impulse on the imposter
  51844. */
  51845. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51846. /**
  51847. * Applies a force on the imposter
  51848. * @param impostor imposter to apply force
  51849. * @param force amount of force to be applied to the imposter
  51850. * @param contactPoint the location to apply the force on the imposter
  51851. */
  51852. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51853. /**
  51854. * Creates a physics body using the plugin
  51855. * @param impostor the imposter to create the physics body on
  51856. */
  51857. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51858. /**
  51859. * Removes the physics body from the imposter and disposes of the body's memory
  51860. * @param impostor imposter to remove the physics body from
  51861. */
  51862. removePhysicsBody(impostor: PhysicsImpostor): void;
  51863. /**
  51864. * Generates a joint
  51865. * @param impostorJoint the imposter joint to create the joint with
  51866. */
  51867. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51868. /**
  51869. * Removes a joint
  51870. * @param impostorJoint the imposter joint to remove the joint from
  51871. */
  51872. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51873. private _addMeshVerts;
  51874. /**
  51875. * Initialise the soft body vertices to match its object's (mesh) vertices
  51876. * Softbody vertices (nodes) are in world space and to match this
  51877. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51878. * @param impostor to create the softbody for
  51879. */
  51880. private _softVertexData;
  51881. /**
  51882. * Create an impostor's soft body
  51883. * @param impostor to create the softbody for
  51884. */
  51885. private _createSoftbody;
  51886. /**
  51887. * Create cloth for an impostor
  51888. * @param impostor to create the softbody for
  51889. */
  51890. private _createCloth;
  51891. /**
  51892. * Create rope for an impostor
  51893. * @param impostor to create the softbody for
  51894. */
  51895. private _createRope;
  51896. private _addHullVerts;
  51897. private _createShape;
  51898. /**
  51899. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51900. * @param impostor imposter containing the physics body and babylon object
  51901. */
  51902. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51903. /**
  51904. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51905. * @param impostor imposter containing the physics body and babylon object
  51906. * @param newPosition new position
  51907. * @param newRotation new rotation
  51908. */
  51909. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51910. /**
  51911. * If this plugin is supported
  51912. * @returns true if its supported
  51913. */
  51914. isSupported(): boolean;
  51915. /**
  51916. * Sets the linear velocity of the physics body
  51917. * @param impostor imposter to set the velocity on
  51918. * @param velocity velocity to set
  51919. */
  51920. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51921. /**
  51922. * Sets the angular velocity of the physics body
  51923. * @param impostor imposter to set the velocity on
  51924. * @param velocity velocity to set
  51925. */
  51926. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51927. /**
  51928. * gets the linear velocity
  51929. * @param impostor imposter to get linear velocity from
  51930. * @returns linear velocity
  51931. */
  51932. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51933. /**
  51934. * gets the angular velocity
  51935. * @param impostor imposter to get angular velocity from
  51936. * @returns angular velocity
  51937. */
  51938. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51939. /**
  51940. * Sets the mass of physics body
  51941. * @param impostor imposter to set the mass on
  51942. * @param mass mass to set
  51943. */
  51944. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51945. /**
  51946. * Gets the mass of the physics body
  51947. * @param impostor imposter to get the mass from
  51948. * @returns mass
  51949. */
  51950. getBodyMass(impostor: PhysicsImpostor): number;
  51951. /**
  51952. * Gets friction of the impostor
  51953. * @param impostor impostor to get friction from
  51954. * @returns friction value
  51955. */
  51956. getBodyFriction(impostor: PhysicsImpostor): number;
  51957. /**
  51958. * Sets friction of the impostor
  51959. * @param impostor impostor to set friction on
  51960. * @param friction friction value
  51961. */
  51962. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51963. /**
  51964. * Gets restitution of the impostor
  51965. * @param impostor impostor to get restitution from
  51966. * @returns restitution value
  51967. */
  51968. getBodyRestitution(impostor: PhysicsImpostor): number;
  51969. /**
  51970. * Sets resitution of the impostor
  51971. * @param impostor impostor to set resitution on
  51972. * @param restitution resitution value
  51973. */
  51974. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51975. /**
  51976. * Gets pressure inside the impostor
  51977. * @param impostor impostor to get pressure from
  51978. * @returns pressure value
  51979. */
  51980. getBodyPressure(impostor: PhysicsImpostor): number;
  51981. /**
  51982. * Sets pressure inside a soft body impostor
  51983. * Cloth and rope must remain 0 pressure
  51984. * @param impostor impostor to set pressure on
  51985. * @param pressure pressure value
  51986. */
  51987. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51988. /**
  51989. * Gets stiffness of the impostor
  51990. * @param impostor impostor to get stiffness from
  51991. * @returns pressure value
  51992. */
  51993. getBodyStiffness(impostor: PhysicsImpostor): number;
  51994. /**
  51995. * Sets stiffness of the impostor
  51996. * @param impostor impostor to set stiffness on
  51997. * @param stiffness stiffness value from 0 to 1
  51998. */
  51999. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52000. /**
  52001. * Gets velocityIterations of the impostor
  52002. * @param impostor impostor to get velocity iterations from
  52003. * @returns velocityIterations value
  52004. */
  52005. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52006. /**
  52007. * Sets velocityIterations of the impostor
  52008. * @param impostor impostor to set velocity iterations on
  52009. * @param velocityIterations velocityIterations value
  52010. */
  52011. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52012. /**
  52013. * Gets positionIterations of the impostor
  52014. * @param impostor impostor to get position iterations from
  52015. * @returns positionIterations value
  52016. */
  52017. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52018. /**
  52019. * Sets positionIterations of the impostor
  52020. * @param impostor impostor to set position on
  52021. * @param positionIterations positionIterations value
  52022. */
  52023. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52024. /**
  52025. * Append an anchor to a cloth object
  52026. * @param impostor is the cloth impostor to add anchor to
  52027. * @param otherImpostor is the rigid impostor to anchor to
  52028. * @param width ratio across width from 0 to 1
  52029. * @param height ratio up height from 0 to 1
  52030. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52031. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52032. */
  52033. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52034. /**
  52035. * Append an hook to a rope object
  52036. * @param impostor is the rope impostor to add hook to
  52037. * @param otherImpostor is the rigid impostor to hook to
  52038. * @param length ratio along the rope from 0 to 1
  52039. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52040. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52041. */
  52042. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52043. /**
  52044. * Sleeps the physics body and stops it from being active
  52045. * @param impostor impostor to sleep
  52046. */
  52047. sleepBody(impostor: PhysicsImpostor): void;
  52048. /**
  52049. * Activates the physics body
  52050. * @param impostor impostor to activate
  52051. */
  52052. wakeUpBody(impostor: PhysicsImpostor): void;
  52053. /**
  52054. * Updates the distance parameters of the joint
  52055. * @param joint joint to update
  52056. * @param maxDistance maximum distance of the joint
  52057. * @param minDistance minimum distance of the joint
  52058. */
  52059. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52060. /**
  52061. * Sets a motor on the joint
  52062. * @param joint joint to set motor on
  52063. * @param speed speed of the motor
  52064. * @param maxForce maximum force of the motor
  52065. * @param motorIndex index of the motor
  52066. */
  52067. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52068. /**
  52069. * Sets the motors limit
  52070. * @param joint joint to set limit on
  52071. * @param upperLimit upper limit
  52072. * @param lowerLimit lower limit
  52073. */
  52074. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52075. /**
  52076. * Syncs the position and rotation of a mesh with the impostor
  52077. * @param mesh mesh to sync
  52078. * @param impostor impostor to update the mesh with
  52079. */
  52080. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52081. /**
  52082. * Gets the radius of the impostor
  52083. * @param impostor impostor to get radius from
  52084. * @returns the radius
  52085. */
  52086. getRadius(impostor: PhysicsImpostor): number;
  52087. /**
  52088. * Gets the box size of the impostor
  52089. * @param impostor impostor to get box size from
  52090. * @param result the resulting box size
  52091. */
  52092. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52093. /**
  52094. * Disposes of the impostor
  52095. */
  52096. dispose(): void;
  52097. /**
  52098. * Does a raycast in the physics world
  52099. * @param from when should the ray start?
  52100. * @param to when should the ray end?
  52101. * @returns PhysicsRaycastResult
  52102. */
  52103. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52104. }
  52105. }
  52106. declare module "babylonjs/Probes/reflectionProbe" {
  52107. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52108. import { Vector3 } from "babylonjs/Maths/math";
  52109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52110. import { Nullable } from "babylonjs/types";
  52111. import { Scene } from "babylonjs/scene";
  52112. module "babylonjs/abstractScene" {
  52113. interface AbstractScene {
  52114. /**
  52115. * The list of reflection probes added to the scene
  52116. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52117. */
  52118. reflectionProbes: Array<ReflectionProbe>;
  52119. /**
  52120. * Removes the given reflection probe from this scene.
  52121. * @param toRemove The reflection probe to remove
  52122. * @returns The index of the removed reflection probe
  52123. */
  52124. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52125. /**
  52126. * Adds the given reflection probe to this scene.
  52127. * @param newReflectionProbe The reflection probe to add
  52128. */
  52129. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52130. }
  52131. }
  52132. /**
  52133. * Class used to generate realtime reflection / refraction cube textures
  52134. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52135. */
  52136. export class ReflectionProbe {
  52137. /** defines the name of the probe */
  52138. name: string;
  52139. private _scene;
  52140. private _renderTargetTexture;
  52141. private _projectionMatrix;
  52142. private _viewMatrix;
  52143. private _target;
  52144. private _add;
  52145. private _attachedMesh;
  52146. private _invertYAxis;
  52147. /** Gets or sets probe position (center of the cube map) */
  52148. position: Vector3;
  52149. /**
  52150. * Creates a new reflection probe
  52151. * @param name defines the name of the probe
  52152. * @param size defines the texture resolution (for each face)
  52153. * @param scene defines the hosting scene
  52154. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52155. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52156. */
  52157. constructor(
  52158. /** defines the name of the probe */
  52159. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52160. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52161. samples: number;
  52162. /** Gets or sets the refresh rate to use (on every frame by default) */
  52163. refreshRate: number;
  52164. /**
  52165. * Gets the hosting scene
  52166. * @returns a Scene
  52167. */
  52168. getScene(): Scene;
  52169. /** Gets the internal CubeTexture used to render to */
  52170. readonly cubeTexture: RenderTargetTexture;
  52171. /** Gets the list of meshes to render */
  52172. readonly renderList: Nullable<AbstractMesh[]>;
  52173. /**
  52174. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52175. * @param mesh defines the mesh to attach to
  52176. */
  52177. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52178. /**
  52179. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52180. * @param renderingGroupId The rendering group id corresponding to its index
  52181. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52182. */
  52183. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52184. /**
  52185. * Clean all associated resources
  52186. */
  52187. dispose(): void;
  52188. /**
  52189. * Converts the reflection probe information to a readable string for debug purpose.
  52190. * @param fullDetails Supports for multiple levels of logging within scene loading
  52191. * @returns the human readable reflection probe info
  52192. */
  52193. toString(fullDetails?: boolean): string;
  52194. /**
  52195. * Get the class name of the relfection probe.
  52196. * @returns "ReflectionProbe"
  52197. */
  52198. getClassName(): string;
  52199. /**
  52200. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52201. * @returns The JSON representation of the texture
  52202. */
  52203. serialize(): any;
  52204. /**
  52205. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52206. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52207. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52208. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52209. * @returns The parsed reflection probe if successful
  52210. */
  52211. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52212. }
  52213. }
  52214. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  52215. /** @hidden */
  52216. export var _BabylonLoaderRegistered: boolean;
  52217. }
  52218. declare module "babylonjs/Loading/Plugins/index" {
  52219. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  52220. }
  52221. declare module "babylonjs/Loading/index" {
  52222. export * from "babylonjs/Loading/loadingScreen";
  52223. export * from "babylonjs/Loading/Plugins/index";
  52224. export * from "babylonjs/Loading/sceneLoader";
  52225. export * from "babylonjs/Loading/sceneLoaderFlags";
  52226. }
  52227. declare module "babylonjs/Materials/Background/index" {
  52228. export * from "babylonjs/Materials/Background/backgroundMaterial";
  52229. }
  52230. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  52231. import { Scene } from "babylonjs/scene";
  52232. import { Color3 } from "babylonjs/Maths/math";
  52233. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52234. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52235. /**
  52236. * The Physically based simple base material of BJS.
  52237. *
  52238. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52239. * It is used as the base class for both the specGloss and metalRough conventions.
  52240. */
  52241. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52242. /**
  52243. * Number of Simultaneous lights allowed on the material.
  52244. */
  52245. maxSimultaneousLights: number;
  52246. /**
  52247. * If sets to true, disables all the lights affecting the material.
  52248. */
  52249. disableLighting: boolean;
  52250. /**
  52251. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52252. */
  52253. environmentTexture: BaseTexture;
  52254. /**
  52255. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52256. */
  52257. invertNormalMapX: boolean;
  52258. /**
  52259. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52260. */
  52261. invertNormalMapY: boolean;
  52262. /**
  52263. * Normal map used in the model.
  52264. */
  52265. normalTexture: BaseTexture;
  52266. /**
  52267. * Emissivie color used to self-illuminate the model.
  52268. */
  52269. emissiveColor: Color3;
  52270. /**
  52271. * Emissivie texture used to self-illuminate the model.
  52272. */
  52273. emissiveTexture: BaseTexture;
  52274. /**
  52275. * Occlusion Channel Strenght.
  52276. */
  52277. occlusionStrength: number;
  52278. /**
  52279. * Occlusion Texture of the material (adding extra occlusion effects).
  52280. */
  52281. occlusionTexture: BaseTexture;
  52282. /**
  52283. * Defines the alpha limits in alpha test mode.
  52284. */
  52285. alphaCutOff: number;
  52286. /**
  52287. * Gets the current double sided mode.
  52288. */
  52289. /**
  52290. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52291. */
  52292. doubleSided: boolean;
  52293. /**
  52294. * Stores the pre-calculated light information of a mesh in a texture.
  52295. */
  52296. lightmapTexture: BaseTexture;
  52297. /**
  52298. * If true, the light map contains occlusion information instead of lighting info.
  52299. */
  52300. useLightmapAsShadowmap: boolean;
  52301. /**
  52302. * Instantiates a new PBRMaterial instance.
  52303. *
  52304. * @param name The material name
  52305. * @param scene The scene the material will be use in.
  52306. */
  52307. constructor(name: string, scene: Scene);
  52308. getClassName(): string;
  52309. }
  52310. }
  52311. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  52312. import { Scene } from "babylonjs/scene";
  52313. import { Color3 } from "babylonjs/Maths/math";
  52314. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52315. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52316. /**
  52317. * The PBR material of BJS following the metal roughness convention.
  52318. *
  52319. * This fits to the PBR convention in the GLTF definition:
  52320. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52321. */
  52322. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52323. /**
  52324. * The base color has two different interpretations depending on the value of metalness.
  52325. * When the material is a metal, the base color is the specific measured reflectance value
  52326. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52327. * of the material.
  52328. */
  52329. baseColor: Color3;
  52330. /**
  52331. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52332. * well as opacity information in the alpha channel.
  52333. */
  52334. baseTexture: BaseTexture;
  52335. /**
  52336. * Specifies the metallic scalar value of the material.
  52337. * Can also be used to scale the metalness values of the metallic texture.
  52338. */
  52339. metallic: number;
  52340. /**
  52341. * Specifies the roughness scalar value of the material.
  52342. * Can also be used to scale the roughness values of the metallic texture.
  52343. */
  52344. roughness: number;
  52345. /**
  52346. * Texture containing both the metallic value in the B channel and the
  52347. * roughness value in the G channel to keep better precision.
  52348. */
  52349. metallicRoughnessTexture: BaseTexture;
  52350. /**
  52351. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52352. *
  52353. * @param name The material name
  52354. * @param scene The scene the material will be use in.
  52355. */
  52356. constructor(name: string, scene: Scene);
  52357. /**
  52358. * Return the currrent class name of the material.
  52359. */
  52360. getClassName(): string;
  52361. /**
  52362. * Makes a duplicate of the current material.
  52363. * @param name - name to use for the new material.
  52364. */
  52365. clone(name: string): PBRMetallicRoughnessMaterial;
  52366. /**
  52367. * Serialize the material to a parsable JSON object.
  52368. */
  52369. serialize(): any;
  52370. /**
  52371. * Parses a JSON object correponding to the serialize function.
  52372. */
  52373. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52374. }
  52375. }
  52376. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  52377. import { Scene } from "babylonjs/scene";
  52378. import { Color3 } from "babylonjs/Maths/math";
  52379. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52380. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52381. /**
  52382. * The PBR material of BJS following the specular glossiness convention.
  52383. *
  52384. * This fits to the PBR convention in the GLTF definition:
  52385. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52386. */
  52387. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52388. /**
  52389. * Specifies the diffuse color of the material.
  52390. */
  52391. diffuseColor: Color3;
  52392. /**
  52393. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52394. * channel.
  52395. */
  52396. diffuseTexture: BaseTexture;
  52397. /**
  52398. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52399. */
  52400. specularColor: Color3;
  52401. /**
  52402. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52403. */
  52404. glossiness: number;
  52405. /**
  52406. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52407. */
  52408. specularGlossinessTexture: BaseTexture;
  52409. /**
  52410. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52411. *
  52412. * @param name The material name
  52413. * @param scene The scene the material will be use in.
  52414. */
  52415. constructor(name: string, scene: Scene);
  52416. /**
  52417. * Return the currrent class name of the material.
  52418. */
  52419. getClassName(): string;
  52420. /**
  52421. * Makes a duplicate of the current material.
  52422. * @param name - name to use for the new material.
  52423. */
  52424. clone(name: string): PBRSpecularGlossinessMaterial;
  52425. /**
  52426. * Serialize the material to a parsable JSON object.
  52427. */
  52428. serialize(): any;
  52429. /**
  52430. * Parses a JSON object correponding to the serialize function.
  52431. */
  52432. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52433. }
  52434. }
  52435. declare module "babylonjs/Materials/PBR/index" {
  52436. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52437. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52438. export * from "babylonjs/Materials/PBR/pbrMaterial";
  52439. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  52440. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  52441. }
  52442. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  52443. import { Nullable } from "babylonjs/types";
  52444. import { Scene } from "babylonjs/scene";
  52445. import { Matrix } from "babylonjs/Maths/math";
  52446. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52447. /**
  52448. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52449. * It can help converting any input color in a desired output one. This can then be used to create effects
  52450. * from sepia, black and white to sixties or futuristic rendering...
  52451. *
  52452. * The only supported format is currently 3dl.
  52453. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52454. */
  52455. export class ColorGradingTexture extends BaseTexture {
  52456. /**
  52457. * The current texture matrix. (will always be identity in color grading texture)
  52458. */
  52459. private _textureMatrix;
  52460. /**
  52461. * The texture URL.
  52462. */
  52463. url: string;
  52464. /**
  52465. * Empty line regex stored for GC.
  52466. */
  52467. private static _noneEmptyLineRegex;
  52468. private _engine;
  52469. /**
  52470. * Instantiates a ColorGradingTexture from the following parameters.
  52471. *
  52472. * @param url The location of the color gradind data (currently only supporting 3dl)
  52473. * @param scene The scene the texture will be used in
  52474. */
  52475. constructor(url: string, scene: Scene);
  52476. /**
  52477. * Returns the texture matrix used in most of the material.
  52478. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52479. */
  52480. getTextureMatrix(): Matrix;
  52481. /**
  52482. * Occurs when the file being loaded is a .3dl LUT file.
  52483. */
  52484. private load3dlTexture;
  52485. /**
  52486. * Starts the loading process of the texture.
  52487. */
  52488. private loadTexture;
  52489. /**
  52490. * Clones the color gradind texture.
  52491. */
  52492. clone(): ColorGradingTexture;
  52493. /**
  52494. * Called during delayed load for textures.
  52495. */
  52496. delayLoad(): void;
  52497. /**
  52498. * Parses a color grading texture serialized by Babylon.
  52499. * @param parsedTexture The texture information being parsedTexture
  52500. * @param scene The scene to load the texture in
  52501. * @param rootUrl The root url of the data assets to load
  52502. * @return A color gradind texture
  52503. */
  52504. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52505. /**
  52506. * Serializes the LUT texture to json format.
  52507. */
  52508. serialize(): any;
  52509. }
  52510. }
  52511. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52512. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52513. import { Scene } from "babylonjs/scene";
  52514. import { Nullable } from "babylonjs/types";
  52515. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52516. /**
  52517. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52518. */
  52519. export class EquiRectangularCubeTexture extends BaseTexture {
  52520. /** The six faces of the cube. */
  52521. private static _FacesMapping;
  52522. private _noMipmap;
  52523. private _onLoad;
  52524. private _onError;
  52525. /** The size of the cubemap. */
  52526. private _size;
  52527. /** The buffer of the image. */
  52528. private _buffer;
  52529. /** The width of the input image. */
  52530. private _width;
  52531. /** The height of the input image. */
  52532. private _height;
  52533. /** The URL to the image. */
  52534. url: string;
  52535. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52536. coordinatesMode: number;
  52537. /**
  52538. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52539. * @param url The location of the image
  52540. * @param scene The scene the texture will be used in
  52541. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52542. * @param noMipmap Forces to not generate the mipmap if true
  52543. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52544. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52545. * @param onLoad — defines a callback called when texture is loaded
  52546. * @param onError — defines a callback called if there is an error
  52547. */
  52548. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52549. /**
  52550. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52551. */
  52552. private loadImage;
  52553. /**
  52554. * Convert the image buffer into a cubemap and create a CubeTexture.
  52555. */
  52556. private loadTexture;
  52557. /**
  52558. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52559. * @param buffer The ArrayBuffer that should be converted.
  52560. * @returns The buffer as Float32Array.
  52561. */
  52562. private getFloat32ArrayFromArrayBuffer;
  52563. /**
  52564. * Get the current class name of the texture useful for serialization or dynamic coding.
  52565. * @returns "EquiRectangularCubeTexture"
  52566. */
  52567. getClassName(): string;
  52568. /**
  52569. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52570. * @returns A clone of the current EquiRectangularCubeTexture.
  52571. */
  52572. clone(): EquiRectangularCubeTexture;
  52573. }
  52574. }
  52575. declare module "babylonjs/Misc/tga" {
  52576. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52577. /**
  52578. * Based on jsTGALoader - Javascript loader for TGA file
  52579. * By Vincent Thibault
  52580. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52581. */
  52582. export class TGATools {
  52583. private static _TYPE_INDEXED;
  52584. private static _TYPE_RGB;
  52585. private static _TYPE_GREY;
  52586. private static _TYPE_RLE_INDEXED;
  52587. private static _TYPE_RLE_RGB;
  52588. private static _TYPE_RLE_GREY;
  52589. private static _ORIGIN_MASK;
  52590. private static _ORIGIN_SHIFT;
  52591. private static _ORIGIN_BL;
  52592. private static _ORIGIN_BR;
  52593. private static _ORIGIN_UL;
  52594. private static _ORIGIN_UR;
  52595. /**
  52596. * Gets the header of a TGA file
  52597. * @param data defines the TGA data
  52598. * @returns the header
  52599. */
  52600. static GetTGAHeader(data: Uint8Array): any;
  52601. /**
  52602. * Uploads TGA content to a Babylon Texture
  52603. * @hidden
  52604. */
  52605. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52606. /** @hidden */
  52607. 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;
  52608. /** @hidden */
  52609. 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;
  52610. /** @hidden */
  52611. 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;
  52612. /** @hidden */
  52613. 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;
  52614. /** @hidden */
  52615. 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;
  52616. /** @hidden */
  52617. 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;
  52618. }
  52619. }
  52620. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  52621. import { Nullable } from "babylonjs/types";
  52622. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52623. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52624. /**
  52625. * Implementation of the TGA Texture Loader.
  52626. * @hidden
  52627. */
  52628. export class _TGATextureLoader implements IInternalTextureLoader {
  52629. /**
  52630. * Defines wether the loader supports cascade loading the different faces.
  52631. */
  52632. readonly supportCascades: boolean;
  52633. /**
  52634. * This returns if the loader support the current file information.
  52635. * @param extension defines the file extension of the file being loaded
  52636. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52637. * @param fallback defines the fallback internal texture if any
  52638. * @param isBase64 defines whether the texture is encoded as a base64
  52639. * @param isBuffer defines whether the texture data are stored as a buffer
  52640. * @returns true if the loader can load the specified file
  52641. */
  52642. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52643. /**
  52644. * Transform the url before loading if required.
  52645. * @param rootUrl the url of the texture
  52646. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52647. * @returns the transformed texture
  52648. */
  52649. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52650. /**
  52651. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52652. * @param rootUrl the url of the texture
  52653. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52654. * @returns the fallback texture
  52655. */
  52656. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52657. /**
  52658. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52659. * @param data contains the texture data
  52660. * @param texture defines the BabylonJS internal texture
  52661. * @param createPolynomials will be true if polynomials have been requested
  52662. * @param onLoad defines the callback to trigger once the texture is ready
  52663. * @param onError defines the callback to trigger in case of error
  52664. */
  52665. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52666. /**
  52667. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52668. * @param data contains the texture data
  52669. * @param texture defines the BabylonJS internal texture
  52670. * @param callback defines the method to call once ready to upload
  52671. */
  52672. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52673. }
  52674. }
  52675. declare module "babylonjs/Misc/basis" {
  52676. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52677. /**
  52678. * Info about the .basis files
  52679. */
  52680. class BasisFileInfo {
  52681. /**
  52682. * If the file has alpha
  52683. */
  52684. hasAlpha: boolean;
  52685. /**
  52686. * Info about each image of the basis file
  52687. */
  52688. images: Array<{
  52689. levels: Array<{
  52690. width: number;
  52691. height: number;
  52692. transcodedPixels: ArrayBufferView;
  52693. }>;
  52694. }>;
  52695. }
  52696. /**
  52697. * Result of transcoding a basis file
  52698. */
  52699. class TranscodeResult {
  52700. /**
  52701. * Info about the .basis file
  52702. */
  52703. fileInfo: BasisFileInfo;
  52704. /**
  52705. * Format to use when loading the file
  52706. */
  52707. format: number;
  52708. }
  52709. /**
  52710. * Configuration options for the Basis transcoder
  52711. */
  52712. export class BasisTranscodeConfiguration {
  52713. /**
  52714. * Supported compression formats used to determine the supported output format of the transcoder
  52715. */
  52716. supportedCompressionFormats?: {
  52717. /**
  52718. * etc1 compression format
  52719. */
  52720. etc1?: boolean;
  52721. /**
  52722. * s3tc compression format
  52723. */
  52724. s3tc?: boolean;
  52725. /**
  52726. * pvrtc compression format
  52727. */
  52728. pvrtc?: boolean;
  52729. /**
  52730. * etc2 compression format
  52731. */
  52732. etc2?: boolean;
  52733. };
  52734. /**
  52735. * If mipmap levels should be loaded for transcoded images (Default: true)
  52736. */
  52737. loadMipmapLevels?: boolean;
  52738. /**
  52739. * Index of a single image to load (Default: all images)
  52740. */
  52741. loadSingleImage?: number;
  52742. }
  52743. /**
  52744. * Used to load .Basis files
  52745. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52746. */
  52747. export class BasisTools {
  52748. private static _IgnoreSupportedFormats;
  52749. /**
  52750. * URL to use when loading the basis transcoder
  52751. */
  52752. static JSModuleURL: string;
  52753. /**
  52754. * URL to use when loading the wasm module for the transcoder
  52755. */
  52756. static WasmModuleURL: string;
  52757. /**
  52758. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52759. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52760. * @returns internal format corresponding to the Basis format
  52761. */
  52762. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52763. private static _WorkerPromise;
  52764. private static _Worker;
  52765. private static _actionId;
  52766. private static _CreateWorkerAsync;
  52767. /**
  52768. * Transcodes a loaded image file to compressed pixel data
  52769. * @param imageData image data to transcode
  52770. * @param config configuration options for the transcoding
  52771. * @returns a promise resulting in the transcoded image
  52772. */
  52773. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52774. /**
  52775. * Loads a texture from the transcode result
  52776. * @param texture texture load to
  52777. * @param transcodeResult the result of transcoding the basis file to load from
  52778. */
  52779. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52780. }
  52781. }
  52782. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  52783. import { Nullable } from "babylonjs/types";
  52784. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52785. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52786. /**
  52787. * Loader for .basis file format
  52788. */
  52789. export class _BasisTextureLoader implements IInternalTextureLoader {
  52790. /**
  52791. * Defines whether the loader supports cascade loading the different faces.
  52792. */
  52793. readonly supportCascades: boolean;
  52794. /**
  52795. * This returns if the loader support the current file information.
  52796. * @param extension defines the file extension of the file being loaded
  52797. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52798. * @param fallback defines the fallback internal texture if any
  52799. * @param isBase64 defines whether the texture is encoded as a base64
  52800. * @param isBuffer defines whether the texture data are stored as a buffer
  52801. * @returns true if the loader can load the specified file
  52802. */
  52803. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52804. /**
  52805. * Transform the url before loading if required.
  52806. * @param rootUrl the url of the texture
  52807. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52808. * @returns the transformed texture
  52809. */
  52810. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52811. /**
  52812. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52813. * @param rootUrl the url of the texture
  52814. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52815. * @returns the fallback texture
  52816. */
  52817. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52818. /**
  52819. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52820. * @param data contains the texture data
  52821. * @param texture defines the BabylonJS internal texture
  52822. * @param createPolynomials will be true if polynomials have been requested
  52823. * @param onLoad defines the callback to trigger once the texture is ready
  52824. * @param onError defines the callback to trigger in case of error
  52825. */
  52826. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52827. /**
  52828. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52829. * @param data contains the texture data
  52830. * @param texture defines the BabylonJS internal texture
  52831. * @param callback defines the method to call once ready to upload
  52832. */
  52833. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52834. }
  52835. }
  52836. declare module "babylonjs/Materials/Textures/Loaders/index" {
  52837. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52838. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52839. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52840. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  52841. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  52842. }
  52843. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  52844. import { Scene } from "babylonjs/scene";
  52845. import { Texture } from "babylonjs/Materials/Textures/texture";
  52846. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52847. /**
  52848. * 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.
  52849. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52850. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52851. */
  52852. export class CustomProceduralTexture extends ProceduralTexture {
  52853. private _animate;
  52854. private _time;
  52855. private _config;
  52856. private _texturePath;
  52857. /**
  52858. * Instantiates a new Custom Procedural Texture.
  52859. * 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.
  52860. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52861. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52862. * @param name Define the name of the texture
  52863. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52864. * @param size Define the size of the texture to create
  52865. * @param scene Define the scene the texture belongs to
  52866. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52867. * @param generateMipMaps Define if the texture should creates mip maps or not
  52868. */
  52869. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52870. private _loadJson;
  52871. /**
  52872. * Is the texture ready to be used ? (rendered at least once)
  52873. * @returns true if ready, otherwise, false.
  52874. */
  52875. isReady(): boolean;
  52876. /**
  52877. * Render the texture to its associated render target.
  52878. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52879. */
  52880. render(useCameraPostProcess?: boolean): void;
  52881. /**
  52882. * Update the list of dependant textures samplers in the shader.
  52883. */
  52884. updateTextures(): void;
  52885. /**
  52886. * Update the uniform values of the procedural texture in the shader.
  52887. */
  52888. updateShaderUniforms(): void;
  52889. /**
  52890. * Define if the texture animates or not.
  52891. */
  52892. animate: boolean;
  52893. }
  52894. }
  52895. declare module "babylonjs/Shaders/noise.fragment" {
  52896. /** @hidden */
  52897. export var noisePixelShader: {
  52898. name: string;
  52899. shader: string;
  52900. };
  52901. }
  52902. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  52903. import { Nullable } from "babylonjs/types";
  52904. import { Scene } from "babylonjs/scene";
  52905. import { Texture } from "babylonjs/Materials/Textures/texture";
  52906. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52907. import "babylonjs/Shaders/noise.fragment";
  52908. /**
  52909. * Class used to generate noise procedural textures
  52910. */
  52911. export class NoiseProceduralTexture extends ProceduralTexture {
  52912. private _time;
  52913. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52914. brightness: number;
  52915. /** Defines the number of octaves to process */
  52916. octaves: number;
  52917. /** Defines the level of persistence (0.8 by default) */
  52918. persistence: number;
  52919. /** Gets or sets animation speed factor (default is 1) */
  52920. animationSpeedFactor: number;
  52921. /**
  52922. * Creates a new NoiseProceduralTexture
  52923. * @param name defines the name fo the texture
  52924. * @param size defines the size of the texture (default is 256)
  52925. * @param scene defines the hosting scene
  52926. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52927. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52928. */
  52929. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52930. private _updateShaderUniforms;
  52931. protected _getDefines(): string;
  52932. /** Generate the current state of the procedural texture */
  52933. render(useCameraPostProcess?: boolean): void;
  52934. /**
  52935. * Serializes this noise procedural texture
  52936. * @returns a serialized noise procedural texture object
  52937. */
  52938. serialize(): any;
  52939. /**
  52940. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52941. * @param parsedTexture defines parsed texture data
  52942. * @param scene defines the current scene
  52943. * @param rootUrl defines the root URL containing noise procedural texture information
  52944. * @returns a parsed NoiseProceduralTexture
  52945. */
  52946. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52947. }
  52948. }
  52949. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  52950. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  52951. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  52952. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52953. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  52954. }
  52955. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  52956. import { Nullable } from "babylonjs/types";
  52957. import { Scene } from "babylonjs/scene";
  52958. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52959. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52960. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  52961. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52962. /**
  52963. * Raw cube texture where the raw buffers are passed in
  52964. */
  52965. export class RawCubeTexture extends CubeTexture {
  52966. /**
  52967. * Creates a cube texture where the raw buffers are passed in.
  52968. * @param scene defines the scene the texture is attached to
  52969. * @param data defines the array of data to use to create each face
  52970. * @param size defines the size of the textures
  52971. * @param format defines the format of the data
  52972. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52973. * @param generateMipMaps defines if the engine should generate the mip levels
  52974. * @param invertY defines if data must be stored with Y axis inverted
  52975. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52976. * @param compression defines the compression used (null by default)
  52977. */
  52978. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52979. /**
  52980. * Updates the raw cube texture.
  52981. * @param data defines the data to store
  52982. * @param format defines the data format
  52983. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52984. * @param invertY defines if data must be stored with Y axis inverted
  52985. * @param compression defines the compression used (null by default)
  52986. * @param level defines which level of the texture to update
  52987. */
  52988. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52989. /**
  52990. * Updates a raw cube texture with RGBD encoded data.
  52991. * @param data defines the array of data [mipmap][face] to use to create each face
  52992. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52993. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52994. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52995. * @returns a promsie that resolves when the operation is complete
  52996. */
  52997. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52998. /**
  52999. * Clones the raw cube texture.
  53000. * @return a new cube texture
  53001. */
  53002. clone(): CubeTexture;
  53003. /** @hidden */
  53004. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53005. }
  53006. }
  53007. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  53008. import { Scene } from "babylonjs/scene";
  53009. import { Texture } from "babylonjs/Materials/Textures/texture";
  53010. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53011. /**
  53012. * Class used to store 3D textures containing user data
  53013. */
  53014. export class RawTexture3D extends Texture {
  53015. /** Gets or sets the texture format to use */
  53016. format: number;
  53017. private _engine;
  53018. /**
  53019. * Create a new RawTexture3D
  53020. * @param data defines the data of the texture
  53021. * @param width defines the width of the texture
  53022. * @param height defines the height of the texture
  53023. * @param depth defines the depth of the texture
  53024. * @param format defines the texture format to use
  53025. * @param scene defines the hosting scene
  53026. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53027. * @param invertY defines if texture must be stored with Y axis inverted
  53028. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53029. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53030. */
  53031. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53032. /** Gets or sets the texture format to use */
  53033. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53034. /**
  53035. * Update the texture with new data
  53036. * @param data defines the data to store in the texture
  53037. */
  53038. update(data: ArrayBufferView): void;
  53039. }
  53040. }
  53041. declare module "babylonjs/Materials/Textures/refractionTexture" {
  53042. import { Scene } from "babylonjs/scene";
  53043. import { Plane } from "babylonjs/Maths/math";
  53044. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53045. /**
  53046. * Creates a refraction texture used by refraction channel of the standard material.
  53047. * It is like a mirror but to see through a material.
  53048. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53049. */
  53050. export class RefractionTexture extends RenderTargetTexture {
  53051. /**
  53052. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53053. * 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.
  53054. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53055. */
  53056. refractionPlane: Plane;
  53057. /**
  53058. * Define how deep under the surface we should see.
  53059. */
  53060. depth: number;
  53061. /**
  53062. * Creates a refraction texture used by refraction channel of the standard material.
  53063. * It is like a mirror but to see through a material.
  53064. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53065. * @param name Define the texture name
  53066. * @param size Define the size of the underlying texture
  53067. * @param scene Define the scene the refraction belongs to
  53068. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53069. */
  53070. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53071. /**
  53072. * Clone the refraction texture.
  53073. * @returns the cloned texture
  53074. */
  53075. clone(): RefractionTexture;
  53076. /**
  53077. * Serialize the texture to a JSON representation you could use in Parse later on
  53078. * @returns the serialized JSON representation
  53079. */
  53080. serialize(): any;
  53081. }
  53082. }
  53083. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  53084. import { Nullable } from "babylonjs/types";
  53085. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53086. import { Matrix } from "babylonjs/Maths/math";
  53087. import { Engine } from "babylonjs/Engines/engine";
  53088. import { Scene } from "babylonjs/scene";
  53089. /**
  53090. * Defines the options related to the creation of an HtmlElementTexture
  53091. */
  53092. export interface IHtmlElementTextureOptions {
  53093. /**
  53094. * Defines wether mip maps should be created or not.
  53095. */
  53096. generateMipMaps?: boolean;
  53097. /**
  53098. * Defines the sampling mode of the texture.
  53099. */
  53100. samplingMode?: number;
  53101. /**
  53102. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53103. */
  53104. engine: Nullable<Engine>;
  53105. /**
  53106. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53107. */
  53108. scene: Nullable<Scene>;
  53109. }
  53110. /**
  53111. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53112. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53113. * is automatically managed.
  53114. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53115. * in your application.
  53116. *
  53117. * As the update is not automatic, you need to call them manually.
  53118. */
  53119. export class HtmlElementTexture extends BaseTexture {
  53120. /**
  53121. * The texture URL.
  53122. */
  53123. element: HTMLVideoElement | HTMLCanvasElement;
  53124. private static readonly DefaultOptions;
  53125. private _textureMatrix;
  53126. private _engine;
  53127. private _isVideo;
  53128. private _generateMipMaps;
  53129. private _samplingMode;
  53130. /**
  53131. * Instantiates a HtmlElementTexture from the following parameters.
  53132. *
  53133. * @param name Defines the name of the texture
  53134. * @param element Defines the video or canvas the texture is filled with
  53135. * @param options Defines the other none mandatory texture creation options
  53136. */
  53137. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53138. private _createInternalTexture;
  53139. /**
  53140. * Returns the texture matrix used in most of the material.
  53141. */
  53142. getTextureMatrix(): Matrix;
  53143. /**
  53144. * Updates the content of the texture.
  53145. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53146. */
  53147. update(invertY?: Nullable<boolean>): void;
  53148. }
  53149. }
  53150. declare module "babylonjs/Materials/Textures/index" {
  53151. export * from "babylonjs/Materials/Textures/baseTexture";
  53152. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  53153. export * from "babylonjs/Materials/Textures/cubeTexture";
  53154. export * from "babylonjs/Materials/Textures/dynamicTexture";
  53155. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  53156. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  53157. export * from "babylonjs/Materials/Textures/internalTexture";
  53158. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  53159. export * from "babylonjs/Materials/Textures/Loaders/index";
  53160. export * from "babylonjs/Materials/Textures/mirrorTexture";
  53161. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  53162. export * from "babylonjs/Materials/Textures/Procedurals/index";
  53163. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  53164. export * from "babylonjs/Materials/Textures/rawTexture";
  53165. export * from "babylonjs/Materials/Textures/rawTexture3D";
  53166. export * from "babylonjs/Materials/Textures/refractionTexture";
  53167. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  53168. export * from "babylonjs/Materials/Textures/texture";
  53169. export * from "babylonjs/Materials/Textures/videoTexture";
  53170. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  53171. }
  53172. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  53173. /**
  53174. * Enum used to define the target of a block
  53175. */
  53176. export enum NodeMaterialBlockTargets {
  53177. /** Vertex shader */
  53178. Vertex = 1,
  53179. /** Fragment shader */
  53180. Fragment = 2,
  53181. /** Neutral */
  53182. Neutral = 4,
  53183. /** Vertex and Fragment */
  53184. VertexAndFragment = 3
  53185. }
  53186. }
  53187. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  53188. /**
  53189. * Defines the kind of connection point for node based material
  53190. */
  53191. export enum NodeMaterialBlockConnectionPointTypes {
  53192. /** Float */
  53193. Float = 1,
  53194. /** Int */
  53195. Int = 2,
  53196. /** Vector2 */
  53197. Vector2 = 4,
  53198. /** Vector3 */
  53199. Vector3 = 8,
  53200. /** Vector4 */
  53201. Vector4 = 16,
  53202. /** Color3 */
  53203. Color3 = 32,
  53204. /** Color4 */
  53205. Color4 = 64,
  53206. /** Matrix */
  53207. Matrix = 128,
  53208. /** Vector3 or Color3 */
  53209. Vector3OrColor3 = 40,
  53210. /** Vector3 or Vector4 */
  53211. Vector3OrVector4 = 24,
  53212. /** Vector4 or Color4 */
  53213. Vector4OrColor4 = 80,
  53214. /** Color3 or Color4 */
  53215. Color3OrColor4 = 96,
  53216. /** Vector2 or Color3 or Color4 */
  53217. Vector2OrColor3OrColor4 = 100,
  53218. /** Vector3 or Color3 or Color4 or Vector4 */
  53219. Vector3OrColor3OrVector4OrColor4 = 120,
  53220. /** Vector2 or Vector3 or Color3 or Color4 or Vector4 */
  53221. Vector2OrVector3OrColor3OrVector4OrColor4 = 124,
  53222. /** Detect type based on connection */
  53223. AutoDetect = 1024,
  53224. /** Output type that will be defined by input type */
  53225. BasedOnInput = 2048
  53226. }
  53227. }
  53228. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  53229. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53230. /**
  53231. * Root class for all node material optimizers
  53232. */
  53233. export class NodeMaterialOptimizer {
  53234. /**
  53235. * Function used to optimize a NodeMaterial graph
  53236. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53237. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53238. */
  53239. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53240. }
  53241. }
  53242. declare module "babylonjs/Materials/Node/Blocks/vector4TransformBlock" {
  53243. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53244. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53245. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53246. /**
  53247. * Block used to transform a vector4 with a matrix
  53248. */
  53249. export class Vector4TransformBlock extends NodeMaterialBlock {
  53250. /**
  53251. * Defines the value to use to complement Vector3 to transform it to a Vector4
  53252. */
  53253. complementW: number;
  53254. /**
  53255. * Creates a new Vector4TransformBlock
  53256. * @param name defines the block name
  53257. */
  53258. constructor(name: string);
  53259. /**
  53260. * Gets the current class name
  53261. * @returns the class name
  53262. */
  53263. getClassName(): string;
  53264. /**
  53265. * Gets the vector input
  53266. */
  53267. readonly vector: NodeMaterialConnectionPoint;
  53268. /**
  53269. * Gets the output component
  53270. */
  53271. readonly output: NodeMaterialConnectionPoint;
  53272. /**
  53273. * Gets the matrix transform input
  53274. */
  53275. readonly transform: NodeMaterialConnectionPoint;
  53276. protected _buildBlock(state: NodeMaterialBuildState): this;
  53277. }
  53278. }
  53279. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53280. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53281. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53282. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53283. /**
  53284. * Block used to output the vertex position
  53285. */
  53286. export class VertexOutputBlock extends NodeMaterialBlock {
  53287. /**
  53288. * Creates a new VertexOutputBlock
  53289. * @param name defines the block name
  53290. */
  53291. constructor(name: string);
  53292. /**
  53293. * Gets the current class name
  53294. * @returns the class name
  53295. */
  53296. getClassName(): string;
  53297. /**
  53298. * Gets the vector input component
  53299. */
  53300. readonly vector: NodeMaterialConnectionPoint;
  53301. protected _buildBlock(state: NodeMaterialBuildState): this;
  53302. }
  53303. }
  53304. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53305. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53306. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53307. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53308. /**
  53309. * Block used to output the final color
  53310. */
  53311. export class FragmentOutputBlock extends NodeMaterialBlock {
  53312. /**
  53313. * Gets or sets a boolean indicating if this block will output an alpha value
  53314. */
  53315. alphaBlendingEnabled: boolean;
  53316. /**
  53317. * Create a new FragmentOutputBlock
  53318. * @param name defines the block name
  53319. */
  53320. constructor(name: string);
  53321. /**
  53322. * Gets the current class name
  53323. * @returns the class name
  53324. */
  53325. getClassName(): string;
  53326. /**
  53327. * Gets the color input component
  53328. */
  53329. readonly color: NodeMaterialConnectionPoint;
  53330. protected _buildBlock(state: NodeMaterialBuildState): this;
  53331. }
  53332. }
  53333. declare module "babylonjs/Materials/Node/nodeMaterial" {
  53334. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53335. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53336. import { Scene } from "babylonjs/scene";
  53337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53338. import { Matrix } from "babylonjs/Maths/math";
  53339. import { Mesh } from "babylonjs/Meshes/mesh";
  53340. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53341. import { Observable } from "babylonjs/Misc/observable";
  53342. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53343. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53344. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53345. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53346. import { Nullable } from "babylonjs/types";
  53347. /**
  53348. * Interface used to configure the node material editor
  53349. */
  53350. export interface INodeMaterialEditorOptions {
  53351. /** Define the URl to load node editor script */
  53352. editorURL?: string;
  53353. }
  53354. /** @hidden */
  53355. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53356. /** BONES */
  53357. NUM_BONE_INFLUENCERS: number;
  53358. BonesPerMesh: number;
  53359. BONETEXTURE: boolean;
  53360. /** MORPH TARGETS */
  53361. MORPHTARGETS: boolean;
  53362. MORPHTARGETS_NORMAL: boolean;
  53363. MORPHTARGETS_TANGENT: boolean;
  53364. MORPHTARGETS_UV: boolean;
  53365. NUM_MORPH_INFLUENCERS: number;
  53366. /** IMAGE PROCESSING */
  53367. IMAGEPROCESSING: boolean;
  53368. VIGNETTE: boolean;
  53369. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53370. VIGNETTEBLENDMODEOPAQUE: boolean;
  53371. TONEMAPPING: boolean;
  53372. TONEMAPPING_ACES: boolean;
  53373. CONTRAST: boolean;
  53374. EXPOSURE: boolean;
  53375. COLORCURVES: boolean;
  53376. COLORGRADING: boolean;
  53377. COLORGRADING3D: boolean;
  53378. SAMPLER3DGREENDEPTH: boolean;
  53379. SAMPLER3DBGRMAP: boolean;
  53380. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53381. constructor();
  53382. setValue(name: string, value: boolean): void;
  53383. }
  53384. /**
  53385. * Class used to configure NodeMaterial
  53386. */
  53387. export interface INodeMaterialOptions {
  53388. /**
  53389. * Defines if blocks should emit comments
  53390. */
  53391. emitComments: boolean;
  53392. }
  53393. /**
  53394. * Class used to create a node based material built by assembling shader blocks
  53395. */
  53396. export class NodeMaterial extends PushMaterial {
  53397. private _options;
  53398. private _vertexCompilationState;
  53399. private _fragmentCompilationState;
  53400. private _sharedData;
  53401. private _buildId;
  53402. private _buildWasSuccessful;
  53403. private _cachedWorldViewMatrix;
  53404. private _cachedWorldViewProjectionMatrix;
  53405. private _optimizers;
  53406. /** Define the URl to load node editor script */
  53407. static EditorURL: string;
  53408. private BJSNODEMATERIALEDITOR;
  53409. /** Get the inspector from bundle or global */
  53410. private _getGlobalNodeMaterialEditor;
  53411. /**
  53412. * Defines the maximum number of lights that can be used in the material
  53413. */
  53414. maxSimultaneousLights: number;
  53415. /**
  53416. * Observable raised when the material is built
  53417. */
  53418. onBuildObservable: Observable<NodeMaterial>;
  53419. /**
  53420. * Gets or sets the root nodes of the material vertex shader
  53421. */
  53422. _vertexOutputNodes: NodeMaterialBlock[];
  53423. /**
  53424. * Gets or sets the root nodes of the material fragment (pixel) shader
  53425. */
  53426. _fragmentOutputNodes: NodeMaterialBlock[];
  53427. /** Gets or sets options to control the node material overall behavior */
  53428. options: INodeMaterialOptions;
  53429. /**
  53430. * Default configuration related to image processing available in the standard Material.
  53431. */
  53432. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53433. /**
  53434. * Gets the image processing configuration used either in this material.
  53435. */
  53436. /**
  53437. * Sets the Default image processing configuration used either in the this material.
  53438. *
  53439. * If sets to null, the scene one is in use.
  53440. */
  53441. imageProcessingConfiguration: ImageProcessingConfiguration;
  53442. /**
  53443. * Create a new node based material
  53444. * @param name defines the material name
  53445. * @param scene defines the hosting scene
  53446. * @param options defines creation option
  53447. */
  53448. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53449. /**
  53450. * Gets the current class name of the material e.g. "NodeMaterial"
  53451. * @returns the class name
  53452. */
  53453. getClassName(): string;
  53454. /**
  53455. * Keep track of the image processing observer to allow dispose and replace.
  53456. */
  53457. private _imageProcessingObserver;
  53458. /**
  53459. * Attaches a new image processing configuration to the Standard Material.
  53460. * @param configuration
  53461. */
  53462. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53463. /**
  53464. * Adds a new optimizer to the list of optimizers
  53465. * @param optimizer defines the optimizers to add
  53466. * @returns the current material
  53467. */
  53468. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53469. /**
  53470. * Remove an optimizer from the list of optimizers
  53471. * @param optimizer defines the optimizers to remove
  53472. * @returns the current material
  53473. */
  53474. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53475. /**
  53476. * Add a new block to the list of output nodes
  53477. * @param node defines the node to add
  53478. * @returns the current material
  53479. */
  53480. addOutputNode(node: NodeMaterialBlock): this;
  53481. /**
  53482. * Remove a block from the list of root nodes
  53483. * @param node defines the node to remove
  53484. * @returns the current material
  53485. */
  53486. removeOutputNode(node: NodeMaterialBlock): this;
  53487. private _addVertexOutputNode;
  53488. private _removeVertexOutputNode;
  53489. private _addFragmentOutputNode;
  53490. private _removeFragmentOutputNode;
  53491. /**
  53492. * Specifies if the material will require alpha blending
  53493. * @returns a boolean specifying if alpha blending is needed
  53494. */
  53495. needAlphaBlending(): boolean;
  53496. /**
  53497. * Specifies if this material should be rendered in alpha test mode
  53498. * @returns a boolean specifying if an alpha test is needed.
  53499. */
  53500. needAlphaTesting(): boolean;
  53501. private _initializeBlock;
  53502. private _resetDualBlocks;
  53503. /**
  53504. * Build the material and generates the inner effect
  53505. * @param verbose defines if the build should log activity
  53506. */
  53507. build(verbose?: boolean): void;
  53508. /**
  53509. * Runs an otpimization phase to try to improve the shader code
  53510. */
  53511. optimize(): void;
  53512. private _prepareDefinesForAttributes;
  53513. /**
  53514. * Get if the submesh is ready to be used and all its information available.
  53515. * Child classes can use it to update shaders
  53516. * @param mesh defines the mesh to check
  53517. * @param subMesh defines which submesh to check
  53518. * @param useInstances specifies that instances should be used
  53519. * @returns a boolean indicating that the submesh is ready or not
  53520. */
  53521. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53522. /**
  53523. * Binds the world matrix to the material
  53524. * @param world defines the world transformation matrix
  53525. */
  53526. bindOnlyWorldMatrix(world: Matrix): void;
  53527. /**
  53528. * Binds the submesh to this material by preparing the effect and shader to draw
  53529. * @param world defines the world transformation matrix
  53530. * @param mesh defines the mesh containing the submesh
  53531. * @param subMesh defines the submesh to bind the material to
  53532. */
  53533. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53534. /**
  53535. * Gets the active textures from the material
  53536. * @returns an array of textures
  53537. */
  53538. getActiveTextures(): BaseTexture[];
  53539. /**
  53540. * Specifies if the material uses a texture
  53541. * @param texture defines the texture to check against the material
  53542. * @returns a boolean specifying if the material uses the texture
  53543. */
  53544. hasTexture(texture: BaseTexture): boolean;
  53545. /**
  53546. * Disposes the material
  53547. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53548. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53549. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53550. */
  53551. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53552. /** Creates the node editor window. */
  53553. private _createNodeEditor;
  53554. /**
  53555. * Launch the node material editor
  53556. * @param config Define the configuration of the editor
  53557. * @return a promise fulfilled when the node editor is visible
  53558. */
  53559. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53560. /**
  53561. * Clear the current material
  53562. */
  53563. clear(): void;
  53564. /**
  53565. * Clear the current material and set it to a default state
  53566. */
  53567. setToDefault(): void;
  53568. }
  53569. }
  53570. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  53571. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53572. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53573. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53574. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53576. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53577. import { Effect } from "babylonjs/Materials/effect";
  53578. import { Mesh } from "babylonjs/Meshes/mesh";
  53579. import { Nullable } from "babylonjs/types";
  53580. /**
  53581. * Block used to read a texture from a sampler
  53582. */
  53583. export class TextureBlock extends NodeMaterialBlock {
  53584. private _defineName;
  53585. private _samplerName;
  53586. private _transformedUVName;
  53587. private _textureTransformName;
  53588. private _textureInfoName;
  53589. private _mainUVName;
  53590. private _mainUVDefineName;
  53591. /**
  53592. * Gets or sets the texture associated with the node
  53593. */
  53594. texture: Nullable<BaseTexture>;
  53595. /**
  53596. * Create a new TextureBlock
  53597. * @param name defines the block name
  53598. */
  53599. constructor(name: string);
  53600. /**
  53601. * Gets the current class name
  53602. * @returns the class name
  53603. */
  53604. getClassName(): string;
  53605. /**
  53606. * Gets the uv input component
  53607. */
  53608. readonly uv: NodeMaterialConnectionPoint;
  53609. /**
  53610. * Gets the output component
  53611. */
  53612. readonly output: NodeMaterialConnectionPoint;
  53613. autoConfigure(): void;
  53614. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53615. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53616. isReady(): boolean;
  53617. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53618. private _injectVertexCode;
  53619. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53620. }
  53621. }
  53622. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  53623. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53624. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53625. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  53626. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  53627. /**
  53628. * Class used to store shared data between 2 NodeMaterialBuildState
  53629. */
  53630. export class NodeMaterialBuildStateSharedData {
  53631. /**
  53632. * Gets the list of emitted varyings
  53633. */
  53634. varyings: string[];
  53635. /**
  53636. * Gets the varying declaration string
  53637. */
  53638. varyingDeclaration: string;
  53639. /**
  53640. * Input blocks
  53641. */
  53642. inputBlocks: InputBlock[];
  53643. /**
  53644. * Input blocks
  53645. */
  53646. textureBlocks: TextureBlock[];
  53647. /**
  53648. * Bindable blocks (Blocks that need to set data to the effect)
  53649. */
  53650. bindableBlocks: NodeMaterialBlock[];
  53651. /**
  53652. * List of blocks that can provide a compilation fallback
  53653. */
  53654. blocksWithFallbacks: NodeMaterialBlock[];
  53655. /**
  53656. * List of blocks that can provide a define update
  53657. */
  53658. blocksWithDefines: NodeMaterialBlock[];
  53659. /**
  53660. * List of blocks that can provide a repeatable content
  53661. */
  53662. repeatableContentBlocks: NodeMaterialBlock[];
  53663. /**
  53664. * List of blocks that can provide a dynamic list of uniforms
  53665. */
  53666. dynamicUniformBlocks: NodeMaterialBlock[];
  53667. /**
  53668. * List of blocks that can block the isReady function for the material
  53669. */
  53670. blockingBlocks: NodeMaterialBlock[];
  53671. /**
  53672. * Build Id used to avoid multiple recompilations
  53673. */
  53674. buildId: number;
  53675. /** List of emitted variables */
  53676. variableNames: {
  53677. [key: string]: number;
  53678. };
  53679. /** List of emitted defines */
  53680. defineNames: {
  53681. [key: string]: number;
  53682. };
  53683. /** Should emit comments? */
  53684. emitComments: boolean;
  53685. /** Emit build activity */
  53686. verbose: boolean;
  53687. /**
  53688. * Gets the compilation hints emitted at compilation time
  53689. */
  53690. hints: {
  53691. needWorldViewMatrix: boolean;
  53692. needWorldViewProjectionMatrix: boolean;
  53693. needAlphaBlending: boolean;
  53694. needAlphaTesting: boolean;
  53695. };
  53696. /**
  53697. * List of compilation checks
  53698. */
  53699. checks: {
  53700. emitVertex: boolean;
  53701. emitFragment: boolean;
  53702. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53703. };
  53704. /** Creates a new shared data */
  53705. constructor();
  53706. /**
  53707. * Emits console errors and exceptions if there is a failing check
  53708. */
  53709. emitErrors(): void;
  53710. }
  53711. }
  53712. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  53713. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53714. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53715. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  53716. /**
  53717. * Class used to store node based material build state
  53718. */
  53719. export class NodeMaterialBuildState {
  53720. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53721. supportUniformBuffers: boolean;
  53722. /**
  53723. * Gets the list of emitted attributes
  53724. */
  53725. attributes: string[];
  53726. /**
  53727. * Gets the list of emitted uniforms
  53728. */
  53729. uniforms: string[];
  53730. /**
  53731. * Gets the list of emitted uniform buffers
  53732. */
  53733. uniformBuffers: string[];
  53734. /**
  53735. * Gets the list of emitted samplers
  53736. */
  53737. samplers: string[];
  53738. /**
  53739. * Gets the list of emitted functions
  53740. */
  53741. functions: {
  53742. [key: string]: string;
  53743. };
  53744. /**
  53745. * Gets the target of the compilation state
  53746. */
  53747. target: NodeMaterialBlockTargets;
  53748. /**
  53749. * Gets the list of emitted counters
  53750. */
  53751. counters: {
  53752. [key: string]: number;
  53753. };
  53754. /**
  53755. * Shared data between multiple NodeMaterialBuildState instances
  53756. */
  53757. sharedData: NodeMaterialBuildStateSharedData;
  53758. /** @hidden */
  53759. _vertexState: NodeMaterialBuildState;
  53760. /** @hidden */
  53761. _attributeDeclaration: string;
  53762. /** @hidden */
  53763. _uniformDeclaration: string;
  53764. /** @hidden */
  53765. _samplerDeclaration: string;
  53766. /** @hidden */
  53767. _varyingTransfer: string;
  53768. private _repeatableContentAnchorIndex;
  53769. /** @hidden */
  53770. _builtCompilationString: string;
  53771. /**
  53772. * Gets the emitted compilation strings
  53773. */
  53774. compilationString: string;
  53775. /**
  53776. * Finalize the compilation strings
  53777. * @param state defines the current compilation state
  53778. */
  53779. finalize(state: NodeMaterialBuildState): void;
  53780. /** @hidden */
  53781. readonly _repeatableContentAnchor: string;
  53782. /** @hidden */
  53783. _getFreeVariableName(prefix: string): string;
  53784. /** @hidden */
  53785. _getFreeDefineName(prefix: string): string;
  53786. /** @hidden */
  53787. _excludeVariableName(name: string): void;
  53788. /** @hidden */
  53789. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53790. /** @hidden */
  53791. _emitFunction(name: string, code: string, comments: string): void;
  53792. /** @hidden */
  53793. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53794. replaceStrings?: {
  53795. search: RegExp;
  53796. replace: string;
  53797. }[];
  53798. repeatKey?: string;
  53799. }): string;
  53800. /** @hidden */
  53801. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53802. repeatKey?: string;
  53803. removeAttributes?: boolean;
  53804. removeUniforms?: boolean;
  53805. removeVaryings?: boolean;
  53806. removeIfDef?: boolean;
  53807. replaceStrings?: {
  53808. search: RegExp;
  53809. replace: string;
  53810. }[];
  53811. }, storeKey?: string): void;
  53812. /** @hidden */
  53813. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  53814. /** @hidden */
  53815. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  53816. }
  53817. }
  53818. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  53819. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53820. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53821. import { Nullable } from "babylonjs/types";
  53822. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53823. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53824. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53826. import { Mesh } from "babylonjs/Meshes/mesh";
  53827. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53828. /**
  53829. * Defines a block that can be used inside a node based material
  53830. */
  53831. export class NodeMaterialBlock {
  53832. private _buildId;
  53833. private _buildTarget;
  53834. private _target;
  53835. private _isFinalMerger;
  53836. private _isInput;
  53837. /** @hidden */
  53838. _inputs: NodeMaterialConnectionPoint[];
  53839. /** @hidden */
  53840. _outputs: NodeMaterialConnectionPoint[];
  53841. /**
  53842. * Gets or sets the name of the block
  53843. */
  53844. name: string;
  53845. /**
  53846. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53847. */
  53848. readonly isFinalMerger: boolean;
  53849. /**
  53850. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  53851. */
  53852. readonly isInput: boolean;
  53853. /**
  53854. * Gets or sets the build Id
  53855. */
  53856. buildId: number;
  53857. /**
  53858. * Gets or sets the target of the block
  53859. */
  53860. target: NodeMaterialBlockTargets;
  53861. /**
  53862. * Gets the list of input points
  53863. */
  53864. readonly inputs: NodeMaterialConnectionPoint[];
  53865. /** Gets the list of output points */
  53866. readonly outputs: NodeMaterialConnectionPoint[];
  53867. /**
  53868. * Find an input by its name
  53869. * @param name defines the name of the input to look for
  53870. * @returns the input or null if not found
  53871. */
  53872. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53873. /**
  53874. * Find an output by its name
  53875. * @param name defines the name of the outputto look for
  53876. * @returns the output or null if not found
  53877. */
  53878. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53879. /**
  53880. * Creates a new NodeMaterialBlock
  53881. * @param name defines the block name
  53882. * @param target defines the target of that block (Vertex by default)
  53883. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53884. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  53885. */
  53886. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  53887. /**
  53888. * Initialize the block and prepare the context for build
  53889. * @param state defines the state that will be used for the build
  53890. */
  53891. initialize(state: NodeMaterialBuildState): void;
  53892. /**
  53893. * Bind data to effect. Will only be called for blocks with isBindable === true
  53894. * @param effect defines the effect to bind data to
  53895. * @param nodeMaterial defines the hosting NodeMaterial
  53896. * @param mesh defines the mesh that will be rendered
  53897. */
  53898. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53899. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53900. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53901. protected _writeFloat(value: number): string;
  53902. /**
  53903. * Gets the current class name e.g. "NodeMaterialBlock"
  53904. * @returns the class name
  53905. */
  53906. getClassName(): string;
  53907. /**
  53908. * Register a new input. Must be called inside a block constructor
  53909. * @param name defines the connection point name
  53910. * @param type defines the connection point type
  53911. * @param isOptional defines a boolean indicating that this input can be omitted
  53912. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53913. * @returns the current block
  53914. */
  53915. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53916. /**
  53917. * Register a new output. Must be called inside a block constructor
  53918. * @param name defines the connection point name
  53919. * @param type defines the connection point type
  53920. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53921. * @returns the current block
  53922. */
  53923. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53924. /**
  53925. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53926. * @param forOutput defines an optional connection point to check compatibility with
  53927. * @returns the first available input or null
  53928. */
  53929. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53930. /**
  53931. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53932. * @param forBlock defines an optional block to check compatibility with
  53933. * @returns the first available input or null
  53934. */
  53935. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53936. /**
  53937. * Connect current block with another block
  53938. * @param other defines the block to connect with
  53939. * @param options define the various options to help pick the right connections
  53940. * @returns the current block
  53941. */
  53942. connectTo(other: NodeMaterialBlock, options?: {
  53943. input?: string;
  53944. output?: string;
  53945. outputSwizzle?: string;
  53946. }): this | undefined;
  53947. protected _buildBlock(state: NodeMaterialBuildState): void;
  53948. /**
  53949. * Add uniforms, samplers and uniform buffers at compilation time
  53950. * @param state defines the state to update
  53951. * @param nodeMaterial defines the node material requesting the update
  53952. * @param defines defines the material defines to update
  53953. */
  53954. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53955. /**
  53956. * Add potential fallbacks if shader compilation fails
  53957. * @param mesh defines the mesh to be rendered
  53958. * @param fallbacks defines the current prioritized list of fallbacks
  53959. */
  53960. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53961. /**
  53962. * Update defines for shader compilation
  53963. * @param mesh defines the mesh to be rendered
  53964. * @param nodeMaterial defines the node material requesting the update
  53965. * @param defines defines the material defines to update
  53966. * @param useInstances specifies that instances should be used
  53967. */
  53968. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53969. /**
  53970. * Initialize defines for shader compilation
  53971. * @param mesh defines the mesh to be rendered
  53972. * @param nodeMaterial defines the node material requesting the update
  53973. * @param defines defines the material defines to be prepared
  53974. * @param useInstances specifies that instances should be used
  53975. */
  53976. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53977. /**
  53978. * Lets the block try to connect some inputs automatically
  53979. */
  53980. autoConfigure(): void;
  53981. /**
  53982. * Function called when a block is declared as repeatable content generator
  53983. * @param vertexShaderState defines the current compilation state for the vertex shader
  53984. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53985. * @param mesh defines the mesh to be rendered
  53986. * @param defines defines the material defines to update
  53987. */
  53988. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53989. /**
  53990. * Checks if the block is ready
  53991. * @param mesh defines the mesh to be rendered
  53992. * @param nodeMaterial defines the node material requesting the update
  53993. * @param defines defines the material defines to update
  53994. * @param useInstances specifies that instances should be used
  53995. * @returns true if the block is ready
  53996. */
  53997. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53998. private _processBuild;
  53999. /**
  54000. * Compile the current node and generate the shader code
  54001. * @param state defines the current compilation state (uniforms, samplers, current string)
  54002. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  54003. * @returns true if already built
  54004. */
  54005. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  54006. }
  54007. }
  54008. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  54009. /**
  54010. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54011. */
  54012. export enum NodeMaterialBlockConnectionPointMode {
  54013. /** Value is an uniform */
  54014. Uniform = 0,
  54015. /** Value is a mesh attribute */
  54016. Attribute = 1,
  54017. /** Value is a varying between vertex and fragment shaders */
  54018. Varying = 2,
  54019. /** Mode is undefined */
  54020. Undefined = 3
  54021. }
  54022. }
  54023. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  54024. /**
  54025. * Enum used to define well known values e.g. values automatically provided by the system
  54026. */
  54027. export enum NodeMaterialWellKnownValues {
  54028. /** World */
  54029. World = 1,
  54030. /** View */
  54031. View = 2,
  54032. /** Projection */
  54033. Projection = 3,
  54034. /** ViewProjection */
  54035. ViewProjection = 4,
  54036. /** WorldView */
  54037. WorldView = 5,
  54038. /** WorldViewProjection */
  54039. WorldViewProjection = 6,
  54040. /** CameraPosition */
  54041. CameraPosition = 7,
  54042. /** Fog Color */
  54043. FogColor = 8
  54044. }
  54045. }
  54046. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  54047. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54048. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54049. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54050. import { Nullable } from "babylonjs/types";
  54051. import { Effect } from "babylonjs/Materials/effect";
  54052. import { Matrix } from "babylonjs/Maths/math";
  54053. import { Scene } from "babylonjs/scene";
  54054. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54055. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54056. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54057. /**
  54058. * Block used to expose an input value
  54059. */
  54060. export class InputBlock extends NodeMaterialBlock {
  54061. private _mode;
  54062. private _associatedVariableName;
  54063. private _storedValue;
  54064. private _valueCallback;
  54065. private _type;
  54066. /** @hidden */
  54067. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  54068. /**
  54069. * Gets or sets the connection point type (default is float)
  54070. */
  54071. readonly type: NodeMaterialBlockConnectionPointTypes;
  54072. /**
  54073. * Creates a new InputBlock
  54074. * @param name defines the block name
  54075. * @param target defines the target of that block (Vertex by default)
  54076. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  54077. */
  54078. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  54079. /**
  54080. * Gets the output component
  54081. */
  54082. readonly output: NodeMaterialConnectionPoint;
  54083. /**
  54084. * Set the source of this connection point to a vertex attribute
  54085. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  54086. * @returns the current connection point
  54087. */
  54088. setAsAttribute(attributeName?: string): InputBlock;
  54089. /**
  54090. * Set the source of this connection point to a well known value
  54091. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  54092. * @returns the current connection point
  54093. */
  54094. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  54095. /**
  54096. * Gets or sets the value of that point.
  54097. * Please note that this value will be ignored if valueCallback is defined
  54098. */
  54099. value: any;
  54100. /**
  54101. * Gets or sets a callback used to get the value of that point.
  54102. * Please note that setting this value will force the connection point to ignore the value property
  54103. */
  54104. valueCallback: () => any;
  54105. /**
  54106. * Gets or sets the associated variable name in the shader
  54107. */
  54108. associatedVariableName: string;
  54109. /**
  54110. * Gets a boolean indicating that this connection point not defined yet
  54111. */
  54112. readonly isUndefined: boolean;
  54113. /**
  54114. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  54115. * In this case the connection point name must be the name of the uniform to use.
  54116. * Can only be set on inputs
  54117. */
  54118. isUniform: boolean;
  54119. /**
  54120. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  54121. * In this case the connection point name must be the name of the attribute to use
  54122. * Can only be set on inputs
  54123. */
  54124. isAttribute: boolean;
  54125. /**
  54126. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  54127. * Can only be set on exit points
  54128. */
  54129. isVarying: boolean;
  54130. /**
  54131. * Gets a boolean indicating that the current connection point is a well known value
  54132. */
  54133. readonly isWellKnownValue: boolean;
  54134. /**
  54135. * Gets or sets the current well known value or null if not defined as well know value
  54136. */
  54137. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  54138. /**
  54139. * Gets the current class name
  54140. * @returns the class name
  54141. */
  54142. getClassName(): string;
  54143. private _emitDefine;
  54144. /**
  54145. * Set the input block to its default value (based on its type)
  54146. */
  54147. setDefaultValue(): void;
  54148. private _emit;
  54149. /** @hidden */
  54150. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  54151. /** @hidden */
  54152. _transmit(effect: Effect, scene: Scene): void;
  54153. protected _buildBlock(state: NodeMaterialBuildState): void;
  54154. }
  54155. }
  54156. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  54157. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54158. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54159. import { Nullable } from "babylonjs/types";
  54160. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54161. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54162. /**
  54163. * Defines a connection point for a block
  54164. */
  54165. export class NodeMaterialConnectionPoint {
  54166. /** @hidden */
  54167. _ownerBlock: NodeMaterialBlock;
  54168. /** @hidden */
  54169. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54170. private _endpoints;
  54171. private _associatedVariableName;
  54172. /** @hidden */
  54173. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54174. private _type;
  54175. /** @hidden */
  54176. _enforceAssociatedVariableName: boolean;
  54177. /**
  54178. * Gets or sets the associated variable name in the shader
  54179. */
  54180. associatedVariableName: string;
  54181. /**
  54182. * Gets or sets the connection point type (default is float)
  54183. */
  54184. type: NodeMaterialBlockConnectionPointTypes;
  54185. /**
  54186. * Gets or sets the connection point name
  54187. */
  54188. name: string;
  54189. /**
  54190. * Gets or sets the swizzle to apply to this connection point when reading or writing
  54191. */
  54192. swizzle: string;
  54193. /**
  54194. * Gets or sets a boolean indicating that this connection point can be omitted
  54195. */
  54196. isOptional: boolean;
  54197. /**
  54198. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  54199. */
  54200. define: string;
  54201. /** Gets or sets the target of that connection point */
  54202. target: NodeMaterialBlockTargets;
  54203. /**
  54204. * Gets a boolean indicating that the current point is connected
  54205. */
  54206. readonly isConnected: boolean;
  54207. /**
  54208. * Gets a boolean indicating that the current point is connected to an input block
  54209. */
  54210. readonly isConnectedToInput: boolean;
  54211. /**
  54212. * Gets a the connected input block (if any)
  54213. */
  54214. readonly connectInputBlock: Nullable<InputBlock>;
  54215. /** Get the other side of the connection (if any) */
  54216. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54217. /** Get the block that owns this connection point */
  54218. readonly ownerBlock: NodeMaterialBlock;
  54219. /** Get the block connected on the other side of this connection (if any) */
  54220. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  54221. /** Get the block connected on the endpoints of this connection (if any) */
  54222. readonly connectedBlocks: Array<NodeMaterialBlock>;
  54223. /** Gets the list of connected endpoints */
  54224. readonly endpoints: NodeMaterialConnectionPoint[];
  54225. /**
  54226. * Creates a new connection point
  54227. * @param name defines the connection point name
  54228. * @param ownerBlock defines the block hosting this connection point
  54229. */
  54230. constructor(name: string, ownerBlock: NodeMaterialBlock);
  54231. /**
  54232. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  54233. * @returns the class name
  54234. */
  54235. getClassName(): string;
  54236. private _getTypeLength;
  54237. /**
  54238. * Gets an boolean indicating if the current point can be connected to another point
  54239. * @param connectionPoint defines the other connection point
  54240. * @returns true if the connection is possible
  54241. */
  54242. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  54243. /**
  54244. * Connect this point to another connection point
  54245. * @param connectionPoint defines the other connection point
  54246. * @returns the current connection point
  54247. */
  54248. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54249. /**
  54250. * Disconnect this point from one of his endpoint
  54251. * @param endpoint defines the other connection point
  54252. * @returns the current connection point
  54253. */
  54254. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54255. }
  54256. }
  54257. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  54258. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54259. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54260. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54261. import { Mesh } from "babylonjs/Meshes/mesh";
  54262. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54263. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54264. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54265. /**
  54266. * Block used to add support for vertex skinning (bones)
  54267. */
  54268. export class BonesBlock extends NodeMaterialBlock {
  54269. /**
  54270. * Creates a new BonesBlock
  54271. * @param name defines the block name
  54272. */
  54273. constructor(name: string);
  54274. /**
  54275. * Initialize the block and prepare the context for build
  54276. * @param state defines the state that will be used for the build
  54277. */
  54278. initialize(state: NodeMaterialBuildState): void;
  54279. /**
  54280. * Gets the current class name
  54281. * @returns the class name
  54282. */
  54283. getClassName(): string;
  54284. /**
  54285. * Gets the matrix indices input component
  54286. */
  54287. readonly matricesIndices: NodeMaterialConnectionPoint;
  54288. /**
  54289. * Gets the matrix weights input component
  54290. */
  54291. readonly matricesWeights: NodeMaterialConnectionPoint;
  54292. /**
  54293. * Gets the extra matrix indices input component
  54294. */
  54295. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  54296. /**
  54297. * Gets the extra matrix weights input component
  54298. */
  54299. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  54300. /**
  54301. * Gets the world input component
  54302. */
  54303. readonly world: NodeMaterialConnectionPoint;
  54304. /**
  54305. * Gets the output component
  54306. */
  54307. readonly output: NodeMaterialConnectionPoint;
  54308. autoConfigure(): void;
  54309. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54310. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54311. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54312. protected _buildBlock(state: NodeMaterialBuildState): this;
  54313. }
  54314. }
  54315. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  54316. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54317. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54318. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54320. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54321. /**
  54322. * Block used to add support for instances
  54323. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  54324. */
  54325. export class InstancesBlock extends NodeMaterialBlock {
  54326. /**
  54327. * Creates a new InstancesBlock
  54328. * @param name defines the block name
  54329. */
  54330. constructor(name: string);
  54331. /**
  54332. * Gets the current class name
  54333. * @returns the class name
  54334. */
  54335. getClassName(): string;
  54336. /**
  54337. * Gets the first world row input component
  54338. */
  54339. readonly world0: NodeMaterialConnectionPoint;
  54340. /**
  54341. * Gets the second world row input component
  54342. */
  54343. readonly world1: NodeMaterialConnectionPoint;
  54344. /**
  54345. * Gets the third world row input component
  54346. */
  54347. readonly world2: NodeMaterialConnectionPoint;
  54348. /**
  54349. * Gets the forth world row input component
  54350. */
  54351. readonly world3: NodeMaterialConnectionPoint;
  54352. /**
  54353. * Gets the world input component
  54354. */
  54355. readonly world: NodeMaterialConnectionPoint;
  54356. /**
  54357. * Gets the output component
  54358. */
  54359. readonly output: NodeMaterialConnectionPoint;
  54360. autoConfigure(): void;
  54361. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54362. protected _buildBlock(state: NodeMaterialBuildState): this;
  54363. }
  54364. }
  54365. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  54366. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54367. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54368. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54370. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54371. import { Effect } from "babylonjs/Materials/effect";
  54372. import { Mesh } from "babylonjs/Meshes/mesh";
  54373. /**
  54374. * Block used to add morph targets support to vertex shader
  54375. */
  54376. export class MorphTargetsBlock extends NodeMaterialBlock {
  54377. private _repeatableContentAnchor;
  54378. private _repeatebleContentGenerated;
  54379. /**
  54380. * Create a new MorphTargetsBlock
  54381. * @param name defines the block name
  54382. */
  54383. constructor(name: string);
  54384. /**
  54385. * Gets the current class name
  54386. * @returns the class name
  54387. */
  54388. getClassName(): string;
  54389. /**
  54390. * Gets the position input component
  54391. */
  54392. readonly position: NodeMaterialConnectionPoint;
  54393. /**
  54394. * Gets the normal input component
  54395. */
  54396. readonly normal: NodeMaterialConnectionPoint;
  54397. /**
  54398. * Gets the tangent input component
  54399. */
  54400. readonly tangent: NodeMaterialConnectionPoint;
  54401. /**
  54402. * Gets the tangent input component
  54403. */
  54404. readonly uv: NodeMaterialConnectionPoint;
  54405. /**
  54406. * Gets the position output component
  54407. */
  54408. readonly positionOutput: NodeMaterialConnectionPoint;
  54409. /**
  54410. * Gets the normal output component
  54411. */
  54412. readonly normalOutput: NodeMaterialConnectionPoint;
  54413. /**
  54414. * Gets the tangent output component
  54415. */
  54416. readonly tangentOutput: NodeMaterialConnectionPoint;
  54417. /**
  54418. * Gets the tangent output component
  54419. */
  54420. readonly uvOutput: NodeMaterialConnectionPoint;
  54421. initialize(state: NodeMaterialBuildState): void;
  54422. autoConfigure(): void;
  54423. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54424. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54425. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54426. protected _buildBlock(state: NodeMaterialBuildState): this;
  54427. }
  54428. }
  54429. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  54430. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  54431. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  54432. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  54433. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  54434. }
  54435. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  54436. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54437. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54438. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54439. /**
  54440. * Block used to add an alpha test in the fragment shader
  54441. */
  54442. export class AlphaTestBlock extends NodeMaterialBlock {
  54443. /**
  54444. * Gets or sets the alpha value where alpha testing happens
  54445. */
  54446. alphaCutOff: number;
  54447. /**
  54448. * Create a new AlphaTestBlock
  54449. * @param name defines the block name
  54450. */
  54451. constructor(name: string);
  54452. /**
  54453. * Gets the current class name
  54454. * @returns the class name
  54455. */
  54456. getClassName(): string;
  54457. /**
  54458. * Gets the color input component
  54459. */
  54460. readonly color: NodeMaterialConnectionPoint;
  54461. protected _buildBlock(state: NodeMaterialBuildState): this;
  54462. }
  54463. }
  54464. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock" {
  54465. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54466. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54467. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54468. /**
  54469. * Block used to create a Color4 out of 4 inputs (one for each component)
  54470. */
  54471. export class RGBAMergerBlock extends NodeMaterialBlock {
  54472. /**
  54473. * Create a new RGBAMergerBlock
  54474. * @param name defines the block name
  54475. */
  54476. constructor(name: string);
  54477. /**
  54478. * Gets the current class name
  54479. * @returns the class name
  54480. */
  54481. getClassName(): string;
  54482. /**
  54483. * Gets the R input component
  54484. */
  54485. readonly r: NodeMaterialConnectionPoint;
  54486. /**
  54487. * Gets the G input component
  54488. */
  54489. readonly g: NodeMaterialConnectionPoint;
  54490. /**
  54491. * Gets the B input component
  54492. */
  54493. readonly b: NodeMaterialConnectionPoint;
  54494. /**
  54495. * Gets the RGB input component
  54496. */
  54497. readonly rgb: NodeMaterialConnectionPoint;
  54498. /**
  54499. * Gets the R input component
  54500. */
  54501. readonly a: NodeMaterialConnectionPoint;
  54502. /**
  54503. * Gets the output component
  54504. */
  54505. readonly output: NodeMaterialConnectionPoint;
  54506. protected _buildBlock(state: NodeMaterialBuildState): this;
  54507. }
  54508. }
  54509. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock" {
  54510. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54511. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54512. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54513. /**
  54514. * Block used to create a Color3 out of 3 inputs (one for each component)
  54515. */
  54516. export class RGBMergerBlock extends NodeMaterialBlock {
  54517. /**
  54518. * Create a new RGBMergerBlock
  54519. * @param name defines the block name
  54520. */
  54521. constructor(name: string);
  54522. /**
  54523. * Gets the current class name
  54524. * @returns the class name
  54525. */
  54526. getClassName(): string;
  54527. /**
  54528. * Gets the R component input
  54529. */
  54530. readonly r: NodeMaterialConnectionPoint;
  54531. /**
  54532. * Gets the G component input
  54533. */
  54534. readonly g: NodeMaterialConnectionPoint;
  54535. /**
  54536. * Gets the B component input
  54537. */
  54538. readonly b: NodeMaterialConnectionPoint;
  54539. /**
  54540. * Gets the output component
  54541. */
  54542. readonly output: NodeMaterialConnectionPoint;
  54543. protected _buildBlock(state: NodeMaterialBuildState): this;
  54544. }
  54545. }
  54546. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock" {
  54547. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54548. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54549. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54550. /**
  54551. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  54552. */
  54553. export class RGBASplitterBlock extends NodeMaterialBlock {
  54554. /**
  54555. * Create a new RGBASplitterBlock
  54556. * @param name defines the block name
  54557. */
  54558. constructor(name: string);
  54559. /**
  54560. * Gets the current class name
  54561. * @returns the class name
  54562. */
  54563. getClassName(): string;
  54564. /**
  54565. * Gets the input component
  54566. */
  54567. readonly input: NodeMaterialConnectionPoint;
  54568. protected _buildBlock(state: NodeMaterialBuildState): this;
  54569. }
  54570. }
  54571. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock" {
  54572. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54573. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54574. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54575. /**
  54576. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  54577. */
  54578. export class RGBSplitterBlock extends NodeMaterialBlock {
  54579. /**
  54580. * Create a new RGBSplitterBlock
  54581. * @param name defines the block name
  54582. */
  54583. constructor(name: string);
  54584. /**
  54585. * Gets the current class name
  54586. * @returns the class name
  54587. */
  54588. getClassName(): string;
  54589. /**
  54590. * Gets the input component
  54591. */
  54592. readonly input: NodeMaterialConnectionPoint;
  54593. protected _buildBlock(state: NodeMaterialBuildState): this;
  54594. }
  54595. }
  54596. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  54597. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54598. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54599. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54601. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54602. import { Effect } from "babylonjs/Materials/effect";
  54603. import { Mesh } from "babylonjs/Meshes/mesh";
  54604. /**
  54605. * Block used to add image processing support to fragment shader
  54606. */
  54607. export class ImageProcessingBlock extends NodeMaterialBlock {
  54608. /**
  54609. * Create a new ImageProcessingBlock
  54610. * @param name defines the block name
  54611. */
  54612. constructor(name: string);
  54613. /**
  54614. * Gets the current class name
  54615. * @returns the class name
  54616. */
  54617. getClassName(): string;
  54618. /**
  54619. * Gets the color input component
  54620. */
  54621. readonly color: NodeMaterialConnectionPoint;
  54622. /**
  54623. * Gets the output component
  54624. */
  54625. readonly output: NodeMaterialConnectionPoint;
  54626. /**
  54627. * Initialize the block and prepare the context for build
  54628. * @param state defines the state that will be used for the build
  54629. */
  54630. initialize(state: NodeMaterialBuildState): void;
  54631. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54632. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54633. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54634. protected _buildBlock(state: NodeMaterialBuildState): this;
  54635. }
  54636. }
  54637. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  54638. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  54639. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  54640. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock";
  54641. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock";
  54642. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock";
  54643. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock";
  54644. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  54645. }
  54646. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  54647. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54648. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54649. import { Mesh } from "babylonjs/Meshes/mesh";
  54650. import { Effect } from "babylonjs/Materials/effect";
  54651. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54653. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54654. /**
  54655. * Block used to add support for scene fog
  54656. */
  54657. export class FogBlock extends NodeMaterialBlock {
  54658. private _fogDistanceName;
  54659. private _fogParameters;
  54660. /**
  54661. * Create a new FogBlock
  54662. * @param name defines the block name
  54663. */
  54664. constructor(name: string);
  54665. /**
  54666. * Gets the current class name
  54667. * @returns the class name
  54668. */
  54669. getClassName(): string;
  54670. /**
  54671. * Gets the world position input component
  54672. */
  54673. readonly worldPosition: NodeMaterialConnectionPoint;
  54674. /**
  54675. * Gets the view input component
  54676. */
  54677. readonly view: NodeMaterialConnectionPoint;
  54678. /**
  54679. * Gets the color input component
  54680. */
  54681. readonly color: NodeMaterialConnectionPoint;
  54682. /**
  54683. * Gets the fog color input component
  54684. */
  54685. readonly fogColor: NodeMaterialConnectionPoint;
  54686. /**
  54687. * Gets the output component
  54688. */
  54689. readonly output: NodeMaterialConnectionPoint;
  54690. autoConfigure(): void;
  54691. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54692. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54693. protected _buildBlock(state: NodeMaterialBuildState): this;
  54694. }
  54695. }
  54696. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  54697. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54698. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54699. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54701. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54702. import { Effect } from "babylonjs/Materials/effect";
  54703. import { Mesh } from "babylonjs/Meshes/mesh";
  54704. import { Light } from "babylonjs/Lights/light";
  54705. import { Nullable } from "babylonjs/types";
  54706. /**
  54707. * Block used to add light in the fragment shader
  54708. */
  54709. export class LightBlock extends NodeMaterialBlock {
  54710. private _lightId;
  54711. /**
  54712. * Gets or sets the light associated with this block
  54713. */
  54714. light: Nullable<Light>;
  54715. /**
  54716. * Create a new LightBlock
  54717. * @param name defines the block name
  54718. */
  54719. constructor(name: string);
  54720. /**
  54721. * Gets the current class name
  54722. * @returns the class name
  54723. */
  54724. getClassName(): string;
  54725. /**
  54726. * Gets the world position input component
  54727. */
  54728. readonly worldPosition: NodeMaterialConnectionPoint;
  54729. /**
  54730. * Gets the world normal input component
  54731. */
  54732. readonly worldNormal: NodeMaterialConnectionPoint;
  54733. /**
  54734. * Gets the camera (or eye) position component
  54735. */
  54736. readonly cameraPosition: NodeMaterialConnectionPoint;
  54737. /**
  54738. * Gets the diffuse output component
  54739. */
  54740. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54741. /**
  54742. * Gets the specular output component
  54743. */
  54744. readonly specularOutput: NodeMaterialConnectionPoint;
  54745. autoConfigure(): void;
  54746. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54747. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54748. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54749. private _injectVertexCode;
  54750. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54751. }
  54752. }
  54753. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  54754. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  54755. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  54756. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54757. }
  54758. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  54759. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54760. }
  54761. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  54762. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54763. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54764. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54765. /**
  54766. * Block used to multiply 2 values
  54767. */
  54768. export class MultiplyBlock extends NodeMaterialBlock {
  54769. /**
  54770. * Creates a new MultiplyBlock
  54771. * @param name defines the block name
  54772. */
  54773. constructor(name: string);
  54774. /**
  54775. * Gets the current class name
  54776. * @returns the class name
  54777. */
  54778. getClassName(): string;
  54779. /**
  54780. * Gets the left operand input component
  54781. */
  54782. readonly left: NodeMaterialConnectionPoint;
  54783. /**
  54784. * Gets the right operand input component
  54785. */
  54786. readonly right: NodeMaterialConnectionPoint;
  54787. /**
  54788. * Gets the output component
  54789. */
  54790. readonly output: NodeMaterialConnectionPoint;
  54791. protected _buildBlock(state: NodeMaterialBuildState): this;
  54792. }
  54793. }
  54794. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  54795. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54796. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54797. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54798. /**
  54799. * Block used to add 2 vector4
  54800. */
  54801. export class AddBlock extends NodeMaterialBlock {
  54802. /**
  54803. * Creates a new AddBlock
  54804. * @param name defines the block name
  54805. */
  54806. constructor(name: string);
  54807. /**
  54808. * Gets the current class name
  54809. * @returns the class name
  54810. */
  54811. getClassName(): string;
  54812. /**
  54813. * Gets the left operand input component
  54814. */
  54815. readonly left: NodeMaterialConnectionPoint;
  54816. /**
  54817. * Gets the right operand input component
  54818. */
  54819. readonly right: NodeMaterialConnectionPoint;
  54820. /**
  54821. * Gets the output component
  54822. */
  54823. readonly output: NodeMaterialConnectionPoint;
  54824. protected _buildBlock(state: NodeMaterialBuildState): this;
  54825. }
  54826. }
  54827. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  54828. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54829. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54830. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54831. /**
  54832. * Block used to clamp a float
  54833. */
  54834. export class ClampBlock extends NodeMaterialBlock {
  54835. /** Gets or sets the minimum range */
  54836. minimum: number;
  54837. /** Gets or sets the maximum range */
  54838. maximum: number;
  54839. /**
  54840. * Creates a new ClampBlock
  54841. * @param name defines the block name
  54842. */
  54843. constructor(name: string);
  54844. /**
  54845. * Gets the current class name
  54846. * @returns the class name
  54847. */
  54848. getClassName(): string;
  54849. /**
  54850. * Gets the value input component
  54851. */
  54852. readonly value: NodeMaterialConnectionPoint;
  54853. /**
  54854. * Gets the output component
  54855. */
  54856. readonly output: NodeMaterialConnectionPoint;
  54857. protected _buildBlock(state: NodeMaterialBuildState): this;
  54858. }
  54859. }
  54860. declare module "babylonjs/Materials/Node/Blocks/vector2TransformBlock" {
  54861. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54862. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54863. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54864. /**
  54865. * Block used to transform a vector2 with a matrix
  54866. */
  54867. export class Vector2TransformBlock extends NodeMaterialBlock {
  54868. /**
  54869. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54870. */
  54871. complementZ: number;
  54872. /**
  54873. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54874. */
  54875. complementW: number;
  54876. /**
  54877. * Creates a new Vector2TransformBlock
  54878. * @param name defines the block name
  54879. */
  54880. constructor(name: string);
  54881. /**
  54882. * Gets the vector input
  54883. */
  54884. readonly vector: NodeMaterialConnectionPoint;
  54885. /**
  54886. * Gets the matrix transform input
  54887. */
  54888. readonly transform: NodeMaterialConnectionPoint;
  54889. /**
  54890. * Gets the output component
  54891. */
  54892. readonly output: NodeMaterialConnectionPoint;
  54893. /**
  54894. * Gets the current class name
  54895. * @returns the class name
  54896. */
  54897. getClassName(): string;
  54898. protected _buildBlock(state: NodeMaterialBuildState): this;
  54899. }
  54900. }
  54901. declare module "babylonjs/Materials/Node/Blocks/vector3TransformBlock" {
  54902. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54903. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54904. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54905. /**
  54906. * Block used to transform a vector3 with a matrix
  54907. */
  54908. export class Vector3TransformBlock extends NodeMaterialBlock {
  54909. /**
  54910. * Defines the value to use to complement Vector3 to transform it to a Vector4
  54911. */
  54912. complement: number;
  54913. /**
  54914. * Creates a new Vector3TransformBlock
  54915. * @param name defines the block name
  54916. */
  54917. constructor(name: string);
  54918. /**
  54919. * Gets the vector input
  54920. */
  54921. readonly vector: NodeMaterialConnectionPoint;
  54922. /**
  54923. * Gets the matrix transform input
  54924. */
  54925. readonly transform: NodeMaterialConnectionPoint;
  54926. /**
  54927. * Gets the output component
  54928. */
  54929. readonly output: NodeMaterialConnectionPoint;
  54930. /**
  54931. * Gets the current class name
  54932. * @returns the class name
  54933. */
  54934. getClassName(): string;
  54935. protected _buildBlock(state: NodeMaterialBuildState): this;
  54936. }
  54937. }
  54938. declare module "babylonjs/Materials/Node/Blocks/index" {
  54939. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  54940. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  54941. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  54942. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  54943. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  54944. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  54945. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  54946. export * from "babylonjs/Materials/Node/Blocks/vector2TransformBlock";
  54947. export * from "babylonjs/Materials/Node/Blocks/vector3TransformBlock";
  54948. export * from "babylonjs/Materials/Node/Blocks/vector4TransformBlock";
  54949. }
  54950. declare module "babylonjs/Materials/Node/Optimizers/index" {
  54951. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54952. }
  54953. declare module "babylonjs/Materials/Node/index" {
  54954. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54955. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54956. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54957. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  54958. export * from "babylonjs/Materials/Node/nodeMaterial";
  54959. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54960. export * from "babylonjs/Materials/Node/Blocks/index";
  54961. export * from "babylonjs/Materials/Node/Optimizers/index";
  54962. }
  54963. declare module "babylonjs/Materials/effectRenderer" {
  54964. import { Nullable } from "babylonjs/types";
  54965. import { Texture } from "babylonjs/Materials/Textures/texture";
  54966. import { Engine } from "babylonjs/Engines/engine";
  54967. import { Observable } from "babylonjs/Misc/observable";
  54968. import { Effect } from "babylonjs/Materials/effect";
  54969. /**
  54970. * Helper class to render one or more effects
  54971. */
  54972. export class EffectRenderer {
  54973. private engine;
  54974. private static _Vertices;
  54975. private static _Indices;
  54976. private _vertexBuffers;
  54977. private _indexBuffer;
  54978. private _ringBufferIndex;
  54979. private _ringScreenBuffer;
  54980. private _getNextFrameBuffer;
  54981. /**
  54982. * Creates an effect renderer
  54983. * @param engine the engine to use for rendering
  54984. */
  54985. constructor(engine: Engine);
  54986. /**
  54987. * renders one or more effects to a specified texture
  54988. * @param effectWrappers list of effects to renderer
  54989. * @param outputTexture texture to draw to, if null it will render to the screen
  54990. */
  54991. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  54992. /**
  54993. * Disposes of the effect renderer
  54994. */
  54995. dispose(): void;
  54996. }
  54997. /**
  54998. * Options to create an EffectWrapper
  54999. */
  55000. interface EffectWrapperCreationOptions {
  55001. /**
  55002. * Engine to use to create the effect
  55003. */
  55004. engine: Engine;
  55005. /**
  55006. * Fragment shader for the effect
  55007. */
  55008. fragmentShader: string;
  55009. /**
  55010. * Attributes to use in the shader
  55011. */
  55012. attributeNames: Array<string>;
  55013. /**
  55014. * Uniforms to use in the shader
  55015. */
  55016. uniformNames: Array<string>;
  55017. /**
  55018. * Texture sampler names to use in the shader
  55019. */
  55020. samplerNames: Array<string>;
  55021. }
  55022. /**
  55023. * Wraps an effect to be used for rendering
  55024. */
  55025. export class EffectWrapper {
  55026. /**
  55027. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55028. */
  55029. onApplyObservable: Observable<{}>;
  55030. /**
  55031. * The underlying effect
  55032. */
  55033. effect: Effect;
  55034. /**
  55035. * Creates an effect to be renderer
  55036. * @param creationOptions options to create the effect
  55037. */
  55038. constructor(creationOptions: EffectWrapperCreationOptions);
  55039. /**
  55040. * Disposes of the effect wrapper
  55041. */
  55042. dispose(): void;
  55043. }
  55044. }
  55045. declare module "babylonjs/Materials/index" {
  55046. export * from "babylonjs/Materials/Background/index";
  55047. export * from "babylonjs/Materials/colorCurves";
  55048. export * from "babylonjs/Materials/effect";
  55049. export * from "babylonjs/Materials/fresnelParameters";
  55050. export * from "babylonjs/Materials/imageProcessingConfiguration";
  55051. export * from "babylonjs/Materials/material";
  55052. export * from "babylonjs/Materials/materialDefines";
  55053. export * from "babylonjs/Materials/materialHelper";
  55054. export * from "babylonjs/Materials/multiMaterial";
  55055. export * from "babylonjs/Materials/PBR/index";
  55056. export * from "babylonjs/Materials/pushMaterial";
  55057. export * from "babylonjs/Materials/shaderMaterial";
  55058. export * from "babylonjs/Materials/standardMaterial";
  55059. export * from "babylonjs/Materials/Textures/index";
  55060. export * from "babylonjs/Materials/uniformBuffer";
  55061. export * from "babylonjs/Materials/materialFlags";
  55062. export * from "babylonjs/Materials/Node/index";
  55063. export * from "babylonjs/Materials/effectRenderer";
  55064. }
  55065. declare module "babylonjs/Maths/index" {
  55066. export * from "babylonjs/Maths/math.scalar";
  55067. export * from "babylonjs/Maths/math";
  55068. export * from "babylonjs/Maths/sphericalPolynomial";
  55069. }
  55070. declare module "babylonjs/Misc/workerPool" {
  55071. import { IDisposable } from "babylonjs/scene";
  55072. /**
  55073. * Helper class to push actions to a pool of workers.
  55074. */
  55075. export class WorkerPool implements IDisposable {
  55076. private _workerInfos;
  55077. private _pendingActions;
  55078. /**
  55079. * Constructor
  55080. * @param workers Array of workers to use for actions
  55081. */
  55082. constructor(workers: Array<Worker>);
  55083. /**
  55084. * Terminates all workers and clears any pending actions.
  55085. */
  55086. dispose(): void;
  55087. /**
  55088. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55089. * pended until a worker has completed its action.
  55090. * @param action The action to perform. Call onComplete when the action is complete.
  55091. */
  55092. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55093. private _execute;
  55094. }
  55095. }
  55096. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  55097. import { IDisposable } from "babylonjs/scene";
  55098. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  55099. /**
  55100. * Configuration for Draco compression
  55101. */
  55102. export interface IDracoCompressionConfiguration {
  55103. /**
  55104. * Configuration for the decoder.
  55105. */
  55106. decoder: {
  55107. /**
  55108. * The url to the WebAssembly module.
  55109. */
  55110. wasmUrl?: string;
  55111. /**
  55112. * The url to the WebAssembly binary.
  55113. */
  55114. wasmBinaryUrl?: string;
  55115. /**
  55116. * The url to the fallback JavaScript module.
  55117. */
  55118. fallbackUrl?: string;
  55119. };
  55120. }
  55121. /**
  55122. * Draco compression (https://google.github.io/draco/)
  55123. *
  55124. * This class wraps the Draco module.
  55125. *
  55126. * **Encoder**
  55127. *
  55128. * The encoder is not currently implemented.
  55129. *
  55130. * **Decoder**
  55131. *
  55132. * 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.
  55133. *
  55134. * To update the configuration, use the following code:
  55135. * ```javascript
  55136. * DracoCompression.Configuration = {
  55137. * decoder: {
  55138. * wasmUrl: "<url to the WebAssembly library>",
  55139. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55140. * fallbackUrl: "<url to the fallback JavaScript library>",
  55141. * }
  55142. * };
  55143. * ```
  55144. *
  55145. * 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.
  55146. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55147. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55148. *
  55149. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55150. * ```javascript
  55151. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55152. * ```
  55153. *
  55154. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55155. */
  55156. export class DracoCompression implements IDisposable {
  55157. private _workerPoolPromise?;
  55158. private _decoderModulePromise?;
  55159. /**
  55160. * The configuration. Defaults to the following urls:
  55161. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55162. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55163. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55164. */
  55165. static Configuration: IDracoCompressionConfiguration;
  55166. /**
  55167. * Returns true if the decoder configuration is available.
  55168. */
  55169. static readonly DecoderAvailable: boolean;
  55170. /**
  55171. * Default number of workers to create when creating the draco compression object.
  55172. */
  55173. static DefaultNumWorkers: number;
  55174. private static GetDefaultNumWorkers;
  55175. private static _Default;
  55176. /**
  55177. * Default instance for the draco compression object.
  55178. */
  55179. static readonly Default: DracoCompression;
  55180. /**
  55181. * Constructor
  55182. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55183. */
  55184. constructor(numWorkers?: number);
  55185. /**
  55186. * Stop all async operations and release resources.
  55187. */
  55188. dispose(): void;
  55189. /**
  55190. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55191. * @returns a promise that resolves when ready
  55192. */
  55193. whenReadyAsync(): Promise<void>;
  55194. /**
  55195. * Decode Draco compressed mesh data to vertex data.
  55196. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55197. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55198. * @returns A promise that resolves with the decoded vertex data
  55199. */
  55200. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55201. [kind: string]: number;
  55202. }): Promise<VertexData>;
  55203. }
  55204. }
  55205. declare module "babylonjs/Meshes/Compression/index" {
  55206. export * from "babylonjs/Meshes/Compression/dracoCompression";
  55207. }
  55208. declare module "babylonjs/Meshes/csg" {
  55209. import { Nullable } from "babylonjs/types";
  55210. import { Scene } from "babylonjs/scene";
  55211. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  55212. import { Mesh } from "babylonjs/Meshes/mesh";
  55213. import { Material } from "babylonjs/Materials/material";
  55214. /**
  55215. * Class for building Constructive Solid Geometry
  55216. */
  55217. export class CSG {
  55218. private polygons;
  55219. /**
  55220. * The world matrix
  55221. */
  55222. matrix: Matrix;
  55223. /**
  55224. * Stores the position
  55225. */
  55226. position: Vector3;
  55227. /**
  55228. * Stores the rotation
  55229. */
  55230. rotation: Vector3;
  55231. /**
  55232. * Stores the rotation quaternion
  55233. */
  55234. rotationQuaternion: Nullable<Quaternion>;
  55235. /**
  55236. * Stores the scaling vector
  55237. */
  55238. scaling: Vector3;
  55239. /**
  55240. * Convert the Mesh to CSG
  55241. * @param mesh The Mesh to convert to CSG
  55242. * @returns A new CSG from the Mesh
  55243. */
  55244. static FromMesh(mesh: Mesh): CSG;
  55245. /**
  55246. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55247. * @param polygons Polygons used to construct a CSG solid
  55248. */
  55249. private static FromPolygons;
  55250. /**
  55251. * Clones, or makes a deep copy, of the CSG
  55252. * @returns A new CSG
  55253. */
  55254. clone(): CSG;
  55255. /**
  55256. * Unions this CSG with another CSG
  55257. * @param csg The CSG to union against this CSG
  55258. * @returns The unioned CSG
  55259. */
  55260. union(csg: CSG): CSG;
  55261. /**
  55262. * Unions this CSG with another CSG in place
  55263. * @param csg The CSG to union against this CSG
  55264. */
  55265. unionInPlace(csg: CSG): void;
  55266. /**
  55267. * Subtracts this CSG with another CSG
  55268. * @param csg The CSG to subtract against this CSG
  55269. * @returns A new CSG
  55270. */
  55271. subtract(csg: CSG): CSG;
  55272. /**
  55273. * Subtracts this CSG with another CSG in place
  55274. * @param csg The CSG to subtact against this CSG
  55275. */
  55276. subtractInPlace(csg: CSG): void;
  55277. /**
  55278. * Intersect this CSG with another CSG
  55279. * @param csg The CSG to intersect against this CSG
  55280. * @returns A new CSG
  55281. */
  55282. intersect(csg: CSG): CSG;
  55283. /**
  55284. * Intersects this CSG with another CSG in place
  55285. * @param csg The CSG to intersect against this CSG
  55286. */
  55287. intersectInPlace(csg: CSG): void;
  55288. /**
  55289. * Return a new CSG solid with solid and empty space switched. This solid is
  55290. * not modified.
  55291. * @returns A new CSG solid with solid and empty space switched
  55292. */
  55293. inverse(): CSG;
  55294. /**
  55295. * Inverses the CSG in place
  55296. */
  55297. inverseInPlace(): void;
  55298. /**
  55299. * This is used to keep meshes transformations so they can be restored
  55300. * when we build back a Babylon Mesh
  55301. * NB : All CSG operations are performed in world coordinates
  55302. * @param csg The CSG to copy the transform attributes from
  55303. * @returns This CSG
  55304. */
  55305. copyTransformAttributes(csg: CSG): CSG;
  55306. /**
  55307. * Build Raw mesh from CSG
  55308. * Coordinates here are in world space
  55309. * @param name The name of the mesh geometry
  55310. * @param scene The Scene
  55311. * @param keepSubMeshes Specifies if the submeshes should be kept
  55312. * @returns A new Mesh
  55313. */
  55314. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  55315. /**
  55316. * Build Mesh from CSG taking material and transforms into account
  55317. * @param name The name of the Mesh
  55318. * @param material The material of the Mesh
  55319. * @param scene The Scene
  55320. * @param keepSubMeshes Specifies if submeshes should be kept
  55321. * @returns The new Mesh
  55322. */
  55323. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  55324. }
  55325. }
  55326. declare module "babylonjs/Meshes/trailMesh" {
  55327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55328. import { Mesh } from "babylonjs/Meshes/mesh";
  55329. import { Scene } from "babylonjs/scene";
  55330. /**
  55331. * Class used to create a trail following a mesh
  55332. */
  55333. export class TrailMesh extends Mesh {
  55334. private _generator;
  55335. private _autoStart;
  55336. private _running;
  55337. private _diameter;
  55338. private _length;
  55339. private _sectionPolygonPointsCount;
  55340. private _sectionVectors;
  55341. private _sectionNormalVectors;
  55342. private _beforeRenderObserver;
  55343. /**
  55344. * @constructor
  55345. * @param name The value used by scene.getMeshByName() to do a lookup.
  55346. * @param generator The mesh to generate a trail.
  55347. * @param scene The scene to add this mesh to.
  55348. * @param diameter Diameter of trailing mesh. Default is 1.
  55349. * @param length Length of trailing mesh. Default is 60.
  55350. * @param autoStart Automatically start trailing mesh. Default true.
  55351. */
  55352. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55353. /**
  55354. * "TrailMesh"
  55355. * @returns "TrailMesh"
  55356. */
  55357. getClassName(): string;
  55358. private _createMesh;
  55359. /**
  55360. * Start trailing mesh.
  55361. */
  55362. start(): void;
  55363. /**
  55364. * Stop trailing mesh.
  55365. */
  55366. stop(): void;
  55367. /**
  55368. * Update trailing mesh geometry.
  55369. */
  55370. update(): void;
  55371. /**
  55372. * Returns a new TrailMesh object.
  55373. * @param name is a string, the name given to the new mesh
  55374. * @param newGenerator use new generator object for cloned trail mesh
  55375. * @returns a new mesh
  55376. */
  55377. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55378. /**
  55379. * Serializes this trail mesh
  55380. * @param serializationObject object to write serialization to
  55381. */
  55382. serialize(serializationObject: any): void;
  55383. /**
  55384. * Parses a serialized trail mesh
  55385. * @param parsedMesh the serialized mesh
  55386. * @param scene the scene to create the trail mesh in
  55387. * @returns the created trail mesh
  55388. */
  55389. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55390. }
  55391. }
  55392. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  55393. import { Nullable } from "babylonjs/types";
  55394. import { Scene } from "babylonjs/scene";
  55395. import { Vector4, Color4 } from "babylonjs/Maths/math";
  55396. import { Mesh } from "babylonjs/Meshes/mesh";
  55397. /**
  55398. * Class containing static functions to help procedurally build meshes
  55399. */
  55400. export class TiledBoxBuilder {
  55401. /**
  55402. * Creates a box mesh
  55403. * 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)
  55404. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55406. * * 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
  55407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55408. * @param name defines the name of the mesh
  55409. * @param options defines the options used to create the mesh
  55410. * @param scene defines the hosting scene
  55411. * @returns the box mesh
  55412. */
  55413. static CreateTiledBox(name: string, options: {
  55414. pattern?: number;
  55415. width?: number;
  55416. height?: number;
  55417. depth?: number;
  55418. tileSize?: number;
  55419. tileWidth?: number;
  55420. tileHeight?: number;
  55421. alignHorizontal?: number;
  55422. alignVertical?: number;
  55423. faceUV?: Vector4[];
  55424. faceColors?: Color4[];
  55425. sideOrientation?: number;
  55426. updatable?: boolean;
  55427. }, scene?: Nullable<Scene>): Mesh;
  55428. }
  55429. }
  55430. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  55431. import { Vector4 } from "babylonjs/Maths/math";
  55432. import { Mesh } from "babylonjs/Meshes/mesh";
  55433. /**
  55434. * Class containing static functions to help procedurally build meshes
  55435. */
  55436. export class TorusKnotBuilder {
  55437. /**
  55438. * Creates a torus knot mesh
  55439. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55440. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55441. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55442. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55443. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55444. * * 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
  55445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55446. * @param name defines the name of the mesh
  55447. * @param options defines the options used to create the mesh
  55448. * @param scene defines the hosting scene
  55449. * @returns the torus knot mesh
  55450. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55451. */
  55452. static CreateTorusKnot(name: string, options: {
  55453. radius?: number;
  55454. tube?: number;
  55455. radialSegments?: number;
  55456. tubularSegments?: number;
  55457. p?: number;
  55458. q?: number;
  55459. updatable?: boolean;
  55460. sideOrientation?: number;
  55461. frontUVs?: Vector4;
  55462. backUVs?: Vector4;
  55463. }, scene: any): Mesh;
  55464. }
  55465. }
  55466. declare module "babylonjs/Meshes/polygonMesh" {
  55467. import { Scene } from "babylonjs/scene";
  55468. import { Vector2, Path2 } from "babylonjs/Maths/math";
  55469. import { Mesh } from "babylonjs/Meshes/mesh";
  55470. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  55471. /**
  55472. * Polygon
  55473. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55474. */
  55475. export class Polygon {
  55476. /**
  55477. * Creates a rectangle
  55478. * @param xmin bottom X coord
  55479. * @param ymin bottom Y coord
  55480. * @param xmax top X coord
  55481. * @param ymax top Y coord
  55482. * @returns points that make the resulting rectation
  55483. */
  55484. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55485. /**
  55486. * Creates a circle
  55487. * @param radius radius of circle
  55488. * @param cx scale in x
  55489. * @param cy scale in y
  55490. * @param numberOfSides number of sides that make up the circle
  55491. * @returns points that make the resulting circle
  55492. */
  55493. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55494. /**
  55495. * Creates a polygon from input string
  55496. * @param input Input polygon data
  55497. * @returns the parsed points
  55498. */
  55499. static Parse(input: string): Vector2[];
  55500. /**
  55501. * Starts building a polygon from x and y coordinates
  55502. * @param x x coordinate
  55503. * @param y y coordinate
  55504. * @returns the started path2
  55505. */
  55506. static StartingAt(x: number, y: number): Path2;
  55507. }
  55508. /**
  55509. * Builds a polygon
  55510. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55511. */
  55512. export class PolygonMeshBuilder {
  55513. private _points;
  55514. private _outlinepoints;
  55515. private _holes;
  55516. private _name;
  55517. private _scene;
  55518. private _epoints;
  55519. private _eholes;
  55520. private _addToepoint;
  55521. /**
  55522. * Babylon reference to the earcut plugin.
  55523. */
  55524. bjsEarcut: any;
  55525. /**
  55526. * Creates a PolygonMeshBuilder
  55527. * @param name name of the builder
  55528. * @param contours Path of the polygon
  55529. * @param scene scene to add to when creating the mesh
  55530. * @param earcutInjection can be used to inject your own earcut reference
  55531. */
  55532. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55533. /**
  55534. * Adds a whole within the polygon
  55535. * @param hole Array of points defining the hole
  55536. * @returns this
  55537. */
  55538. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55539. /**
  55540. * Creates the polygon
  55541. * @param updatable If the mesh should be updatable
  55542. * @param depth The depth of the mesh created
  55543. * @returns the created mesh
  55544. */
  55545. build(updatable?: boolean, depth?: number): Mesh;
  55546. /**
  55547. * Creates the polygon
  55548. * @param depth The depth of the mesh created
  55549. * @returns the created VertexData
  55550. */
  55551. buildVertexData(depth?: number): VertexData;
  55552. /**
  55553. * Adds a side to the polygon
  55554. * @param positions points that make the polygon
  55555. * @param normals normals of the polygon
  55556. * @param uvs uvs of the polygon
  55557. * @param indices indices of the polygon
  55558. * @param bounds bounds of the polygon
  55559. * @param points points of the polygon
  55560. * @param depth depth of the polygon
  55561. * @param flip flip of the polygon
  55562. */
  55563. private addSide;
  55564. }
  55565. }
  55566. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  55567. import { Scene } from "babylonjs/scene";
  55568. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  55569. import { Mesh } from "babylonjs/Meshes/mesh";
  55570. import { Nullable } from "babylonjs/types";
  55571. /**
  55572. * Class containing static functions to help procedurally build meshes
  55573. */
  55574. export class PolygonBuilder {
  55575. /**
  55576. * Creates a polygon mesh
  55577. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55578. * * 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
  55579. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55581. * * 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)
  55582. * * Remember you can only change the shape positions, not their number when updating a polygon
  55583. * @param name defines the name of the mesh
  55584. * @param options defines the options used to create the mesh
  55585. * @param scene defines the hosting scene
  55586. * @param earcutInjection can be used to inject your own earcut reference
  55587. * @returns the polygon mesh
  55588. */
  55589. static CreatePolygon(name: string, options: {
  55590. shape: Vector3[];
  55591. holes?: Vector3[][];
  55592. depth?: number;
  55593. faceUV?: Vector4[];
  55594. faceColors?: Color4[];
  55595. updatable?: boolean;
  55596. sideOrientation?: number;
  55597. frontUVs?: Vector4;
  55598. backUVs?: Vector4;
  55599. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55600. /**
  55601. * Creates an extruded polygon mesh, with depth in the Y direction.
  55602. * * 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)
  55603. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55604. * @param name defines the name of the mesh
  55605. * @param options defines the options used to create the mesh
  55606. * @param scene defines the hosting scene
  55607. * @param earcutInjection can be used to inject your own earcut reference
  55608. * @returns the polygon mesh
  55609. */
  55610. static ExtrudePolygon(name: string, options: {
  55611. shape: Vector3[];
  55612. holes?: Vector3[][];
  55613. depth?: number;
  55614. faceUV?: Vector4[];
  55615. faceColors?: Color4[];
  55616. updatable?: boolean;
  55617. sideOrientation?: number;
  55618. frontUVs?: Vector4;
  55619. backUVs?: Vector4;
  55620. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55621. }
  55622. }
  55623. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  55624. import { Scene } from "babylonjs/scene";
  55625. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  55626. import { Mesh } from "babylonjs/Meshes/mesh";
  55627. import { Nullable } from "babylonjs/types";
  55628. /**
  55629. * Class containing static functions to help procedurally build meshes
  55630. */
  55631. export class LatheBuilder {
  55632. /**
  55633. * Creates lathe mesh.
  55634. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55635. * * 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
  55636. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55637. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55638. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55639. * * 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
  55640. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55641. * * 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
  55642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55643. * * 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
  55644. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55646. * @param name defines the name of the mesh
  55647. * @param options defines the options used to create the mesh
  55648. * @param scene defines the hosting scene
  55649. * @returns the lathe mesh
  55650. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55651. */
  55652. static CreateLathe(name: string, options: {
  55653. shape: Vector3[];
  55654. radius?: number;
  55655. tessellation?: number;
  55656. clip?: number;
  55657. arc?: number;
  55658. closed?: boolean;
  55659. updatable?: boolean;
  55660. sideOrientation?: number;
  55661. frontUVs?: Vector4;
  55662. backUVs?: Vector4;
  55663. cap?: number;
  55664. invertUV?: boolean;
  55665. }, scene?: Nullable<Scene>): Mesh;
  55666. }
  55667. }
  55668. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  55669. import { Nullable } from "babylonjs/types";
  55670. import { Scene } from "babylonjs/scene";
  55671. import { Vector4 } from "babylonjs/Maths/math";
  55672. import { Mesh } from "babylonjs/Meshes/mesh";
  55673. /**
  55674. * Class containing static functions to help procedurally build meshes
  55675. */
  55676. export class TiledPlaneBuilder {
  55677. /**
  55678. * Creates a tiled plane mesh
  55679. * * The parameter `pattern` will, depending on value, do nothing or
  55680. * * * flip (reflect about central vertical) alternate tiles across and up
  55681. * * * flip every tile on alternate rows
  55682. * * * rotate (180 degs) alternate tiles across and up
  55683. * * * rotate every tile on alternate rows
  55684. * * * flip and rotate alternate tiles across and up
  55685. * * * flip and rotate every tile on alternate rows
  55686. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55687. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55688. * * 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
  55689. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55690. * * 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)
  55691. * * 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)
  55692. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55693. * @param name defines the name of the mesh
  55694. * @param options defines the options used to create the mesh
  55695. * @param scene defines the hosting scene
  55696. * @returns the box mesh
  55697. */
  55698. static CreateTiledPlane(name: string, options: {
  55699. pattern?: number;
  55700. tileSize?: number;
  55701. tileWidth?: number;
  55702. tileHeight?: number;
  55703. size?: number;
  55704. width?: number;
  55705. height?: number;
  55706. alignHorizontal?: number;
  55707. alignVertical?: number;
  55708. sideOrientation?: number;
  55709. frontUVs?: Vector4;
  55710. backUVs?: Vector4;
  55711. updatable?: boolean;
  55712. }, scene?: Nullable<Scene>): Mesh;
  55713. }
  55714. }
  55715. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  55716. import { Nullable } from "babylonjs/types";
  55717. import { Scene } from "babylonjs/scene";
  55718. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  55719. import { Mesh } from "babylonjs/Meshes/mesh";
  55720. /**
  55721. * Class containing static functions to help procedurally build meshes
  55722. */
  55723. export class TubeBuilder {
  55724. /**
  55725. * Creates a tube mesh.
  55726. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55727. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55728. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55729. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55730. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55731. * * 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)
  55732. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55733. * * 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
  55734. * * 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
  55735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55736. * * 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
  55737. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55739. * @param name defines the name of the mesh
  55740. * @param options defines the options used to create the mesh
  55741. * @param scene defines the hosting scene
  55742. * @returns the tube mesh
  55743. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55744. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55745. */
  55746. static CreateTube(name: string, options: {
  55747. path: Vector3[];
  55748. radius?: number;
  55749. tessellation?: number;
  55750. radiusFunction?: {
  55751. (i: number, distance: number): number;
  55752. };
  55753. cap?: number;
  55754. arc?: number;
  55755. updatable?: boolean;
  55756. sideOrientation?: number;
  55757. frontUVs?: Vector4;
  55758. backUVs?: Vector4;
  55759. instance?: Mesh;
  55760. invertUV?: boolean;
  55761. }, scene?: Nullable<Scene>): Mesh;
  55762. }
  55763. }
  55764. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  55765. import { Scene } from "babylonjs/scene";
  55766. import { Vector4 } from "babylonjs/Maths/math";
  55767. import { Mesh } from "babylonjs/Meshes/mesh";
  55768. import { Nullable } from "babylonjs/types";
  55769. /**
  55770. * Class containing static functions to help procedurally build meshes
  55771. */
  55772. export class IcoSphereBuilder {
  55773. /**
  55774. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55775. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55776. * * 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`)
  55777. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55778. * * 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
  55779. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55780. * * 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
  55781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55782. * @param name defines the name of the mesh
  55783. * @param options defines the options used to create the mesh
  55784. * @param scene defines the hosting scene
  55785. * @returns the icosahedron mesh
  55786. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55787. */
  55788. static CreateIcoSphere(name: string, options: {
  55789. radius?: number;
  55790. radiusX?: number;
  55791. radiusY?: number;
  55792. radiusZ?: number;
  55793. flat?: boolean;
  55794. subdivisions?: number;
  55795. sideOrientation?: number;
  55796. frontUVs?: Vector4;
  55797. backUVs?: Vector4;
  55798. updatable?: boolean;
  55799. }, scene?: Nullable<Scene>): Mesh;
  55800. }
  55801. }
  55802. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  55803. import { Vector3 } from "babylonjs/Maths/math";
  55804. import { Mesh } from "babylonjs/Meshes/mesh";
  55805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55806. /**
  55807. * Class containing static functions to help procedurally build meshes
  55808. */
  55809. export class DecalBuilder {
  55810. /**
  55811. * Creates a decal mesh.
  55812. * 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
  55813. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55814. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55815. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55816. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55817. * @param name defines the name of the mesh
  55818. * @param sourceMesh defines the mesh where the decal must be applied
  55819. * @param options defines the options used to create the mesh
  55820. * @param scene defines the hosting scene
  55821. * @returns the decal mesh
  55822. * @see https://doc.babylonjs.com/how_to/decals
  55823. */
  55824. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55825. position?: Vector3;
  55826. normal?: Vector3;
  55827. size?: Vector3;
  55828. angle?: number;
  55829. }): Mesh;
  55830. }
  55831. }
  55832. declare module "babylonjs/Meshes/meshBuilder" {
  55833. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  55834. import { Nullable } from "babylonjs/types";
  55835. import { Scene } from "babylonjs/scene";
  55836. import { Mesh } from "babylonjs/Meshes/mesh";
  55837. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  55838. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  55839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55840. /**
  55841. * Class containing static functions to help procedurally build meshes
  55842. */
  55843. export class MeshBuilder {
  55844. /**
  55845. * Creates a box mesh
  55846. * * The parameter `size` sets the size (float) of each box side (default 1)
  55847. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55848. * * 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)
  55849. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55851. * * 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
  55852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55853. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55854. * @param name defines the name of the mesh
  55855. * @param options defines the options used to create the mesh
  55856. * @param scene defines the hosting scene
  55857. * @returns the box mesh
  55858. */
  55859. static CreateBox(name: string, options: {
  55860. size?: number;
  55861. width?: number;
  55862. height?: number;
  55863. depth?: number;
  55864. faceUV?: Vector4[];
  55865. faceColors?: Color4[];
  55866. sideOrientation?: number;
  55867. frontUVs?: Vector4;
  55868. backUVs?: Vector4;
  55869. updatable?: boolean;
  55870. }, scene?: Nullable<Scene>): Mesh;
  55871. /**
  55872. * Creates a tiled box mesh
  55873. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55875. * @param name defines the name of the mesh
  55876. * @param options defines the options used to create the mesh
  55877. * @param scene defines the hosting scene
  55878. * @returns the tiled box mesh
  55879. */
  55880. static CreateTiledBox(name: string, options: {
  55881. pattern?: number;
  55882. size?: number;
  55883. width?: number;
  55884. height?: number;
  55885. depth: number;
  55886. tileSize?: number;
  55887. tileWidth?: number;
  55888. tileHeight?: number;
  55889. faceUV?: Vector4[];
  55890. faceColors?: Color4[];
  55891. alignHorizontal?: number;
  55892. alignVertical?: number;
  55893. sideOrientation?: number;
  55894. updatable?: boolean;
  55895. }, scene?: Nullable<Scene>): Mesh;
  55896. /**
  55897. * Creates a sphere mesh
  55898. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55899. * * 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`)
  55900. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55901. * * 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
  55902. * * 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)
  55903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55904. * * 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
  55905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55906. * @param name defines the name of the mesh
  55907. * @param options defines the options used to create the mesh
  55908. * @param scene defines the hosting scene
  55909. * @returns the sphere mesh
  55910. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55911. */
  55912. static CreateSphere(name: string, options: {
  55913. segments?: number;
  55914. diameter?: number;
  55915. diameterX?: number;
  55916. diameterY?: number;
  55917. diameterZ?: number;
  55918. arc?: number;
  55919. slice?: number;
  55920. sideOrientation?: number;
  55921. frontUVs?: Vector4;
  55922. backUVs?: Vector4;
  55923. updatable?: boolean;
  55924. }, scene?: Nullable<Scene>): Mesh;
  55925. /**
  55926. * Creates a plane polygonal mesh. By default, this is a disc
  55927. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55928. * * 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
  55929. * * 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
  55930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55931. * * 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
  55932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55933. * @param name defines the name of the mesh
  55934. * @param options defines the options used to create the mesh
  55935. * @param scene defines the hosting scene
  55936. * @returns the plane polygonal mesh
  55937. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55938. */
  55939. static CreateDisc(name: string, options: {
  55940. radius?: number;
  55941. tessellation?: number;
  55942. arc?: number;
  55943. updatable?: boolean;
  55944. sideOrientation?: number;
  55945. frontUVs?: Vector4;
  55946. backUVs?: Vector4;
  55947. }, scene?: Nullable<Scene>): Mesh;
  55948. /**
  55949. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55950. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55951. * * 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`)
  55952. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55953. * * 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
  55954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55955. * * 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
  55956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55957. * @param name defines the name of the mesh
  55958. * @param options defines the options used to create the mesh
  55959. * @param scene defines the hosting scene
  55960. * @returns the icosahedron mesh
  55961. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55962. */
  55963. static CreateIcoSphere(name: string, options: {
  55964. radius?: number;
  55965. radiusX?: number;
  55966. radiusY?: number;
  55967. radiusZ?: number;
  55968. flat?: boolean;
  55969. subdivisions?: number;
  55970. sideOrientation?: number;
  55971. frontUVs?: Vector4;
  55972. backUVs?: Vector4;
  55973. updatable?: boolean;
  55974. }, scene?: Nullable<Scene>): Mesh;
  55975. /**
  55976. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55977. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55978. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55979. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55980. * * 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
  55981. * * 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
  55982. * * 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
  55983. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55984. * * 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
  55985. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55986. * * 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
  55987. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55988. * * 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
  55989. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55991. * @param name defines the name of the mesh
  55992. * @param options defines the options used to create the mesh
  55993. * @param scene defines the hosting scene
  55994. * @returns the ribbon mesh
  55995. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55996. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55997. */
  55998. static CreateRibbon(name: string, options: {
  55999. pathArray: Vector3[][];
  56000. closeArray?: boolean;
  56001. closePath?: boolean;
  56002. offset?: number;
  56003. updatable?: boolean;
  56004. sideOrientation?: number;
  56005. frontUVs?: Vector4;
  56006. backUVs?: Vector4;
  56007. instance?: Mesh;
  56008. invertUV?: boolean;
  56009. uvs?: Vector2[];
  56010. colors?: Color4[];
  56011. }, scene?: Nullable<Scene>): Mesh;
  56012. /**
  56013. * Creates a cylinder or a cone mesh
  56014. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56015. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56016. * * 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.
  56017. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56018. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56019. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56020. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56021. * * 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).
  56022. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56023. * * 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).
  56024. * * 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
  56025. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56026. * * 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
  56027. * * 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.
  56028. * * If `enclose` is false, a ring surface is one element.
  56029. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56030. * * 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
  56031. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56032. * * 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
  56033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56034. * @param name defines the name of the mesh
  56035. * @param options defines the options used to create the mesh
  56036. * @param scene defines the hosting scene
  56037. * @returns the cylinder mesh
  56038. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56039. */
  56040. static CreateCylinder(name: string, options: {
  56041. height?: number;
  56042. diameterTop?: number;
  56043. diameterBottom?: number;
  56044. diameter?: number;
  56045. tessellation?: number;
  56046. subdivisions?: number;
  56047. arc?: number;
  56048. faceColors?: Color4[];
  56049. faceUV?: Vector4[];
  56050. updatable?: boolean;
  56051. hasRings?: boolean;
  56052. enclose?: boolean;
  56053. cap?: number;
  56054. sideOrientation?: number;
  56055. frontUVs?: Vector4;
  56056. backUVs?: Vector4;
  56057. }, scene?: Nullable<Scene>): Mesh;
  56058. /**
  56059. * Creates a torus mesh
  56060. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56061. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  56062. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  56063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56064. * * 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
  56065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56066. * @param name defines the name of the mesh
  56067. * @param options defines the options used to create the mesh
  56068. * @param scene defines the hosting scene
  56069. * @returns the torus mesh
  56070. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  56071. */
  56072. static CreateTorus(name: string, options: {
  56073. diameter?: number;
  56074. thickness?: number;
  56075. tessellation?: number;
  56076. updatable?: boolean;
  56077. sideOrientation?: number;
  56078. frontUVs?: Vector4;
  56079. backUVs?: Vector4;
  56080. }, scene?: Nullable<Scene>): Mesh;
  56081. /**
  56082. * Creates a torus knot mesh
  56083. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56084. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56085. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56086. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56088. * * 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
  56089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56090. * @param name defines the name of the mesh
  56091. * @param options defines the options used to create the mesh
  56092. * @param scene defines the hosting scene
  56093. * @returns the torus knot mesh
  56094. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56095. */
  56096. static CreateTorusKnot(name: string, options: {
  56097. radius?: number;
  56098. tube?: number;
  56099. radialSegments?: number;
  56100. tubularSegments?: number;
  56101. p?: number;
  56102. q?: number;
  56103. updatable?: boolean;
  56104. sideOrientation?: number;
  56105. frontUVs?: Vector4;
  56106. backUVs?: Vector4;
  56107. }, scene?: Nullable<Scene>): Mesh;
  56108. /**
  56109. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56110. * * 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
  56111. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56112. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56113. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56114. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56115. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56116. * * 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
  56117. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56119. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56120. * @param name defines the name of the new line system
  56121. * @param options defines the options used to create the line system
  56122. * @param scene defines the hosting scene
  56123. * @returns a new line system mesh
  56124. */
  56125. static CreateLineSystem(name: string, options: {
  56126. lines: Vector3[][];
  56127. updatable?: boolean;
  56128. instance?: Nullable<LinesMesh>;
  56129. colors?: Nullable<Color4[][]>;
  56130. useVertexAlpha?: boolean;
  56131. }, scene: Nullable<Scene>): LinesMesh;
  56132. /**
  56133. * Creates a line mesh
  56134. * 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
  56135. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56136. * * The parameter `points` is an array successive Vector3
  56137. * * 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
  56138. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56139. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56140. * * When updating an instance, remember that only point positions can change, not the number of points
  56141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56142. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56143. * @param name defines the name of the new line system
  56144. * @param options defines the options used to create the line system
  56145. * @param scene defines the hosting scene
  56146. * @returns a new line mesh
  56147. */
  56148. static CreateLines(name: string, options: {
  56149. points: Vector3[];
  56150. updatable?: boolean;
  56151. instance?: Nullable<LinesMesh>;
  56152. colors?: Color4[];
  56153. useVertexAlpha?: boolean;
  56154. }, scene?: Nullable<Scene>): LinesMesh;
  56155. /**
  56156. * Creates a dashed line mesh
  56157. * * 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
  56158. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56159. * * The parameter `points` is an array successive Vector3
  56160. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56161. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56162. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56163. * * 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
  56164. * * When updating an instance, remember that only point positions can change, not the number of points
  56165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56166. * @param name defines the name of the mesh
  56167. * @param options defines the options used to create the mesh
  56168. * @param scene defines the hosting scene
  56169. * @returns the dashed line mesh
  56170. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56171. */
  56172. static CreateDashedLines(name: string, options: {
  56173. points: Vector3[];
  56174. dashSize?: number;
  56175. gapSize?: number;
  56176. dashNb?: number;
  56177. updatable?: boolean;
  56178. instance?: LinesMesh;
  56179. }, scene?: Nullable<Scene>): LinesMesh;
  56180. /**
  56181. * 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.
  56182. * * 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.
  56183. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56184. * * 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.
  56185. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56186. * * 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
  56187. * * 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
  56188. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56190. * * 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
  56191. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56193. * @param name defines the name of the mesh
  56194. * @param options defines the options used to create the mesh
  56195. * @param scene defines the hosting scene
  56196. * @returns the extruded shape mesh
  56197. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56198. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56199. */
  56200. static ExtrudeShape(name: string, options: {
  56201. shape: Vector3[];
  56202. path: Vector3[];
  56203. scale?: number;
  56204. rotation?: number;
  56205. cap?: number;
  56206. updatable?: boolean;
  56207. sideOrientation?: number;
  56208. frontUVs?: Vector4;
  56209. backUVs?: Vector4;
  56210. instance?: Mesh;
  56211. invertUV?: boolean;
  56212. }, scene?: Nullable<Scene>): Mesh;
  56213. /**
  56214. * Creates an custom extruded shape mesh.
  56215. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56216. * * 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.
  56217. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56218. * * 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
  56219. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56220. * * 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
  56221. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56222. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56223. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56224. * * 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
  56225. * * 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
  56226. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56227. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56228. * * 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
  56229. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56231. * @param name defines the name of the mesh
  56232. * @param options defines the options used to create the mesh
  56233. * @param scene defines the hosting scene
  56234. * @returns the custom extruded shape mesh
  56235. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56236. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56237. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56238. */
  56239. static ExtrudeShapeCustom(name: string, options: {
  56240. shape: Vector3[];
  56241. path: Vector3[];
  56242. scaleFunction?: any;
  56243. rotationFunction?: any;
  56244. ribbonCloseArray?: boolean;
  56245. ribbonClosePath?: boolean;
  56246. cap?: number;
  56247. updatable?: boolean;
  56248. sideOrientation?: number;
  56249. frontUVs?: Vector4;
  56250. backUVs?: Vector4;
  56251. instance?: Mesh;
  56252. invertUV?: boolean;
  56253. }, scene?: Nullable<Scene>): Mesh;
  56254. /**
  56255. * Creates lathe mesh.
  56256. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56257. * * 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
  56258. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56259. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56260. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56261. * * 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
  56262. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56263. * * 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
  56264. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56265. * * 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
  56266. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56268. * @param name defines the name of the mesh
  56269. * @param options defines the options used to create the mesh
  56270. * @param scene defines the hosting scene
  56271. * @returns the lathe mesh
  56272. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56273. */
  56274. static CreateLathe(name: string, options: {
  56275. shape: Vector3[];
  56276. radius?: number;
  56277. tessellation?: number;
  56278. clip?: number;
  56279. arc?: number;
  56280. closed?: boolean;
  56281. updatable?: boolean;
  56282. sideOrientation?: number;
  56283. frontUVs?: Vector4;
  56284. backUVs?: Vector4;
  56285. cap?: number;
  56286. invertUV?: boolean;
  56287. }, scene?: Nullable<Scene>): Mesh;
  56288. /**
  56289. * Creates a tiled plane mesh
  56290. * * You can set a limited pattern arrangement with the tiles
  56291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56292. * * 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
  56293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56294. * @param name defines the name of the mesh
  56295. * @param options defines the options used to create the mesh
  56296. * @param scene defines the hosting scene
  56297. * @returns the plane mesh
  56298. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56299. */
  56300. static CreateTiledPlane(name: string, options: {
  56301. pattern?: number;
  56302. tileSize?: number;
  56303. tileWidth?: number;
  56304. tileHeight?: number;
  56305. size?: number;
  56306. width?: number;
  56307. height?: number;
  56308. alignHorizontal?: number;
  56309. alignVertical?: number;
  56310. sideOrientation?: number;
  56311. frontUVs?: Vector4;
  56312. backUVs?: Vector4;
  56313. updatable?: boolean;
  56314. }, scene?: Nullable<Scene>): Mesh;
  56315. /**
  56316. * Creates a plane mesh
  56317. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56318. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56319. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56320. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56321. * * 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
  56322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56323. * @param name defines the name of the mesh
  56324. * @param options defines the options used to create the mesh
  56325. * @param scene defines the hosting scene
  56326. * @returns the plane mesh
  56327. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56328. */
  56329. static CreatePlane(name: string, options: {
  56330. size?: number;
  56331. width?: number;
  56332. height?: number;
  56333. sideOrientation?: number;
  56334. frontUVs?: Vector4;
  56335. backUVs?: Vector4;
  56336. updatable?: boolean;
  56337. sourcePlane?: Plane;
  56338. }, scene?: Nullable<Scene>): Mesh;
  56339. /**
  56340. * Creates a ground mesh
  56341. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56342. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56344. * @param name defines the name of the mesh
  56345. * @param options defines the options used to create the mesh
  56346. * @param scene defines the hosting scene
  56347. * @returns the ground mesh
  56348. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56349. */
  56350. static CreateGround(name: string, options: {
  56351. width?: number;
  56352. height?: number;
  56353. subdivisions?: number;
  56354. subdivisionsX?: number;
  56355. subdivisionsY?: number;
  56356. updatable?: boolean;
  56357. }, scene?: Nullable<Scene>): Mesh;
  56358. /**
  56359. * Creates a tiled ground mesh
  56360. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56361. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56362. * * 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
  56363. * * 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
  56364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56365. * @param name defines the name of the mesh
  56366. * @param options defines the options used to create the mesh
  56367. * @param scene defines the hosting scene
  56368. * @returns the tiled ground mesh
  56369. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56370. */
  56371. static CreateTiledGround(name: string, options: {
  56372. xmin: number;
  56373. zmin: number;
  56374. xmax: number;
  56375. zmax: number;
  56376. subdivisions?: {
  56377. w: number;
  56378. h: number;
  56379. };
  56380. precision?: {
  56381. w: number;
  56382. h: number;
  56383. };
  56384. updatable?: boolean;
  56385. }, scene?: Nullable<Scene>): Mesh;
  56386. /**
  56387. * Creates a ground mesh from a height map
  56388. * * The parameter `url` sets the URL of the height map image resource.
  56389. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56390. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56391. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56392. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56393. * * 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.
  56394. * * 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).
  56395. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56397. * @param name defines the name of the mesh
  56398. * @param url defines the url to the height map
  56399. * @param options defines the options used to create the mesh
  56400. * @param scene defines the hosting scene
  56401. * @returns the ground mesh
  56402. * @see https://doc.babylonjs.com/babylon101/height_map
  56403. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56404. */
  56405. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56406. width?: number;
  56407. height?: number;
  56408. subdivisions?: number;
  56409. minHeight?: number;
  56410. maxHeight?: number;
  56411. colorFilter?: Color3;
  56412. alphaFilter?: number;
  56413. updatable?: boolean;
  56414. onReady?: (mesh: GroundMesh) => void;
  56415. }, scene?: Nullable<Scene>): GroundMesh;
  56416. /**
  56417. * Creates a polygon mesh
  56418. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56419. * * 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
  56420. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56422. * * 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)
  56423. * * Remember you can only change the shape positions, not their number when updating a polygon
  56424. * @param name defines the name of the mesh
  56425. * @param options defines the options used to create the mesh
  56426. * @param scene defines the hosting scene
  56427. * @param earcutInjection can be used to inject your own earcut reference
  56428. * @returns the polygon mesh
  56429. */
  56430. static CreatePolygon(name: string, options: {
  56431. shape: Vector3[];
  56432. holes?: Vector3[][];
  56433. depth?: number;
  56434. faceUV?: Vector4[];
  56435. faceColors?: Color4[];
  56436. updatable?: boolean;
  56437. sideOrientation?: number;
  56438. frontUVs?: Vector4;
  56439. backUVs?: Vector4;
  56440. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56441. /**
  56442. * Creates an extruded polygon mesh, with depth in the Y direction.
  56443. * * 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)
  56444. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56445. * @param name defines the name of the mesh
  56446. * @param options defines the options used to create the mesh
  56447. * @param scene defines the hosting scene
  56448. * @param earcutInjection can be used to inject your own earcut reference
  56449. * @returns the polygon mesh
  56450. */
  56451. static ExtrudePolygon(name: string, options: {
  56452. shape: Vector3[];
  56453. holes?: Vector3[][];
  56454. depth?: number;
  56455. faceUV?: Vector4[];
  56456. faceColors?: Color4[];
  56457. updatable?: boolean;
  56458. sideOrientation?: number;
  56459. frontUVs?: Vector4;
  56460. backUVs?: Vector4;
  56461. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56462. /**
  56463. * Creates a tube mesh.
  56464. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56465. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56466. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56467. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56468. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56469. * * 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)
  56470. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56471. * * 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
  56472. * * 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
  56473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56474. * * 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
  56475. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56477. * @param name defines the name of the mesh
  56478. * @param options defines the options used to create the mesh
  56479. * @param scene defines the hosting scene
  56480. * @returns the tube mesh
  56481. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56482. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56483. */
  56484. static CreateTube(name: string, options: {
  56485. path: Vector3[];
  56486. radius?: number;
  56487. tessellation?: number;
  56488. radiusFunction?: {
  56489. (i: number, distance: number): number;
  56490. };
  56491. cap?: number;
  56492. arc?: number;
  56493. updatable?: boolean;
  56494. sideOrientation?: number;
  56495. frontUVs?: Vector4;
  56496. backUVs?: Vector4;
  56497. instance?: Mesh;
  56498. invertUV?: boolean;
  56499. }, scene?: Nullable<Scene>): Mesh;
  56500. /**
  56501. * Creates a polyhedron mesh
  56502. * * 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
  56503. * * The parameter `size` (positive float, default 1) sets the polygon size
  56504. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56505. * * 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`
  56506. * * 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
  56507. * * 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)`)
  56508. * * 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
  56509. * * 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
  56510. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56511. * * 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
  56512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56513. * @param name defines the name of the mesh
  56514. * @param options defines the options used to create the mesh
  56515. * @param scene defines the hosting scene
  56516. * @returns the polyhedron mesh
  56517. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56518. */
  56519. static CreatePolyhedron(name: string, options: {
  56520. type?: number;
  56521. size?: number;
  56522. sizeX?: number;
  56523. sizeY?: number;
  56524. sizeZ?: number;
  56525. custom?: any;
  56526. faceUV?: Vector4[];
  56527. faceColors?: Color4[];
  56528. flat?: boolean;
  56529. updatable?: boolean;
  56530. sideOrientation?: number;
  56531. frontUVs?: Vector4;
  56532. backUVs?: Vector4;
  56533. }, scene?: Nullable<Scene>): Mesh;
  56534. /**
  56535. * Creates a decal mesh.
  56536. * 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
  56537. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56538. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56539. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56540. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56541. * @param name defines the name of the mesh
  56542. * @param sourceMesh defines the mesh where the decal must be applied
  56543. * @param options defines the options used to create the mesh
  56544. * @param scene defines the hosting scene
  56545. * @returns the decal mesh
  56546. * @see https://doc.babylonjs.com/how_to/decals
  56547. */
  56548. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56549. position?: Vector3;
  56550. normal?: Vector3;
  56551. size?: Vector3;
  56552. angle?: number;
  56553. }): Mesh;
  56554. }
  56555. }
  56556. declare module "babylonjs/Meshes/meshSimplification" {
  56557. import { Mesh } from "babylonjs/Meshes/mesh";
  56558. /**
  56559. * A simplifier interface for future simplification implementations
  56560. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56561. */
  56562. export interface ISimplifier {
  56563. /**
  56564. * Simplification of a given mesh according to the given settings.
  56565. * Since this requires computation, it is assumed that the function runs async.
  56566. * @param settings The settings of the simplification, including quality and distance
  56567. * @param successCallback A callback that will be called after the mesh was simplified.
  56568. * @param errorCallback in case of an error, this callback will be called. optional.
  56569. */
  56570. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56571. }
  56572. /**
  56573. * Expected simplification settings.
  56574. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56575. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56576. */
  56577. export interface ISimplificationSettings {
  56578. /**
  56579. * Gets or sets the expected quality
  56580. */
  56581. quality: number;
  56582. /**
  56583. * Gets or sets the distance when this optimized version should be used
  56584. */
  56585. distance: number;
  56586. /**
  56587. * Gets an already optimized mesh
  56588. */
  56589. optimizeMesh?: boolean;
  56590. }
  56591. /**
  56592. * Class used to specify simplification options
  56593. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56594. */
  56595. export class SimplificationSettings implements ISimplificationSettings {
  56596. /** expected quality */
  56597. quality: number;
  56598. /** distance when this optimized version should be used */
  56599. distance: number;
  56600. /** already optimized mesh */
  56601. optimizeMesh?: boolean | undefined;
  56602. /**
  56603. * Creates a SimplificationSettings
  56604. * @param quality expected quality
  56605. * @param distance distance when this optimized version should be used
  56606. * @param optimizeMesh already optimized mesh
  56607. */
  56608. constructor(
  56609. /** expected quality */
  56610. quality: number,
  56611. /** distance when this optimized version should be used */
  56612. distance: number,
  56613. /** already optimized mesh */
  56614. optimizeMesh?: boolean | undefined);
  56615. }
  56616. /**
  56617. * Interface used to define a simplification task
  56618. */
  56619. export interface ISimplificationTask {
  56620. /**
  56621. * Array of settings
  56622. */
  56623. settings: Array<ISimplificationSettings>;
  56624. /**
  56625. * Simplification type
  56626. */
  56627. simplificationType: SimplificationType;
  56628. /**
  56629. * Mesh to simplify
  56630. */
  56631. mesh: Mesh;
  56632. /**
  56633. * Callback called on success
  56634. */
  56635. successCallback?: () => void;
  56636. /**
  56637. * Defines if parallel processing can be used
  56638. */
  56639. parallelProcessing: boolean;
  56640. }
  56641. /**
  56642. * Queue used to order the simplification tasks
  56643. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56644. */
  56645. export class SimplificationQueue {
  56646. private _simplificationArray;
  56647. /**
  56648. * Gets a boolean indicating that the process is still running
  56649. */
  56650. running: boolean;
  56651. /**
  56652. * Creates a new queue
  56653. */
  56654. constructor();
  56655. /**
  56656. * Adds a new simplification task
  56657. * @param task defines a task to add
  56658. */
  56659. addTask(task: ISimplificationTask): void;
  56660. /**
  56661. * Execute next task
  56662. */
  56663. executeNext(): void;
  56664. /**
  56665. * Execute a simplification task
  56666. * @param task defines the task to run
  56667. */
  56668. runSimplification(task: ISimplificationTask): void;
  56669. private getSimplifier;
  56670. }
  56671. /**
  56672. * The implemented types of simplification
  56673. * At the moment only Quadratic Error Decimation is implemented
  56674. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56675. */
  56676. export enum SimplificationType {
  56677. /** Quadratic error decimation */
  56678. QUADRATIC = 0
  56679. }
  56680. }
  56681. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  56682. import { Scene } from "babylonjs/scene";
  56683. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  56684. import { ISceneComponent } from "babylonjs/sceneComponent";
  56685. module "babylonjs/scene" {
  56686. interface Scene {
  56687. /** @hidden (Backing field) */
  56688. _simplificationQueue: SimplificationQueue;
  56689. /**
  56690. * Gets or sets the simplification queue attached to the scene
  56691. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56692. */
  56693. simplificationQueue: SimplificationQueue;
  56694. }
  56695. }
  56696. module "babylonjs/Meshes/mesh" {
  56697. interface Mesh {
  56698. /**
  56699. * Simplify the mesh according to the given array of settings.
  56700. * Function will return immediately and will simplify async
  56701. * @param settings a collection of simplification settings
  56702. * @param parallelProcessing should all levels calculate parallel or one after the other
  56703. * @param simplificationType the type of simplification to run
  56704. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56705. * @returns the current mesh
  56706. */
  56707. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56708. }
  56709. }
  56710. /**
  56711. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56712. * created in a scene
  56713. */
  56714. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56715. /**
  56716. * The component name helpfull to identify the component in the list of scene components.
  56717. */
  56718. readonly name: string;
  56719. /**
  56720. * The scene the component belongs to.
  56721. */
  56722. scene: Scene;
  56723. /**
  56724. * Creates a new instance of the component for the given scene
  56725. * @param scene Defines the scene to register the component in
  56726. */
  56727. constructor(scene: Scene);
  56728. /**
  56729. * Registers the component in a given scene
  56730. */
  56731. register(): void;
  56732. /**
  56733. * Rebuilds the elements related to this component in case of
  56734. * context lost for instance.
  56735. */
  56736. rebuild(): void;
  56737. /**
  56738. * Disposes the component and the associated ressources
  56739. */
  56740. dispose(): void;
  56741. private _beforeCameraUpdate;
  56742. }
  56743. }
  56744. declare module "babylonjs/Meshes/Builders/index" {
  56745. export * from "babylonjs/Meshes/Builders/boxBuilder";
  56746. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  56747. export * from "babylonjs/Meshes/Builders/discBuilder";
  56748. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  56749. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  56750. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  56751. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  56752. export * from "babylonjs/Meshes/Builders/torusBuilder";
  56753. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  56754. export * from "babylonjs/Meshes/Builders/linesBuilder";
  56755. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  56756. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  56757. export * from "babylonjs/Meshes/Builders/latheBuilder";
  56758. export * from "babylonjs/Meshes/Builders/planeBuilder";
  56759. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  56760. export * from "babylonjs/Meshes/Builders/groundBuilder";
  56761. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  56762. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  56763. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  56764. export * from "babylonjs/Meshes/Builders/decalBuilder";
  56765. }
  56766. declare module "babylonjs/Meshes/index" {
  56767. export * from "babylonjs/Meshes/abstractMesh";
  56768. export * from "babylonjs/Meshes/buffer";
  56769. export * from "babylonjs/Meshes/Compression/index";
  56770. export * from "babylonjs/Meshes/csg";
  56771. export * from "babylonjs/Meshes/geometry";
  56772. export * from "babylonjs/Meshes/groundMesh";
  56773. export * from "babylonjs/Meshes/trailMesh";
  56774. export * from "babylonjs/Meshes/instancedMesh";
  56775. export * from "babylonjs/Meshes/linesMesh";
  56776. export * from "babylonjs/Meshes/mesh";
  56777. export * from "babylonjs/Meshes/mesh.vertexData";
  56778. export * from "babylonjs/Meshes/meshBuilder";
  56779. export * from "babylonjs/Meshes/meshSimplification";
  56780. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  56781. export * from "babylonjs/Meshes/polygonMesh";
  56782. export * from "babylonjs/Meshes/subMesh";
  56783. export * from "babylonjs/Meshes/meshLODLevel";
  56784. export * from "babylonjs/Meshes/transformNode";
  56785. export * from "babylonjs/Meshes/Builders/index";
  56786. export * from "babylonjs/Meshes/dataBuffer";
  56787. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  56788. }
  56789. declare module "babylonjs/Morph/index" {
  56790. export * from "babylonjs/Morph/morphTarget";
  56791. export * from "babylonjs/Morph/morphTargetManager";
  56792. }
  56793. declare module "babylonjs/Offline/database" {
  56794. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  56795. /**
  56796. * Class used to enable access to IndexedDB
  56797. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56798. */
  56799. export class Database implements IOfflineProvider {
  56800. private _callbackManifestChecked;
  56801. private _currentSceneUrl;
  56802. private _db;
  56803. private _enableSceneOffline;
  56804. private _enableTexturesOffline;
  56805. private _manifestVersionFound;
  56806. private _mustUpdateRessources;
  56807. private _hasReachedQuota;
  56808. private _isSupported;
  56809. private _idbFactory;
  56810. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56811. private static IsUASupportingBlobStorage;
  56812. /**
  56813. * Gets a boolean indicating if Database storate is enabled (off by default)
  56814. */
  56815. static IDBStorageEnabled: boolean;
  56816. /**
  56817. * Gets a boolean indicating if scene must be saved in the database
  56818. */
  56819. readonly enableSceneOffline: boolean;
  56820. /**
  56821. * Gets a boolean indicating if textures must be saved in the database
  56822. */
  56823. readonly enableTexturesOffline: boolean;
  56824. /**
  56825. * Creates a new Database
  56826. * @param urlToScene defines the url to load the scene
  56827. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56828. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56829. */
  56830. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56831. private static _ParseURL;
  56832. private static _ReturnFullUrlLocation;
  56833. private _checkManifestFile;
  56834. /**
  56835. * Open the database and make it available
  56836. * @param successCallback defines the callback to call on success
  56837. * @param errorCallback defines the callback to call on error
  56838. */
  56839. open(successCallback: () => void, errorCallback: () => void): void;
  56840. /**
  56841. * Loads an image from the database
  56842. * @param url defines the url to load from
  56843. * @param image defines the target DOM image
  56844. */
  56845. loadImage(url: string, image: HTMLImageElement): void;
  56846. private _loadImageFromDBAsync;
  56847. private _saveImageIntoDBAsync;
  56848. private _checkVersionFromDB;
  56849. private _loadVersionFromDBAsync;
  56850. private _saveVersionIntoDBAsync;
  56851. /**
  56852. * Loads a file from database
  56853. * @param url defines the URL to load from
  56854. * @param sceneLoaded defines a callback to call on success
  56855. * @param progressCallBack defines a callback to call when progress changed
  56856. * @param errorCallback defines a callback to call on error
  56857. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56858. */
  56859. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56860. private _loadFileAsync;
  56861. private _saveFileAsync;
  56862. /**
  56863. * Validates if xhr data is correct
  56864. * @param xhr defines the request to validate
  56865. * @param dataType defines the expected data type
  56866. * @returns true if data is correct
  56867. */
  56868. private static _ValidateXHRData;
  56869. }
  56870. }
  56871. declare module "babylonjs/Offline/index" {
  56872. export * from "babylonjs/Offline/database";
  56873. export * from "babylonjs/Offline/IOfflineProvider";
  56874. }
  56875. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  56876. /** @hidden */
  56877. export var gpuUpdateParticlesPixelShader: {
  56878. name: string;
  56879. shader: string;
  56880. };
  56881. }
  56882. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  56883. /** @hidden */
  56884. export var gpuUpdateParticlesVertexShader: {
  56885. name: string;
  56886. shader: string;
  56887. };
  56888. }
  56889. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  56890. /** @hidden */
  56891. export var clipPlaneFragmentDeclaration2: {
  56892. name: string;
  56893. shader: string;
  56894. };
  56895. }
  56896. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  56897. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  56898. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56899. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56900. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56901. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56902. /** @hidden */
  56903. export var gpuRenderParticlesPixelShader: {
  56904. name: string;
  56905. shader: string;
  56906. };
  56907. }
  56908. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  56909. /** @hidden */
  56910. export var clipPlaneVertexDeclaration2: {
  56911. name: string;
  56912. shader: string;
  56913. };
  56914. }
  56915. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  56916. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  56917. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56918. /** @hidden */
  56919. export var gpuRenderParticlesVertexShader: {
  56920. name: string;
  56921. shader: string;
  56922. };
  56923. }
  56924. declare module "babylonjs/Particles/gpuParticleSystem" {
  56925. import { Nullable } from "babylonjs/types";
  56926. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  56927. import { Observable } from "babylonjs/Misc/observable";
  56928. import { Color4, Color3 } from "babylonjs/Maths/math";
  56929. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56930. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  56931. import { Scene, IDisposable } from "babylonjs/scene";
  56932. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  56933. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  56934. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  56935. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  56936. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  56937. /**
  56938. * This represents a GPU particle system in Babylon
  56939. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56940. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56941. */
  56942. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56943. /**
  56944. * The layer mask we are rendering the particles through.
  56945. */
  56946. layerMask: number;
  56947. private _capacity;
  56948. private _activeCount;
  56949. private _currentActiveCount;
  56950. private _accumulatedCount;
  56951. private _renderEffect;
  56952. private _updateEffect;
  56953. private _buffer0;
  56954. private _buffer1;
  56955. private _spriteBuffer;
  56956. private _updateVAO;
  56957. private _renderVAO;
  56958. private _targetIndex;
  56959. private _sourceBuffer;
  56960. private _targetBuffer;
  56961. private _engine;
  56962. private _currentRenderId;
  56963. private _started;
  56964. private _stopped;
  56965. private _timeDelta;
  56966. private _randomTexture;
  56967. private _randomTexture2;
  56968. private _attributesStrideSize;
  56969. private _updateEffectOptions;
  56970. private _randomTextureSize;
  56971. private _actualFrame;
  56972. private readonly _rawTextureWidth;
  56973. /**
  56974. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56975. */
  56976. static readonly IsSupported: boolean;
  56977. /**
  56978. * An event triggered when the system is disposed.
  56979. */
  56980. onDisposeObservable: Observable<GPUParticleSystem>;
  56981. /**
  56982. * Gets the maximum number of particles active at the same time.
  56983. * @returns The max number of active particles.
  56984. */
  56985. getCapacity(): number;
  56986. /**
  56987. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56988. * to override the particles.
  56989. */
  56990. forceDepthWrite: boolean;
  56991. /**
  56992. * Gets or set the number of active particles
  56993. */
  56994. activeParticleCount: number;
  56995. private _preWarmDone;
  56996. /**
  56997. * Is this system ready to be used/rendered
  56998. * @return true if the system is ready
  56999. */
  57000. isReady(): boolean;
  57001. /**
  57002. * Gets if the system has been started. (Note: this will still be true after stop is called)
  57003. * @returns True if it has been started, otherwise false.
  57004. */
  57005. isStarted(): boolean;
  57006. /**
  57007. * Starts the particle system and begins to emit
  57008. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57009. */
  57010. start(delay?: number): void;
  57011. /**
  57012. * Stops the particle system.
  57013. */
  57014. stop(): void;
  57015. /**
  57016. * Remove all active particles
  57017. */
  57018. reset(): void;
  57019. /**
  57020. * Returns the string "GPUParticleSystem"
  57021. * @returns a string containing the class name
  57022. */
  57023. getClassName(): string;
  57024. private _colorGradientsTexture;
  57025. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57026. /**
  57027. * Adds a new color gradient
  57028. * @param gradient defines the gradient to use (between 0 and 1)
  57029. * @param color1 defines the color to affect to the specified gradient
  57030. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  57031. * @returns the current particle system
  57032. */
  57033. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  57034. /**
  57035. * Remove a specific color gradient
  57036. * @param gradient defines the gradient to remove
  57037. * @returns the current particle system
  57038. */
  57039. removeColorGradient(gradient: number): GPUParticleSystem;
  57040. private _angularSpeedGradientsTexture;
  57041. private _sizeGradientsTexture;
  57042. private _velocityGradientsTexture;
  57043. private _limitVelocityGradientsTexture;
  57044. private _dragGradientsTexture;
  57045. private _addFactorGradient;
  57046. /**
  57047. * Adds a new size gradient
  57048. * @param gradient defines the gradient to use (between 0 and 1)
  57049. * @param factor defines the size factor to affect to the specified gradient
  57050. * @returns the current particle system
  57051. */
  57052. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57053. /**
  57054. * Remove a specific size gradient
  57055. * @param gradient defines the gradient to remove
  57056. * @returns the current particle system
  57057. */
  57058. removeSizeGradient(gradient: number): GPUParticleSystem;
  57059. /**
  57060. * Adds a new angular speed gradient
  57061. * @param gradient defines the gradient to use (between 0 and 1)
  57062. * @param factor defines the angular speed to affect to the specified gradient
  57063. * @returns the current particle system
  57064. */
  57065. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57066. /**
  57067. * Remove a specific angular speed gradient
  57068. * @param gradient defines the gradient to remove
  57069. * @returns the current particle system
  57070. */
  57071. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57072. /**
  57073. * Adds a new velocity gradient
  57074. * @param gradient defines the gradient to use (between 0 and 1)
  57075. * @param factor defines the velocity to affect to the specified gradient
  57076. * @returns the current particle system
  57077. */
  57078. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57079. /**
  57080. * Remove a specific velocity gradient
  57081. * @param gradient defines the gradient to remove
  57082. * @returns the current particle system
  57083. */
  57084. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57085. /**
  57086. * Adds a new limit velocity gradient
  57087. * @param gradient defines the gradient to use (between 0 and 1)
  57088. * @param factor defines the limit velocity value to affect to the specified gradient
  57089. * @returns the current particle system
  57090. */
  57091. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57092. /**
  57093. * Remove a specific limit velocity gradient
  57094. * @param gradient defines the gradient to remove
  57095. * @returns the current particle system
  57096. */
  57097. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57098. /**
  57099. * Adds a new drag gradient
  57100. * @param gradient defines the gradient to use (between 0 and 1)
  57101. * @param factor defines the drag value to affect to the specified gradient
  57102. * @returns the current particle system
  57103. */
  57104. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  57105. /**
  57106. * Remove a specific drag gradient
  57107. * @param gradient defines the gradient to remove
  57108. * @returns the current particle system
  57109. */
  57110. removeDragGradient(gradient: number): GPUParticleSystem;
  57111. /**
  57112. * Not supported by GPUParticleSystem
  57113. * @param gradient defines the gradient to use (between 0 and 1)
  57114. * @param factor defines the emit rate value to affect to the specified gradient
  57115. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57116. * @returns the current particle system
  57117. */
  57118. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57119. /**
  57120. * Not supported by GPUParticleSystem
  57121. * @param gradient defines the gradient to remove
  57122. * @returns the current particle system
  57123. */
  57124. removeEmitRateGradient(gradient: number): IParticleSystem;
  57125. /**
  57126. * Not supported by GPUParticleSystem
  57127. * @param gradient defines the gradient to use (between 0 and 1)
  57128. * @param factor defines the start size value to affect to the specified gradient
  57129. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57130. * @returns the current particle system
  57131. */
  57132. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57133. /**
  57134. * Not supported by GPUParticleSystem
  57135. * @param gradient defines the gradient to remove
  57136. * @returns the current particle system
  57137. */
  57138. removeStartSizeGradient(gradient: number): IParticleSystem;
  57139. /**
  57140. * Not supported by GPUParticleSystem
  57141. * @param gradient defines the gradient to use (between 0 and 1)
  57142. * @param min defines the color remap minimal range
  57143. * @param max defines the color remap maximal range
  57144. * @returns the current particle system
  57145. */
  57146. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57147. /**
  57148. * Not supported by GPUParticleSystem
  57149. * @param gradient defines the gradient to remove
  57150. * @returns the current particle system
  57151. */
  57152. removeColorRemapGradient(): IParticleSystem;
  57153. /**
  57154. * Not supported by GPUParticleSystem
  57155. * @param gradient defines the gradient to use (between 0 and 1)
  57156. * @param min defines the alpha remap minimal range
  57157. * @param max defines the alpha remap maximal range
  57158. * @returns the current particle system
  57159. */
  57160. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57161. /**
  57162. * Not supported by GPUParticleSystem
  57163. * @param gradient defines the gradient to remove
  57164. * @returns the current particle system
  57165. */
  57166. removeAlphaRemapGradient(): IParticleSystem;
  57167. /**
  57168. * Not supported by GPUParticleSystem
  57169. * @param gradient defines the gradient to use (between 0 and 1)
  57170. * @param color defines the color to affect to the specified gradient
  57171. * @returns the current particle system
  57172. */
  57173. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  57174. /**
  57175. * Not supported by GPUParticleSystem
  57176. * @param gradient defines the gradient to remove
  57177. * @returns the current particle system
  57178. */
  57179. removeRampGradient(): IParticleSystem;
  57180. /**
  57181. * Not supported by GPUParticleSystem
  57182. * @returns the list of ramp gradients
  57183. */
  57184. getRampGradients(): Nullable<Array<Color3Gradient>>;
  57185. /**
  57186. * Not supported by GPUParticleSystem
  57187. * Gets or sets a boolean indicating that ramp gradients must be used
  57188. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  57189. */
  57190. useRampGradients: boolean;
  57191. /**
  57192. * Not supported by GPUParticleSystem
  57193. * @param gradient defines the gradient to use (between 0 and 1)
  57194. * @param factor defines the life time factor to affect to the specified gradient
  57195. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57196. * @returns the current particle system
  57197. */
  57198. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57199. /**
  57200. * Not supported by GPUParticleSystem
  57201. * @param gradient defines the gradient to remove
  57202. * @returns the current particle system
  57203. */
  57204. removeLifeTimeGradient(gradient: number): IParticleSystem;
  57205. /**
  57206. * Instantiates a GPU particle system.
  57207. * 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.
  57208. * @param name The name of the particle system
  57209. * @param options The options used to create the system
  57210. * @param scene The scene the particle system belongs to
  57211. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  57212. */
  57213. constructor(name: string, options: Partial<{
  57214. capacity: number;
  57215. randomTextureSize: number;
  57216. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  57217. protected _reset(): void;
  57218. private _createUpdateVAO;
  57219. private _createRenderVAO;
  57220. private _initialize;
  57221. /** @hidden */
  57222. _recreateUpdateEffect(): void;
  57223. /** @hidden */
  57224. _recreateRenderEffect(): void;
  57225. /**
  57226. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  57227. * @param preWarm defines if we are in the pre-warmimg phase
  57228. */
  57229. animate(preWarm?: boolean): void;
  57230. private _createFactorGradientTexture;
  57231. private _createSizeGradientTexture;
  57232. private _createAngularSpeedGradientTexture;
  57233. private _createVelocityGradientTexture;
  57234. private _createLimitVelocityGradientTexture;
  57235. private _createDragGradientTexture;
  57236. private _createColorGradientTexture;
  57237. /**
  57238. * Renders the particle system in its current state
  57239. * @param preWarm defines if the system should only update the particles but not render them
  57240. * @returns the current number of particles
  57241. */
  57242. render(preWarm?: boolean): number;
  57243. /**
  57244. * Rebuilds the particle system
  57245. */
  57246. rebuild(): void;
  57247. private _releaseBuffers;
  57248. private _releaseVAOs;
  57249. /**
  57250. * Disposes the particle system and free the associated resources
  57251. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  57252. */
  57253. dispose(disposeTexture?: boolean): void;
  57254. /**
  57255. * Clones the particle system.
  57256. * @param name The name of the cloned object
  57257. * @param newEmitter The new emitter to use
  57258. * @returns the cloned particle system
  57259. */
  57260. clone(name: string, newEmitter: any): GPUParticleSystem;
  57261. /**
  57262. * Serializes the particle system to a JSON object.
  57263. * @returns the JSON object
  57264. */
  57265. serialize(): any;
  57266. /**
  57267. * Parses a JSON object to create a GPU particle system.
  57268. * @param parsedParticleSystem The JSON object to parse
  57269. * @param scene The scene to create the particle system in
  57270. * @param rootUrl The root url to use to load external dependencies like texture
  57271. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  57272. * @returns the parsed GPU particle system
  57273. */
  57274. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  57275. }
  57276. }
  57277. declare module "babylonjs/Particles/particleSystemSet" {
  57278. import { Nullable } from "babylonjs/types";
  57279. import { Color3 } from "babylonjs/Maths/math";
  57280. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57282. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57283. import { Scene, IDisposable } from "babylonjs/scene";
  57284. /**
  57285. * Represents a set of particle systems working together to create a specific effect
  57286. */
  57287. export class ParticleSystemSet implements IDisposable {
  57288. private _emitterCreationOptions;
  57289. private _emitterNode;
  57290. /**
  57291. * Gets the particle system list
  57292. */
  57293. systems: IParticleSystem[];
  57294. /**
  57295. * Gets the emitter node used with this set
  57296. */
  57297. readonly emitterNode: Nullable<TransformNode>;
  57298. /**
  57299. * Creates a new emitter mesh as a sphere
  57300. * @param options defines the options used to create the sphere
  57301. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  57302. * @param scene defines the hosting scene
  57303. */
  57304. setEmitterAsSphere(options: {
  57305. diameter: number;
  57306. segments: number;
  57307. color: Color3;
  57308. }, renderingGroupId: number, scene: Scene): void;
  57309. /**
  57310. * Starts all particle systems of the set
  57311. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57312. */
  57313. start(emitter?: AbstractMesh): void;
  57314. /**
  57315. * Release all associated resources
  57316. */
  57317. dispose(): void;
  57318. /**
  57319. * Serialize the set into a JSON compatible object
  57320. * @returns a JSON compatible representation of the set
  57321. */
  57322. serialize(): any;
  57323. /**
  57324. * Parse a new ParticleSystemSet from a serialized source
  57325. * @param data defines a JSON compatible representation of the set
  57326. * @param scene defines the hosting scene
  57327. * @param gpu defines if we want GPU particles or CPU particles
  57328. * @returns a new ParticleSystemSet
  57329. */
  57330. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57331. }
  57332. }
  57333. declare module "babylonjs/Particles/particleHelper" {
  57334. import { Nullable } from "babylonjs/types";
  57335. import { Scene } from "babylonjs/scene";
  57336. import { Vector3 } from "babylonjs/Maths/math";
  57337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57338. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57339. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  57340. /**
  57341. * This class is made for on one-liner static method to help creating particle system set.
  57342. */
  57343. export class ParticleHelper {
  57344. /**
  57345. * Gets or sets base Assets URL
  57346. */
  57347. static BaseAssetsUrl: string;
  57348. /**
  57349. * Create a default particle system that you can tweak
  57350. * @param emitter defines the emitter to use
  57351. * @param capacity defines the system capacity (default is 500 particles)
  57352. * @param scene defines the hosting scene
  57353. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57354. * @returns the new Particle system
  57355. */
  57356. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57357. /**
  57358. * This is the main static method (one-liner) of this helper to create different particle systems
  57359. * @param type This string represents the type to the particle system to create
  57360. * @param scene The scene where the particle system should live
  57361. * @param gpu If the system will use gpu
  57362. * @returns the ParticleSystemSet created
  57363. */
  57364. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57365. /**
  57366. * Static function used to export a particle system to a ParticleSystemSet variable.
  57367. * Please note that the emitter shape is not exported
  57368. * @param systems defines the particle systems to export
  57369. * @returns the created particle system set
  57370. */
  57371. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57372. }
  57373. }
  57374. declare module "babylonjs/Particles/particleSystemComponent" {
  57375. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57376. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  57377. import "babylonjs/Shaders/particles.vertex";
  57378. module "babylonjs/Engines/engine" {
  57379. interface Engine {
  57380. /**
  57381. * Create an effect to use with particle systems.
  57382. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57383. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57384. * @param uniformsNames defines a list of attribute names
  57385. * @param samplers defines an array of string used to represent textures
  57386. * @param defines defines the string containing the defines to use to compile the shaders
  57387. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57388. * @param onCompiled defines a function to call when the effect creation is successful
  57389. * @param onError defines a function to call when the effect creation has failed
  57390. * @returns the new Effect
  57391. */
  57392. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57393. }
  57394. }
  57395. module "babylonjs/Meshes/mesh" {
  57396. interface Mesh {
  57397. /**
  57398. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57399. * @returns an array of IParticleSystem
  57400. */
  57401. getEmittedParticleSystems(): IParticleSystem[];
  57402. /**
  57403. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57404. * @returns an array of IParticleSystem
  57405. */
  57406. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57407. }
  57408. }
  57409. /**
  57410. * @hidden
  57411. */
  57412. export var _IDoNeedToBeInTheBuild: number;
  57413. }
  57414. declare module "babylonjs/Particles/index" {
  57415. export * from "babylonjs/Particles/baseParticleSystem";
  57416. export * from "babylonjs/Particles/EmitterTypes/index";
  57417. export * from "babylonjs/Particles/gpuParticleSystem";
  57418. export * from "babylonjs/Particles/IParticleSystem";
  57419. export * from "babylonjs/Particles/particle";
  57420. export * from "babylonjs/Particles/particleHelper";
  57421. export * from "babylonjs/Particles/particleSystem";
  57422. export * from "babylonjs/Particles/particleSystemComponent";
  57423. export * from "babylonjs/Particles/particleSystemSet";
  57424. export * from "babylonjs/Particles/solidParticle";
  57425. export * from "babylonjs/Particles/solidParticleSystem";
  57426. export * from "babylonjs/Particles/subEmitter";
  57427. }
  57428. declare module "babylonjs/Physics/physicsEngineComponent" {
  57429. import { Nullable } from "babylonjs/types";
  57430. import { Observable, Observer } from "babylonjs/Misc/observable";
  57431. import { Vector3 } from "babylonjs/Maths/math";
  57432. import { Mesh } from "babylonjs/Meshes/mesh";
  57433. import { ISceneComponent } from "babylonjs/sceneComponent";
  57434. import { Scene } from "babylonjs/scene";
  57435. import { Node } from "babylonjs/node";
  57436. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57437. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57438. module "babylonjs/scene" {
  57439. interface Scene {
  57440. /** @hidden (Backing field) */
  57441. _physicsEngine: Nullable<IPhysicsEngine>;
  57442. /**
  57443. * Gets the current physics engine
  57444. * @returns a IPhysicsEngine or null if none attached
  57445. */
  57446. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57447. /**
  57448. * Enables physics to the current scene
  57449. * @param gravity defines the scene's gravity for the physics engine
  57450. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57451. * @return a boolean indicating if the physics engine was initialized
  57452. */
  57453. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57454. /**
  57455. * Disables and disposes the physics engine associated with the scene
  57456. */
  57457. disablePhysicsEngine(): void;
  57458. /**
  57459. * Gets a boolean indicating if there is an active physics engine
  57460. * @returns a boolean indicating if there is an active physics engine
  57461. */
  57462. isPhysicsEnabled(): boolean;
  57463. /**
  57464. * Deletes a physics compound impostor
  57465. * @param compound defines the compound to delete
  57466. */
  57467. deleteCompoundImpostor(compound: any): void;
  57468. /**
  57469. * An event triggered when physic simulation is about to be run
  57470. */
  57471. onBeforePhysicsObservable: Observable<Scene>;
  57472. /**
  57473. * An event triggered when physic simulation has been done
  57474. */
  57475. onAfterPhysicsObservable: Observable<Scene>;
  57476. }
  57477. }
  57478. module "babylonjs/Meshes/abstractMesh" {
  57479. interface AbstractMesh {
  57480. /** @hidden */
  57481. _physicsImpostor: Nullable<PhysicsImpostor>;
  57482. /**
  57483. * Gets or sets impostor used for physic simulation
  57484. * @see http://doc.babylonjs.com/features/physics_engine
  57485. */
  57486. physicsImpostor: Nullable<PhysicsImpostor>;
  57487. /**
  57488. * Gets the current physics impostor
  57489. * @see http://doc.babylonjs.com/features/physics_engine
  57490. * @returns a physics impostor or null
  57491. */
  57492. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57493. /** Apply a physic impulse to the mesh
  57494. * @param force defines the force to apply
  57495. * @param contactPoint defines where to apply the force
  57496. * @returns the current mesh
  57497. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57498. */
  57499. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57500. /**
  57501. * Creates a physic joint between two meshes
  57502. * @param otherMesh defines the other mesh to use
  57503. * @param pivot1 defines the pivot to use on this mesh
  57504. * @param pivot2 defines the pivot to use on the other mesh
  57505. * @param options defines additional options (can be plugin dependent)
  57506. * @returns the current mesh
  57507. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57508. */
  57509. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57510. /** @hidden */
  57511. _disposePhysicsObserver: Nullable<Observer<Node>>;
  57512. }
  57513. }
  57514. /**
  57515. * Defines the physics engine scene component responsible to manage a physics engine
  57516. */
  57517. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57518. /**
  57519. * The component name helpful to identify the component in the list of scene components.
  57520. */
  57521. readonly name: string;
  57522. /**
  57523. * The scene the component belongs to.
  57524. */
  57525. scene: Scene;
  57526. /**
  57527. * Creates a new instance of the component for the given scene
  57528. * @param scene Defines the scene to register the component in
  57529. */
  57530. constructor(scene: Scene);
  57531. /**
  57532. * Registers the component in a given scene
  57533. */
  57534. register(): void;
  57535. /**
  57536. * Rebuilds the elements related to this component in case of
  57537. * context lost for instance.
  57538. */
  57539. rebuild(): void;
  57540. /**
  57541. * Disposes the component and the associated ressources
  57542. */
  57543. dispose(): void;
  57544. }
  57545. }
  57546. declare module "babylonjs/Physics/physicsHelper" {
  57547. import { Nullable } from "babylonjs/types";
  57548. import { Vector3 } from "babylonjs/Maths/math";
  57549. import { Mesh } from "babylonjs/Meshes/mesh";
  57550. import { Scene } from "babylonjs/scene";
  57551. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57552. /**
  57553. * A helper for physics simulations
  57554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57555. */
  57556. export class PhysicsHelper {
  57557. private _scene;
  57558. private _physicsEngine;
  57559. /**
  57560. * Initializes the Physics helper
  57561. * @param scene Babylon.js scene
  57562. */
  57563. constructor(scene: Scene);
  57564. /**
  57565. * Applies a radial explosion impulse
  57566. * @param origin the origin of the explosion
  57567. * @param radiusOrEventOptions the radius or the options of radial explosion
  57568. * @param strength the explosion strength
  57569. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57570. * @returns A physics radial explosion event, or null
  57571. */
  57572. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57573. /**
  57574. * Applies a radial explosion force
  57575. * @param origin the origin of the explosion
  57576. * @param radiusOrEventOptions the radius or the options of radial explosion
  57577. * @param strength the explosion strength
  57578. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57579. * @returns A physics radial explosion event, or null
  57580. */
  57581. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57582. /**
  57583. * Creates a gravitational field
  57584. * @param origin the origin of the explosion
  57585. * @param radiusOrEventOptions the radius or the options of radial explosion
  57586. * @param strength the explosion strength
  57587. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57588. * @returns A physics gravitational field event, or null
  57589. */
  57590. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57591. /**
  57592. * Creates a physics updraft event
  57593. * @param origin the origin of the updraft
  57594. * @param radiusOrEventOptions the radius or the options of the updraft
  57595. * @param strength the strength of the updraft
  57596. * @param height the height of the updraft
  57597. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57598. * @returns A physics updraft event, or null
  57599. */
  57600. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57601. /**
  57602. * Creates a physics vortex event
  57603. * @param origin the of the vortex
  57604. * @param radiusOrEventOptions the radius or the options of the vortex
  57605. * @param strength the strength of the vortex
  57606. * @param height the height of the vortex
  57607. * @returns a Physics vortex event, or null
  57608. * A physics vortex event or null
  57609. */
  57610. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57611. }
  57612. /**
  57613. * Represents a physics radial explosion event
  57614. */
  57615. class PhysicsRadialExplosionEvent {
  57616. private _scene;
  57617. private _options;
  57618. private _sphere;
  57619. private _dataFetched;
  57620. /**
  57621. * Initializes a radial explosioin event
  57622. * @param _scene BabylonJS scene
  57623. * @param _options The options for the vortex event
  57624. */
  57625. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57626. /**
  57627. * Returns the data related to the radial explosion event (sphere).
  57628. * @returns The radial explosion event data
  57629. */
  57630. getData(): PhysicsRadialExplosionEventData;
  57631. /**
  57632. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57633. * @param impostor A physics imposter
  57634. * @param origin the origin of the explosion
  57635. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57636. */
  57637. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57638. /**
  57639. * Triggers affecterd impostors callbacks
  57640. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57641. */
  57642. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57643. /**
  57644. * Disposes the sphere.
  57645. * @param force Specifies if the sphere should be disposed by force
  57646. */
  57647. dispose(force?: boolean): void;
  57648. /*** Helpers ***/
  57649. private _prepareSphere;
  57650. private _intersectsWithSphere;
  57651. }
  57652. /**
  57653. * Represents a gravitational field event
  57654. */
  57655. class PhysicsGravitationalFieldEvent {
  57656. private _physicsHelper;
  57657. private _scene;
  57658. private _origin;
  57659. private _options;
  57660. private _tickCallback;
  57661. private _sphere;
  57662. private _dataFetched;
  57663. /**
  57664. * Initializes the physics gravitational field event
  57665. * @param _physicsHelper A physics helper
  57666. * @param _scene BabylonJS scene
  57667. * @param _origin The origin position of the gravitational field event
  57668. * @param _options The options for the vortex event
  57669. */
  57670. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  57671. /**
  57672. * Returns the data related to the gravitational field event (sphere).
  57673. * @returns A gravitational field event
  57674. */
  57675. getData(): PhysicsGravitationalFieldEventData;
  57676. /**
  57677. * Enables the gravitational field.
  57678. */
  57679. enable(): void;
  57680. /**
  57681. * Disables the gravitational field.
  57682. */
  57683. disable(): void;
  57684. /**
  57685. * Disposes the sphere.
  57686. * @param force The force to dispose from the gravitational field event
  57687. */
  57688. dispose(force?: boolean): void;
  57689. private _tick;
  57690. }
  57691. /**
  57692. * Represents a physics updraft event
  57693. */
  57694. class PhysicsUpdraftEvent {
  57695. private _scene;
  57696. private _origin;
  57697. private _options;
  57698. private _physicsEngine;
  57699. private _originTop;
  57700. private _originDirection;
  57701. private _tickCallback;
  57702. private _cylinder;
  57703. private _cylinderPosition;
  57704. private _dataFetched;
  57705. /**
  57706. * Initializes the physics updraft event
  57707. * @param _scene BabylonJS scene
  57708. * @param _origin The origin position of the updraft
  57709. * @param _options The options for the updraft event
  57710. */
  57711. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57712. /**
  57713. * Returns the data related to the updraft event (cylinder).
  57714. * @returns A physics updraft event
  57715. */
  57716. getData(): PhysicsUpdraftEventData;
  57717. /**
  57718. * Enables the updraft.
  57719. */
  57720. enable(): void;
  57721. /**
  57722. * Disables the updraft.
  57723. */
  57724. disable(): void;
  57725. /**
  57726. * Disposes the cylinder.
  57727. * @param force Specifies if the updraft should be disposed by force
  57728. */
  57729. dispose(force?: boolean): void;
  57730. private getImpostorHitData;
  57731. private _tick;
  57732. /*** Helpers ***/
  57733. private _prepareCylinder;
  57734. private _intersectsWithCylinder;
  57735. }
  57736. /**
  57737. * Represents a physics vortex event
  57738. */
  57739. class PhysicsVortexEvent {
  57740. private _scene;
  57741. private _origin;
  57742. private _options;
  57743. private _physicsEngine;
  57744. private _originTop;
  57745. private _tickCallback;
  57746. private _cylinder;
  57747. private _cylinderPosition;
  57748. private _dataFetched;
  57749. /**
  57750. * Initializes the physics vortex event
  57751. * @param _scene The BabylonJS scene
  57752. * @param _origin The origin position of the vortex
  57753. * @param _options The options for the vortex event
  57754. */
  57755. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57756. /**
  57757. * Returns the data related to the vortex event (cylinder).
  57758. * @returns The physics vortex event data
  57759. */
  57760. getData(): PhysicsVortexEventData;
  57761. /**
  57762. * Enables the vortex.
  57763. */
  57764. enable(): void;
  57765. /**
  57766. * Disables the cortex.
  57767. */
  57768. disable(): void;
  57769. /**
  57770. * Disposes the sphere.
  57771. * @param force
  57772. */
  57773. dispose(force?: boolean): void;
  57774. private getImpostorHitData;
  57775. private _tick;
  57776. /*** Helpers ***/
  57777. private _prepareCylinder;
  57778. private _intersectsWithCylinder;
  57779. }
  57780. /**
  57781. * Options fot the radial explosion event
  57782. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57783. */
  57784. export class PhysicsRadialExplosionEventOptions {
  57785. /**
  57786. * The radius of the sphere for the radial explosion.
  57787. */
  57788. radius: number;
  57789. /**
  57790. * The strenth of the explosion.
  57791. */
  57792. strength: number;
  57793. /**
  57794. * The strenght of the force in correspondence to the distance of the affected object
  57795. */
  57796. falloff: PhysicsRadialImpulseFalloff;
  57797. /**
  57798. * Sphere options for the radial explosion.
  57799. */
  57800. sphere: {
  57801. segments: number;
  57802. diameter: number;
  57803. };
  57804. /**
  57805. * Sphere options for the radial explosion.
  57806. */
  57807. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57808. }
  57809. /**
  57810. * Options fot the updraft event
  57811. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57812. */
  57813. export class PhysicsUpdraftEventOptions {
  57814. /**
  57815. * The radius of the cylinder for the vortex
  57816. */
  57817. radius: number;
  57818. /**
  57819. * The strenth of the updraft.
  57820. */
  57821. strength: number;
  57822. /**
  57823. * The height of the cylinder for the updraft.
  57824. */
  57825. height: number;
  57826. /**
  57827. * The mode for the the updraft.
  57828. */
  57829. updraftMode: PhysicsUpdraftMode;
  57830. }
  57831. /**
  57832. * Options fot the vortex event
  57833. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57834. */
  57835. export class PhysicsVortexEventOptions {
  57836. /**
  57837. * The radius of the cylinder for the vortex
  57838. */
  57839. radius: number;
  57840. /**
  57841. * The strenth of the vortex.
  57842. */
  57843. strength: number;
  57844. /**
  57845. * The height of the cylinder for the vortex.
  57846. */
  57847. height: number;
  57848. /**
  57849. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57850. */
  57851. centripetalForceThreshold: number;
  57852. /**
  57853. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57854. */
  57855. centripetalForceMultiplier: number;
  57856. /**
  57857. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57858. */
  57859. centrifugalForceMultiplier: number;
  57860. /**
  57861. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57862. */
  57863. updraftForceMultiplier: number;
  57864. }
  57865. /**
  57866. * The strenght of the force in correspondence to the distance of the affected object
  57867. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57868. */
  57869. export enum PhysicsRadialImpulseFalloff {
  57870. /** Defines that impulse is constant in strength across it's whole radius */
  57871. Constant = 0,
  57872. /** Defines that impulse gets weaker if it's further from the origin */
  57873. Linear = 1
  57874. }
  57875. /**
  57876. * The strength of the force in correspondence to the distance of the affected object
  57877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57878. */
  57879. export enum PhysicsUpdraftMode {
  57880. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57881. Center = 0,
  57882. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57883. Perpendicular = 1
  57884. }
  57885. /**
  57886. * Interface for a physics hit data
  57887. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57888. */
  57889. export interface PhysicsHitData {
  57890. /**
  57891. * The force applied at the contact point
  57892. */
  57893. force: Vector3;
  57894. /**
  57895. * The contact point
  57896. */
  57897. contactPoint: Vector3;
  57898. /**
  57899. * The distance from the origin to the contact point
  57900. */
  57901. distanceFromOrigin: number;
  57902. }
  57903. /**
  57904. * Interface for radial explosion event data
  57905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57906. */
  57907. export interface PhysicsRadialExplosionEventData {
  57908. /**
  57909. * A sphere used for the radial explosion event
  57910. */
  57911. sphere: Mesh;
  57912. }
  57913. /**
  57914. * Interface for gravitational field event data
  57915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57916. */
  57917. export interface PhysicsGravitationalFieldEventData {
  57918. /**
  57919. * A sphere mesh used for the gravitational field event
  57920. */
  57921. sphere: Mesh;
  57922. }
  57923. /**
  57924. * Interface for updraft event data
  57925. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57926. */
  57927. export interface PhysicsUpdraftEventData {
  57928. /**
  57929. * A cylinder used for the updraft event
  57930. */
  57931. cylinder: Mesh;
  57932. }
  57933. /**
  57934. * Interface for vortex event data
  57935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57936. */
  57937. export interface PhysicsVortexEventData {
  57938. /**
  57939. * A cylinder used for the vortex event
  57940. */
  57941. cylinder: Mesh;
  57942. }
  57943. /**
  57944. * Interface for an affected physics impostor
  57945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57946. */
  57947. export interface PhysicsAffectedImpostorWithData {
  57948. /**
  57949. * The impostor affected by the effect
  57950. */
  57951. impostor: PhysicsImpostor;
  57952. /**
  57953. * The data about the hit/horce from the explosion
  57954. */
  57955. hitData: PhysicsHitData;
  57956. }
  57957. }
  57958. declare module "babylonjs/Physics/Plugins/index" {
  57959. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  57960. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  57961. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  57962. }
  57963. declare module "babylonjs/Physics/index" {
  57964. export * from "babylonjs/Physics/IPhysicsEngine";
  57965. export * from "babylonjs/Physics/physicsEngine";
  57966. export * from "babylonjs/Physics/physicsEngineComponent";
  57967. export * from "babylonjs/Physics/physicsHelper";
  57968. export * from "babylonjs/Physics/physicsImpostor";
  57969. export * from "babylonjs/Physics/physicsJoint";
  57970. export * from "babylonjs/Physics/Plugins/index";
  57971. }
  57972. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  57973. /** @hidden */
  57974. export var blackAndWhitePixelShader: {
  57975. name: string;
  57976. shader: string;
  57977. };
  57978. }
  57979. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  57980. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57981. import { Camera } from "babylonjs/Cameras/camera";
  57982. import { Engine } from "babylonjs/Engines/engine";
  57983. import "babylonjs/Shaders/blackAndWhite.fragment";
  57984. /**
  57985. * Post process used to render in black and white
  57986. */
  57987. export class BlackAndWhitePostProcess extends PostProcess {
  57988. /**
  57989. * Linear about to convert he result to black and white (default: 1)
  57990. */
  57991. degree: number;
  57992. /**
  57993. * Creates a black and white post process
  57994. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57995. * @param name The name of the effect.
  57996. * @param options The required width/height ratio to downsize to before computing the render pass.
  57997. * @param camera The camera to apply the render pass to.
  57998. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57999. * @param engine The engine which the post process will be applied. (default: current engine)
  58000. * @param reusable If the post process can be reused on the same frame. (default: false)
  58001. */
  58002. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58003. }
  58004. }
  58005. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  58006. import { Nullable } from "babylonjs/types";
  58007. import { Camera } from "babylonjs/Cameras/camera";
  58008. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58009. import { Engine } from "babylonjs/Engines/engine";
  58010. /**
  58011. * This represents a set of one or more post processes in Babylon.
  58012. * A post process can be used to apply a shader to a texture after it is rendered.
  58013. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58014. */
  58015. export class PostProcessRenderEffect {
  58016. private _postProcesses;
  58017. private _getPostProcesses;
  58018. private _singleInstance;
  58019. private _cameras;
  58020. private _indicesForCamera;
  58021. /**
  58022. * Name of the effect
  58023. * @hidden
  58024. */
  58025. _name: string;
  58026. /**
  58027. * Instantiates a post process render effect.
  58028. * A post process can be used to apply a shader to a texture after it is rendered.
  58029. * @param engine The engine the effect is tied to
  58030. * @param name The name of the effect
  58031. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  58032. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  58033. */
  58034. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  58035. /**
  58036. * Checks if all the post processes in the effect are supported.
  58037. */
  58038. readonly isSupported: boolean;
  58039. /**
  58040. * Updates the current state of the effect
  58041. * @hidden
  58042. */
  58043. _update(): void;
  58044. /**
  58045. * Attaches the effect on cameras
  58046. * @param cameras The camera to attach to.
  58047. * @hidden
  58048. */
  58049. _attachCameras(cameras: Camera): void;
  58050. /**
  58051. * Attaches the effect on cameras
  58052. * @param cameras The camera to attach to.
  58053. * @hidden
  58054. */
  58055. _attachCameras(cameras: Camera[]): void;
  58056. /**
  58057. * Detaches the effect on cameras
  58058. * @param cameras The camera to detatch from.
  58059. * @hidden
  58060. */
  58061. _detachCameras(cameras: Camera): void;
  58062. /**
  58063. * Detatches the effect on cameras
  58064. * @param cameras The camera to detatch from.
  58065. * @hidden
  58066. */
  58067. _detachCameras(cameras: Camera[]): void;
  58068. /**
  58069. * Enables the effect on given cameras
  58070. * @param cameras The camera to enable.
  58071. * @hidden
  58072. */
  58073. _enable(cameras: Camera): void;
  58074. /**
  58075. * Enables the effect on given cameras
  58076. * @param cameras The camera to enable.
  58077. * @hidden
  58078. */
  58079. _enable(cameras: Nullable<Camera[]>): void;
  58080. /**
  58081. * Disables the effect on the given cameras
  58082. * @param cameras The camera to disable.
  58083. * @hidden
  58084. */
  58085. _disable(cameras: Camera): void;
  58086. /**
  58087. * Disables the effect on the given cameras
  58088. * @param cameras The camera to disable.
  58089. * @hidden
  58090. */
  58091. _disable(cameras: Nullable<Camera[]>): void;
  58092. /**
  58093. * Gets a list of the post processes contained in the effect.
  58094. * @param camera The camera to get the post processes on.
  58095. * @returns The list of the post processes in the effect.
  58096. */
  58097. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  58098. }
  58099. }
  58100. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  58101. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58102. /** @hidden */
  58103. export var extractHighlightsPixelShader: {
  58104. name: string;
  58105. shader: string;
  58106. };
  58107. }
  58108. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  58109. import { Nullable } from "babylonjs/types";
  58110. import { Camera } from "babylonjs/Cameras/camera";
  58111. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58112. import { Engine } from "babylonjs/Engines/engine";
  58113. import "babylonjs/Shaders/extractHighlights.fragment";
  58114. /**
  58115. * 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.
  58116. */
  58117. export class ExtractHighlightsPostProcess extends PostProcess {
  58118. /**
  58119. * The luminance threshold, pixels below this value will be set to black.
  58120. */
  58121. threshold: number;
  58122. /** @hidden */
  58123. _exposure: number;
  58124. /**
  58125. * Post process which has the input texture to be used when performing highlight extraction
  58126. * @hidden
  58127. */
  58128. _inputPostProcess: Nullable<PostProcess>;
  58129. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58130. }
  58131. }
  58132. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  58133. /** @hidden */
  58134. export var bloomMergePixelShader: {
  58135. name: string;
  58136. shader: string;
  58137. };
  58138. }
  58139. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  58140. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58141. import { Nullable } from "babylonjs/types";
  58142. import { Engine } from "babylonjs/Engines/engine";
  58143. import { Camera } from "babylonjs/Cameras/camera";
  58144. import "babylonjs/Shaders/bloomMerge.fragment";
  58145. /**
  58146. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58147. */
  58148. export class BloomMergePostProcess extends PostProcess {
  58149. /** Weight of the bloom to be added to the original input. */
  58150. weight: number;
  58151. /**
  58152. * Creates a new instance of @see BloomMergePostProcess
  58153. * @param name The name of the effect.
  58154. * @param originalFromInput Post process which's input will be used for the merge.
  58155. * @param blurred Blurred highlights post process which's output will be used.
  58156. * @param weight Weight of the bloom to be added to the original input.
  58157. * @param options The required width/height ratio to downsize to before computing the render pass.
  58158. * @param camera The camera to apply the render pass to.
  58159. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58160. * @param engine The engine which the post process will be applied. (default: current engine)
  58161. * @param reusable If the post process can be reused on the same frame. (default: false)
  58162. * @param textureType Type of textures used when performing the post process. (default: 0)
  58163. * @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)
  58164. */
  58165. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  58166. /** Weight of the bloom to be added to the original input. */
  58167. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58168. }
  58169. }
  58170. declare module "babylonjs/PostProcesses/bloomEffect" {
  58171. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58172. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58173. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  58174. import { Camera } from "babylonjs/Cameras/camera";
  58175. import { Scene } from "babylonjs/scene";
  58176. /**
  58177. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  58178. */
  58179. export class BloomEffect extends PostProcessRenderEffect {
  58180. private bloomScale;
  58181. /**
  58182. * @hidden Internal
  58183. */
  58184. _effects: Array<PostProcess>;
  58185. /**
  58186. * @hidden Internal
  58187. */
  58188. _downscale: ExtractHighlightsPostProcess;
  58189. private _blurX;
  58190. private _blurY;
  58191. private _merge;
  58192. /**
  58193. * The luminance threshold to find bright areas of the image to bloom.
  58194. */
  58195. threshold: number;
  58196. /**
  58197. * The strength of the bloom.
  58198. */
  58199. weight: number;
  58200. /**
  58201. * Specifies the size of the bloom blur kernel, relative to the final output size
  58202. */
  58203. kernel: number;
  58204. /**
  58205. * Creates a new instance of @see BloomEffect
  58206. * @param scene The scene the effect belongs to.
  58207. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  58208. * @param bloomKernel The size of the kernel to be used when applying the blur.
  58209. * @param bloomWeight The the strength of bloom.
  58210. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58211. * @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)
  58212. */
  58213. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  58214. /**
  58215. * Disposes each of the internal effects for a given camera.
  58216. * @param camera The camera to dispose the effect on.
  58217. */
  58218. disposeEffects(camera: Camera): void;
  58219. /**
  58220. * @hidden Internal
  58221. */
  58222. _updateEffects(): void;
  58223. /**
  58224. * Internal
  58225. * @returns if all the contained post processes are ready.
  58226. * @hidden
  58227. */
  58228. _isReady(): boolean;
  58229. }
  58230. }
  58231. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  58232. /** @hidden */
  58233. export var chromaticAberrationPixelShader: {
  58234. name: string;
  58235. shader: string;
  58236. };
  58237. }
  58238. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  58239. import { Vector2 } from "babylonjs/Maths/math";
  58240. import { Nullable } from "babylonjs/types";
  58241. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58242. import { Camera } from "babylonjs/Cameras/camera";
  58243. import { Engine } from "babylonjs/Engines/engine";
  58244. import "babylonjs/Shaders/chromaticAberration.fragment";
  58245. /**
  58246. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  58247. */
  58248. export class ChromaticAberrationPostProcess extends PostProcess {
  58249. /**
  58250. * The amount of seperation of rgb channels (default: 30)
  58251. */
  58252. aberrationAmount: number;
  58253. /**
  58254. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  58255. */
  58256. radialIntensity: number;
  58257. /**
  58258. * 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))
  58259. */
  58260. direction: Vector2;
  58261. /**
  58262. * 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))
  58263. */
  58264. centerPosition: Vector2;
  58265. /**
  58266. * Creates a new instance ChromaticAberrationPostProcess
  58267. * @param name The name of the effect.
  58268. * @param screenWidth The width of the screen to apply the effect on.
  58269. * @param screenHeight The height of the screen to apply the effect on.
  58270. * @param options The required width/height ratio to downsize to before computing the render pass.
  58271. * @param camera The camera to apply the render pass to.
  58272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58273. * @param engine The engine which the post process will be applied. (default: current engine)
  58274. * @param reusable If the post process can be reused on the same frame. (default: false)
  58275. * @param textureType Type of textures used when performing the post process. (default: 0)
  58276. * @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)
  58277. */
  58278. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58279. }
  58280. }
  58281. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  58282. /** @hidden */
  58283. export var circleOfConfusionPixelShader: {
  58284. name: string;
  58285. shader: string;
  58286. };
  58287. }
  58288. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  58289. import { Nullable } from "babylonjs/types";
  58290. import { Engine } from "babylonjs/Engines/engine";
  58291. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58292. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58293. import { Camera } from "babylonjs/Cameras/camera";
  58294. import "babylonjs/Shaders/circleOfConfusion.fragment";
  58295. /**
  58296. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  58297. */
  58298. export class CircleOfConfusionPostProcess extends PostProcess {
  58299. /**
  58300. * 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.
  58301. */
  58302. lensSize: number;
  58303. /**
  58304. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58305. */
  58306. fStop: number;
  58307. /**
  58308. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58309. */
  58310. focusDistance: number;
  58311. /**
  58312. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  58313. */
  58314. focalLength: number;
  58315. private _depthTexture;
  58316. /**
  58317. * Creates a new instance CircleOfConfusionPostProcess
  58318. * @param name The name of the effect.
  58319. * @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.
  58320. * @param options The required width/height ratio to downsize to before computing the render pass.
  58321. * @param camera The camera to apply the render pass to.
  58322. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58323. * @param engine The engine which the post process will be applied. (default: current engine)
  58324. * @param reusable If the post process can be reused on the same frame. (default: false)
  58325. * @param textureType Type of textures used when performing the post process. (default: 0)
  58326. * @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)
  58327. */
  58328. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58329. /**
  58330. * 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.
  58331. */
  58332. depthTexture: RenderTargetTexture;
  58333. }
  58334. }
  58335. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  58336. /** @hidden */
  58337. export var colorCorrectionPixelShader: {
  58338. name: string;
  58339. shader: string;
  58340. };
  58341. }
  58342. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  58343. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58344. import { Engine } from "babylonjs/Engines/engine";
  58345. import { Camera } from "babylonjs/Cameras/camera";
  58346. import "babylonjs/Shaders/colorCorrection.fragment";
  58347. /**
  58348. *
  58349. * This post-process allows the modification of rendered colors by using
  58350. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58351. *
  58352. * The object needs to be provided an url to a texture containing the color
  58353. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58354. * Use an image editing software to tweak the LUT to match your needs.
  58355. *
  58356. * For an example of a color LUT, see here:
  58357. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58358. * For explanations on color grading, see here:
  58359. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58360. *
  58361. */
  58362. export class ColorCorrectionPostProcess extends PostProcess {
  58363. private _colorTableTexture;
  58364. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58365. }
  58366. }
  58367. declare module "babylonjs/Shaders/convolution.fragment" {
  58368. /** @hidden */
  58369. export var convolutionPixelShader: {
  58370. name: string;
  58371. shader: string;
  58372. };
  58373. }
  58374. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  58375. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58376. import { Nullable } from "babylonjs/types";
  58377. import { Camera } from "babylonjs/Cameras/camera";
  58378. import { Engine } from "babylonjs/Engines/engine";
  58379. import "babylonjs/Shaders/convolution.fragment";
  58380. /**
  58381. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58382. * input texture to perform effects such as edge detection or sharpening
  58383. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58384. */
  58385. export class ConvolutionPostProcess extends PostProcess {
  58386. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58387. kernel: number[];
  58388. /**
  58389. * Creates a new instance ConvolutionPostProcess
  58390. * @param name The name of the effect.
  58391. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58392. * @param options The required width/height ratio to downsize to before computing the render pass.
  58393. * @param camera The camera to apply the render pass to.
  58394. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58395. * @param engine The engine which the post process will be applied. (default: current engine)
  58396. * @param reusable If the post process can be reused on the same frame. (default: false)
  58397. * @param textureType Type of textures used when performing the post process. (default: 0)
  58398. */
  58399. constructor(name: string,
  58400. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58401. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58402. /**
  58403. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58404. */
  58405. static EdgeDetect0Kernel: number[];
  58406. /**
  58407. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58408. */
  58409. static EdgeDetect1Kernel: number[];
  58410. /**
  58411. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58412. */
  58413. static EdgeDetect2Kernel: number[];
  58414. /**
  58415. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58416. */
  58417. static SharpenKernel: number[];
  58418. /**
  58419. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58420. */
  58421. static EmbossKernel: number[];
  58422. /**
  58423. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58424. */
  58425. static GaussianKernel: number[];
  58426. }
  58427. }
  58428. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  58429. import { Nullable } from "babylonjs/types";
  58430. import { Vector2 } from "babylonjs/Maths/math";
  58431. import { Camera } from "babylonjs/Cameras/camera";
  58432. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58433. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  58434. import { Engine } from "babylonjs/Engines/engine";
  58435. import { Scene } from "babylonjs/scene";
  58436. /**
  58437. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58438. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58439. * based on samples that have a large difference in distance than the center pixel.
  58440. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58441. */
  58442. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58443. direction: Vector2;
  58444. /**
  58445. * Creates a new instance CircleOfConfusionPostProcess
  58446. * @param name The name of the effect.
  58447. * @param scene The scene the effect belongs to.
  58448. * @param direction The direction the blur should be applied.
  58449. * @param kernel The size of the kernel used to blur.
  58450. * @param options The required width/height ratio to downsize to before computing the render pass.
  58451. * @param camera The camera to apply the render pass to.
  58452. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58453. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58455. * @param engine The engine which the post process will be applied. (default: current engine)
  58456. * @param reusable If the post process can be reused on the same frame. (default: false)
  58457. * @param textureType Type of textures used when performing the post process. (default: 0)
  58458. * @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)
  58459. */
  58460. 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);
  58461. }
  58462. }
  58463. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  58464. /** @hidden */
  58465. export var depthOfFieldMergePixelShader: {
  58466. name: string;
  58467. shader: string;
  58468. };
  58469. }
  58470. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  58471. import { Nullable } from "babylonjs/types";
  58472. import { Camera } from "babylonjs/Cameras/camera";
  58473. import { Effect } from "babylonjs/Materials/effect";
  58474. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58475. import { Engine } from "babylonjs/Engines/engine";
  58476. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  58477. /**
  58478. * Options to be set when merging outputs from the default pipeline.
  58479. */
  58480. export class DepthOfFieldMergePostProcessOptions {
  58481. /**
  58482. * The original image to merge on top of
  58483. */
  58484. originalFromInput: PostProcess;
  58485. /**
  58486. * Parameters to perform the merge of the depth of field effect
  58487. */
  58488. depthOfField?: {
  58489. circleOfConfusion: PostProcess;
  58490. blurSteps: Array<PostProcess>;
  58491. };
  58492. /**
  58493. * Parameters to perform the merge of bloom effect
  58494. */
  58495. bloom?: {
  58496. blurred: PostProcess;
  58497. weight: number;
  58498. };
  58499. }
  58500. /**
  58501. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58502. */
  58503. export class DepthOfFieldMergePostProcess extends PostProcess {
  58504. private blurSteps;
  58505. /**
  58506. * Creates a new instance of DepthOfFieldMergePostProcess
  58507. * @param name The name of the effect.
  58508. * @param originalFromInput Post process which's input will be used for the merge.
  58509. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58510. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58511. * @param options The required width/height ratio to downsize to before computing the render pass.
  58512. * @param camera The camera to apply the render pass to.
  58513. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58514. * @param engine The engine which the post process will be applied. (default: current engine)
  58515. * @param reusable If the post process can be reused on the same frame. (default: false)
  58516. * @param textureType Type of textures used when performing the post process. (default: 0)
  58517. * @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)
  58518. */
  58519. 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);
  58520. /**
  58521. * Updates the effect with the current post process compile time values and recompiles the shader.
  58522. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58523. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58524. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58525. * @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
  58526. * @param onCompiled Called when the shader has been compiled.
  58527. * @param onError Called if there is an error when compiling a shader.
  58528. */
  58529. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58530. }
  58531. }
  58532. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  58533. import { Nullable } from "babylonjs/types";
  58534. import { Camera } from "babylonjs/Cameras/camera";
  58535. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58536. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58537. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58538. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  58539. import { Scene } from "babylonjs/scene";
  58540. /**
  58541. * Specifies the level of max blur that should be applied when using the depth of field effect
  58542. */
  58543. export enum DepthOfFieldEffectBlurLevel {
  58544. /**
  58545. * Subtle blur
  58546. */
  58547. Low = 0,
  58548. /**
  58549. * Medium blur
  58550. */
  58551. Medium = 1,
  58552. /**
  58553. * Large blur
  58554. */
  58555. High = 2
  58556. }
  58557. /**
  58558. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58559. */
  58560. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58561. private _circleOfConfusion;
  58562. /**
  58563. * @hidden Internal, blurs from high to low
  58564. */
  58565. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58566. private _depthOfFieldBlurY;
  58567. private _dofMerge;
  58568. /**
  58569. * @hidden Internal post processes in depth of field effect
  58570. */
  58571. _effects: Array<PostProcess>;
  58572. /**
  58573. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58574. */
  58575. focalLength: number;
  58576. /**
  58577. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58578. */
  58579. fStop: number;
  58580. /**
  58581. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58582. */
  58583. focusDistance: number;
  58584. /**
  58585. * 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.
  58586. */
  58587. lensSize: number;
  58588. /**
  58589. * Creates a new instance DepthOfFieldEffect
  58590. * @param scene The scene the effect belongs to.
  58591. * @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.
  58592. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58593. * @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)
  58594. */
  58595. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58596. /**
  58597. * Get the current class name of the current effet
  58598. * @returns "DepthOfFieldEffect"
  58599. */
  58600. getClassName(): string;
  58601. /**
  58602. * 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.
  58603. */
  58604. depthTexture: RenderTargetTexture;
  58605. /**
  58606. * Disposes each of the internal effects for a given camera.
  58607. * @param camera The camera to dispose the effect on.
  58608. */
  58609. disposeEffects(camera: Camera): void;
  58610. /**
  58611. * @hidden Internal
  58612. */
  58613. _updateEffects(): void;
  58614. /**
  58615. * Internal
  58616. * @returns if all the contained post processes are ready.
  58617. * @hidden
  58618. */
  58619. _isReady(): boolean;
  58620. }
  58621. }
  58622. declare module "babylonjs/Shaders/displayPass.fragment" {
  58623. /** @hidden */
  58624. export var displayPassPixelShader: {
  58625. name: string;
  58626. shader: string;
  58627. };
  58628. }
  58629. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  58630. import { Nullable } from "babylonjs/types";
  58631. import { Camera } from "babylonjs/Cameras/camera";
  58632. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58633. import { Engine } from "babylonjs/Engines/engine";
  58634. import "babylonjs/Shaders/displayPass.fragment";
  58635. /**
  58636. * DisplayPassPostProcess which produces an output the same as it's input
  58637. */
  58638. export class DisplayPassPostProcess extends PostProcess {
  58639. /**
  58640. * Creates the DisplayPassPostProcess
  58641. * @param name The name of the effect.
  58642. * @param options The required width/height ratio to downsize to before computing the render pass.
  58643. * @param camera The camera to apply the render pass to.
  58644. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58645. * @param engine The engine which the post process will be applied. (default: current engine)
  58646. * @param reusable If the post process can be reused on the same frame. (default: false)
  58647. */
  58648. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58649. }
  58650. }
  58651. declare module "babylonjs/Shaders/filter.fragment" {
  58652. /** @hidden */
  58653. export var filterPixelShader: {
  58654. name: string;
  58655. shader: string;
  58656. };
  58657. }
  58658. declare module "babylonjs/PostProcesses/filterPostProcess" {
  58659. import { Nullable } from "babylonjs/types";
  58660. import { Matrix } from "babylonjs/Maths/math";
  58661. import { Camera } from "babylonjs/Cameras/camera";
  58662. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58663. import { Engine } from "babylonjs/Engines/engine";
  58664. import "babylonjs/Shaders/filter.fragment";
  58665. /**
  58666. * Applies a kernel filter to the image
  58667. */
  58668. export class FilterPostProcess extends PostProcess {
  58669. /** The matrix to be applied to the image */
  58670. kernelMatrix: Matrix;
  58671. /**
  58672. *
  58673. * @param name The name of the effect.
  58674. * @param kernelMatrix The matrix to be applied to the image
  58675. * @param options The required width/height ratio to downsize to before computing the render pass.
  58676. * @param camera The camera to apply the render pass to.
  58677. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58678. * @param engine The engine which the post process will be applied. (default: current engine)
  58679. * @param reusable If the post process can be reused on the same frame. (default: false)
  58680. */
  58681. constructor(name: string,
  58682. /** The matrix to be applied to the image */
  58683. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58684. }
  58685. }
  58686. declare module "babylonjs/Shaders/fxaa.fragment" {
  58687. /** @hidden */
  58688. export var fxaaPixelShader: {
  58689. name: string;
  58690. shader: string;
  58691. };
  58692. }
  58693. declare module "babylonjs/Shaders/fxaa.vertex" {
  58694. /** @hidden */
  58695. export var fxaaVertexShader: {
  58696. name: string;
  58697. shader: string;
  58698. };
  58699. }
  58700. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  58701. import { Nullable } from "babylonjs/types";
  58702. import { Camera } from "babylonjs/Cameras/camera";
  58703. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58704. import { Engine } from "babylonjs/Engines/engine";
  58705. import "babylonjs/Shaders/fxaa.fragment";
  58706. import "babylonjs/Shaders/fxaa.vertex";
  58707. /**
  58708. * Fxaa post process
  58709. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58710. */
  58711. export class FxaaPostProcess extends PostProcess {
  58712. /** @hidden */
  58713. texelWidth: number;
  58714. /** @hidden */
  58715. texelHeight: number;
  58716. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58717. private _getDefines;
  58718. }
  58719. }
  58720. declare module "babylonjs/Shaders/grain.fragment" {
  58721. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58722. /** @hidden */
  58723. export var grainPixelShader: {
  58724. name: string;
  58725. shader: string;
  58726. };
  58727. }
  58728. declare module "babylonjs/PostProcesses/grainPostProcess" {
  58729. import { Nullable } from "babylonjs/types";
  58730. import { Camera } from "babylonjs/Cameras/camera";
  58731. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58732. import { Engine } from "babylonjs/Engines/engine";
  58733. import "babylonjs/Shaders/grain.fragment";
  58734. /**
  58735. * The GrainPostProcess adds noise to the image at mid luminance levels
  58736. */
  58737. export class GrainPostProcess extends PostProcess {
  58738. /**
  58739. * The intensity of the grain added (default: 30)
  58740. */
  58741. intensity: number;
  58742. /**
  58743. * If the grain should be randomized on every frame
  58744. */
  58745. animated: boolean;
  58746. /**
  58747. * Creates a new instance of @see GrainPostProcess
  58748. * @param name The name of the effect.
  58749. * @param options The required width/height ratio to downsize to before computing the render pass.
  58750. * @param camera The camera to apply the render pass to.
  58751. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58752. * @param engine The engine which the post process will be applied. (default: current engine)
  58753. * @param reusable If the post process can be reused on the same frame. (default: false)
  58754. * @param textureType Type of textures used when performing the post process. (default: 0)
  58755. * @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)
  58756. */
  58757. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58758. }
  58759. }
  58760. declare module "babylonjs/Shaders/highlights.fragment" {
  58761. /** @hidden */
  58762. export var highlightsPixelShader: {
  58763. name: string;
  58764. shader: string;
  58765. };
  58766. }
  58767. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  58768. import { Nullable } from "babylonjs/types";
  58769. import { Camera } from "babylonjs/Cameras/camera";
  58770. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58771. import { Engine } from "babylonjs/Engines/engine";
  58772. import "babylonjs/Shaders/highlights.fragment";
  58773. /**
  58774. * Extracts highlights from the image
  58775. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58776. */
  58777. export class HighlightsPostProcess extends PostProcess {
  58778. /**
  58779. * Extracts highlights from the image
  58780. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58781. * @param name The name of the effect.
  58782. * @param options The required width/height ratio to downsize to before computing the render pass.
  58783. * @param camera The camera to apply the render pass to.
  58784. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58785. * @param engine The engine which the post process will be applied. (default: current engine)
  58786. * @param reusable If the post process can be reused on the same frame. (default: false)
  58787. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58788. */
  58789. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58790. }
  58791. }
  58792. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  58793. /** @hidden */
  58794. export var mrtFragmentDeclaration: {
  58795. name: string;
  58796. shader: string;
  58797. };
  58798. }
  58799. declare module "babylonjs/Shaders/geometry.fragment" {
  58800. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  58801. /** @hidden */
  58802. export var geometryPixelShader: {
  58803. name: string;
  58804. shader: string;
  58805. };
  58806. }
  58807. declare module "babylonjs/Shaders/geometry.vertex" {
  58808. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58809. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58810. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58811. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58812. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58813. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58814. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58815. /** @hidden */
  58816. export var geometryVertexShader: {
  58817. name: string;
  58818. shader: string;
  58819. };
  58820. }
  58821. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  58822. import { Matrix } from "babylonjs/Maths/math";
  58823. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58824. import { Mesh } from "babylonjs/Meshes/mesh";
  58825. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  58826. import { Effect } from "babylonjs/Materials/effect";
  58827. import { Scene } from "babylonjs/scene";
  58828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58829. import "babylonjs/Shaders/geometry.fragment";
  58830. import "babylonjs/Shaders/geometry.vertex";
  58831. /** @hidden */
  58832. interface ISavedTransformationMatrix {
  58833. world: Matrix;
  58834. viewProjection: Matrix;
  58835. }
  58836. /**
  58837. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58838. */
  58839. export class GeometryBufferRenderer {
  58840. /**
  58841. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58842. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58843. */
  58844. static readonly POSITION_TEXTURE_TYPE: number;
  58845. /**
  58846. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58847. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58848. */
  58849. static readonly VELOCITY_TEXTURE_TYPE: number;
  58850. /**
  58851. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58852. * in order to compute objects velocities when enableVelocity is set to "true"
  58853. * @hidden
  58854. */
  58855. _previousTransformationMatrices: {
  58856. [index: number]: ISavedTransformationMatrix;
  58857. };
  58858. /**
  58859. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58860. * in order to compute objects velocities when enableVelocity is set to "true"
  58861. * @hidden
  58862. */
  58863. _previousBonesTransformationMatrices: {
  58864. [index: number]: Float32Array;
  58865. };
  58866. /**
  58867. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58868. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58869. */
  58870. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58871. private _scene;
  58872. private _multiRenderTarget;
  58873. private _ratio;
  58874. private _enablePosition;
  58875. private _enableVelocity;
  58876. private _positionIndex;
  58877. private _velocityIndex;
  58878. protected _effect: Effect;
  58879. protected _cachedDefines: string;
  58880. /**
  58881. * Set the render list (meshes to be rendered) used in the G buffer.
  58882. */
  58883. renderList: Mesh[];
  58884. /**
  58885. * Gets wether or not G buffer are supported by the running hardware.
  58886. * This requires draw buffer supports
  58887. */
  58888. readonly isSupported: boolean;
  58889. /**
  58890. * Returns the index of the given texture type in the G-Buffer textures array
  58891. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58892. * @returns the index of the given texture type in the G-Buffer textures array
  58893. */
  58894. getTextureIndex(textureType: number): number;
  58895. /**
  58896. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58897. */
  58898. /**
  58899. * Sets whether or not objects positions are enabled for the G buffer.
  58900. */
  58901. enablePosition: boolean;
  58902. /**
  58903. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58904. */
  58905. /**
  58906. * Sets wether or not objects velocities are enabled for the G buffer.
  58907. */
  58908. enableVelocity: boolean;
  58909. /**
  58910. * Gets the scene associated with the buffer.
  58911. */
  58912. readonly scene: Scene;
  58913. /**
  58914. * Gets the ratio used by the buffer during its creation.
  58915. * How big is the buffer related to the main canvas.
  58916. */
  58917. readonly ratio: number;
  58918. /** @hidden */
  58919. static _SceneComponentInitialization: (scene: Scene) => void;
  58920. /**
  58921. * Creates a new G Buffer for the scene
  58922. * @param scene The scene the buffer belongs to
  58923. * @param ratio How big is the buffer related to the main canvas.
  58924. */
  58925. constructor(scene: Scene, ratio?: number);
  58926. /**
  58927. * Checks wether everything is ready to render a submesh to the G buffer.
  58928. * @param subMesh the submesh to check readiness for
  58929. * @param useInstances is the mesh drawn using instance or not
  58930. * @returns true if ready otherwise false
  58931. */
  58932. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58933. /**
  58934. * Gets the current underlying G Buffer.
  58935. * @returns the buffer
  58936. */
  58937. getGBuffer(): MultiRenderTarget;
  58938. /**
  58939. * Gets the number of samples used to render the buffer (anti aliasing).
  58940. */
  58941. /**
  58942. * Sets the number of samples used to render the buffer (anti aliasing).
  58943. */
  58944. samples: number;
  58945. /**
  58946. * Disposes the renderer and frees up associated resources.
  58947. */
  58948. dispose(): void;
  58949. protected _createRenderTargets(): void;
  58950. private _copyBonesTransformationMatrices;
  58951. }
  58952. }
  58953. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  58954. import { Nullable } from "babylonjs/types";
  58955. import { Scene } from "babylonjs/scene";
  58956. import { ISceneComponent } from "babylonjs/sceneComponent";
  58957. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  58958. module "babylonjs/scene" {
  58959. interface Scene {
  58960. /** @hidden (Backing field) */
  58961. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58962. /**
  58963. * Gets or Sets the current geometry buffer associated to the scene.
  58964. */
  58965. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58966. /**
  58967. * Enables a GeometryBufferRender and associates it with the scene
  58968. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58969. * @returns the GeometryBufferRenderer
  58970. */
  58971. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58972. /**
  58973. * Disables the GeometryBufferRender associated with the scene
  58974. */
  58975. disableGeometryBufferRenderer(): void;
  58976. }
  58977. }
  58978. /**
  58979. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58980. * in several rendering techniques.
  58981. */
  58982. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58983. /**
  58984. * The component name helpful to identify the component in the list of scene components.
  58985. */
  58986. readonly name: string;
  58987. /**
  58988. * The scene the component belongs to.
  58989. */
  58990. scene: Scene;
  58991. /**
  58992. * Creates a new instance of the component for the given scene
  58993. * @param scene Defines the scene to register the component in
  58994. */
  58995. constructor(scene: Scene);
  58996. /**
  58997. * Registers the component in a given scene
  58998. */
  58999. register(): void;
  59000. /**
  59001. * Rebuilds the elements related to this component in case of
  59002. * context lost for instance.
  59003. */
  59004. rebuild(): void;
  59005. /**
  59006. * Disposes the component and the associated ressources
  59007. */
  59008. dispose(): void;
  59009. private _gatherRenderTargets;
  59010. }
  59011. }
  59012. declare module "babylonjs/Shaders/motionBlur.fragment" {
  59013. /** @hidden */
  59014. export var motionBlurPixelShader: {
  59015. name: string;
  59016. shader: string;
  59017. };
  59018. }
  59019. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  59020. import { Nullable } from "babylonjs/types";
  59021. import { Camera } from "babylonjs/Cameras/camera";
  59022. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59023. import { Scene } from "babylonjs/scene";
  59024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59025. import "babylonjs/Animations/animatable";
  59026. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  59027. import "babylonjs/Shaders/motionBlur.fragment";
  59028. import { Engine } from "babylonjs/Engines/engine";
  59029. /**
  59030. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  59031. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  59032. * As an example, all you have to do is to create the post-process:
  59033. * var mb = new BABYLON.MotionBlurPostProcess(
  59034. * 'mb', // The name of the effect.
  59035. * scene, // The scene containing the objects to blur according to their velocity.
  59036. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  59037. * camera // The camera to apply the render pass to.
  59038. * );
  59039. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  59040. */
  59041. export class MotionBlurPostProcess extends PostProcess {
  59042. /**
  59043. * Defines how much the image is blurred by the movement. Default value is equal to 1
  59044. */
  59045. motionStrength: number;
  59046. /**
  59047. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  59048. */
  59049. /**
  59050. * Sets the number of iterations to be used for motion blur quality
  59051. */
  59052. motionBlurSamples: number;
  59053. private _motionBlurSamples;
  59054. private _geometryBufferRenderer;
  59055. /**
  59056. * Creates a new instance MotionBlurPostProcess
  59057. * @param name The name of the effect.
  59058. * @param scene The scene containing the objects to blur according to their velocity.
  59059. * @param options The required width/height ratio to downsize to before computing the render pass.
  59060. * @param camera The camera to apply the render pass to.
  59061. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59062. * @param engine The engine which the post process will be applied. (default: current engine)
  59063. * @param reusable If the post process can be reused on the same frame. (default: false)
  59064. * @param textureType Type of textures used when performing the post process. (default: 0)
  59065. * @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)
  59066. */
  59067. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59068. /**
  59069. * Excludes the given skinned mesh from computing bones velocities.
  59070. * 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.
  59071. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  59072. */
  59073. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59074. /**
  59075. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  59076. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  59077. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  59078. */
  59079. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59080. /**
  59081. * Disposes the post process.
  59082. * @param camera The camera to dispose the post process on.
  59083. */
  59084. dispose(camera?: Camera): void;
  59085. }
  59086. }
  59087. declare module "babylonjs/Shaders/refraction.fragment" {
  59088. /** @hidden */
  59089. export var refractionPixelShader: {
  59090. name: string;
  59091. shader: string;
  59092. };
  59093. }
  59094. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  59095. import { Color3 } from "babylonjs/Maths/math";
  59096. import { Camera } from "babylonjs/Cameras/camera";
  59097. import { Texture } from "babylonjs/Materials/Textures/texture";
  59098. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59099. import { Engine } from "babylonjs/Engines/engine";
  59100. import "babylonjs/Shaders/refraction.fragment";
  59101. /**
  59102. * Post process which applies a refractin texture
  59103. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59104. */
  59105. export class RefractionPostProcess extends PostProcess {
  59106. /** the base color of the refraction (used to taint the rendering) */
  59107. color: Color3;
  59108. /** simulated refraction depth */
  59109. depth: number;
  59110. /** the coefficient of the base color (0 to remove base color tainting) */
  59111. colorLevel: number;
  59112. private _refTexture;
  59113. private _ownRefractionTexture;
  59114. /**
  59115. * Gets or sets the refraction texture
  59116. * Please note that you are responsible for disposing the texture if you set it manually
  59117. */
  59118. refractionTexture: Texture;
  59119. /**
  59120. * Initializes the RefractionPostProcess
  59121. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59122. * @param name The name of the effect.
  59123. * @param refractionTextureUrl Url of the refraction texture to use
  59124. * @param color the base color of the refraction (used to taint the rendering)
  59125. * @param depth simulated refraction depth
  59126. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  59127. * @param camera The camera to apply the render pass to.
  59128. * @param options The required width/height ratio to downsize to before computing the render pass.
  59129. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59130. * @param engine The engine which the post process will be applied. (default: current engine)
  59131. * @param reusable If the post process can be reused on the same frame. (default: false)
  59132. */
  59133. constructor(name: string, refractionTextureUrl: string,
  59134. /** the base color of the refraction (used to taint the rendering) */
  59135. color: Color3,
  59136. /** simulated refraction depth */
  59137. depth: number,
  59138. /** the coefficient of the base color (0 to remove base color tainting) */
  59139. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59140. /**
  59141. * Disposes of the post process
  59142. * @param camera Camera to dispose post process on
  59143. */
  59144. dispose(camera: Camera): void;
  59145. }
  59146. }
  59147. declare module "babylonjs/Shaders/sharpen.fragment" {
  59148. /** @hidden */
  59149. export var sharpenPixelShader: {
  59150. name: string;
  59151. shader: string;
  59152. };
  59153. }
  59154. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  59155. import { Nullable } from "babylonjs/types";
  59156. import { Camera } from "babylonjs/Cameras/camera";
  59157. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59158. import "babylonjs/Shaders/sharpen.fragment";
  59159. import { Engine } from "babylonjs/Engines/engine";
  59160. /**
  59161. * The SharpenPostProcess applies a sharpen kernel to every pixel
  59162. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59163. */
  59164. export class SharpenPostProcess extends PostProcess {
  59165. /**
  59166. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  59167. */
  59168. colorAmount: number;
  59169. /**
  59170. * How much sharpness should be applied (default: 0.3)
  59171. */
  59172. edgeAmount: number;
  59173. /**
  59174. * Creates a new instance ConvolutionPostProcess
  59175. * @param name The name of the effect.
  59176. * @param options The required width/height ratio to downsize to before computing the render pass.
  59177. * @param camera The camera to apply the render pass to.
  59178. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59179. * @param engine The engine which the post process will be applied. (default: current engine)
  59180. * @param reusable If the post process can be reused on the same frame. (default: false)
  59181. * @param textureType Type of textures used when performing the post process. (default: 0)
  59182. * @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)
  59183. */
  59184. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59185. }
  59186. }
  59187. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  59188. import { Nullable } from "babylonjs/types";
  59189. import { Camera } from "babylonjs/Cameras/camera";
  59190. import { Engine } from "babylonjs/Engines/engine";
  59191. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59192. import { IInspectable } from "babylonjs/Misc/iInspectable";
  59193. /**
  59194. * PostProcessRenderPipeline
  59195. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59196. */
  59197. export class PostProcessRenderPipeline {
  59198. private engine;
  59199. private _renderEffects;
  59200. private _renderEffectsForIsolatedPass;
  59201. /**
  59202. * List of inspectable custom properties (used by the Inspector)
  59203. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  59204. */
  59205. inspectableCustomProperties: IInspectable[];
  59206. /**
  59207. * @hidden
  59208. */
  59209. protected _cameras: Camera[];
  59210. /** @hidden */
  59211. _name: string;
  59212. /**
  59213. * Gets pipeline name
  59214. */
  59215. readonly name: string;
  59216. /**
  59217. * Initializes a PostProcessRenderPipeline
  59218. * @param engine engine to add the pipeline to
  59219. * @param name name of the pipeline
  59220. */
  59221. constructor(engine: Engine, name: string);
  59222. /**
  59223. * Gets the class name
  59224. * @returns "PostProcessRenderPipeline"
  59225. */
  59226. getClassName(): string;
  59227. /**
  59228. * If all the render effects in the pipeline are supported
  59229. */
  59230. readonly isSupported: boolean;
  59231. /**
  59232. * Adds an effect to the pipeline
  59233. * @param renderEffect the effect to add
  59234. */
  59235. addEffect(renderEffect: PostProcessRenderEffect): void;
  59236. /** @hidden */
  59237. _rebuild(): void;
  59238. /** @hidden */
  59239. _enableEffect(renderEffectName: string, cameras: Camera): void;
  59240. /** @hidden */
  59241. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  59242. /** @hidden */
  59243. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59244. /** @hidden */
  59245. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59246. /** @hidden */
  59247. _attachCameras(cameras: Camera, unique: boolean): void;
  59248. /** @hidden */
  59249. _attachCameras(cameras: Camera[], unique: boolean): void;
  59250. /** @hidden */
  59251. _detachCameras(cameras: Camera): void;
  59252. /** @hidden */
  59253. _detachCameras(cameras: Nullable<Camera[]>): void;
  59254. /** @hidden */
  59255. _update(): void;
  59256. /** @hidden */
  59257. _reset(): void;
  59258. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  59259. /**
  59260. * Disposes of the pipeline
  59261. */
  59262. dispose(): void;
  59263. }
  59264. }
  59265. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  59266. import { Camera } from "babylonjs/Cameras/camera";
  59267. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59268. /**
  59269. * PostProcessRenderPipelineManager class
  59270. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59271. */
  59272. export class PostProcessRenderPipelineManager {
  59273. private _renderPipelines;
  59274. /**
  59275. * Initializes a PostProcessRenderPipelineManager
  59276. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59277. */
  59278. constructor();
  59279. /**
  59280. * Gets the list of supported render pipelines
  59281. */
  59282. readonly supportedPipelines: PostProcessRenderPipeline[];
  59283. /**
  59284. * Adds a pipeline to the manager
  59285. * @param renderPipeline The pipeline to add
  59286. */
  59287. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  59288. /**
  59289. * Attaches a camera to the pipeline
  59290. * @param renderPipelineName The name of the pipeline to attach to
  59291. * @param cameras the camera to attach
  59292. * @param unique if the camera can be attached multiple times to the pipeline
  59293. */
  59294. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  59295. /**
  59296. * Detaches a camera from the pipeline
  59297. * @param renderPipelineName The name of the pipeline to detach from
  59298. * @param cameras the camera to detach
  59299. */
  59300. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59301. /**
  59302. * Enables an effect by name on a pipeline
  59303. * @param renderPipelineName the name of the pipeline to enable the effect in
  59304. * @param renderEffectName the name of the effect to enable
  59305. * @param cameras the cameras that the effect should be enabled on
  59306. */
  59307. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59308. /**
  59309. * Disables an effect by name on a pipeline
  59310. * @param renderPipelineName the name of the pipeline to disable the effect in
  59311. * @param renderEffectName the name of the effect to disable
  59312. * @param cameras the cameras that the effect should be disabled on
  59313. */
  59314. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59315. /**
  59316. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59317. */
  59318. update(): void;
  59319. /** @hidden */
  59320. _rebuild(): void;
  59321. /**
  59322. * Disposes of the manager and pipelines
  59323. */
  59324. dispose(): void;
  59325. }
  59326. }
  59327. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  59328. import { ISceneComponent } from "babylonjs/sceneComponent";
  59329. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  59330. import { Scene } from "babylonjs/scene";
  59331. module "babylonjs/scene" {
  59332. interface Scene {
  59333. /** @hidden (Backing field) */
  59334. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59335. /**
  59336. * Gets the postprocess render pipeline manager
  59337. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59338. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59339. */
  59340. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59341. }
  59342. }
  59343. /**
  59344. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59345. */
  59346. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59347. /**
  59348. * The component name helpfull to identify the component in the list of scene components.
  59349. */
  59350. readonly name: string;
  59351. /**
  59352. * The scene the component belongs to.
  59353. */
  59354. scene: Scene;
  59355. /**
  59356. * Creates a new instance of the component for the given scene
  59357. * @param scene Defines the scene to register the component in
  59358. */
  59359. constructor(scene: Scene);
  59360. /**
  59361. * Registers the component in a given scene
  59362. */
  59363. register(): void;
  59364. /**
  59365. * Rebuilds the elements related to this component in case of
  59366. * context lost for instance.
  59367. */
  59368. rebuild(): void;
  59369. /**
  59370. * Disposes the component and the associated ressources
  59371. */
  59372. dispose(): void;
  59373. private _gatherRenderTargets;
  59374. }
  59375. }
  59376. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  59377. import { Nullable } from "babylonjs/types";
  59378. import { IAnimatable } from "babylonjs/Misc/tools";
  59379. import { Camera } from "babylonjs/Cameras/camera";
  59380. import { IDisposable } from "babylonjs/scene";
  59381. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  59382. import { Scene } from "babylonjs/scene";
  59383. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  59384. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  59385. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  59386. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  59387. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59388. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59389. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  59390. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  59391. import { Animation } from "babylonjs/Animations/animation";
  59392. /**
  59393. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59394. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59395. */
  59396. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59397. private _scene;
  59398. private _camerasToBeAttached;
  59399. /**
  59400. * ID of the sharpen post process,
  59401. */
  59402. private readonly SharpenPostProcessId;
  59403. /**
  59404. * @ignore
  59405. * ID of the image processing post process;
  59406. */
  59407. readonly ImageProcessingPostProcessId: string;
  59408. /**
  59409. * @ignore
  59410. * ID of the Fast Approximate Anti-Aliasing post process;
  59411. */
  59412. readonly FxaaPostProcessId: string;
  59413. /**
  59414. * ID of the chromatic aberration post process,
  59415. */
  59416. private readonly ChromaticAberrationPostProcessId;
  59417. /**
  59418. * ID of the grain post process
  59419. */
  59420. private readonly GrainPostProcessId;
  59421. /**
  59422. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59423. */
  59424. sharpen: SharpenPostProcess;
  59425. private _sharpenEffect;
  59426. private bloom;
  59427. /**
  59428. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59429. */
  59430. depthOfField: DepthOfFieldEffect;
  59431. /**
  59432. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59433. */
  59434. fxaa: FxaaPostProcess;
  59435. /**
  59436. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59437. */
  59438. imageProcessing: ImageProcessingPostProcess;
  59439. /**
  59440. * Chromatic aberration post process which will shift rgb colors in the image
  59441. */
  59442. chromaticAberration: ChromaticAberrationPostProcess;
  59443. private _chromaticAberrationEffect;
  59444. /**
  59445. * Grain post process which add noise to the image
  59446. */
  59447. grain: GrainPostProcess;
  59448. private _grainEffect;
  59449. /**
  59450. * Glow post process which adds a glow to emissive areas of the image
  59451. */
  59452. private _glowLayer;
  59453. /**
  59454. * Animations which can be used to tweak settings over a period of time
  59455. */
  59456. animations: Animation[];
  59457. private _imageProcessingConfigurationObserver;
  59458. private _sharpenEnabled;
  59459. private _bloomEnabled;
  59460. private _depthOfFieldEnabled;
  59461. private _depthOfFieldBlurLevel;
  59462. private _fxaaEnabled;
  59463. private _imageProcessingEnabled;
  59464. private _defaultPipelineTextureType;
  59465. private _bloomScale;
  59466. private _chromaticAberrationEnabled;
  59467. private _grainEnabled;
  59468. private _buildAllowed;
  59469. /**
  59470. * Gets active scene
  59471. */
  59472. readonly scene: Scene;
  59473. /**
  59474. * Enable or disable the sharpen process from the pipeline
  59475. */
  59476. sharpenEnabled: boolean;
  59477. private _resizeObserver;
  59478. private _hardwareScaleLevel;
  59479. private _bloomKernel;
  59480. /**
  59481. * Specifies the size of the bloom blur kernel, relative to the final output size
  59482. */
  59483. bloomKernel: number;
  59484. /**
  59485. * Specifies the weight of the bloom in the final rendering
  59486. */
  59487. private _bloomWeight;
  59488. /**
  59489. * Specifies the luma threshold for the area that will be blurred by the bloom
  59490. */
  59491. private _bloomThreshold;
  59492. private _hdr;
  59493. /**
  59494. * The strength of the bloom.
  59495. */
  59496. bloomWeight: number;
  59497. /**
  59498. * The strength of the bloom.
  59499. */
  59500. bloomThreshold: number;
  59501. /**
  59502. * The scale of the bloom, lower value will provide better performance.
  59503. */
  59504. bloomScale: number;
  59505. /**
  59506. * Enable or disable the bloom from the pipeline
  59507. */
  59508. bloomEnabled: boolean;
  59509. private _rebuildBloom;
  59510. /**
  59511. * If the depth of field is enabled.
  59512. */
  59513. depthOfFieldEnabled: boolean;
  59514. /**
  59515. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59516. */
  59517. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59518. /**
  59519. * If the anti aliasing is enabled.
  59520. */
  59521. fxaaEnabled: boolean;
  59522. private _samples;
  59523. /**
  59524. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59525. */
  59526. samples: number;
  59527. /**
  59528. * If image processing is enabled.
  59529. */
  59530. imageProcessingEnabled: boolean;
  59531. /**
  59532. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59533. */
  59534. glowLayerEnabled: boolean;
  59535. /**
  59536. * Gets the glow layer (or null if not defined)
  59537. */
  59538. readonly glowLayer: Nullable<GlowLayer>;
  59539. /**
  59540. * Enable or disable the chromaticAberration process from the pipeline
  59541. */
  59542. chromaticAberrationEnabled: boolean;
  59543. /**
  59544. * Enable or disable the grain process from the pipeline
  59545. */
  59546. grainEnabled: boolean;
  59547. /**
  59548. * @constructor
  59549. * @param name - The rendering pipeline name (default: "")
  59550. * @param hdr - If high dynamic range textures should be used (default: true)
  59551. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59552. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59553. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59554. */
  59555. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59556. /**
  59557. * Get the class name
  59558. * @returns "DefaultRenderingPipeline"
  59559. */
  59560. getClassName(): string;
  59561. /**
  59562. * Force the compilation of the entire pipeline.
  59563. */
  59564. prepare(): void;
  59565. private _hasCleared;
  59566. private _prevPostProcess;
  59567. private _prevPrevPostProcess;
  59568. private _setAutoClearAndTextureSharing;
  59569. private _depthOfFieldSceneObserver;
  59570. private _buildPipeline;
  59571. private _disposePostProcesses;
  59572. /**
  59573. * Adds a camera to the pipeline
  59574. * @param camera the camera to be added
  59575. */
  59576. addCamera(camera: Camera): void;
  59577. /**
  59578. * Removes a camera from the pipeline
  59579. * @param camera the camera to remove
  59580. */
  59581. removeCamera(camera: Camera): void;
  59582. /**
  59583. * Dispose of the pipeline and stop all post processes
  59584. */
  59585. dispose(): void;
  59586. /**
  59587. * Serialize the rendering pipeline (Used when exporting)
  59588. * @returns the serialized object
  59589. */
  59590. serialize(): any;
  59591. /**
  59592. * Parse the serialized pipeline
  59593. * @param source Source pipeline.
  59594. * @param scene The scene to load the pipeline to.
  59595. * @param rootUrl The URL of the serialized pipeline.
  59596. * @returns An instantiated pipeline from the serialized object.
  59597. */
  59598. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59599. }
  59600. }
  59601. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  59602. /** @hidden */
  59603. export var lensHighlightsPixelShader: {
  59604. name: string;
  59605. shader: string;
  59606. };
  59607. }
  59608. declare module "babylonjs/Shaders/depthOfField.fragment" {
  59609. /** @hidden */
  59610. export var depthOfFieldPixelShader: {
  59611. name: string;
  59612. shader: string;
  59613. };
  59614. }
  59615. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  59616. import { Camera } from "babylonjs/Cameras/camera";
  59617. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59618. import { Scene } from "babylonjs/scene";
  59619. import "babylonjs/Shaders/chromaticAberration.fragment";
  59620. import "babylonjs/Shaders/lensHighlights.fragment";
  59621. import "babylonjs/Shaders/depthOfField.fragment";
  59622. /**
  59623. * BABYLON.JS Chromatic Aberration GLSL Shader
  59624. * Author: Olivier Guyot
  59625. * Separates very slightly R, G and B colors on the edges of the screen
  59626. * Inspired by Francois Tarlier & Martins Upitis
  59627. */
  59628. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59629. /**
  59630. * @ignore
  59631. * The chromatic aberration PostProcess id in the pipeline
  59632. */
  59633. LensChromaticAberrationEffect: string;
  59634. /**
  59635. * @ignore
  59636. * The highlights enhancing PostProcess id in the pipeline
  59637. */
  59638. HighlightsEnhancingEffect: string;
  59639. /**
  59640. * @ignore
  59641. * The depth-of-field PostProcess id in the pipeline
  59642. */
  59643. LensDepthOfFieldEffect: string;
  59644. private _scene;
  59645. private _depthTexture;
  59646. private _grainTexture;
  59647. private _chromaticAberrationPostProcess;
  59648. private _highlightsPostProcess;
  59649. private _depthOfFieldPostProcess;
  59650. private _edgeBlur;
  59651. private _grainAmount;
  59652. private _chromaticAberration;
  59653. private _distortion;
  59654. private _highlightsGain;
  59655. private _highlightsThreshold;
  59656. private _dofDistance;
  59657. private _dofAperture;
  59658. private _dofDarken;
  59659. private _dofPentagon;
  59660. private _blurNoise;
  59661. /**
  59662. * @constructor
  59663. *
  59664. * Effect parameters are as follow:
  59665. * {
  59666. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59667. * edge_blur: number; // from 0 to x (1 for realism)
  59668. * distortion: number; // from 0 to x (1 for realism)
  59669. * grain_amount: number; // from 0 to 1
  59670. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59671. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59672. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59673. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59674. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59675. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59676. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59677. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59678. * }
  59679. * Note: if an effect parameter is unset, effect is disabled
  59680. *
  59681. * @param name The rendering pipeline name
  59682. * @param parameters - An object containing all parameters (see above)
  59683. * @param scene The scene linked to this pipeline
  59684. * @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)
  59685. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59686. */
  59687. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59688. /**
  59689. * Get the class name
  59690. * @returns "LensRenderingPipeline"
  59691. */
  59692. getClassName(): string;
  59693. /**
  59694. * Gets associated scene
  59695. */
  59696. readonly scene: Scene;
  59697. /**
  59698. * Gets or sets the edge blur
  59699. */
  59700. edgeBlur: number;
  59701. /**
  59702. * Gets or sets the grain amount
  59703. */
  59704. grainAmount: number;
  59705. /**
  59706. * Gets or sets the chromatic aberration amount
  59707. */
  59708. chromaticAberration: number;
  59709. /**
  59710. * Gets or sets the depth of field aperture
  59711. */
  59712. dofAperture: number;
  59713. /**
  59714. * Gets or sets the edge distortion
  59715. */
  59716. edgeDistortion: number;
  59717. /**
  59718. * Gets or sets the depth of field distortion
  59719. */
  59720. dofDistortion: number;
  59721. /**
  59722. * Gets or sets the darken out of focus amount
  59723. */
  59724. darkenOutOfFocus: number;
  59725. /**
  59726. * Gets or sets a boolean indicating if blur noise is enabled
  59727. */
  59728. blurNoise: boolean;
  59729. /**
  59730. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59731. */
  59732. pentagonBokeh: boolean;
  59733. /**
  59734. * Gets or sets the highlight grain amount
  59735. */
  59736. highlightsGain: number;
  59737. /**
  59738. * Gets or sets the highlight threshold
  59739. */
  59740. highlightsThreshold: number;
  59741. /**
  59742. * Sets the amount of blur at the edges
  59743. * @param amount blur amount
  59744. */
  59745. setEdgeBlur(amount: number): void;
  59746. /**
  59747. * Sets edge blur to 0
  59748. */
  59749. disableEdgeBlur(): void;
  59750. /**
  59751. * Sets the amout of grain
  59752. * @param amount Amount of grain
  59753. */
  59754. setGrainAmount(amount: number): void;
  59755. /**
  59756. * Set grain amount to 0
  59757. */
  59758. disableGrain(): void;
  59759. /**
  59760. * Sets the chromatic aberration amount
  59761. * @param amount amount of chromatic aberration
  59762. */
  59763. setChromaticAberration(amount: number): void;
  59764. /**
  59765. * Sets chromatic aberration amount to 0
  59766. */
  59767. disableChromaticAberration(): void;
  59768. /**
  59769. * Sets the EdgeDistortion amount
  59770. * @param amount amount of EdgeDistortion
  59771. */
  59772. setEdgeDistortion(amount: number): void;
  59773. /**
  59774. * Sets edge distortion to 0
  59775. */
  59776. disableEdgeDistortion(): void;
  59777. /**
  59778. * Sets the FocusDistance amount
  59779. * @param amount amount of FocusDistance
  59780. */
  59781. setFocusDistance(amount: number): void;
  59782. /**
  59783. * Disables depth of field
  59784. */
  59785. disableDepthOfField(): void;
  59786. /**
  59787. * Sets the Aperture amount
  59788. * @param amount amount of Aperture
  59789. */
  59790. setAperture(amount: number): void;
  59791. /**
  59792. * Sets the DarkenOutOfFocus amount
  59793. * @param amount amount of DarkenOutOfFocus
  59794. */
  59795. setDarkenOutOfFocus(amount: number): void;
  59796. private _pentagonBokehIsEnabled;
  59797. /**
  59798. * Creates a pentagon bokeh effect
  59799. */
  59800. enablePentagonBokeh(): void;
  59801. /**
  59802. * Disables the pentagon bokeh effect
  59803. */
  59804. disablePentagonBokeh(): void;
  59805. /**
  59806. * Enables noise blur
  59807. */
  59808. enableNoiseBlur(): void;
  59809. /**
  59810. * Disables noise blur
  59811. */
  59812. disableNoiseBlur(): void;
  59813. /**
  59814. * Sets the HighlightsGain amount
  59815. * @param amount amount of HighlightsGain
  59816. */
  59817. setHighlightsGain(amount: number): void;
  59818. /**
  59819. * Sets the HighlightsThreshold amount
  59820. * @param amount amount of HighlightsThreshold
  59821. */
  59822. setHighlightsThreshold(amount: number): void;
  59823. /**
  59824. * Disables highlights
  59825. */
  59826. disableHighlights(): void;
  59827. /**
  59828. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59829. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59830. */
  59831. dispose(disableDepthRender?: boolean): void;
  59832. private _createChromaticAberrationPostProcess;
  59833. private _createHighlightsPostProcess;
  59834. private _createDepthOfFieldPostProcess;
  59835. private _createGrainTexture;
  59836. }
  59837. }
  59838. declare module "babylonjs/Shaders/ssao2.fragment" {
  59839. /** @hidden */
  59840. export var ssao2PixelShader: {
  59841. name: string;
  59842. shader: string;
  59843. };
  59844. }
  59845. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  59846. /** @hidden */
  59847. export var ssaoCombinePixelShader: {
  59848. name: string;
  59849. shader: string;
  59850. };
  59851. }
  59852. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  59853. import { Camera } from "babylonjs/Cameras/camera";
  59854. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59855. import { Scene } from "babylonjs/scene";
  59856. import "babylonjs/Shaders/ssao2.fragment";
  59857. import "babylonjs/Shaders/ssaoCombine.fragment";
  59858. /**
  59859. * Render pipeline to produce ssao effect
  59860. */
  59861. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59862. /**
  59863. * @ignore
  59864. * The PassPostProcess id in the pipeline that contains the original scene color
  59865. */
  59866. SSAOOriginalSceneColorEffect: string;
  59867. /**
  59868. * @ignore
  59869. * The SSAO PostProcess id in the pipeline
  59870. */
  59871. SSAORenderEffect: string;
  59872. /**
  59873. * @ignore
  59874. * The horizontal blur PostProcess id in the pipeline
  59875. */
  59876. SSAOBlurHRenderEffect: string;
  59877. /**
  59878. * @ignore
  59879. * The vertical blur PostProcess id in the pipeline
  59880. */
  59881. SSAOBlurVRenderEffect: string;
  59882. /**
  59883. * @ignore
  59884. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59885. */
  59886. SSAOCombineRenderEffect: string;
  59887. /**
  59888. * The output strength of the SSAO post-process. Default value is 1.0.
  59889. */
  59890. totalStrength: number;
  59891. /**
  59892. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59893. */
  59894. maxZ: number;
  59895. /**
  59896. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59897. */
  59898. minZAspect: number;
  59899. private _samples;
  59900. /**
  59901. * Number of samples used for the SSAO calculations. Default value is 8
  59902. */
  59903. samples: number;
  59904. private _textureSamples;
  59905. /**
  59906. * Number of samples to use for antialiasing
  59907. */
  59908. textureSamples: number;
  59909. /**
  59910. * Ratio object used for SSAO ratio and blur ratio
  59911. */
  59912. private _ratio;
  59913. /**
  59914. * Dynamically generated sphere sampler.
  59915. */
  59916. private _sampleSphere;
  59917. /**
  59918. * Blur filter offsets
  59919. */
  59920. private _samplerOffsets;
  59921. private _expensiveBlur;
  59922. /**
  59923. * If bilateral blur should be used
  59924. */
  59925. expensiveBlur: boolean;
  59926. /**
  59927. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59928. */
  59929. radius: number;
  59930. /**
  59931. * The base color of the SSAO post-process
  59932. * The final result is "base + ssao" between [0, 1]
  59933. */
  59934. base: number;
  59935. /**
  59936. * Support test.
  59937. */
  59938. static readonly IsSupported: boolean;
  59939. private _scene;
  59940. private _depthTexture;
  59941. private _normalTexture;
  59942. private _randomTexture;
  59943. private _originalColorPostProcess;
  59944. private _ssaoPostProcess;
  59945. private _blurHPostProcess;
  59946. private _blurVPostProcess;
  59947. private _ssaoCombinePostProcess;
  59948. private _firstUpdate;
  59949. /**
  59950. * Gets active scene
  59951. */
  59952. readonly scene: Scene;
  59953. /**
  59954. * @constructor
  59955. * @param name The rendering pipeline name
  59956. * @param scene The scene linked to this pipeline
  59957. * @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 }
  59958. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59959. */
  59960. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59961. /**
  59962. * Get the class name
  59963. * @returns "SSAO2RenderingPipeline"
  59964. */
  59965. getClassName(): string;
  59966. /**
  59967. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59968. */
  59969. dispose(disableGeometryBufferRenderer?: boolean): void;
  59970. private _createBlurPostProcess;
  59971. /** @hidden */
  59972. _rebuild(): void;
  59973. private _bits;
  59974. private _radicalInverse_VdC;
  59975. private _hammersley;
  59976. private _hemisphereSample_uniform;
  59977. private _generateHemisphere;
  59978. private _createSSAOPostProcess;
  59979. private _createSSAOCombinePostProcess;
  59980. private _createRandomTexture;
  59981. /**
  59982. * Serialize the rendering pipeline (Used when exporting)
  59983. * @returns the serialized object
  59984. */
  59985. serialize(): any;
  59986. /**
  59987. * Parse the serialized pipeline
  59988. * @param source Source pipeline.
  59989. * @param scene The scene to load the pipeline to.
  59990. * @param rootUrl The URL of the serialized pipeline.
  59991. * @returns An instantiated pipeline from the serialized object.
  59992. */
  59993. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59994. }
  59995. }
  59996. declare module "babylonjs/Shaders/ssao.fragment" {
  59997. /** @hidden */
  59998. export var ssaoPixelShader: {
  59999. name: string;
  60000. shader: string;
  60001. };
  60002. }
  60003. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  60004. import { Camera } from "babylonjs/Cameras/camera";
  60005. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60006. import { Scene } from "babylonjs/scene";
  60007. import "babylonjs/Shaders/ssao.fragment";
  60008. import "babylonjs/Shaders/ssaoCombine.fragment";
  60009. /**
  60010. * Render pipeline to produce ssao effect
  60011. */
  60012. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  60013. /**
  60014. * @ignore
  60015. * The PassPostProcess id in the pipeline that contains the original scene color
  60016. */
  60017. SSAOOriginalSceneColorEffect: string;
  60018. /**
  60019. * @ignore
  60020. * The SSAO PostProcess id in the pipeline
  60021. */
  60022. SSAORenderEffect: string;
  60023. /**
  60024. * @ignore
  60025. * The horizontal blur PostProcess id in the pipeline
  60026. */
  60027. SSAOBlurHRenderEffect: string;
  60028. /**
  60029. * @ignore
  60030. * The vertical blur PostProcess id in the pipeline
  60031. */
  60032. SSAOBlurVRenderEffect: string;
  60033. /**
  60034. * @ignore
  60035. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60036. */
  60037. SSAOCombineRenderEffect: string;
  60038. /**
  60039. * The output strength of the SSAO post-process. Default value is 1.0.
  60040. */
  60041. totalStrength: number;
  60042. /**
  60043. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  60044. */
  60045. radius: number;
  60046. /**
  60047. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  60048. * Must not be equal to fallOff and superior to fallOff.
  60049. * Default value is 0.0075
  60050. */
  60051. area: number;
  60052. /**
  60053. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  60054. * Must not be equal to area and inferior to area.
  60055. * Default value is 0.000001
  60056. */
  60057. fallOff: number;
  60058. /**
  60059. * The base color of the SSAO post-process
  60060. * The final result is "base + ssao" between [0, 1]
  60061. */
  60062. base: number;
  60063. private _scene;
  60064. private _depthTexture;
  60065. private _randomTexture;
  60066. private _originalColorPostProcess;
  60067. private _ssaoPostProcess;
  60068. private _blurHPostProcess;
  60069. private _blurVPostProcess;
  60070. private _ssaoCombinePostProcess;
  60071. private _firstUpdate;
  60072. /**
  60073. * Gets active scene
  60074. */
  60075. readonly scene: Scene;
  60076. /**
  60077. * @constructor
  60078. * @param name - The rendering pipeline name
  60079. * @param scene - The scene linked to this pipeline
  60080. * @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 }
  60081. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  60082. */
  60083. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60084. /**
  60085. * Get the class name
  60086. * @returns "SSAORenderingPipeline"
  60087. */
  60088. getClassName(): string;
  60089. /**
  60090. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60091. */
  60092. dispose(disableDepthRender?: boolean): void;
  60093. private _createBlurPostProcess;
  60094. /** @hidden */
  60095. _rebuild(): void;
  60096. private _createSSAOPostProcess;
  60097. private _createSSAOCombinePostProcess;
  60098. private _createRandomTexture;
  60099. }
  60100. }
  60101. declare module "babylonjs/Shaders/standard.fragment" {
  60102. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60103. /** @hidden */
  60104. export var standardPixelShader: {
  60105. name: string;
  60106. shader: string;
  60107. };
  60108. }
  60109. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  60110. import { Nullable } from "babylonjs/types";
  60111. import { IAnimatable } from "babylonjs/Misc/tools";
  60112. import { Camera } from "babylonjs/Cameras/camera";
  60113. import { Texture } from "babylonjs/Materials/Textures/texture";
  60114. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60115. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60116. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  60117. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  60118. import { IDisposable } from "babylonjs/scene";
  60119. import { SpotLight } from "babylonjs/Lights/spotLight";
  60120. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  60121. import { Scene } from "babylonjs/scene";
  60122. import { Animation } from "babylonjs/Animations/animation";
  60123. import "babylonjs/Shaders/standard.fragment";
  60124. /**
  60125. * Standard rendering pipeline
  60126. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60127. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  60128. */
  60129. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60130. /**
  60131. * Public members
  60132. */
  60133. /**
  60134. * Post-process which contains the original scene color before the pipeline applies all the effects
  60135. */
  60136. originalPostProcess: Nullable<PostProcess>;
  60137. /**
  60138. * Post-process used to down scale an image x4
  60139. */
  60140. downSampleX4PostProcess: Nullable<PostProcess>;
  60141. /**
  60142. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  60143. */
  60144. brightPassPostProcess: Nullable<PostProcess>;
  60145. /**
  60146. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  60147. */
  60148. blurHPostProcesses: PostProcess[];
  60149. /**
  60150. * Post-process array storing all the vertical blur post-processes used by the pipeline
  60151. */
  60152. blurVPostProcesses: PostProcess[];
  60153. /**
  60154. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  60155. */
  60156. textureAdderPostProcess: Nullable<PostProcess>;
  60157. /**
  60158. * Post-process used to create volumetric lighting effect
  60159. */
  60160. volumetricLightPostProcess: Nullable<PostProcess>;
  60161. /**
  60162. * Post-process used to smooth the previous volumetric light post-process on the X axis
  60163. */
  60164. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  60165. /**
  60166. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  60167. */
  60168. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  60169. /**
  60170. * Post-process used to merge the volumetric light effect and the real scene color
  60171. */
  60172. volumetricLightMergePostProces: Nullable<PostProcess>;
  60173. /**
  60174. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  60175. */
  60176. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  60177. /**
  60178. * Base post-process used to calculate the average luminance of the final image for HDR
  60179. */
  60180. luminancePostProcess: Nullable<PostProcess>;
  60181. /**
  60182. * Post-processes used to create down sample post-processes in order to get
  60183. * the average luminance of the final image for HDR
  60184. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  60185. */
  60186. luminanceDownSamplePostProcesses: PostProcess[];
  60187. /**
  60188. * Post-process used to create a HDR effect (light adaptation)
  60189. */
  60190. hdrPostProcess: Nullable<PostProcess>;
  60191. /**
  60192. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  60193. */
  60194. textureAdderFinalPostProcess: Nullable<PostProcess>;
  60195. /**
  60196. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  60197. */
  60198. lensFlareFinalPostProcess: Nullable<PostProcess>;
  60199. /**
  60200. * Post-process used to merge the final HDR post-process and the real scene color
  60201. */
  60202. hdrFinalPostProcess: Nullable<PostProcess>;
  60203. /**
  60204. * Post-process used to create a lens flare effect
  60205. */
  60206. lensFlarePostProcess: Nullable<PostProcess>;
  60207. /**
  60208. * Post-process that merges the result of the lens flare post-process and the real scene color
  60209. */
  60210. lensFlareComposePostProcess: Nullable<PostProcess>;
  60211. /**
  60212. * Post-process used to create a motion blur effect
  60213. */
  60214. motionBlurPostProcess: Nullable<PostProcess>;
  60215. /**
  60216. * Post-process used to create a depth of field effect
  60217. */
  60218. depthOfFieldPostProcess: Nullable<PostProcess>;
  60219. /**
  60220. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60221. */
  60222. fxaaPostProcess: Nullable<FxaaPostProcess>;
  60223. /**
  60224. * Represents the brightness threshold in order to configure the illuminated surfaces
  60225. */
  60226. brightThreshold: number;
  60227. /**
  60228. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  60229. */
  60230. blurWidth: number;
  60231. /**
  60232. * Sets if the blur for highlighted surfaces must be only horizontal
  60233. */
  60234. horizontalBlur: boolean;
  60235. /**
  60236. * Gets the overall exposure used by the pipeline
  60237. */
  60238. /**
  60239. * Sets the overall exposure used by the pipeline
  60240. */
  60241. exposure: number;
  60242. /**
  60243. * Texture used typically to simulate "dirty" on camera lens
  60244. */
  60245. lensTexture: Nullable<Texture>;
  60246. /**
  60247. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  60248. */
  60249. volumetricLightCoefficient: number;
  60250. /**
  60251. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  60252. */
  60253. volumetricLightPower: number;
  60254. /**
  60255. * Used the set the blur intensity to smooth the volumetric lights
  60256. */
  60257. volumetricLightBlurScale: number;
  60258. /**
  60259. * Light (spot or directional) used to generate the volumetric lights rays
  60260. * The source light must have a shadow generate so the pipeline can get its
  60261. * depth map
  60262. */
  60263. sourceLight: Nullable<SpotLight | DirectionalLight>;
  60264. /**
  60265. * For eye adaptation, represents the minimum luminance the eye can see
  60266. */
  60267. hdrMinimumLuminance: number;
  60268. /**
  60269. * For eye adaptation, represents the decrease luminance speed
  60270. */
  60271. hdrDecreaseRate: number;
  60272. /**
  60273. * For eye adaptation, represents the increase luminance speed
  60274. */
  60275. hdrIncreaseRate: number;
  60276. /**
  60277. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60278. */
  60279. /**
  60280. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60281. */
  60282. hdrAutoExposure: boolean;
  60283. /**
  60284. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  60285. */
  60286. lensColorTexture: Nullable<Texture>;
  60287. /**
  60288. * The overall strengh for the lens flare effect
  60289. */
  60290. lensFlareStrength: number;
  60291. /**
  60292. * Dispersion coefficient for lens flare ghosts
  60293. */
  60294. lensFlareGhostDispersal: number;
  60295. /**
  60296. * Main lens flare halo width
  60297. */
  60298. lensFlareHaloWidth: number;
  60299. /**
  60300. * Based on the lens distortion effect, defines how much the lens flare result
  60301. * is distorted
  60302. */
  60303. lensFlareDistortionStrength: number;
  60304. /**
  60305. * Lens star texture must be used to simulate rays on the flares and is available
  60306. * in the documentation
  60307. */
  60308. lensStarTexture: Nullable<Texture>;
  60309. /**
  60310. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60311. * flare effect by taking account of the dirt texture
  60312. */
  60313. lensFlareDirtTexture: Nullable<Texture>;
  60314. /**
  60315. * Represents the focal length for the depth of field effect
  60316. */
  60317. depthOfFieldDistance: number;
  60318. /**
  60319. * Represents the blur intensity for the blurred part of the depth of field effect
  60320. */
  60321. depthOfFieldBlurWidth: number;
  60322. /**
  60323. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60324. */
  60325. /**
  60326. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60327. */
  60328. motionStrength: number;
  60329. /**
  60330. * Gets wether or not the motion blur post-process is object based or screen based.
  60331. */
  60332. /**
  60333. * Sets wether or not the motion blur post-process should be object based or screen based
  60334. */
  60335. objectBasedMotionBlur: boolean;
  60336. /**
  60337. * List of animations for the pipeline (IAnimatable implementation)
  60338. */
  60339. animations: Animation[];
  60340. /**
  60341. * Private members
  60342. */
  60343. private _scene;
  60344. private _currentDepthOfFieldSource;
  60345. private _basePostProcess;
  60346. private _fixedExposure;
  60347. private _currentExposure;
  60348. private _hdrAutoExposure;
  60349. private _hdrCurrentLuminance;
  60350. private _motionStrength;
  60351. private _isObjectBasedMotionBlur;
  60352. private _floatTextureType;
  60353. private _ratio;
  60354. private _bloomEnabled;
  60355. private _depthOfFieldEnabled;
  60356. private _vlsEnabled;
  60357. private _lensFlareEnabled;
  60358. private _hdrEnabled;
  60359. private _motionBlurEnabled;
  60360. private _fxaaEnabled;
  60361. private _motionBlurSamples;
  60362. private _volumetricLightStepsCount;
  60363. private _samples;
  60364. /**
  60365. * @ignore
  60366. * Specifies if the bloom pipeline is enabled
  60367. */
  60368. BloomEnabled: boolean;
  60369. /**
  60370. * @ignore
  60371. * Specifies if the depth of field pipeline is enabed
  60372. */
  60373. DepthOfFieldEnabled: boolean;
  60374. /**
  60375. * @ignore
  60376. * Specifies if the lens flare pipeline is enabed
  60377. */
  60378. LensFlareEnabled: boolean;
  60379. /**
  60380. * @ignore
  60381. * Specifies if the HDR pipeline is enabled
  60382. */
  60383. HDREnabled: boolean;
  60384. /**
  60385. * @ignore
  60386. * Specifies if the volumetric lights scattering effect is enabled
  60387. */
  60388. VLSEnabled: boolean;
  60389. /**
  60390. * @ignore
  60391. * Specifies if the motion blur effect is enabled
  60392. */
  60393. MotionBlurEnabled: boolean;
  60394. /**
  60395. * Specifies if anti-aliasing is enabled
  60396. */
  60397. fxaaEnabled: boolean;
  60398. /**
  60399. * Specifies the number of steps used to calculate the volumetric lights
  60400. * Typically in interval [50, 200]
  60401. */
  60402. volumetricLightStepsCount: number;
  60403. /**
  60404. * Specifies the number of samples used for the motion blur effect
  60405. * Typically in interval [16, 64]
  60406. */
  60407. motionBlurSamples: number;
  60408. /**
  60409. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60410. */
  60411. samples: number;
  60412. /**
  60413. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60414. * @constructor
  60415. * @param name The rendering pipeline name
  60416. * @param scene The scene linked to this pipeline
  60417. * @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)
  60418. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60419. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60420. */
  60421. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60422. private _buildPipeline;
  60423. private _createDownSampleX4PostProcess;
  60424. private _createBrightPassPostProcess;
  60425. private _createBlurPostProcesses;
  60426. private _createTextureAdderPostProcess;
  60427. private _createVolumetricLightPostProcess;
  60428. private _createLuminancePostProcesses;
  60429. private _createHdrPostProcess;
  60430. private _createLensFlarePostProcess;
  60431. private _createDepthOfFieldPostProcess;
  60432. private _createMotionBlurPostProcess;
  60433. private _getDepthTexture;
  60434. private _disposePostProcesses;
  60435. /**
  60436. * Dispose of the pipeline and stop all post processes
  60437. */
  60438. dispose(): void;
  60439. /**
  60440. * Serialize the rendering pipeline (Used when exporting)
  60441. * @returns the serialized object
  60442. */
  60443. serialize(): any;
  60444. /**
  60445. * Parse the serialized pipeline
  60446. * @param source Source pipeline.
  60447. * @param scene The scene to load the pipeline to.
  60448. * @param rootUrl The URL of the serialized pipeline.
  60449. * @returns An instantiated pipeline from the serialized object.
  60450. */
  60451. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60452. /**
  60453. * Luminance steps
  60454. */
  60455. static LuminanceSteps: number;
  60456. }
  60457. }
  60458. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  60459. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  60460. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  60461. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  60462. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  60463. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  60464. }
  60465. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  60466. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  60467. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60468. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60469. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  60470. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60471. }
  60472. declare module "babylonjs/Shaders/tonemap.fragment" {
  60473. /** @hidden */
  60474. export var tonemapPixelShader: {
  60475. name: string;
  60476. shader: string;
  60477. };
  60478. }
  60479. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  60480. import { Camera } from "babylonjs/Cameras/camera";
  60481. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60482. import "babylonjs/Shaders/tonemap.fragment";
  60483. import { Engine } from "babylonjs/Engines/engine";
  60484. /** Defines operator used for tonemapping */
  60485. export enum TonemappingOperator {
  60486. /** Hable */
  60487. Hable = 0,
  60488. /** Reinhard */
  60489. Reinhard = 1,
  60490. /** HejiDawson */
  60491. HejiDawson = 2,
  60492. /** Photographic */
  60493. Photographic = 3
  60494. }
  60495. /**
  60496. * Defines a post process to apply tone mapping
  60497. */
  60498. export class TonemapPostProcess extends PostProcess {
  60499. private _operator;
  60500. /** Defines the required exposure adjustement */
  60501. exposureAdjustment: number;
  60502. /**
  60503. * Creates a new TonemapPostProcess
  60504. * @param name defines the name of the postprocess
  60505. * @param _operator defines the operator to use
  60506. * @param exposureAdjustment defines the required exposure adjustement
  60507. * @param camera defines the camera to use (can be null)
  60508. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60509. * @param engine defines the hosting engine (can be ignore if camera is set)
  60510. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60511. */
  60512. constructor(name: string, _operator: TonemappingOperator,
  60513. /** Defines the required exposure adjustement */
  60514. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60515. }
  60516. }
  60517. declare module "babylonjs/Shaders/depth.vertex" {
  60518. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60519. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60520. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60521. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60522. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60523. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60524. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60525. /** @hidden */
  60526. export var depthVertexShader: {
  60527. name: string;
  60528. shader: string;
  60529. };
  60530. }
  60531. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  60532. /** @hidden */
  60533. export var volumetricLightScatteringPixelShader: {
  60534. name: string;
  60535. shader: string;
  60536. };
  60537. }
  60538. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  60539. /** @hidden */
  60540. export var volumetricLightScatteringPassPixelShader: {
  60541. name: string;
  60542. shader: string;
  60543. };
  60544. }
  60545. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  60546. import { Vector3 } from "babylonjs/Maths/math";
  60547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60548. import { Mesh } from "babylonjs/Meshes/mesh";
  60549. import { Camera } from "babylonjs/Cameras/camera";
  60550. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60551. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60552. import { Scene } from "babylonjs/scene";
  60553. import "babylonjs/Meshes/Builders/planeBuilder";
  60554. import "babylonjs/Shaders/depth.vertex";
  60555. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  60556. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  60557. import { Engine } from "babylonjs/Engines/engine";
  60558. /**
  60559. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60560. */
  60561. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60562. private _volumetricLightScatteringPass;
  60563. private _volumetricLightScatteringRTT;
  60564. private _viewPort;
  60565. private _screenCoordinates;
  60566. private _cachedDefines;
  60567. /**
  60568. * If not undefined, the mesh position is computed from the attached node position
  60569. */
  60570. attachedNode: {
  60571. position: Vector3;
  60572. };
  60573. /**
  60574. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60575. */
  60576. customMeshPosition: Vector3;
  60577. /**
  60578. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60579. */
  60580. useCustomMeshPosition: boolean;
  60581. /**
  60582. * If the post-process should inverse the light scattering direction
  60583. */
  60584. invert: boolean;
  60585. /**
  60586. * The internal mesh used by the post-process
  60587. */
  60588. mesh: Mesh;
  60589. /**
  60590. * @hidden
  60591. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60592. */
  60593. useDiffuseColor: boolean;
  60594. /**
  60595. * Array containing the excluded meshes not rendered in the internal pass
  60596. */
  60597. excludedMeshes: AbstractMesh[];
  60598. /**
  60599. * Controls the overall intensity of the post-process
  60600. */
  60601. exposure: number;
  60602. /**
  60603. * Dissipates each sample's contribution in range [0, 1]
  60604. */
  60605. decay: number;
  60606. /**
  60607. * Controls the overall intensity of each sample
  60608. */
  60609. weight: number;
  60610. /**
  60611. * Controls the density of each sample
  60612. */
  60613. density: number;
  60614. /**
  60615. * @constructor
  60616. * @param name The post-process name
  60617. * @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)
  60618. * @param camera The camera that the post-process will be attached to
  60619. * @param mesh The mesh used to create the light scattering
  60620. * @param samples The post-process quality, default 100
  60621. * @param samplingModeThe post-process filtering mode
  60622. * @param engine The babylon engine
  60623. * @param reusable If the post-process is reusable
  60624. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60625. */
  60626. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60627. /**
  60628. * Returns the string "VolumetricLightScatteringPostProcess"
  60629. * @returns "VolumetricLightScatteringPostProcess"
  60630. */
  60631. getClassName(): string;
  60632. private _isReady;
  60633. /**
  60634. * Sets the new light position for light scattering effect
  60635. * @param position The new custom light position
  60636. */
  60637. setCustomMeshPosition(position: Vector3): void;
  60638. /**
  60639. * Returns the light position for light scattering effect
  60640. * @return Vector3 The custom light position
  60641. */
  60642. getCustomMeshPosition(): Vector3;
  60643. /**
  60644. * Disposes the internal assets and detaches the post-process from the camera
  60645. */
  60646. dispose(camera: Camera): void;
  60647. /**
  60648. * Returns the render target texture used by the post-process
  60649. * @return the render target texture used by the post-process
  60650. */
  60651. getPass(): RenderTargetTexture;
  60652. private _meshExcluded;
  60653. private _createPass;
  60654. private _updateMeshScreenCoordinates;
  60655. /**
  60656. * Creates a default mesh for the Volumeric Light Scattering post-process
  60657. * @param name The mesh name
  60658. * @param scene The scene where to create the mesh
  60659. * @return the default mesh
  60660. */
  60661. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60662. }
  60663. }
  60664. declare module "babylonjs/PostProcesses/index" {
  60665. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  60666. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  60667. export * from "babylonjs/PostProcesses/bloomEffect";
  60668. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  60669. export * from "babylonjs/PostProcesses/blurPostProcess";
  60670. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  60671. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  60672. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  60673. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  60674. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  60675. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  60676. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  60677. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  60678. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  60679. export * from "babylonjs/PostProcesses/filterPostProcess";
  60680. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  60681. export * from "babylonjs/PostProcesses/grainPostProcess";
  60682. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  60683. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  60684. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  60685. export * from "babylonjs/PostProcesses/passPostProcess";
  60686. export * from "babylonjs/PostProcesses/postProcess";
  60687. export * from "babylonjs/PostProcesses/postProcessManager";
  60688. export * from "babylonjs/PostProcesses/refractionPostProcess";
  60689. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  60690. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  60691. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  60692. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  60693. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  60694. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  60695. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  60696. }
  60697. declare module "babylonjs/Probes/index" {
  60698. export * from "babylonjs/Probes/reflectionProbe";
  60699. }
  60700. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  60701. import { Scene } from "babylonjs/scene";
  60702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60703. import { Color3 } from "babylonjs/Maths/math";
  60704. import { SmartArray } from "babylonjs/Misc/smartArray";
  60705. import { ISceneComponent } from "babylonjs/sceneComponent";
  60706. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  60707. import "babylonjs/Meshes/Builders/boxBuilder";
  60708. import "babylonjs/Shaders/color.fragment";
  60709. import "babylonjs/Shaders/color.vertex";
  60710. module "babylonjs/scene" {
  60711. interface Scene {
  60712. /** @hidden (Backing field) */
  60713. _boundingBoxRenderer: BoundingBoxRenderer;
  60714. /** @hidden (Backing field) */
  60715. _forceShowBoundingBoxes: boolean;
  60716. /**
  60717. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60718. */
  60719. forceShowBoundingBoxes: boolean;
  60720. /**
  60721. * Gets the bounding box renderer associated with the scene
  60722. * @returns a BoundingBoxRenderer
  60723. */
  60724. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60725. }
  60726. }
  60727. module "babylonjs/Meshes/abstractMesh" {
  60728. interface AbstractMesh {
  60729. /** @hidden (Backing field) */
  60730. _showBoundingBox: boolean;
  60731. /**
  60732. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60733. */
  60734. showBoundingBox: boolean;
  60735. }
  60736. }
  60737. /**
  60738. * Component responsible of rendering the bounding box of the meshes in a scene.
  60739. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60740. */
  60741. export class BoundingBoxRenderer implements ISceneComponent {
  60742. /**
  60743. * The component name helpfull to identify the component in the list of scene components.
  60744. */
  60745. readonly name: string;
  60746. /**
  60747. * The scene the component belongs to.
  60748. */
  60749. scene: Scene;
  60750. /**
  60751. * Color of the bounding box lines placed in front of an object
  60752. */
  60753. frontColor: Color3;
  60754. /**
  60755. * Color of the bounding box lines placed behind an object
  60756. */
  60757. backColor: Color3;
  60758. /**
  60759. * Defines if the renderer should show the back lines or not
  60760. */
  60761. showBackLines: boolean;
  60762. /**
  60763. * @hidden
  60764. */
  60765. renderList: SmartArray<BoundingBox>;
  60766. private _colorShader;
  60767. private _vertexBuffers;
  60768. private _indexBuffer;
  60769. private _fillIndexBuffer;
  60770. private _fillIndexData;
  60771. /**
  60772. * Instantiates a new bounding box renderer in a scene.
  60773. * @param scene the scene the renderer renders in
  60774. */
  60775. constructor(scene: Scene);
  60776. /**
  60777. * Registers the component in a given scene
  60778. */
  60779. register(): void;
  60780. private _evaluateSubMesh;
  60781. private _activeMesh;
  60782. private _prepareRessources;
  60783. private _createIndexBuffer;
  60784. /**
  60785. * Rebuilds the elements related to this component in case of
  60786. * context lost for instance.
  60787. */
  60788. rebuild(): void;
  60789. /**
  60790. * @hidden
  60791. */
  60792. reset(): void;
  60793. /**
  60794. * Render the bounding boxes of a specific rendering group
  60795. * @param renderingGroupId defines the rendering group to render
  60796. */
  60797. render(renderingGroupId: number): void;
  60798. /**
  60799. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60800. * @param mesh Define the mesh to render the occlusion bounding box for
  60801. */
  60802. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60803. /**
  60804. * Dispose and release the resources attached to this renderer.
  60805. */
  60806. dispose(): void;
  60807. }
  60808. }
  60809. declare module "babylonjs/Shaders/depth.fragment" {
  60810. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60811. /** @hidden */
  60812. export var depthPixelShader: {
  60813. name: string;
  60814. shader: string;
  60815. };
  60816. }
  60817. declare module "babylonjs/Rendering/depthRenderer" {
  60818. import { Nullable } from "babylonjs/types";
  60819. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60820. import { Scene } from "babylonjs/scene";
  60821. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60822. import { Camera } from "babylonjs/Cameras/camera";
  60823. import "babylonjs/Shaders/depth.fragment";
  60824. import "babylonjs/Shaders/depth.vertex";
  60825. /**
  60826. * This represents a depth renderer in Babylon.
  60827. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60828. */
  60829. export class DepthRenderer {
  60830. private _scene;
  60831. private _depthMap;
  60832. private _effect;
  60833. private readonly _storeNonLinearDepth;
  60834. private readonly _clearColor;
  60835. /** Get if the depth renderer is using packed depth or not */
  60836. readonly isPacked: boolean;
  60837. private _cachedDefines;
  60838. private _camera;
  60839. /**
  60840. * Specifiess that the depth renderer will only be used within
  60841. * the camera it is created for.
  60842. * This can help forcing its rendering during the camera processing.
  60843. */
  60844. useOnlyInActiveCamera: boolean;
  60845. /** @hidden */
  60846. static _SceneComponentInitialization: (scene: Scene) => void;
  60847. /**
  60848. * Instantiates a depth renderer
  60849. * @param scene The scene the renderer belongs to
  60850. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60851. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60852. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60853. */
  60854. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60855. /**
  60856. * Creates the depth rendering effect and checks if the effect is ready.
  60857. * @param subMesh The submesh to be used to render the depth map of
  60858. * @param useInstances If multiple world instances should be used
  60859. * @returns if the depth renderer is ready to render the depth map
  60860. */
  60861. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60862. /**
  60863. * Gets the texture which the depth map will be written to.
  60864. * @returns The depth map texture
  60865. */
  60866. getDepthMap(): RenderTargetTexture;
  60867. /**
  60868. * Disposes of the depth renderer.
  60869. */
  60870. dispose(): void;
  60871. }
  60872. }
  60873. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  60874. import { Nullable } from "babylonjs/types";
  60875. import { Scene } from "babylonjs/scene";
  60876. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60877. import { Camera } from "babylonjs/Cameras/camera";
  60878. import { ISceneComponent } from "babylonjs/sceneComponent";
  60879. module "babylonjs/scene" {
  60880. interface Scene {
  60881. /** @hidden (Backing field) */
  60882. _depthRenderer: {
  60883. [id: string]: DepthRenderer;
  60884. };
  60885. /**
  60886. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60887. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60888. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60889. * @returns the created depth renderer
  60890. */
  60891. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  60892. /**
  60893. * Disables a depth renderer for a given camera
  60894. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60895. */
  60896. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60897. }
  60898. }
  60899. /**
  60900. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60901. * in several rendering techniques.
  60902. */
  60903. export class DepthRendererSceneComponent implements ISceneComponent {
  60904. /**
  60905. * The component name helpfull to identify the component in the list of scene components.
  60906. */
  60907. readonly name: string;
  60908. /**
  60909. * The scene the component belongs to.
  60910. */
  60911. scene: Scene;
  60912. /**
  60913. * Creates a new instance of the component for the given scene
  60914. * @param scene Defines the scene to register the component in
  60915. */
  60916. constructor(scene: Scene);
  60917. /**
  60918. * Registers the component in a given scene
  60919. */
  60920. register(): void;
  60921. /**
  60922. * Rebuilds the elements related to this component in case of
  60923. * context lost for instance.
  60924. */
  60925. rebuild(): void;
  60926. /**
  60927. * Disposes the component and the associated ressources
  60928. */
  60929. dispose(): void;
  60930. private _gatherRenderTargets;
  60931. private _gatherActiveCameraRenderTargets;
  60932. }
  60933. }
  60934. declare module "babylonjs/Shaders/outline.fragment" {
  60935. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60936. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  60937. /** @hidden */
  60938. export var outlinePixelShader: {
  60939. name: string;
  60940. shader: string;
  60941. };
  60942. }
  60943. declare module "babylonjs/Shaders/outline.vertex" {
  60944. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60945. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60946. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60947. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60948. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60949. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60950. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60951. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60952. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  60953. /** @hidden */
  60954. export var outlineVertexShader: {
  60955. name: string;
  60956. shader: string;
  60957. };
  60958. }
  60959. declare module "babylonjs/Rendering/outlineRenderer" {
  60960. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60961. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  60962. import { Scene } from "babylonjs/scene";
  60963. import { ISceneComponent } from "babylonjs/sceneComponent";
  60964. import "babylonjs/Shaders/outline.fragment";
  60965. import "babylonjs/Shaders/outline.vertex";
  60966. module "babylonjs/scene" {
  60967. interface Scene {
  60968. /** @hidden */
  60969. _outlineRenderer: OutlineRenderer;
  60970. /**
  60971. * Gets the outline renderer associated with the scene
  60972. * @returns a OutlineRenderer
  60973. */
  60974. getOutlineRenderer(): OutlineRenderer;
  60975. }
  60976. }
  60977. module "babylonjs/Meshes/abstractMesh" {
  60978. interface AbstractMesh {
  60979. /** @hidden (Backing field) */
  60980. _renderOutline: boolean;
  60981. /**
  60982. * Gets or sets a boolean indicating if the outline must be rendered as well
  60983. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60984. */
  60985. renderOutline: boolean;
  60986. /** @hidden (Backing field) */
  60987. _renderOverlay: boolean;
  60988. /**
  60989. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60990. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60991. */
  60992. renderOverlay: boolean;
  60993. }
  60994. }
  60995. /**
  60996. * This class is responsible to draw bothe outline/overlay of meshes.
  60997. * It should not be used directly but through the available method on mesh.
  60998. */
  60999. export class OutlineRenderer implements ISceneComponent {
  61000. /**
  61001. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  61002. */
  61003. private static _StencilReference;
  61004. /**
  61005. * The name of the component. Each component must have a unique name.
  61006. */
  61007. name: string;
  61008. /**
  61009. * The scene the component belongs to.
  61010. */
  61011. scene: Scene;
  61012. /**
  61013. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  61014. */
  61015. zOffset: number;
  61016. private _engine;
  61017. private _effect;
  61018. private _cachedDefines;
  61019. private _savedDepthWrite;
  61020. /**
  61021. * Instantiates a new outline renderer. (There could be only one per scene).
  61022. * @param scene Defines the scene it belongs to
  61023. */
  61024. constructor(scene: Scene);
  61025. /**
  61026. * Register the component to one instance of a scene.
  61027. */
  61028. register(): void;
  61029. /**
  61030. * Rebuilds the elements related to this component in case of
  61031. * context lost for instance.
  61032. */
  61033. rebuild(): void;
  61034. /**
  61035. * Disposes the component and the associated ressources.
  61036. */
  61037. dispose(): void;
  61038. /**
  61039. * Renders the outline in the canvas.
  61040. * @param subMesh Defines the sumesh to render
  61041. * @param batch Defines the batch of meshes in case of instances
  61042. * @param useOverlay Defines if the rendering is for the overlay or the outline
  61043. */
  61044. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  61045. /**
  61046. * Returns whether or not the outline renderer is ready for a given submesh.
  61047. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  61048. * @param subMesh Defines the submesh to check readyness for
  61049. * @param useInstances Defines wheter wee are trying to render instances or not
  61050. * @returns true if ready otherwise false
  61051. */
  61052. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61053. private _beforeRenderingMesh;
  61054. private _afterRenderingMesh;
  61055. }
  61056. }
  61057. declare module "babylonjs/Rendering/index" {
  61058. export * from "babylonjs/Rendering/boundingBoxRenderer";
  61059. export * from "babylonjs/Rendering/depthRenderer";
  61060. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  61061. export * from "babylonjs/Rendering/edgesRenderer";
  61062. export * from "babylonjs/Rendering/geometryBufferRenderer";
  61063. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  61064. export * from "babylonjs/Rendering/outlineRenderer";
  61065. export * from "babylonjs/Rendering/renderingGroup";
  61066. export * from "babylonjs/Rendering/renderingManager";
  61067. export * from "babylonjs/Rendering/utilityLayerRenderer";
  61068. }
  61069. declare module "babylonjs/Sprites/index" {
  61070. export * from "babylonjs/Sprites/sprite";
  61071. export * from "babylonjs/Sprites/spriteManager";
  61072. export * from "babylonjs/Sprites/spriteSceneComponent";
  61073. }
  61074. declare module "babylonjs/Misc/assetsManager" {
  61075. import { Scene } from "babylonjs/scene";
  61076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61077. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61078. import { Skeleton } from "babylonjs/Bones/skeleton";
  61079. import { Observable } from "babylonjs/Misc/observable";
  61080. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61081. import { Texture } from "babylonjs/Materials/Textures/texture";
  61082. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  61083. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  61084. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  61085. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  61086. /**
  61087. * Defines the list of states available for a task inside a AssetsManager
  61088. */
  61089. export enum AssetTaskState {
  61090. /**
  61091. * Initialization
  61092. */
  61093. INIT = 0,
  61094. /**
  61095. * Running
  61096. */
  61097. RUNNING = 1,
  61098. /**
  61099. * Done
  61100. */
  61101. DONE = 2,
  61102. /**
  61103. * Error
  61104. */
  61105. ERROR = 3
  61106. }
  61107. /**
  61108. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  61109. */
  61110. export abstract class AbstractAssetTask {
  61111. /**
  61112. * Task name
  61113. */ name: string;
  61114. /**
  61115. * Callback called when the task is successful
  61116. */
  61117. onSuccess: (task: any) => void;
  61118. /**
  61119. * Callback called when the task is not successful
  61120. */
  61121. onError: (task: any, message?: string, exception?: any) => void;
  61122. /**
  61123. * Creates a new AssetsManager
  61124. * @param name defines the name of the task
  61125. */
  61126. constructor(
  61127. /**
  61128. * Task name
  61129. */ name: string);
  61130. private _isCompleted;
  61131. private _taskState;
  61132. private _errorObject;
  61133. /**
  61134. * Get if the task is completed
  61135. */
  61136. readonly isCompleted: boolean;
  61137. /**
  61138. * Gets the current state of the task
  61139. */
  61140. readonly taskState: AssetTaskState;
  61141. /**
  61142. * Gets the current error object (if task is in error)
  61143. */
  61144. readonly errorObject: {
  61145. message?: string;
  61146. exception?: any;
  61147. };
  61148. /**
  61149. * Internal only
  61150. * @hidden
  61151. */
  61152. _setErrorObject(message?: string, exception?: any): void;
  61153. /**
  61154. * Execute the current task
  61155. * @param scene defines the scene where you want your assets to be loaded
  61156. * @param onSuccess is a callback called when the task is successfully executed
  61157. * @param onError is a callback called if an error occurs
  61158. */
  61159. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61160. /**
  61161. * Execute the current task
  61162. * @param scene defines the scene where you want your assets to be loaded
  61163. * @param onSuccess is a callback called when the task is successfully executed
  61164. * @param onError is a callback called if an error occurs
  61165. */
  61166. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61167. /**
  61168. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  61169. * This can be used with failed tasks that have the reason for failure fixed.
  61170. */
  61171. reset(): void;
  61172. private onErrorCallback;
  61173. private onDoneCallback;
  61174. }
  61175. /**
  61176. * Define the interface used by progress events raised during assets loading
  61177. */
  61178. export interface IAssetsProgressEvent {
  61179. /**
  61180. * Defines the number of remaining tasks to process
  61181. */
  61182. remainingCount: number;
  61183. /**
  61184. * Defines the total number of tasks
  61185. */
  61186. totalCount: number;
  61187. /**
  61188. * Defines the task that was just processed
  61189. */
  61190. task: AbstractAssetTask;
  61191. }
  61192. /**
  61193. * Class used to share progress information about assets loading
  61194. */
  61195. export class AssetsProgressEvent implements IAssetsProgressEvent {
  61196. /**
  61197. * Defines the number of remaining tasks to process
  61198. */
  61199. remainingCount: number;
  61200. /**
  61201. * Defines the total number of tasks
  61202. */
  61203. totalCount: number;
  61204. /**
  61205. * Defines the task that was just processed
  61206. */
  61207. task: AbstractAssetTask;
  61208. /**
  61209. * Creates a AssetsProgressEvent
  61210. * @param remainingCount defines the number of remaining tasks to process
  61211. * @param totalCount defines the total number of tasks
  61212. * @param task defines the task that was just processed
  61213. */
  61214. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  61215. }
  61216. /**
  61217. * Define a task used by AssetsManager to load meshes
  61218. */
  61219. export class MeshAssetTask extends AbstractAssetTask {
  61220. /**
  61221. * Defines the name of the task
  61222. */
  61223. name: string;
  61224. /**
  61225. * Defines the list of mesh's names you want to load
  61226. */
  61227. meshesNames: any;
  61228. /**
  61229. * Defines the root url to use as a base to load your meshes and associated resources
  61230. */
  61231. rootUrl: string;
  61232. /**
  61233. * Defines the filename of the scene to load from
  61234. */
  61235. sceneFilename: string;
  61236. /**
  61237. * Gets the list of loaded meshes
  61238. */
  61239. loadedMeshes: Array<AbstractMesh>;
  61240. /**
  61241. * Gets the list of loaded particle systems
  61242. */
  61243. loadedParticleSystems: Array<IParticleSystem>;
  61244. /**
  61245. * Gets the list of loaded skeletons
  61246. */
  61247. loadedSkeletons: Array<Skeleton>;
  61248. /**
  61249. * Gets the list of loaded animation groups
  61250. */
  61251. loadedAnimationGroups: Array<AnimationGroup>;
  61252. /**
  61253. * Callback called when the task is successful
  61254. */
  61255. onSuccess: (task: MeshAssetTask) => void;
  61256. /**
  61257. * Callback called when the task is successful
  61258. */
  61259. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  61260. /**
  61261. * Creates a new MeshAssetTask
  61262. * @param name defines the name of the task
  61263. * @param meshesNames defines the list of mesh's names you want to load
  61264. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  61265. * @param sceneFilename defines the filename of the scene to load from
  61266. */
  61267. constructor(
  61268. /**
  61269. * Defines the name of the task
  61270. */
  61271. name: string,
  61272. /**
  61273. * Defines the list of mesh's names you want to load
  61274. */
  61275. meshesNames: any,
  61276. /**
  61277. * Defines the root url to use as a base to load your meshes and associated resources
  61278. */
  61279. rootUrl: string,
  61280. /**
  61281. * Defines the filename of the scene to load from
  61282. */
  61283. sceneFilename: string);
  61284. /**
  61285. * Execute the current task
  61286. * @param scene defines the scene where you want your assets to be loaded
  61287. * @param onSuccess is a callback called when the task is successfully executed
  61288. * @param onError is a callback called if an error occurs
  61289. */
  61290. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61291. }
  61292. /**
  61293. * Define a task used by AssetsManager to load text content
  61294. */
  61295. export class TextFileAssetTask extends AbstractAssetTask {
  61296. /**
  61297. * Defines the name of the task
  61298. */
  61299. name: string;
  61300. /**
  61301. * Defines the location of the file to load
  61302. */
  61303. url: string;
  61304. /**
  61305. * Gets the loaded text string
  61306. */
  61307. text: string;
  61308. /**
  61309. * Callback called when the task is successful
  61310. */
  61311. onSuccess: (task: TextFileAssetTask) => void;
  61312. /**
  61313. * Callback called when the task is successful
  61314. */
  61315. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  61316. /**
  61317. * Creates a new TextFileAssetTask object
  61318. * @param name defines the name of the task
  61319. * @param url defines the location of the file to load
  61320. */
  61321. constructor(
  61322. /**
  61323. * Defines the name of the task
  61324. */
  61325. name: string,
  61326. /**
  61327. * Defines the location of the file to load
  61328. */
  61329. url: string);
  61330. /**
  61331. * Execute the current task
  61332. * @param scene defines the scene where you want your assets to be loaded
  61333. * @param onSuccess is a callback called when the task is successfully executed
  61334. * @param onError is a callback called if an error occurs
  61335. */
  61336. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61337. }
  61338. /**
  61339. * Define a task used by AssetsManager to load binary data
  61340. */
  61341. export class BinaryFileAssetTask extends AbstractAssetTask {
  61342. /**
  61343. * Defines the name of the task
  61344. */
  61345. name: string;
  61346. /**
  61347. * Defines the location of the file to load
  61348. */
  61349. url: string;
  61350. /**
  61351. * Gets the lodaded data (as an array buffer)
  61352. */
  61353. data: ArrayBuffer;
  61354. /**
  61355. * Callback called when the task is successful
  61356. */
  61357. onSuccess: (task: BinaryFileAssetTask) => void;
  61358. /**
  61359. * Callback called when the task is successful
  61360. */
  61361. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  61362. /**
  61363. * Creates a new BinaryFileAssetTask object
  61364. * @param name defines the name of the new task
  61365. * @param url defines the location of the file to load
  61366. */
  61367. constructor(
  61368. /**
  61369. * Defines the name of the task
  61370. */
  61371. name: string,
  61372. /**
  61373. * Defines the location of the file to load
  61374. */
  61375. url: string);
  61376. /**
  61377. * Execute the current task
  61378. * @param scene defines the scene where you want your assets to be loaded
  61379. * @param onSuccess is a callback called when the task is successfully executed
  61380. * @param onError is a callback called if an error occurs
  61381. */
  61382. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61383. }
  61384. /**
  61385. * Define a task used by AssetsManager to load images
  61386. */
  61387. export class ImageAssetTask extends AbstractAssetTask {
  61388. /**
  61389. * Defines the name of the task
  61390. */
  61391. name: string;
  61392. /**
  61393. * Defines the location of the image to load
  61394. */
  61395. url: string;
  61396. /**
  61397. * Gets the loaded images
  61398. */
  61399. image: HTMLImageElement;
  61400. /**
  61401. * Callback called when the task is successful
  61402. */
  61403. onSuccess: (task: ImageAssetTask) => void;
  61404. /**
  61405. * Callback called when the task is successful
  61406. */
  61407. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61408. /**
  61409. * Creates a new ImageAssetTask
  61410. * @param name defines the name of the task
  61411. * @param url defines the location of the image to load
  61412. */
  61413. constructor(
  61414. /**
  61415. * Defines the name of the task
  61416. */
  61417. name: string,
  61418. /**
  61419. * Defines the location of the image to load
  61420. */
  61421. url: string);
  61422. /**
  61423. * Execute the current task
  61424. * @param scene defines the scene where you want your assets to be loaded
  61425. * @param onSuccess is a callback called when the task is successfully executed
  61426. * @param onError is a callback called if an error occurs
  61427. */
  61428. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61429. }
  61430. /**
  61431. * Defines the interface used by texture loading tasks
  61432. */
  61433. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61434. /**
  61435. * Gets the loaded texture
  61436. */
  61437. texture: TEX;
  61438. }
  61439. /**
  61440. * Define a task used by AssetsManager to load 2D textures
  61441. */
  61442. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61443. /**
  61444. * Defines the name of the task
  61445. */
  61446. name: string;
  61447. /**
  61448. * Defines the location of the file to load
  61449. */
  61450. url: string;
  61451. /**
  61452. * Defines if mipmap should not be generated (default is false)
  61453. */
  61454. noMipmap?: boolean | undefined;
  61455. /**
  61456. * Defines if texture must be inverted on Y axis (default is false)
  61457. */
  61458. invertY?: boolean | undefined;
  61459. /**
  61460. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61461. */
  61462. samplingMode: number;
  61463. /**
  61464. * Gets the loaded texture
  61465. */
  61466. texture: Texture;
  61467. /**
  61468. * Callback called when the task is successful
  61469. */
  61470. onSuccess: (task: TextureAssetTask) => void;
  61471. /**
  61472. * Callback called when the task is successful
  61473. */
  61474. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61475. /**
  61476. * Creates a new TextureAssetTask object
  61477. * @param name defines the name of the task
  61478. * @param url defines the location of the file to load
  61479. * @param noMipmap defines if mipmap should not be generated (default is false)
  61480. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61481. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61482. */
  61483. constructor(
  61484. /**
  61485. * Defines the name of the task
  61486. */
  61487. name: string,
  61488. /**
  61489. * Defines the location of the file to load
  61490. */
  61491. url: string,
  61492. /**
  61493. * Defines if mipmap should not be generated (default is false)
  61494. */
  61495. noMipmap?: boolean | undefined,
  61496. /**
  61497. * Defines if texture must be inverted on Y axis (default is false)
  61498. */
  61499. invertY?: boolean | undefined,
  61500. /**
  61501. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61502. */
  61503. samplingMode?: number);
  61504. /**
  61505. * Execute the current task
  61506. * @param scene defines the scene where you want your assets to be loaded
  61507. * @param onSuccess is a callback called when the task is successfully executed
  61508. * @param onError is a callback called if an error occurs
  61509. */
  61510. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61511. }
  61512. /**
  61513. * Define a task used by AssetsManager to load cube textures
  61514. */
  61515. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61516. /**
  61517. * Defines the name of the task
  61518. */
  61519. name: string;
  61520. /**
  61521. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61522. */
  61523. url: string;
  61524. /**
  61525. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61526. */
  61527. extensions?: string[] | undefined;
  61528. /**
  61529. * Defines if mipmaps should not be generated (default is false)
  61530. */
  61531. noMipmap?: boolean | undefined;
  61532. /**
  61533. * Defines the explicit list of files (undefined by default)
  61534. */
  61535. files?: string[] | undefined;
  61536. /**
  61537. * Gets the loaded texture
  61538. */
  61539. texture: CubeTexture;
  61540. /**
  61541. * Callback called when the task is successful
  61542. */
  61543. onSuccess: (task: CubeTextureAssetTask) => void;
  61544. /**
  61545. * Callback called when the task is successful
  61546. */
  61547. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61548. /**
  61549. * Creates a new CubeTextureAssetTask
  61550. * @param name defines the name of the task
  61551. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61552. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61553. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61554. * @param files defines the explicit list of files (undefined by default)
  61555. */
  61556. constructor(
  61557. /**
  61558. * Defines the name of the task
  61559. */
  61560. name: string,
  61561. /**
  61562. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61563. */
  61564. url: string,
  61565. /**
  61566. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61567. */
  61568. extensions?: string[] | undefined,
  61569. /**
  61570. * Defines if mipmaps should not be generated (default is false)
  61571. */
  61572. noMipmap?: boolean | undefined,
  61573. /**
  61574. * Defines the explicit list of files (undefined by default)
  61575. */
  61576. files?: string[] | undefined);
  61577. /**
  61578. * Execute the current task
  61579. * @param scene defines the scene where you want your assets to be loaded
  61580. * @param onSuccess is a callback called when the task is successfully executed
  61581. * @param onError is a callback called if an error occurs
  61582. */
  61583. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61584. }
  61585. /**
  61586. * Define a task used by AssetsManager to load HDR cube textures
  61587. */
  61588. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61589. /**
  61590. * Defines the name of the task
  61591. */
  61592. name: string;
  61593. /**
  61594. * Defines the location of the file to load
  61595. */
  61596. url: string;
  61597. /**
  61598. * Defines the desired size (the more it increases the longer the generation will be)
  61599. */
  61600. size: number;
  61601. /**
  61602. * Defines if mipmaps should not be generated (default is false)
  61603. */
  61604. noMipmap: boolean;
  61605. /**
  61606. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61607. */
  61608. generateHarmonics: boolean;
  61609. /**
  61610. * 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)
  61611. */
  61612. gammaSpace: boolean;
  61613. /**
  61614. * Internal Use Only
  61615. */
  61616. reserved: boolean;
  61617. /**
  61618. * Gets the loaded texture
  61619. */
  61620. texture: HDRCubeTexture;
  61621. /**
  61622. * Callback called when the task is successful
  61623. */
  61624. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61625. /**
  61626. * Callback called when the task is successful
  61627. */
  61628. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61629. /**
  61630. * Creates a new HDRCubeTextureAssetTask object
  61631. * @param name defines the name of the task
  61632. * @param url defines the location of the file to load
  61633. * @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.
  61634. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61635. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61636. * @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)
  61637. * @param reserved Internal use only
  61638. */
  61639. constructor(
  61640. /**
  61641. * Defines the name of the task
  61642. */
  61643. name: string,
  61644. /**
  61645. * Defines the location of the file to load
  61646. */
  61647. url: string,
  61648. /**
  61649. * Defines the desired size (the more it increases the longer the generation will be)
  61650. */
  61651. size: number,
  61652. /**
  61653. * Defines if mipmaps should not be generated (default is false)
  61654. */
  61655. noMipmap?: boolean,
  61656. /**
  61657. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61658. */
  61659. generateHarmonics?: boolean,
  61660. /**
  61661. * 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)
  61662. */
  61663. gammaSpace?: boolean,
  61664. /**
  61665. * Internal Use Only
  61666. */
  61667. reserved?: boolean);
  61668. /**
  61669. * Execute the current task
  61670. * @param scene defines the scene where you want your assets to be loaded
  61671. * @param onSuccess is a callback called when the task is successfully executed
  61672. * @param onError is a callback called if an error occurs
  61673. */
  61674. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61675. }
  61676. /**
  61677. * Define a task used by AssetsManager to load Equirectangular cube textures
  61678. */
  61679. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61680. /**
  61681. * Defines the name of the task
  61682. */
  61683. name: string;
  61684. /**
  61685. * Defines the location of the file to load
  61686. */
  61687. url: string;
  61688. /**
  61689. * Defines the desired size (the more it increases the longer the generation will be)
  61690. */
  61691. size: number;
  61692. /**
  61693. * Defines if mipmaps should not be generated (default is false)
  61694. */
  61695. noMipmap: boolean;
  61696. /**
  61697. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61698. * but the standard material would require them in Gamma space) (default is true)
  61699. */
  61700. gammaSpace: boolean;
  61701. /**
  61702. * Gets the loaded texture
  61703. */
  61704. texture: EquiRectangularCubeTexture;
  61705. /**
  61706. * Callback called when the task is successful
  61707. */
  61708. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61709. /**
  61710. * Callback called when the task is successful
  61711. */
  61712. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61713. /**
  61714. * Creates a new EquiRectangularCubeTextureAssetTask object
  61715. * @param name defines the name of the task
  61716. * @param url defines the location of the file to load
  61717. * @param size defines the desired size (the more it increases the longer the generation will be)
  61718. * If the size is omitted this implies you are using a preprocessed cubemap.
  61719. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61720. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61721. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61722. * (default is true)
  61723. */
  61724. constructor(
  61725. /**
  61726. * Defines the name of the task
  61727. */
  61728. name: string,
  61729. /**
  61730. * Defines the location of the file to load
  61731. */
  61732. url: string,
  61733. /**
  61734. * Defines the desired size (the more it increases the longer the generation will be)
  61735. */
  61736. size: number,
  61737. /**
  61738. * Defines if mipmaps should not be generated (default is false)
  61739. */
  61740. noMipmap?: boolean,
  61741. /**
  61742. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61743. * but the standard material would require them in Gamma space) (default is true)
  61744. */
  61745. gammaSpace?: boolean);
  61746. /**
  61747. * Execute the current task
  61748. * @param scene defines the scene where you want your assets to be loaded
  61749. * @param onSuccess is a callback called when the task is successfully executed
  61750. * @param onError is a callback called if an error occurs
  61751. */
  61752. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61753. }
  61754. /**
  61755. * This class can be used to easily import assets into a scene
  61756. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61757. */
  61758. export class AssetsManager {
  61759. private _scene;
  61760. private _isLoading;
  61761. protected _tasks: AbstractAssetTask[];
  61762. protected _waitingTasksCount: number;
  61763. protected _totalTasksCount: number;
  61764. /**
  61765. * Callback called when all tasks are processed
  61766. */
  61767. onFinish: (tasks: AbstractAssetTask[]) => void;
  61768. /**
  61769. * Callback called when a task is successful
  61770. */
  61771. onTaskSuccess: (task: AbstractAssetTask) => void;
  61772. /**
  61773. * Callback called when a task had an error
  61774. */
  61775. onTaskError: (task: AbstractAssetTask) => void;
  61776. /**
  61777. * Callback called when a task is done (whatever the result is)
  61778. */
  61779. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61780. /**
  61781. * Observable called when all tasks are processed
  61782. */
  61783. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61784. /**
  61785. * Observable called when a task had an error
  61786. */
  61787. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61788. /**
  61789. * Observable called when all tasks were executed
  61790. */
  61791. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61792. /**
  61793. * Observable called when a task is done (whatever the result is)
  61794. */
  61795. onProgressObservable: Observable<IAssetsProgressEvent>;
  61796. /**
  61797. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61798. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61799. */
  61800. useDefaultLoadingScreen: boolean;
  61801. /**
  61802. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  61803. * when all assets have been downloaded.
  61804. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  61805. */
  61806. autoHideLoadingUI: boolean;
  61807. /**
  61808. * Creates a new AssetsManager
  61809. * @param scene defines the scene to work on
  61810. */
  61811. constructor(scene: Scene);
  61812. /**
  61813. * Add a MeshAssetTask to the list of active tasks
  61814. * @param taskName defines the name of the new task
  61815. * @param meshesNames defines the name of meshes to load
  61816. * @param rootUrl defines the root url to use to locate files
  61817. * @param sceneFilename defines the filename of the scene file
  61818. * @returns a new MeshAssetTask object
  61819. */
  61820. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61821. /**
  61822. * Add a TextFileAssetTask to the list of active tasks
  61823. * @param taskName defines the name of the new task
  61824. * @param url defines the url of the file to load
  61825. * @returns a new TextFileAssetTask object
  61826. */
  61827. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61828. /**
  61829. * Add a BinaryFileAssetTask to the list of active tasks
  61830. * @param taskName defines the name of the new task
  61831. * @param url defines the url of the file to load
  61832. * @returns a new BinaryFileAssetTask object
  61833. */
  61834. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61835. /**
  61836. * Add a ImageAssetTask to the list of active tasks
  61837. * @param taskName defines the name of the new task
  61838. * @param url defines the url of the file to load
  61839. * @returns a new ImageAssetTask object
  61840. */
  61841. addImageTask(taskName: string, url: string): ImageAssetTask;
  61842. /**
  61843. * Add a TextureAssetTask to the list of active tasks
  61844. * @param taskName defines the name of the new task
  61845. * @param url defines the url of the file to load
  61846. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61847. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61848. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61849. * @returns a new TextureAssetTask object
  61850. */
  61851. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61852. /**
  61853. * Add a CubeTextureAssetTask to the list of active tasks
  61854. * @param taskName defines the name of the new task
  61855. * @param url defines the url of the file to load
  61856. * @param extensions defines the extension to use to load the cube map (can be null)
  61857. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61858. * @param files defines the list of files to load (can be null)
  61859. * @returns a new CubeTextureAssetTask object
  61860. */
  61861. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61862. /**
  61863. *
  61864. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61865. * @param taskName defines the name of the new task
  61866. * @param url defines the url of the file to load
  61867. * @param size defines the size you want for the cubemap (can be null)
  61868. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61869. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61870. * @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)
  61871. * @param reserved Internal use only
  61872. * @returns a new HDRCubeTextureAssetTask object
  61873. */
  61874. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61875. /**
  61876. *
  61877. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61878. * @param taskName defines the name of the new task
  61879. * @param url defines the url of the file to load
  61880. * @param size defines the size you want for the cubemap (can be null)
  61881. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61882. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61883. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61884. * @returns a new EquiRectangularCubeTextureAssetTask object
  61885. */
  61886. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61887. /**
  61888. * Remove a task from the assets manager.
  61889. * @param task the task to remove
  61890. */
  61891. removeTask(task: AbstractAssetTask): void;
  61892. private _decreaseWaitingTasksCount;
  61893. private _runTask;
  61894. /**
  61895. * Reset the AssetsManager and remove all tasks
  61896. * @return the current instance of the AssetsManager
  61897. */
  61898. reset(): AssetsManager;
  61899. /**
  61900. * Start the loading process
  61901. * @return the current instance of the AssetsManager
  61902. */
  61903. load(): AssetsManager;
  61904. /**
  61905. * Start the loading process as an async operation
  61906. * @return a promise returning the list of failed tasks
  61907. */
  61908. loadAsync(): Promise<void>;
  61909. }
  61910. }
  61911. declare module "babylonjs/Misc/deferred" {
  61912. /**
  61913. * Wrapper class for promise with external resolve and reject.
  61914. */
  61915. export class Deferred<T> {
  61916. /**
  61917. * The promise associated with this deferred object.
  61918. */
  61919. readonly promise: Promise<T>;
  61920. private _resolve;
  61921. private _reject;
  61922. /**
  61923. * The resolve method of the promise associated with this deferred object.
  61924. */
  61925. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61926. /**
  61927. * The reject method of the promise associated with this deferred object.
  61928. */
  61929. readonly reject: (reason?: any) => void;
  61930. /**
  61931. * Constructor for this deferred object.
  61932. */
  61933. constructor();
  61934. }
  61935. }
  61936. declare module "babylonjs/Misc/meshExploder" {
  61937. import { Mesh } from "babylonjs/Meshes/mesh";
  61938. /**
  61939. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61940. */
  61941. export class MeshExploder {
  61942. private _centerMesh;
  61943. private _meshes;
  61944. private _meshesOrigins;
  61945. private _toCenterVectors;
  61946. private _scaledDirection;
  61947. private _newPosition;
  61948. private _centerPosition;
  61949. /**
  61950. * Explodes meshes from a center mesh.
  61951. * @param meshes The meshes to explode.
  61952. * @param centerMesh The mesh to be center of explosion.
  61953. */
  61954. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61955. private _setCenterMesh;
  61956. /**
  61957. * Get class name
  61958. * @returns "MeshExploder"
  61959. */
  61960. getClassName(): string;
  61961. /**
  61962. * "Exploded meshes"
  61963. * @returns Array of meshes with the centerMesh at index 0.
  61964. */
  61965. getMeshes(): Array<Mesh>;
  61966. /**
  61967. * Explodes meshes giving a specific direction
  61968. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61969. */
  61970. explode(direction?: number): void;
  61971. }
  61972. }
  61973. declare module "babylonjs/Misc/filesInput" {
  61974. import { Engine } from "babylonjs/Engines/engine";
  61975. import { Scene } from "babylonjs/scene";
  61976. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  61977. /**
  61978. * Class used to help managing file picking and drag'n'drop
  61979. */
  61980. export class FilesInput {
  61981. /**
  61982. * List of files ready to be loaded
  61983. */
  61984. static readonly FilesToLoad: {
  61985. [key: string]: File;
  61986. };
  61987. /**
  61988. * Callback called when a file is processed
  61989. */
  61990. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61991. private _engine;
  61992. private _currentScene;
  61993. private _sceneLoadedCallback;
  61994. private _progressCallback;
  61995. private _additionalRenderLoopLogicCallback;
  61996. private _textureLoadingCallback;
  61997. private _startingProcessingFilesCallback;
  61998. private _onReloadCallback;
  61999. private _errorCallback;
  62000. private _elementToMonitor;
  62001. private _sceneFileToLoad;
  62002. private _filesToLoad;
  62003. /**
  62004. * Creates a new FilesInput
  62005. * @param engine defines the rendering engine
  62006. * @param scene defines the hosting scene
  62007. * @param sceneLoadedCallback callback called when scene is loaded
  62008. * @param progressCallback callback called to track progress
  62009. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  62010. * @param textureLoadingCallback callback called when a texture is loading
  62011. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  62012. * @param onReloadCallback callback called when a reload is requested
  62013. * @param errorCallback callback call if an error occurs
  62014. */
  62015. 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);
  62016. private _dragEnterHandler;
  62017. private _dragOverHandler;
  62018. private _dropHandler;
  62019. /**
  62020. * Calls this function to listen to drag'n'drop events on a specific DOM element
  62021. * @param elementToMonitor defines the DOM element to track
  62022. */
  62023. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  62024. /**
  62025. * Release all associated resources
  62026. */
  62027. dispose(): void;
  62028. private renderFunction;
  62029. private drag;
  62030. private drop;
  62031. private _traverseFolder;
  62032. private _processFiles;
  62033. /**
  62034. * Load files from a drop event
  62035. * @param event defines the drop event to use as source
  62036. */
  62037. loadFiles(event: any): void;
  62038. private _processReload;
  62039. /**
  62040. * Reload the current scene from the loaded files
  62041. */
  62042. reload(): void;
  62043. }
  62044. }
  62045. declare module "babylonjs/Misc/HighDynamicRange/index" {
  62046. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  62047. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  62048. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  62049. }
  62050. declare module "babylonjs/Misc/sceneOptimizer" {
  62051. import { Scene, IDisposable } from "babylonjs/scene";
  62052. import { Observable } from "babylonjs/Misc/observable";
  62053. /**
  62054. * Defines the root class used to create scene optimization to use with SceneOptimizer
  62055. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62056. */
  62057. export class SceneOptimization {
  62058. /**
  62059. * Defines the priority of this optimization (0 by default which means first in the list)
  62060. */
  62061. priority: number;
  62062. /**
  62063. * Gets a string describing the action executed by the current optimization
  62064. * @returns description string
  62065. */
  62066. getDescription(): string;
  62067. /**
  62068. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62069. * @param scene defines the current scene where to apply this optimization
  62070. * @param optimizer defines the current optimizer
  62071. * @returns true if everything that can be done was applied
  62072. */
  62073. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62074. /**
  62075. * Creates the SceneOptimization object
  62076. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62077. * @param desc defines the description associated with the optimization
  62078. */
  62079. constructor(
  62080. /**
  62081. * Defines the priority of this optimization (0 by default which means first in the list)
  62082. */
  62083. priority?: number);
  62084. }
  62085. /**
  62086. * Defines an optimization used to reduce the size of render target textures
  62087. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62088. */
  62089. export class TextureOptimization extends SceneOptimization {
  62090. /**
  62091. * Defines the priority of this optimization (0 by default which means first in the list)
  62092. */
  62093. priority: number;
  62094. /**
  62095. * 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
  62096. */
  62097. maximumSize: number;
  62098. /**
  62099. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62100. */
  62101. step: number;
  62102. /**
  62103. * Gets a string describing the action executed by the current optimization
  62104. * @returns description string
  62105. */
  62106. getDescription(): string;
  62107. /**
  62108. * Creates the TextureOptimization object
  62109. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62110. * @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
  62111. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62112. */
  62113. constructor(
  62114. /**
  62115. * Defines the priority of this optimization (0 by default which means first in the list)
  62116. */
  62117. priority?: number,
  62118. /**
  62119. * 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
  62120. */
  62121. maximumSize?: number,
  62122. /**
  62123. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62124. */
  62125. step?: number);
  62126. /**
  62127. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62128. * @param scene defines the current scene where to apply this optimization
  62129. * @param optimizer defines the current optimizer
  62130. * @returns true if everything that can be done was applied
  62131. */
  62132. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62133. }
  62134. /**
  62135. * Defines an optimization used to increase or decrease the rendering resolution
  62136. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62137. */
  62138. export class HardwareScalingOptimization extends SceneOptimization {
  62139. /**
  62140. * Defines the priority of this optimization (0 by default which means first in the list)
  62141. */
  62142. priority: number;
  62143. /**
  62144. * Defines the maximum scale to use (2 by default)
  62145. */
  62146. maximumScale: number;
  62147. /**
  62148. * Defines the step to use between two passes (0.5 by default)
  62149. */
  62150. step: number;
  62151. private _currentScale;
  62152. private _directionOffset;
  62153. /**
  62154. * Gets a string describing the action executed by the current optimization
  62155. * @return description string
  62156. */
  62157. getDescription(): string;
  62158. /**
  62159. * Creates the HardwareScalingOptimization object
  62160. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62161. * @param maximumScale defines the maximum scale to use (2 by default)
  62162. * @param step defines the step to use between two passes (0.5 by default)
  62163. */
  62164. constructor(
  62165. /**
  62166. * Defines the priority of this optimization (0 by default which means first in the list)
  62167. */
  62168. priority?: number,
  62169. /**
  62170. * Defines the maximum scale to use (2 by default)
  62171. */
  62172. maximumScale?: number,
  62173. /**
  62174. * Defines the step to use between two passes (0.5 by default)
  62175. */
  62176. step?: number);
  62177. /**
  62178. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62179. * @param scene defines the current scene where to apply this optimization
  62180. * @param optimizer defines the current optimizer
  62181. * @returns true if everything that can be done was applied
  62182. */
  62183. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62184. }
  62185. /**
  62186. * Defines an optimization used to remove shadows
  62187. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62188. */
  62189. export class ShadowsOptimization extends SceneOptimization {
  62190. /**
  62191. * Gets a string describing the action executed by the current optimization
  62192. * @return description string
  62193. */
  62194. getDescription(): string;
  62195. /**
  62196. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62197. * @param scene defines the current scene where to apply this optimization
  62198. * @param optimizer defines the current optimizer
  62199. * @returns true if everything that can be done was applied
  62200. */
  62201. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62202. }
  62203. /**
  62204. * Defines an optimization used to turn post-processes off
  62205. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62206. */
  62207. export class PostProcessesOptimization extends SceneOptimization {
  62208. /**
  62209. * Gets a string describing the action executed by the current optimization
  62210. * @return description string
  62211. */
  62212. getDescription(): string;
  62213. /**
  62214. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62215. * @param scene defines the current scene where to apply this optimization
  62216. * @param optimizer defines the current optimizer
  62217. * @returns true if everything that can be done was applied
  62218. */
  62219. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62220. }
  62221. /**
  62222. * Defines an optimization used to turn lens flares off
  62223. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62224. */
  62225. export class LensFlaresOptimization extends SceneOptimization {
  62226. /**
  62227. * Gets a string describing the action executed by the current optimization
  62228. * @return description string
  62229. */
  62230. getDescription(): string;
  62231. /**
  62232. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62233. * @param scene defines the current scene where to apply this optimization
  62234. * @param optimizer defines the current optimizer
  62235. * @returns true if everything that can be done was applied
  62236. */
  62237. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62238. }
  62239. /**
  62240. * Defines an optimization based on user defined callback.
  62241. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62242. */
  62243. export class CustomOptimization extends SceneOptimization {
  62244. /**
  62245. * Callback called to apply the custom optimization.
  62246. */
  62247. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  62248. /**
  62249. * Callback called to get custom description
  62250. */
  62251. onGetDescription: () => string;
  62252. /**
  62253. * Gets a string describing the action executed by the current optimization
  62254. * @returns description string
  62255. */
  62256. getDescription(): string;
  62257. /**
  62258. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62259. * @param scene defines the current scene where to apply this optimization
  62260. * @param optimizer defines the current optimizer
  62261. * @returns true if everything that can be done was applied
  62262. */
  62263. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62264. }
  62265. /**
  62266. * Defines an optimization used to turn particles off
  62267. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62268. */
  62269. export class ParticlesOptimization extends SceneOptimization {
  62270. /**
  62271. * Gets a string describing the action executed by the current optimization
  62272. * @return description string
  62273. */
  62274. getDescription(): string;
  62275. /**
  62276. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62277. * @param scene defines the current scene where to apply this optimization
  62278. * @param optimizer defines the current optimizer
  62279. * @returns true if everything that can be done was applied
  62280. */
  62281. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62282. }
  62283. /**
  62284. * Defines an optimization used to turn render targets off
  62285. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62286. */
  62287. export class RenderTargetsOptimization extends SceneOptimization {
  62288. /**
  62289. * Gets a string describing the action executed by the current optimization
  62290. * @return description string
  62291. */
  62292. getDescription(): string;
  62293. /**
  62294. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62295. * @param scene defines the current scene where to apply this optimization
  62296. * @param optimizer defines the current optimizer
  62297. * @returns true if everything that can be done was applied
  62298. */
  62299. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62300. }
  62301. /**
  62302. * Defines an optimization used to merge meshes with compatible materials
  62303. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62304. */
  62305. export class MergeMeshesOptimization extends SceneOptimization {
  62306. private static _UpdateSelectionTree;
  62307. /**
  62308. * Gets or sets a boolean which defines if optimization octree has to be updated
  62309. */
  62310. /**
  62311. * Gets or sets a boolean which defines if optimization octree has to be updated
  62312. */
  62313. static UpdateSelectionTree: boolean;
  62314. /**
  62315. * Gets a string describing the action executed by the current optimization
  62316. * @return description string
  62317. */
  62318. getDescription(): string;
  62319. private _canBeMerged;
  62320. /**
  62321. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62322. * @param scene defines the current scene where to apply this optimization
  62323. * @param optimizer defines the current optimizer
  62324. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  62325. * @returns true if everything that can be done was applied
  62326. */
  62327. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  62328. }
  62329. /**
  62330. * Defines a list of options used by SceneOptimizer
  62331. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62332. */
  62333. export class SceneOptimizerOptions {
  62334. /**
  62335. * Defines the target frame rate to reach (60 by default)
  62336. */
  62337. targetFrameRate: number;
  62338. /**
  62339. * Defines the interval between two checkes (2000ms by default)
  62340. */
  62341. trackerDuration: number;
  62342. /**
  62343. * Gets the list of optimizations to apply
  62344. */
  62345. optimizations: SceneOptimization[];
  62346. /**
  62347. * Creates a new list of options used by SceneOptimizer
  62348. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  62349. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  62350. */
  62351. constructor(
  62352. /**
  62353. * Defines the target frame rate to reach (60 by default)
  62354. */
  62355. targetFrameRate?: number,
  62356. /**
  62357. * Defines the interval between two checkes (2000ms by default)
  62358. */
  62359. trackerDuration?: number);
  62360. /**
  62361. * Add a new optimization
  62362. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  62363. * @returns the current SceneOptimizerOptions
  62364. */
  62365. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  62366. /**
  62367. * Add a new custom optimization
  62368. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  62369. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  62370. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62371. * @returns the current SceneOptimizerOptions
  62372. */
  62373. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62374. /**
  62375. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62376. * @param targetFrameRate defines the target frame rate (60 by default)
  62377. * @returns a SceneOptimizerOptions object
  62378. */
  62379. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62380. /**
  62381. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62382. * @param targetFrameRate defines the target frame rate (60 by default)
  62383. * @returns a SceneOptimizerOptions object
  62384. */
  62385. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62386. /**
  62387. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62388. * @param targetFrameRate defines the target frame rate (60 by default)
  62389. * @returns a SceneOptimizerOptions object
  62390. */
  62391. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62392. }
  62393. /**
  62394. * Class used to run optimizations in order to reach a target frame rate
  62395. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62396. */
  62397. export class SceneOptimizer implements IDisposable {
  62398. private _isRunning;
  62399. private _options;
  62400. private _scene;
  62401. private _currentPriorityLevel;
  62402. private _targetFrameRate;
  62403. private _trackerDuration;
  62404. private _currentFrameRate;
  62405. private _sceneDisposeObserver;
  62406. private _improvementMode;
  62407. /**
  62408. * Defines an observable called when the optimizer reaches the target frame rate
  62409. */
  62410. onSuccessObservable: Observable<SceneOptimizer>;
  62411. /**
  62412. * Defines an observable called when the optimizer enables an optimization
  62413. */
  62414. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62415. /**
  62416. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62417. */
  62418. onFailureObservable: Observable<SceneOptimizer>;
  62419. /**
  62420. * Gets a boolean indicating if the optimizer is in improvement mode
  62421. */
  62422. readonly isInImprovementMode: boolean;
  62423. /**
  62424. * Gets the current priority level (0 at start)
  62425. */
  62426. readonly currentPriorityLevel: number;
  62427. /**
  62428. * Gets the current frame rate checked by the SceneOptimizer
  62429. */
  62430. readonly currentFrameRate: number;
  62431. /**
  62432. * Gets or sets the current target frame rate (60 by default)
  62433. */
  62434. /**
  62435. * Gets or sets the current target frame rate (60 by default)
  62436. */
  62437. targetFrameRate: number;
  62438. /**
  62439. * Gets or sets the current interval between two checks (every 2000ms by default)
  62440. */
  62441. /**
  62442. * Gets or sets the current interval between two checks (every 2000ms by default)
  62443. */
  62444. trackerDuration: number;
  62445. /**
  62446. * Gets the list of active optimizations
  62447. */
  62448. readonly optimizations: SceneOptimization[];
  62449. /**
  62450. * Creates a new SceneOptimizer
  62451. * @param scene defines the scene to work on
  62452. * @param options defines the options to use with the SceneOptimizer
  62453. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62454. * @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)
  62455. */
  62456. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62457. /**
  62458. * Stops the current optimizer
  62459. */
  62460. stop(): void;
  62461. /**
  62462. * Reset the optimizer to initial step (current priority level = 0)
  62463. */
  62464. reset(): void;
  62465. /**
  62466. * Start the optimizer. By default it will try to reach a specific framerate
  62467. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62468. */
  62469. start(): void;
  62470. private _checkCurrentState;
  62471. /**
  62472. * Release all resources
  62473. */
  62474. dispose(): void;
  62475. /**
  62476. * Helper function to create a SceneOptimizer with one single line of code
  62477. * @param scene defines the scene to work on
  62478. * @param options defines the options to use with the SceneOptimizer
  62479. * @param onSuccess defines a callback to call on success
  62480. * @param onFailure defines a callback to call on failure
  62481. * @returns the new SceneOptimizer object
  62482. */
  62483. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62484. }
  62485. }
  62486. declare module "babylonjs/Misc/sceneSerializer" {
  62487. import { Scene } from "babylonjs/scene";
  62488. /**
  62489. * Class used to serialize a scene into a string
  62490. */
  62491. export class SceneSerializer {
  62492. /**
  62493. * Clear cache used by a previous serialization
  62494. */
  62495. static ClearCache(): void;
  62496. /**
  62497. * Serialize a scene into a JSON compatible object
  62498. * @param scene defines the scene to serialize
  62499. * @returns a JSON compatible object
  62500. */
  62501. static Serialize(scene: Scene): any;
  62502. /**
  62503. * Serialize a mesh into a JSON compatible object
  62504. * @param toSerialize defines the mesh to serialize
  62505. * @param withParents defines if parents must be serialized as well
  62506. * @param withChildren defines if children must be serialized as well
  62507. * @returns a JSON compatible object
  62508. */
  62509. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62510. }
  62511. }
  62512. declare module "babylonjs/Misc/textureTools" {
  62513. import { Texture } from "babylonjs/Materials/Textures/texture";
  62514. /**
  62515. * Class used to host texture specific utilities
  62516. */
  62517. export class TextureTools {
  62518. /**
  62519. * Uses the GPU to create a copy texture rescaled at a given size
  62520. * @param texture Texture to copy from
  62521. * @param width defines the desired width
  62522. * @param height defines the desired height
  62523. * @param useBilinearMode defines if bilinear mode has to be used
  62524. * @return the generated texture
  62525. */
  62526. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62527. }
  62528. }
  62529. declare module "babylonjs/Misc/videoRecorder" {
  62530. import { Nullable } from "babylonjs/types";
  62531. import { Engine } from "babylonjs/Engines/engine";
  62532. /**
  62533. * This represents the different options available for the video capture.
  62534. */
  62535. export interface VideoRecorderOptions {
  62536. /** Defines the mime type of the video. */
  62537. mimeType: string;
  62538. /** Defines the FPS the video should be recorded at. */
  62539. fps: number;
  62540. /** Defines the chunk size for the recording data. */
  62541. recordChunckSize: number;
  62542. /** The audio tracks to attach to the recording. */
  62543. audioTracks?: MediaStreamTrack[];
  62544. }
  62545. /**
  62546. * This can help with recording videos from BabylonJS.
  62547. * This is based on the available WebRTC functionalities of the browser.
  62548. *
  62549. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62550. */
  62551. export class VideoRecorder {
  62552. private static readonly _defaultOptions;
  62553. /**
  62554. * Returns whether or not the VideoRecorder is available in your browser.
  62555. * @param engine Defines the Babylon Engine.
  62556. * @returns true if supported otherwise false.
  62557. */
  62558. static IsSupported(engine: Engine): boolean;
  62559. private readonly _options;
  62560. private _canvas;
  62561. private _mediaRecorder;
  62562. private _recordedChunks;
  62563. private _fileName;
  62564. private _resolve;
  62565. private _reject;
  62566. /**
  62567. * True when a recording is already in progress.
  62568. */
  62569. readonly isRecording: boolean;
  62570. /**
  62571. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62572. * @param engine Defines the BabylonJS Engine you wish to record.
  62573. * @param options Defines options that can be used to customize the capture.
  62574. */
  62575. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62576. /**
  62577. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62578. */
  62579. stopRecording(): void;
  62580. /**
  62581. * Starts recording the canvas for a max duration specified in parameters.
  62582. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62583. * If null no automatic download will start and you can rely on the promise to get the data back.
  62584. * @param maxDuration Defines the maximum recording time in seconds.
  62585. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62586. * @return A promise callback at the end of the recording with the video data in Blob.
  62587. */
  62588. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62589. /**
  62590. * Releases internal resources used during the recording.
  62591. */
  62592. dispose(): void;
  62593. private _handleDataAvailable;
  62594. private _handleError;
  62595. private _handleStop;
  62596. }
  62597. }
  62598. declare module "babylonjs/Misc/screenshotTools" {
  62599. import { Camera } from "babylonjs/Cameras/camera";
  62600. import { Engine } from "babylonjs/Engines/engine";
  62601. /**
  62602. * Class containing a set of static utilities functions for screenshots
  62603. */
  62604. export class ScreenshotTools {
  62605. /**
  62606. * Captures a screenshot of the current rendering
  62607. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62608. * @param engine defines the rendering engine
  62609. * @param camera defines the source camera
  62610. * @param size This parameter can be set to a single number or to an object with the
  62611. * following (optional) properties: precision, width, height. If a single number is passed,
  62612. * it will be used for both width and height. If an object is passed, the screenshot size
  62613. * will be derived from the parameters. The precision property is a multiplier allowing
  62614. * rendering at a higher or lower resolution
  62615. * @param successCallback defines the callback receives a single parameter which contains the
  62616. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62617. * src parameter of an <img> to display it
  62618. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62619. * Check your browser for supported MIME types
  62620. */
  62621. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  62622. /**
  62623. * Generates an image screenshot from the specified camera.
  62624. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62625. * @param engine The engine to use for rendering
  62626. * @param camera The camera to use for rendering
  62627. * @param size This parameter can be set to a single number or to an object with the
  62628. * following (optional) properties: precision, width, height. If a single number is passed,
  62629. * it will be used for both width and height. If an object is passed, the screenshot size
  62630. * will be derived from the parameters. The precision property is a multiplier allowing
  62631. * rendering at a higher or lower resolution
  62632. * @param successCallback The callback receives a single parameter which contains the
  62633. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62634. * src parameter of an <img> to display it
  62635. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62636. * Check your browser for supported MIME types
  62637. * @param samples Texture samples (default: 1)
  62638. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62639. * @param fileName A name for for the downloaded file.
  62640. */
  62641. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62642. }
  62643. }
  62644. declare module "babylonjs/Misc/index" {
  62645. export * from "babylonjs/Misc/andOrNotEvaluator";
  62646. export * from "babylonjs/Misc/assetsManager";
  62647. export * from "babylonjs/Misc/dds";
  62648. export * from "babylonjs/Misc/decorators";
  62649. export * from "babylonjs/Misc/deferred";
  62650. export * from "babylonjs/Misc/environmentTextureTools";
  62651. export * from "babylonjs/Misc/meshExploder";
  62652. export * from "babylonjs/Misc/filesInput";
  62653. export * from "babylonjs/Misc/HighDynamicRange/index";
  62654. export * from "babylonjs/Misc/khronosTextureContainer";
  62655. export * from "babylonjs/Misc/observable";
  62656. export * from "babylonjs/Misc/performanceMonitor";
  62657. export * from "babylonjs/Misc/promise";
  62658. export * from "babylonjs/Misc/sceneOptimizer";
  62659. export * from "babylonjs/Misc/sceneSerializer";
  62660. export * from "babylonjs/Misc/smartArray";
  62661. export * from "babylonjs/Misc/stringDictionary";
  62662. export * from "babylonjs/Misc/tags";
  62663. export * from "babylonjs/Misc/textureTools";
  62664. export * from "babylonjs/Misc/tga";
  62665. export * from "babylonjs/Misc/tools";
  62666. export * from "babylonjs/Misc/videoRecorder";
  62667. export * from "babylonjs/Misc/virtualJoystick";
  62668. export * from "babylonjs/Misc/workerPool";
  62669. export * from "babylonjs/Misc/logger";
  62670. export * from "babylonjs/Misc/typeStore";
  62671. export * from "babylonjs/Misc/filesInputStore";
  62672. export * from "babylonjs/Misc/deepCopier";
  62673. export * from "babylonjs/Misc/pivotTools";
  62674. export * from "babylonjs/Misc/precisionDate";
  62675. export * from "babylonjs/Misc/screenshotTools";
  62676. export * from "babylonjs/Misc/typeStore";
  62677. export * from "babylonjs/Misc/webRequest";
  62678. export * from "babylonjs/Misc/iInspectable";
  62679. export * from "babylonjs/Misc/brdfTextureTools";
  62680. }
  62681. declare module "babylonjs/index" {
  62682. export * from "babylonjs/abstractScene";
  62683. export * from "babylonjs/Actions/index";
  62684. export * from "babylonjs/Animations/index";
  62685. export * from "babylonjs/assetContainer";
  62686. export * from "babylonjs/Audio/index";
  62687. export * from "babylonjs/Behaviors/index";
  62688. export * from "babylonjs/Bones/index";
  62689. export * from "babylonjs/Cameras/index";
  62690. export * from "babylonjs/Collisions/index";
  62691. export * from "babylonjs/Culling/index";
  62692. export * from "babylonjs/Debug/index";
  62693. export * from "babylonjs/Engines/index";
  62694. export * from "babylonjs/Events/index";
  62695. export * from "babylonjs/Gamepads/index";
  62696. export * from "babylonjs/Gizmos/index";
  62697. export * from "babylonjs/Helpers/index";
  62698. export * from "babylonjs/Instrumentation/index";
  62699. export * from "babylonjs/Layers/index";
  62700. export * from "babylonjs/LensFlares/index";
  62701. export * from "babylonjs/Lights/index";
  62702. export * from "babylonjs/Loading/index";
  62703. export * from "babylonjs/Materials/index";
  62704. export * from "babylonjs/Maths/index";
  62705. export * from "babylonjs/Meshes/index";
  62706. export * from "babylonjs/Morph/index";
  62707. export * from "babylonjs/node";
  62708. export * from "babylonjs/Offline/index";
  62709. export * from "babylonjs/Particles/index";
  62710. export * from "babylonjs/Physics/index";
  62711. export * from "babylonjs/PostProcesses/index";
  62712. export * from "babylonjs/Probes/index";
  62713. export * from "babylonjs/Rendering/index";
  62714. export * from "babylonjs/scene";
  62715. export * from "babylonjs/sceneComponent";
  62716. export * from "babylonjs/Sprites/index";
  62717. export * from "babylonjs/States/index";
  62718. export * from "babylonjs/Misc/index";
  62719. export * from "babylonjs/types";
  62720. }
  62721. declare module "babylonjs/Animations/pathCursor" {
  62722. import { Path2, Vector3 } from "babylonjs/Maths/math";
  62723. /**
  62724. * A cursor which tracks a point on a path
  62725. */
  62726. export class PathCursor {
  62727. private path;
  62728. /**
  62729. * Stores path cursor callbacks for when an onchange event is triggered
  62730. */
  62731. private _onchange;
  62732. /**
  62733. * The value of the path cursor
  62734. */
  62735. value: number;
  62736. /**
  62737. * The animation array of the path cursor
  62738. */
  62739. animations: Animation[];
  62740. /**
  62741. * Initializes the path cursor
  62742. * @param path The path to track
  62743. */
  62744. constructor(path: Path2);
  62745. /**
  62746. * Gets the cursor point on the path
  62747. * @returns A point on the path cursor at the cursor location
  62748. */
  62749. getPoint(): Vector3;
  62750. /**
  62751. * Moves the cursor ahead by the step amount
  62752. * @param step The amount to move the cursor forward
  62753. * @returns This path cursor
  62754. */
  62755. moveAhead(step?: number): PathCursor;
  62756. /**
  62757. * Moves the cursor behind by the step amount
  62758. * @param step The amount to move the cursor back
  62759. * @returns This path cursor
  62760. */
  62761. moveBack(step?: number): PathCursor;
  62762. /**
  62763. * Moves the cursor by the step amount
  62764. * If the step amount is greater than one, an exception is thrown
  62765. * @param step The amount to move the cursor
  62766. * @returns This path cursor
  62767. */
  62768. move(step: number): PathCursor;
  62769. /**
  62770. * Ensures that the value is limited between zero and one
  62771. * @returns This path cursor
  62772. */
  62773. private ensureLimits;
  62774. /**
  62775. * Runs onchange callbacks on change (used by the animation engine)
  62776. * @returns This path cursor
  62777. */
  62778. private raiseOnChange;
  62779. /**
  62780. * Executes a function on change
  62781. * @param f A path cursor onchange callback
  62782. * @returns This path cursor
  62783. */
  62784. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62785. }
  62786. }
  62787. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  62788. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  62789. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  62790. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  62791. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  62792. }
  62793. declare module "babylonjs/Engines/Processors/Expressions/index" {
  62794. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  62795. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  62796. }
  62797. declare module "babylonjs/Engines/Processors/index" {
  62798. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  62799. export * from "babylonjs/Engines/Processors/Expressions/index";
  62800. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  62801. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  62802. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  62803. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  62804. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  62805. export * from "babylonjs/Engines/Processors/shaderProcessor";
  62806. }
  62807. declare module "babylonjs/Legacy/legacy" {
  62808. import * as Babylon from "babylonjs/index";
  62809. export * from "babylonjs/index";
  62810. }
  62811. declare module "babylonjs/Shaders/blur.fragment" {
  62812. /** @hidden */
  62813. export var blurPixelShader: {
  62814. name: string;
  62815. shader: string;
  62816. };
  62817. }
  62818. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  62819. /** @hidden */
  62820. export var pointCloudVertexDeclaration: {
  62821. name: string;
  62822. shader: string;
  62823. };
  62824. }
  62825. declare module "babylonjs" {
  62826. export * from "babylonjs/Legacy/legacy";
  62827. }
  62828. declare module BABYLON {
  62829. /** Alias type for value that can be null */
  62830. export type Nullable<T> = T | null;
  62831. /**
  62832. * Alias type for number that are floats
  62833. * @ignorenaming
  62834. */
  62835. export type float = number;
  62836. /**
  62837. * Alias type for number that are doubles.
  62838. * @ignorenaming
  62839. */
  62840. export type double = number;
  62841. /**
  62842. * Alias type for number that are integer
  62843. * @ignorenaming
  62844. */
  62845. export type int = number;
  62846. /** Alias type for number array or Float32Array */
  62847. export type FloatArray = number[] | Float32Array;
  62848. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  62849. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  62850. /**
  62851. * Alias for types that can be used by a Buffer or VertexBuffer.
  62852. */
  62853. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  62854. /**
  62855. * Alias type for primitive types
  62856. * @ignorenaming
  62857. */
  62858. type Primitive = undefined | null | boolean | string | number | Function;
  62859. /**
  62860. * Type modifier to make all the properties of an object Readonly
  62861. */
  62862. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  62863. /**
  62864. * Type modifier to make all the properties of an object Readonly recursively
  62865. */
  62866. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  62867. /** @hidden */
  62868. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  62869. }
  62870. /** @hidden */
  62871. /** @hidden */
  62872. type DeepImmutableObject<T> = {
  62873. readonly [K in keyof T]: DeepImmutable<T[K]>;
  62874. };
  62875. }
  62876. declare module BABYLON {
  62877. /**
  62878. * Class containing a set of static utilities functions for arrays.
  62879. */
  62880. export class ArrayTools {
  62881. /**
  62882. * Returns an array of the given size filled with element built from the given constructor and the paramters
  62883. * @param size the number of element to construct and put in the array
  62884. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  62885. * @returns a new array filled with new objects
  62886. */
  62887. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  62888. }
  62889. }
  62890. declare module BABYLON {
  62891. /**
  62892. * Scalar computation library
  62893. */
  62894. export class Scalar {
  62895. /**
  62896. * Two pi constants convenient for computation.
  62897. */
  62898. static TwoPi: number;
  62899. /**
  62900. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62901. * @param a number
  62902. * @param b number
  62903. * @param epsilon (default = 1.401298E-45)
  62904. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62905. */
  62906. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  62907. /**
  62908. * Returns a string : the upper case translation of the number i to hexadecimal.
  62909. * @param i number
  62910. * @returns the upper case translation of the number i to hexadecimal.
  62911. */
  62912. static ToHex(i: number): string;
  62913. /**
  62914. * Returns -1 if value is negative and +1 is value is positive.
  62915. * @param value the value
  62916. * @returns the value itself if it's equal to zero.
  62917. */
  62918. static Sign(value: number): number;
  62919. /**
  62920. * Returns the value itself if it's between min and max.
  62921. * Returns min if the value is lower than min.
  62922. * Returns max if the value is greater than max.
  62923. * @param value the value to clmap
  62924. * @param min the min value to clamp to (default: 0)
  62925. * @param max the max value to clamp to (default: 1)
  62926. * @returns the clamped value
  62927. */
  62928. static Clamp(value: number, min?: number, max?: number): number;
  62929. /**
  62930. * the log2 of value.
  62931. * @param value the value to compute log2 of
  62932. * @returns the log2 of value.
  62933. */
  62934. static Log2(value: number): number;
  62935. /**
  62936. * Loops the value, so that it is never larger than length and never smaller than 0.
  62937. *
  62938. * This is similar to the modulo operator but it works with floating point numbers.
  62939. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  62940. * With t = 5 and length = 2.5, the result would be 0.0.
  62941. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  62942. * @param value the value
  62943. * @param length the length
  62944. * @returns the looped value
  62945. */
  62946. static Repeat(value: number, length: number): number;
  62947. /**
  62948. * Normalize the value between 0.0 and 1.0 using min and max values
  62949. * @param value value to normalize
  62950. * @param min max to normalize between
  62951. * @param max min to normalize between
  62952. * @returns the normalized value
  62953. */
  62954. static Normalize(value: number, min: number, max: number): number;
  62955. /**
  62956. * Denormalize the value from 0.0 and 1.0 using min and max values
  62957. * @param normalized value to denormalize
  62958. * @param min max to denormalize between
  62959. * @param max min to denormalize between
  62960. * @returns the denormalized value
  62961. */
  62962. static Denormalize(normalized: number, min: number, max: number): number;
  62963. /**
  62964. * Calculates the shortest difference between two given angles given in degrees.
  62965. * @param current current angle in degrees
  62966. * @param target target angle in degrees
  62967. * @returns the delta
  62968. */
  62969. static DeltaAngle(current: number, target: number): number;
  62970. /**
  62971. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  62972. * @param tx value
  62973. * @param length length
  62974. * @returns The returned value will move back and forth between 0 and length
  62975. */
  62976. static PingPong(tx: number, length: number): number;
  62977. /**
  62978. * Interpolates between min and max with smoothing at the limits.
  62979. *
  62980. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  62981. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  62982. * @param from from
  62983. * @param to to
  62984. * @param tx value
  62985. * @returns the smooth stepped value
  62986. */
  62987. static SmoothStep(from: number, to: number, tx: number): number;
  62988. /**
  62989. * Moves a value current towards target.
  62990. *
  62991. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  62992. * Negative values of maxDelta pushes the value away from target.
  62993. * @param current current value
  62994. * @param target target value
  62995. * @param maxDelta max distance to move
  62996. * @returns resulting value
  62997. */
  62998. static MoveTowards(current: number, target: number, maxDelta: number): number;
  62999. /**
  63000. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  63001. *
  63002. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  63003. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  63004. * @param current current value
  63005. * @param target target value
  63006. * @param maxDelta max distance to move
  63007. * @returns resulting angle
  63008. */
  63009. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  63010. /**
  63011. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  63012. * @param start start value
  63013. * @param end target value
  63014. * @param amount amount to lerp between
  63015. * @returns the lerped value
  63016. */
  63017. static Lerp(start: number, end: number, amount: number): number;
  63018. /**
  63019. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  63020. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  63021. * @param start start value
  63022. * @param end target value
  63023. * @param amount amount to lerp between
  63024. * @returns the lerped value
  63025. */
  63026. static LerpAngle(start: number, end: number, amount: number): number;
  63027. /**
  63028. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  63029. * @param a start value
  63030. * @param b target value
  63031. * @param value value between a and b
  63032. * @returns the inverseLerp value
  63033. */
  63034. static InverseLerp(a: number, b: number, value: number): number;
  63035. /**
  63036. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  63037. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  63038. * @param value1 spline value
  63039. * @param tangent1 spline value
  63040. * @param value2 spline value
  63041. * @param tangent2 spline value
  63042. * @param amount input value
  63043. * @returns hermite result
  63044. */
  63045. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  63046. /**
  63047. * Returns a random float number between and min and max values
  63048. * @param min min value of random
  63049. * @param max max value of random
  63050. * @returns random value
  63051. */
  63052. static RandomRange(min: number, max: number): number;
  63053. /**
  63054. * This function returns percentage of a number in a given range.
  63055. *
  63056. * RangeToPercent(40,20,60) will return 0.5 (50%)
  63057. * RangeToPercent(34,0,100) will return 0.34 (34%)
  63058. * @param number to convert to percentage
  63059. * @param min min range
  63060. * @param max max range
  63061. * @returns the percentage
  63062. */
  63063. static RangeToPercent(number: number, min: number, max: number): number;
  63064. /**
  63065. * This function returns number that corresponds to the percentage in a given range.
  63066. *
  63067. * PercentToRange(0.34,0,100) will return 34.
  63068. * @param percent to convert to number
  63069. * @param min min range
  63070. * @param max max range
  63071. * @returns the number
  63072. */
  63073. static PercentToRange(percent: number, min: number, max: number): number;
  63074. /**
  63075. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  63076. * @param angle The angle to normalize in radian.
  63077. * @return The converted angle.
  63078. */
  63079. static NormalizeRadians(angle: number): number;
  63080. }
  63081. }
  63082. declare module BABYLON {
  63083. /**
  63084. * Constant used to convert a value to gamma space
  63085. * @ignorenaming
  63086. */
  63087. export const ToGammaSpace: number;
  63088. /**
  63089. * Constant used to convert a value to linear space
  63090. * @ignorenaming
  63091. */
  63092. export const ToLinearSpace = 2.2;
  63093. /**
  63094. * Constant used to define the minimal number value in Babylon.js
  63095. * @ignorenaming
  63096. */
  63097. let Epsilon: number;
  63098. /**
  63099. * Class used to hold a RBG color
  63100. */
  63101. export class Color3 {
  63102. /**
  63103. * Defines the red component (between 0 and 1, default is 0)
  63104. */
  63105. r: number;
  63106. /**
  63107. * Defines the green component (between 0 and 1, default is 0)
  63108. */
  63109. g: number;
  63110. /**
  63111. * Defines the blue component (between 0 and 1, default is 0)
  63112. */
  63113. b: number;
  63114. /**
  63115. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  63116. * @param r defines the red component (between 0 and 1, default is 0)
  63117. * @param g defines the green component (between 0 and 1, default is 0)
  63118. * @param b defines the blue component (between 0 and 1, default is 0)
  63119. */
  63120. constructor(
  63121. /**
  63122. * Defines the red component (between 0 and 1, default is 0)
  63123. */
  63124. r?: number,
  63125. /**
  63126. * Defines the green component (between 0 and 1, default is 0)
  63127. */
  63128. g?: number,
  63129. /**
  63130. * Defines the blue component (between 0 and 1, default is 0)
  63131. */
  63132. b?: number);
  63133. /**
  63134. * Creates a string with the Color3 current values
  63135. * @returns the string representation of the Color3 object
  63136. */
  63137. toString(): string;
  63138. /**
  63139. * Returns the string "Color3"
  63140. * @returns "Color3"
  63141. */
  63142. getClassName(): string;
  63143. /**
  63144. * Compute the Color3 hash code
  63145. * @returns an unique number that can be used to hash Color3 objects
  63146. */
  63147. getHashCode(): number;
  63148. /**
  63149. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  63150. * @param array defines the array where to store the r,g,b components
  63151. * @param index defines an optional index in the target array to define where to start storing values
  63152. * @returns the current Color3 object
  63153. */
  63154. toArray(array: FloatArray, index?: number): Color3;
  63155. /**
  63156. * Returns a new Color4 object from the current Color3 and the given alpha
  63157. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  63158. * @returns a new Color4 object
  63159. */
  63160. toColor4(alpha?: number): Color4;
  63161. /**
  63162. * Returns a new array populated with 3 numeric elements : red, green and blue values
  63163. * @returns the new array
  63164. */
  63165. asArray(): number[];
  63166. /**
  63167. * Returns the luminance value
  63168. * @returns a float value
  63169. */
  63170. toLuminance(): number;
  63171. /**
  63172. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  63173. * @param otherColor defines the second operand
  63174. * @returns the new Color3 object
  63175. */
  63176. multiply(otherColor: DeepImmutable<Color3>): Color3;
  63177. /**
  63178. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  63179. * @param otherColor defines the second operand
  63180. * @param result defines the Color3 object where to store the result
  63181. * @returns the current Color3
  63182. */
  63183. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63184. /**
  63185. * Determines equality between Color3 objects
  63186. * @param otherColor defines the second operand
  63187. * @returns true if the rgb values are equal to the given ones
  63188. */
  63189. equals(otherColor: DeepImmutable<Color3>): boolean;
  63190. /**
  63191. * Determines equality between the current Color3 object and a set of r,b,g values
  63192. * @param r defines the red component to check
  63193. * @param g defines the green component to check
  63194. * @param b defines the blue component to check
  63195. * @returns true if the rgb values are equal to the given ones
  63196. */
  63197. equalsFloats(r: number, g: number, b: number): boolean;
  63198. /**
  63199. * Multiplies in place each rgb value by scale
  63200. * @param scale defines the scaling factor
  63201. * @returns the updated Color3
  63202. */
  63203. scale(scale: number): Color3;
  63204. /**
  63205. * Multiplies the rgb values by scale and stores the result into "result"
  63206. * @param scale defines the scaling factor
  63207. * @param result defines the Color3 object where to store the result
  63208. * @returns the unmodified current Color3
  63209. */
  63210. scaleToRef(scale: number, result: Color3): Color3;
  63211. /**
  63212. * Scale the current Color3 values by a factor and add the result to a given Color3
  63213. * @param scale defines the scale factor
  63214. * @param result defines color to store the result into
  63215. * @returns the unmodified current Color3
  63216. */
  63217. scaleAndAddToRef(scale: number, result: Color3): Color3;
  63218. /**
  63219. * Clamps the rgb values by the min and max values and stores the result into "result"
  63220. * @param min defines minimum clamping value (default is 0)
  63221. * @param max defines maximum clamping value (default is 1)
  63222. * @param result defines color to store the result into
  63223. * @returns the original Color3
  63224. */
  63225. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  63226. /**
  63227. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  63228. * @param otherColor defines the second operand
  63229. * @returns the new Color3
  63230. */
  63231. add(otherColor: DeepImmutable<Color3>): Color3;
  63232. /**
  63233. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  63234. * @param otherColor defines the second operand
  63235. * @param result defines Color3 object to store the result into
  63236. * @returns the unmodified current Color3
  63237. */
  63238. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63239. /**
  63240. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  63241. * @param otherColor defines the second operand
  63242. * @returns the new Color3
  63243. */
  63244. subtract(otherColor: DeepImmutable<Color3>): Color3;
  63245. /**
  63246. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  63247. * @param otherColor defines the second operand
  63248. * @param result defines Color3 object to store the result into
  63249. * @returns the unmodified current Color3
  63250. */
  63251. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63252. /**
  63253. * Copy the current object
  63254. * @returns a new Color3 copied the current one
  63255. */
  63256. clone(): Color3;
  63257. /**
  63258. * Copies the rgb values from the source in the current Color3
  63259. * @param source defines the source Color3 object
  63260. * @returns the updated Color3 object
  63261. */
  63262. copyFrom(source: DeepImmutable<Color3>): Color3;
  63263. /**
  63264. * Updates the Color3 rgb values from the given floats
  63265. * @param r defines the red component to read from
  63266. * @param g defines the green component to read from
  63267. * @param b defines the blue component to read from
  63268. * @returns the current Color3 object
  63269. */
  63270. copyFromFloats(r: number, g: number, b: number): Color3;
  63271. /**
  63272. * Updates the Color3 rgb values from the given floats
  63273. * @param r defines the red component to read from
  63274. * @param g defines the green component to read from
  63275. * @param b defines the blue component to read from
  63276. * @returns the current Color3 object
  63277. */
  63278. set(r: number, g: number, b: number): Color3;
  63279. /**
  63280. * Compute the Color3 hexadecimal code as a string
  63281. * @returns a string containing the hexadecimal representation of the Color3 object
  63282. */
  63283. toHexString(): string;
  63284. /**
  63285. * Computes a new Color3 converted from the current one to linear space
  63286. * @returns a new Color3 object
  63287. */
  63288. toLinearSpace(): Color3;
  63289. /**
  63290. * Converts current color in rgb space to HSV values
  63291. * @returns a new color3 representing the HSV values
  63292. */
  63293. toHSV(): Color3;
  63294. /**
  63295. * Converts current color in rgb space to HSV values
  63296. * @param result defines the Color3 where to store the HSV values
  63297. */
  63298. toHSVToRef(result: Color3): void;
  63299. /**
  63300. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  63301. * @param convertedColor defines the Color3 object where to store the linear space version
  63302. * @returns the unmodified Color3
  63303. */
  63304. toLinearSpaceToRef(convertedColor: Color3): Color3;
  63305. /**
  63306. * Computes a new Color3 converted from the current one to gamma space
  63307. * @returns a new Color3 object
  63308. */
  63309. toGammaSpace(): Color3;
  63310. /**
  63311. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  63312. * @param convertedColor defines the Color3 object where to store the gamma space version
  63313. * @returns the unmodified Color3
  63314. */
  63315. toGammaSpaceToRef(convertedColor: Color3): Color3;
  63316. private static _BlackReadOnly;
  63317. /**
  63318. * Convert Hue, saturation and value to a Color3 (RGB)
  63319. * @param hue defines the hue
  63320. * @param saturation defines the saturation
  63321. * @param value defines the value
  63322. * @param result defines the Color3 where to store the RGB values
  63323. */
  63324. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  63325. /**
  63326. * Creates a new Color3 from the string containing valid hexadecimal values
  63327. * @param hex defines a string containing valid hexadecimal values
  63328. * @returns a new Color3 object
  63329. */
  63330. static FromHexString(hex: string): Color3;
  63331. /**
  63332. * Creates a new Color3 from the starting index of the given array
  63333. * @param array defines the source array
  63334. * @param offset defines an offset in the source array
  63335. * @returns a new Color3 object
  63336. */
  63337. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  63338. /**
  63339. * Creates a new Color3 from integer values (< 256)
  63340. * @param r defines the red component to read from (value between 0 and 255)
  63341. * @param g defines the green component to read from (value between 0 and 255)
  63342. * @param b defines the blue component to read from (value between 0 and 255)
  63343. * @returns a new Color3 object
  63344. */
  63345. static FromInts(r: number, g: number, b: number): Color3;
  63346. /**
  63347. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63348. * @param start defines the start Color3 value
  63349. * @param end defines the end Color3 value
  63350. * @param amount defines the gradient value between start and end
  63351. * @returns a new Color3 object
  63352. */
  63353. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  63354. /**
  63355. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63356. * @param left defines the start value
  63357. * @param right defines the end value
  63358. * @param amount defines the gradient factor
  63359. * @param result defines the Color3 object where to store the result
  63360. */
  63361. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  63362. /**
  63363. * Returns a Color3 value containing a red color
  63364. * @returns a new Color3 object
  63365. */
  63366. static Red(): Color3;
  63367. /**
  63368. * Returns a Color3 value containing a green color
  63369. * @returns a new Color3 object
  63370. */
  63371. static Green(): Color3;
  63372. /**
  63373. * Returns a Color3 value containing a blue color
  63374. * @returns a new Color3 object
  63375. */
  63376. static Blue(): Color3;
  63377. /**
  63378. * Returns a Color3 value containing a black color
  63379. * @returns a new Color3 object
  63380. */
  63381. static Black(): Color3;
  63382. /**
  63383. * Gets a Color3 value containing a black color that must not be updated
  63384. */
  63385. static readonly BlackReadOnly: DeepImmutable<Color3>;
  63386. /**
  63387. * Returns a Color3 value containing a white color
  63388. * @returns a new Color3 object
  63389. */
  63390. static White(): Color3;
  63391. /**
  63392. * Returns a Color3 value containing a purple color
  63393. * @returns a new Color3 object
  63394. */
  63395. static Purple(): Color3;
  63396. /**
  63397. * Returns a Color3 value containing a magenta color
  63398. * @returns a new Color3 object
  63399. */
  63400. static Magenta(): Color3;
  63401. /**
  63402. * Returns a Color3 value containing a yellow color
  63403. * @returns a new Color3 object
  63404. */
  63405. static Yellow(): Color3;
  63406. /**
  63407. * Returns a Color3 value containing a gray color
  63408. * @returns a new Color3 object
  63409. */
  63410. static Gray(): Color3;
  63411. /**
  63412. * Returns a Color3 value containing a teal color
  63413. * @returns a new Color3 object
  63414. */
  63415. static Teal(): Color3;
  63416. /**
  63417. * Returns a Color3 value containing a random color
  63418. * @returns a new Color3 object
  63419. */
  63420. static Random(): Color3;
  63421. }
  63422. /**
  63423. * Class used to hold a RBGA color
  63424. */
  63425. export class Color4 {
  63426. /**
  63427. * Defines the red component (between 0 and 1, default is 0)
  63428. */
  63429. r: number;
  63430. /**
  63431. * Defines the green component (between 0 and 1, default is 0)
  63432. */
  63433. g: number;
  63434. /**
  63435. * Defines the blue component (between 0 and 1, default is 0)
  63436. */
  63437. b: number;
  63438. /**
  63439. * Defines the alpha component (between 0 and 1, default is 1)
  63440. */
  63441. a: number;
  63442. /**
  63443. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  63444. * @param r defines the red component (between 0 and 1, default is 0)
  63445. * @param g defines the green component (between 0 and 1, default is 0)
  63446. * @param b defines the blue component (between 0 and 1, default is 0)
  63447. * @param a defines the alpha component (between 0 and 1, default is 1)
  63448. */
  63449. constructor(
  63450. /**
  63451. * Defines the red component (between 0 and 1, default is 0)
  63452. */
  63453. r?: number,
  63454. /**
  63455. * Defines the green component (between 0 and 1, default is 0)
  63456. */
  63457. g?: number,
  63458. /**
  63459. * Defines the blue component (between 0 and 1, default is 0)
  63460. */
  63461. b?: number,
  63462. /**
  63463. * Defines the alpha component (between 0 and 1, default is 1)
  63464. */
  63465. a?: number);
  63466. /**
  63467. * Adds in place the given Color4 values to the current Color4 object
  63468. * @param right defines the second operand
  63469. * @returns the current updated Color4 object
  63470. */
  63471. addInPlace(right: DeepImmutable<Color4>): Color4;
  63472. /**
  63473. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  63474. * @returns the new array
  63475. */
  63476. asArray(): number[];
  63477. /**
  63478. * Stores from the starting index in the given array the Color4 successive values
  63479. * @param array defines the array where to store the r,g,b components
  63480. * @param index defines an optional index in the target array to define where to start storing values
  63481. * @returns the current Color4 object
  63482. */
  63483. toArray(array: number[], index?: number): Color4;
  63484. /**
  63485. * Determines equality between Color4 objects
  63486. * @param otherColor defines the second operand
  63487. * @returns true if the rgba values are equal to the given ones
  63488. */
  63489. equals(otherColor: DeepImmutable<Color4>): boolean;
  63490. /**
  63491. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  63492. * @param right defines the second operand
  63493. * @returns a new Color4 object
  63494. */
  63495. add(right: DeepImmutable<Color4>): Color4;
  63496. /**
  63497. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  63498. * @param right defines the second operand
  63499. * @returns a new Color4 object
  63500. */
  63501. subtract(right: DeepImmutable<Color4>): Color4;
  63502. /**
  63503. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  63504. * @param right defines the second operand
  63505. * @param result defines the Color4 object where to store the result
  63506. * @returns the current Color4 object
  63507. */
  63508. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  63509. /**
  63510. * Creates a new Color4 with the current Color4 values multiplied by scale
  63511. * @param scale defines the scaling factor to apply
  63512. * @returns a new Color4 object
  63513. */
  63514. scale(scale: number): Color4;
  63515. /**
  63516. * Multiplies the current Color4 values by scale and stores the result in "result"
  63517. * @param scale defines the scaling factor to apply
  63518. * @param result defines the Color4 object where to store the result
  63519. * @returns the current unmodified Color4
  63520. */
  63521. scaleToRef(scale: number, result: Color4): Color4;
  63522. /**
  63523. * Scale the current Color4 values by a factor and add the result to a given Color4
  63524. * @param scale defines the scale factor
  63525. * @param result defines the Color4 object where to store the result
  63526. * @returns the unmodified current Color4
  63527. */
  63528. scaleAndAddToRef(scale: number, result: Color4): Color4;
  63529. /**
  63530. * Clamps the rgb values by the min and max values and stores the result into "result"
  63531. * @param min defines minimum clamping value (default is 0)
  63532. * @param max defines maximum clamping value (default is 1)
  63533. * @param result defines color to store the result into.
  63534. * @returns the cuurent Color4
  63535. */
  63536. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  63537. /**
  63538. * Multipy an Color4 value by another and return a new Color4 object
  63539. * @param color defines the Color4 value to multiply by
  63540. * @returns a new Color4 object
  63541. */
  63542. multiply(color: Color4): Color4;
  63543. /**
  63544. * Multipy a Color4 value by another and push the result in a reference value
  63545. * @param color defines the Color4 value to multiply by
  63546. * @param result defines the Color4 to fill the result in
  63547. * @returns the result Color4
  63548. */
  63549. multiplyToRef(color: Color4, result: Color4): Color4;
  63550. /**
  63551. * Creates a string with the Color4 current values
  63552. * @returns the string representation of the Color4 object
  63553. */
  63554. toString(): string;
  63555. /**
  63556. * Returns the string "Color4"
  63557. * @returns "Color4"
  63558. */
  63559. getClassName(): string;
  63560. /**
  63561. * Compute the Color4 hash code
  63562. * @returns an unique number that can be used to hash Color4 objects
  63563. */
  63564. getHashCode(): number;
  63565. /**
  63566. * Creates a new Color4 copied from the current one
  63567. * @returns a new Color4 object
  63568. */
  63569. clone(): Color4;
  63570. /**
  63571. * Copies the given Color4 values into the current one
  63572. * @param source defines the source Color4 object
  63573. * @returns the current updated Color4 object
  63574. */
  63575. copyFrom(source: Color4): Color4;
  63576. /**
  63577. * Copies the given float values into the current one
  63578. * @param r defines the red component to read from
  63579. * @param g defines the green component to read from
  63580. * @param b defines the blue component to read from
  63581. * @param a defines the alpha component to read from
  63582. * @returns the current updated Color4 object
  63583. */
  63584. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  63585. /**
  63586. * Copies the given float values into the current one
  63587. * @param r defines the red component to read from
  63588. * @param g defines the green component to read from
  63589. * @param b defines the blue component to read from
  63590. * @param a defines the alpha component to read from
  63591. * @returns the current updated Color4 object
  63592. */
  63593. set(r: number, g: number, b: number, a: number): Color4;
  63594. /**
  63595. * Compute the Color4 hexadecimal code as a string
  63596. * @returns a string containing the hexadecimal representation of the Color4 object
  63597. */
  63598. toHexString(): string;
  63599. /**
  63600. * Computes a new Color4 converted from the current one to linear space
  63601. * @returns a new Color4 object
  63602. */
  63603. toLinearSpace(): Color4;
  63604. /**
  63605. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  63606. * @param convertedColor defines the Color4 object where to store the linear space version
  63607. * @returns the unmodified Color4
  63608. */
  63609. toLinearSpaceToRef(convertedColor: Color4): Color4;
  63610. /**
  63611. * Computes a new Color4 converted from the current one to gamma space
  63612. * @returns a new Color4 object
  63613. */
  63614. toGammaSpace(): Color4;
  63615. /**
  63616. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  63617. * @param convertedColor defines the Color4 object where to store the gamma space version
  63618. * @returns the unmodified Color4
  63619. */
  63620. toGammaSpaceToRef(convertedColor: Color4): Color4;
  63621. /**
  63622. * Creates a new Color4 from the string containing valid hexadecimal values
  63623. * @param hex defines a string containing valid hexadecimal values
  63624. * @returns a new Color4 object
  63625. */
  63626. static FromHexString(hex: string): Color4;
  63627. /**
  63628. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63629. * @param left defines the start value
  63630. * @param right defines the end value
  63631. * @param amount defines the gradient factor
  63632. * @returns a new Color4 object
  63633. */
  63634. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  63635. /**
  63636. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63637. * @param left defines the start value
  63638. * @param right defines the end value
  63639. * @param amount defines the gradient factor
  63640. * @param result defines the Color4 object where to store data
  63641. */
  63642. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  63643. /**
  63644. * Creates a new Color4 from a Color3 and an alpha value
  63645. * @param color3 defines the source Color3 to read from
  63646. * @param alpha defines the alpha component (1.0 by default)
  63647. * @returns a new Color4 object
  63648. */
  63649. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  63650. /**
  63651. * Creates a new Color4 from the starting index element of the given array
  63652. * @param array defines the source array to read from
  63653. * @param offset defines the offset in the source array
  63654. * @returns a new Color4 object
  63655. */
  63656. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  63657. /**
  63658. * Creates a new Color3 from integer values (< 256)
  63659. * @param r defines the red component to read from (value between 0 and 255)
  63660. * @param g defines the green component to read from (value between 0 and 255)
  63661. * @param b defines the blue component to read from (value between 0 and 255)
  63662. * @param a defines the alpha component to read from (value between 0 and 255)
  63663. * @returns a new Color3 object
  63664. */
  63665. static FromInts(r: number, g: number, b: number, a: number): Color4;
  63666. /**
  63667. * Check the content of a given array and convert it to an array containing RGBA data
  63668. * If the original array was already containing count * 4 values then it is returned directly
  63669. * @param colors defines the array to check
  63670. * @param count defines the number of RGBA data to expect
  63671. * @returns an array containing count * 4 values (RGBA)
  63672. */
  63673. static CheckColors4(colors: number[], count: number): number[];
  63674. }
  63675. /**
  63676. * Class representing a vector containing 2 coordinates
  63677. */
  63678. export class Vector2 {
  63679. /** defines the first coordinate */
  63680. x: number;
  63681. /** defines the second coordinate */
  63682. y: number;
  63683. /**
  63684. * Creates a new Vector2 from the given x and y coordinates
  63685. * @param x defines the first coordinate
  63686. * @param y defines the second coordinate
  63687. */
  63688. constructor(
  63689. /** defines the first coordinate */
  63690. x?: number,
  63691. /** defines the second coordinate */
  63692. y?: number);
  63693. /**
  63694. * Gets a string with the Vector2 coordinates
  63695. * @returns a string with the Vector2 coordinates
  63696. */
  63697. toString(): string;
  63698. /**
  63699. * Gets class name
  63700. * @returns the string "Vector2"
  63701. */
  63702. getClassName(): string;
  63703. /**
  63704. * Gets current vector hash code
  63705. * @returns the Vector2 hash code as a number
  63706. */
  63707. getHashCode(): number;
  63708. /**
  63709. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  63710. * @param array defines the source array
  63711. * @param index defines the offset in source array
  63712. * @returns the current Vector2
  63713. */
  63714. toArray(array: FloatArray, index?: number): Vector2;
  63715. /**
  63716. * Copy the current vector to an array
  63717. * @returns a new array with 2 elements: the Vector2 coordinates.
  63718. */
  63719. asArray(): number[];
  63720. /**
  63721. * Sets the Vector2 coordinates with the given Vector2 coordinates
  63722. * @param source defines the source Vector2
  63723. * @returns the current updated Vector2
  63724. */
  63725. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  63726. /**
  63727. * Sets the Vector2 coordinates with the given floats
  63728. * @param x defines the first coordinate
  63729. * @param y defines the second coordinate
  63730. * @returns the current updated Vector2
  63731. */
  63732. copyFromFloats(x: number, y: number): Vector2;
  63733. /**
  63734. * Sets the Vector2 coordinates with the given floats
  63735. * @param x defines the first coordinate
  63736. * @param y defines the second coordinate
  63737. * @returns the current updated Vector2
  63738. */
  63739. set(x: number, y: number): Vector2;
  63740. /**
  63741. * Add another vector with the current one
  63742. * @param otherVector defines the other vector
  63743. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  63744. */
  63745. add(otherVector: DeepImmutable<Vector2>): Vector2;
  63746. /**
  63747. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  63748. * @param otherVector defines the other vector
  63749. * @param result defines the target vector
  63750. * @returns the unmodified current Vector2
  63751. */
  63752. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63753. /**
  63754. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  63755. * @param otherVector defines the other vector
  63756. * @returns the current updated Vector2
  63757. */
  63758. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63759. /**
  63760. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  63761. * @param otherVector defines the other vector
  63762. * @returns a new Vector2
  63763. */
  63764. addVector3(otherVector: Vector3): Vector2;
  63765. /**
  63766. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  63767. * @param otherVector defines the other vector
  63768. * @returns a new Vector2
  63769. */
  63770. subtract(otherVector: Vector2): Vector2;
  63771. /**
  63772. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  63773. * @param otherVector defines the other vector
  63774. * @param result defines the target vector
  63775. * @returns the unmodified current Vector2
  63776. */
  63777. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63778. /**
  63779. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  63780. * @param otherVector defines the other vector
  63781. * @returns the current updated Vector2
  63782. */
  63783. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63784. /**
  63785. * Multiplies in place the current Vector2 coordinates by the given ones
  63786. * @param otherVector defines the other vector
  63787. * @returns the current updated Vector2
  63788. */
  63789. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63790. /**
  63791. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  63792. * @param otherVector defines the other vector
  63793. * @returns a new Vector2
  63794. */
  63795. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  63796. /**
  63797. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  63798. * @param otherVector defines the other vector
  63799. * @param result defines the target vector
  63800. * @returns the unmodified current Vector2
  63801. */
  63802. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63803. /**
  63804. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  63805. * @param x defines the first coordinate
  63806. * @param y defines the second coordinate
  63807. * @returns a new Vector2
  63808. */
  63809. multiplyByFloats(x: number, y: number): Vector2;
  63810. /**
  63811. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  63812. * @param otherVector defines the other vector
  63813. * @returns a new Vector2
  63814. */
  63815. divide(otherVector: Vector2): Vector2;
  63816. /**
  63817. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  63818. * @param otherVector defines the other vector
  63819. * @param result defines the target vector
  63820. * @returns the unmodified current Vector2
  63821. */
  63822. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63823. /**
  63824. * Divides the current Vector2 coordinates by the given ones
  63825. * @param otherVector defines the other vector
  63826. * @returns the current updated Vector2
  63827. */
  63828. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63829. /**
  63830. * Gets a new Vector2 with current Vector2 negated coordinates
  63831. * @returns a new Vector2
  63832. */
  63833. negate(): Vector2;
  63834. /**
  63835. * Multiply the Vector2 coordinates by scale
  63836. * @param scale defines the scaling factor
  63837. * @returns the current updated Vector2
  63838. */
  63839. scaleInPlace(scale: number): Vector2;
  63840. /**
  63841. * Returns a new Vector2 scaled by "scale" from the current Vector2
  63842. * @param scale defines the scaling factor
  63843. * @returns a new Vector2
  63844. */
  63845. scale(scale: number): Vector2;
  63846. /**
  63847. * Scale the current Vector2 values by a factor to a given Vector2
  63848. * @param scale defines the scale factor
  63849. * @param result defines the Vector2 object where to store the result
  63850. * @returns the unmodified current Vector2
  63851. */
  63852. scaleToRef(scale: number, result: Vector2): Vector2;
  63853. /**
  63854. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  63855. * @param scale defines the scale factor
  63856. * @param result defines the Vector2 object where to store the result
  63857. * @returns the unmodified current Vector2
  63858. */
  63859. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  63860. /**
  63861. * Gets a boolean if two vectors are equals
  63862. * @param otherVector defines the other vector
  63863. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  63864. */
  63865. equals(otherVector: DeepImmutable<Vector2>): boolean;
  63866. /**
  63867. * Gets a boolean if two vectors are equals (using an epsilon value)
  63868. * @param otherVector defines the other vector
  63869. * @param epsilon defines the minimal distance to consider equality
  63870. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  63871. */
  63872. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  63873. /**
  63874. * Gets a new Vector2 from current Vector2 floored values
  63875. * @returns a new Vector2
  63876. */
  63877. floor(): Vector2;
  63878. /**
  63879. * Gets a new Vector2 from current Vector2 floored values
  63880. * @returns a new Vector2
  63881. */
  63882. fract(): Vector2;
  63883. /**
  63884. * Gets the length of the vector
  63885. * @returns the vector length (float)
  63886. */
  63887. length(): number;
  63888. /**
  63889. * Gets the vector squared length
  63890. * @returns the vector squared length (float)
  63891. */
  63892. lengthSquared(): number;
  63893. /**
  63894. * Normalize the vector
  63895. * @returns the current updated Vector2
  63896. */
  63897. normalize(): Vector2;
  63898. /**
  63899. * Gets a new Vector2 copied from the Vector2
  63900. * @returns a new Vector2
  63901. */
  63902. clone(): Vector2;
  63903. /**
  63904. * Gets a new Vector2(0, 0)
  63905. * @returns a new Vector2
  63906. */
  63907. static Zero(): Vector2;
  63908. /**
  63909. * Gets a new Vector2(1, 1)
  63910. * @returns a new Vector2
  63911. */
  63912. static One(): Vector2;
  63913. /**
  63914. * Gets a new Vector2 set from the given index element of the given array
  63915. * @param array defines the data source
  63916. * @param offset defines the offset in the data source
  63917. * @returns a new Vector2
  63918. */
  63919. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  63920. /**
  63921. * Sets "result" from the given index element of the given array
  63922. * @param array defines the data source
  63923. * @param offset defines the offset in the data source
  63924. * @param result defines the target vector
  63925. */
  63926. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  63927. /**
  63928. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  63929. * @param value1 defines 1st point of control
  63930. * @param value2 defines 2nd point of control
  63931. * @param value3 defines 3rd point of control
  63932. * @param value4 defines 4th point of control
  63933. * @param amount defines the interpolation factor
  63934. * @returns a new Vector2
  63935. */
  63936. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  63937. /**
  63938. * 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".
  63939. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  63940. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  63941. * @param value defines the value to clamp
  63942. * @param min defines the lower limit
  63943. * @param max defines the upper limit
  63944. * @returns a new Vector2
  63945. */
  63946. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  63947. /**
  63948. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  63949. * @param value1 defines the 1st control point
  63950. * @param tangent1 defines the outgoing tangent
  63951. * @param value2 defines the 2nd control point
  63952. * @param tangent2 defines the incoming tangent
  63953. * @param amount defines the interpolation factor
  63954. * @returns a new Vector2
  63955. */
  63956. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  63957. /**
  63958. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  63959. * @param start defines the start vector
  63960. * @param end defines the end vector
  63961. * @param amount defines the interpolation factor
  63962. * @returns a new Vector2
  63963. */
  63964. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  63965. /**
  63966. * Gets the dot product of the vector "left" and the vector "right"
  63967. * @param left defines first vector
  63968. * @param right defines second vector
  63969. * @returns the dot product (float)
  63970. */
  63971. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  63972. /**
  63973. * Returns a new Vector2 equal to the normalized given vector
  63974. * @param vector defines the vector to normalize
  63975. * @returns a new Vector2
  63976. */
  63977. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  63978. /**
  63979. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  63980. * @param left defines 1st vector
  63981. * @param right defines 2nd vector
  63982. * @returns a new Vector2
  63983. */
  63984. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63985. /**
  63986. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  63987. * @param left defines 1st vector
  63988. * @param right defines 2nd vector
  63989. * @returns a new Vector2
  63990. */
  63991. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63992. /**
  63993. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  63994. * @param vector defines the vector to transform
  63995. * @param transformation defines the matrix to apply
  63996. * @returns a new Vector2
  63997. */
  63998. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  63999. /**
  64000. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  64001. * @param vector defines the vector to transform
  64002. * @param transformation defines the matrix to apply
  64003. * @param result defines the target vector
  64004. */
  64005. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  64006. /**
  64007. * Determines if a given vector is included in a triangle
  64008. * @param p defines the vector to test
  64009. * @param p0 defines 1st triangle point
  64010. * @param p1 defines 2nd triangle point
  64011. * @param p2 defines 3rd triangle point
  64012. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  64013. */
  64014. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  64015. /**
  64016. * Gets the distance between the vectors "value1" and "value2"
  64017. * @param value1 defines first vector
  64018. * @param value2 defines second vector
  64019. * @returns the distance between vectors
  64020. */
  64021. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  64022. /**
  64023. * Returns the squared distance between the vectors "value1" and "value2"
  64024. * @param value1 defines first vector
  64025. * @param value2 defines second vector
  64026. * @returns the squared distance between vectors
  64027. */
  64028. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  64029. /**
  64030. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  64031. * @param value1 defines first vector
  64032. * @param value2 defines second vector
  64033. * @returns a new Vector2
  64034. */
  64035. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  64036. /**
  64037. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  64038. * @param p defines the middle point
  64039. * @param segA defines one point of the segment
  64040. * @param segB defines the other point of the segment
  64041. * @returns the shortest distance
  64042. */
  64043. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  64044. }
  64045. /**
  64046. * Classed used to store (x,y,z) vector representation
  64047. * A Vector3 is the main object used in 3D geometry
  64048. * It can represent etiher the coordinates of a point the space, either a direction
  64049. * Reminder: js uses a left handed forward facing system
  64050. */
  64051. export class Vector3 {
  64052. /**
  64053. * Defines the first coordinates (on X axis)
  64054. */
  64055. x: number;
  64056. /**
  64057. * Defines the second coordinates (on Y axis)
  64058. */
  64059. y: number;
  64060. /**
  64061. * Defines the third coordinates (on Z axis)
  64062. */
  64063. z: number;
  64064. private static _UpReadOnly;
  64065. private static _ZeroReadOnly;
  64066. /**
  64067. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  64068. * @param x defines the first coordinates (on X axis)
  64069. * @param y defines the second coordinates (on Y axis)
  64070. * @param z defines the third coordinates (on Z axis)
  64071. */
  64072. constructor(
  64073. /**
  64074. * Defines the first coordinates (on X axis)
  64075. */
  64076. x?: number,
  64077. /**
  64078. * Defines the second coordinates (on Y axis)
  64079. */
  64080. y?: number,
  64081. /**
  64082. * Defines the third coordinates (on Z axis)
  64083. */
  64084. z?: number);
  64085. /**
  64086. * Creates a string representation of the Vector3
  64087. * @returns a string with the Vector3 coordinates.
  64088. */
  64089. toString(): string;
  64090. /**
  64091. * Gets the class name
  64092. * @returns the string "Vector3"
  64093. */
  64094. getClassName(): string;
  64095. /**
  64096. * Creates the Vector3 hash code
  64097. * @returns a number which tends to be unique between Vector3 instances
  64098. */
  64099. getHashCode(): number;
  64100. /**
  64101. * Creates an array containing three elements : the coordinates of the Vector3
  64102. * @returns a new array of numbers
  64103. */
  64104. asArray(): number[];
  64105. /**
  64106. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  64107. * @param array defines the destination array
  64108. * @param index defines the offset in the destination array
  64109. * @returns the current Vector3
  64110. */
  64111. toArray(array: FloatArray, index?: number): Vector3;
  64112. /**
  64113. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  64114. * @returns a new Quaternion object, computed from the Vector3 coordinates
  64115. */
  64116. toQuaternion(): Quaternion;
  64117. /**
  64118. * Adds the given vector to the current Vector3
  64119. * @param otherVector defines the second operand
  64120. * @returns the current updated Vector3
  64121. */
  64122. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  64123. /**
  64124. * Adds the given coordinates to the current Vector3
  64125. * @param x defines the x coordinate of the operand
  64126. * @param y defines the y coordinate of the operand
  64127. * @param z defines the z coordinate of the operand
  64128. * @returns the current updated Vector3
  64129. */
  64130. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64131. /**
  64132. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  64133. * @param otherVector defines the second operand
  64134. * @returns the resulting Vector3
  64135. */
  64136. add(otherVector: DeepImmutable<Vector3>): Vector3;
  64137. /**
  64138. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  64139. * @param otherVector defines the second operand
  64140. * @param result defines the Vector3 object where to store the result
  64141. * @returns the current Vector3
  64142. */
  64143. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64144. /**
  64145. * Subtract the given vector from the current Vector3
  64146. * @param otherVector defines the second operand
  64147. * @returns the current updated Vector3
  64148. */
  64149. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  64150. /**
  64151. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  64152. * @param otherVector defines the second operand
  64153. * @returns the resulting Vector3
  64154. */
  64155. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  64156. /**
  64157. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  64158. * @param otherVector defines the second operand
  64159. * @param result defines the Vector3 object where to store the result
  64160. * @returns the current Vector3
  64161. */
  64162. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64163. /**
  64164. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  64165. * @param x defines the x coordinate of the operand
  64166. * @param y defines the y coordinate of the operand
  64167. * @param z defines the z coordinate of the operand
  64168. * @returns the resulting Vector3
  64169. */
  64170. subtractFromFloats(x: number, y: number, z: number): Vector3;
  64171. /**
  64172. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  64173. * @param x defines the x coordinate of the operand
  64174. * @param y defines the y coordinate of the operand
  64175. * @param z defines the z coordinate of the operand
  64176. * @param result defines the Vector3 object where to store the result
  64177. * @returns the current Vector3
  64178. */
  64179. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  64180. /**
  64181. * Gets a new Vector3 set with the current Vector3 negated coordinates
  64182. * @returns a new Vector3
  64183. */
  64184. negate(): Vector3;
  64185. /**
  64186. * Multiplies the Vector3 coordinates by the float "scale"
  64187. * @param scale defines the multiplier factor
  64188. * @returns the current updated Vector3
  64189. */
  64190. scaleInPlace(scale: number): Vector3;
  64191. /**
  64192. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  64193. * @param scale defines the multiplier factor
  64194. * @returns a new Vector3
  64195. */
  64196. scale(scale: number): Vector3;
  64197. /**
  64198. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  64199. * @param scale defines the multiplier factor
  64200. * @param result defines the Vector3 object where to store the result
  64201. * @returns the current Vector3
  64202. */
  64203. scaleToRef(scale: number, result: Vector3): Vector3;
  64204. /**
  64205. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  64206. * @param scale defines the scale factor
  64207. * @param result defines the Vector3 object where to store the result
  64208. * @returns the unmodified current Vector3
  64209. */
  64210. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  64211. /**
  64212. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  64213. * @param otherVector defines the second operand
  64214. * @returns true if both vectors are equals
  64215. */
  64216. equals(otherVector: DeepImmutable<Vector3>): boolean;
  64217. /**
  64218. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  64219. * @param otherVector defines the second operand
  64220. * @param epsilon defines the minimal distance to define values as equals
  64221. * @returns true if both vectors are distant less than epsilon
  64222. */
  64223. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  64224. /**
  64225. * Returns true if the current Vector3 coordinates equals the given floats
  64226. * @param x defines the x coordinate of the operand
  64227. * @param y defines the y coordinate of the operand
  64228. * @param z defines the z coordinate of the operand
  64229. * @returns true if both vectors are equals
  64230. */
  64231. equalsToFloats(x: number, y: number, z: number): boolean;
  64232. /**
  64233. * Multiplies the current Vector3 coordinates by the given ones
  64234. * @param otherVector defines the second operand
  64235. * @returns the current updated Vector3
  64236. */
  64237. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  64238. /**
  64239. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  64240. * @param otherVector defines the second operand
  64241. * @returns the new Vector3
  64242. */
  64243. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  64244. /**
  64245. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  64246. * @param otherVector defines the second operand
  64247. * @param result defines the Vector3 object where to store the result
  64248. * @returns the current Vector3
  64249. */
  64250. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64251. /**
  64252. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  64253. * @param x defines the x coordinate of the operand
  64254. * @param y defines the y coordinate of the operand
  64255. * @param z defines the z coordinate of the operand
  64256. * @returns the new Vector3
  64257. */
  64258. multiplyByFloats(x: number, y: number, z: number): Vector3;
  64259. /**
  64260. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  64261. * @param otherVector defines the second operand
  64262. * @returns the new Vector3
  64263. */
  64264. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  64265. /**
  64266. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  64267. * @param otherVector defines the second operand
  64268. * @param result defines the Vector3 object where to store the result
  64269. * @returns the current Vector3
  64270. */
  64271. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64272. /**
  64273. * Divides the current Vector3 coordinates by the given ones.
  64274. * @param otherVector defines the second operand
  64275. * @returns the current updated Vector3
  64276. */
  64277. divideInPlace(otherVector: Vector3): Vector3;
  64278. /**
  64279. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  64280. * @param other defines the second operand
  64281. * @returns the current updated Vector3
  64282. */
  64283. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64284. /**
  64285. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  64286. * @param other defines the second operand
  64287. * @returns the current updated Vector3
  64288. */
  64289. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64290. /**
  64291. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  64292. * @param x defines the x coordinate of the operand
  64293. * @param y defines the y coordinate of the operand
  64294. * @param z defines the z coordinate of the operand
  64295. * @returns the current updated Vector3
  64296. */
  64297. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64298. /**
  64299. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  64300. * @param x defines the x coordinate of the operand
  64301. * @param y defines the y coordinate of the operand
  64302. * @param z defines the z coordinate of the operand
  64303. * @returns the current updated Vector3
  64304. */
  64305. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64306. /**
  64307. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  64308. * Check if is non uniform within a certain amount of decimal places to account for this
  64309. * @param epsilon the amount the values can differ
  64310. * @returns if the the vector is non uniform to a certain number of decimal places
  64311. */
  64312. isNonUniformWithinEpsilon(epsilon: number): boolean;
  64313. /**
  64314. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  64315. */
  64316. readonly isNonUniform: boolean;
  64317. /**
  64318. * Gets a new Vector3 from current Vector3 floored values
  64319. * @returns a new Vector3
  64320. */
  64321. floor(): Vector3;
  64322. /**
  64323. * Gets a new Vector3 from current Vector3 floored values
  64324. * @returns a new Vector3
  64325. */
  64326. fract(): Vector3;
  64327. /**
  64328. * Gets the length of the Vector3
  64329. * @returns the length of the Vector3
  64330. */
  64331. length(): number;
  64332. /**
  64333. * Gets the squared length of the Vector3
  64334. * @returns squared length of the Vector3
  64335. */
  64336. lengthSquared(): number;
  64337. /**
  64338. * Normalize the current Vector3.
  64339. * Please note that this is an in place operation.
  64340. * @returns the current updated Vector3
  64341. */
  64342. normalize(): Vector3;
  64343. /**
  64344. * Reorders the x y z properties of the vector in place
  64345. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  64346. * @returns the current updated vector
  64347. */
  64348. reorderInPlace(order: string): this;
  64349. /**
  64350. * Rotates the vector around 0,0,0 by a quaternion
  64351. * @param quaternion the rotation quaternion
  64352. * @param result vector to store the result
  64353. * @returns the resulting vector
  64354. */
  64355. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  64356. /**
  64357. * Rotates a vector around a given point
  64358. * @param quaternion the rotation quaternion
  64359. * @param point the point to rotate around
  64360. * @param result vector to store the result
  64361. * @returns the resulting vector
  64362. */
  64363. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  64364. /**
  64365. * Normalize the current Vector3 with the given input length.
  64366. * Please note that this is an in place operation.
  64367. * @param len the length of the vector
  64368. * @returns the current updated Vector3
  64369. */
  64370. normalizeFromLength(len: number): Vector3;
  64371. /**
  64372. * Normalize the current Vector3 to a new vector
  64373. * @returns the new Vector3
  64374. */
  64375. normalizeToNew(): Vector3;
  64376. /**
  64377. * Normalize the current Vector3 to the reference
  64378. * @param reference define the Vector3 to update
  64379. * @returns the updated Vector3
  64380. */
  64381. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  64382. /**
  64383. * Creates a new Vector3 copied from the current Vector3
  64384. * @returns the new Vector3
  64385. */
  64386. clone(): Vector3;
  64387. /**
  64388. * Copies the given vector coordinates to the current Vector3 ones
  64389. * @param source defines the source Vector3
  64390. * @returns the current updated Vector3
  64391. */
  64392. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  64393. /**
  64394. * Copies the given floats to the current Vector3 coordinates
  64395. * @param x defines the x coordinate of the operand
  64396. * @param y defines the y coordinate of the operand
  64397. * @param z defines the z coordinate of the operand
  64398. * @returns the current updated Vector3
  64399. */
  64400. copyFromFloats(x: number, y: number, z: number): Vector3;
  64401. /**
  64402. * Copies the given floats to the current Vector3 coordinates
  64403. * @param x defines the x coordinate of the operand
  64404. * @param y defines the y coordinate of the operand
  64405. * @param z defines the z coordinate of the operand
  64406. * @returns the current updated Vector3
  64407. */
  64408. set(x: number, y: number, z: number): Vector3;
  64409. /**
  64410. * Copies the given float to the current Vector3 coordinates
  64411. * @param v defines the x, y and z coordinates of the operand
  64412. * @returns the current updated Vector3
  64413. */
  64414. setAll(v: number): Vector3;
  64415. /**
  64416. * Get the clip factor between two vectors
  64417. * @param vector0 defines the first operand
  64418. * @param vector1 defines the second operand
  64419. * @param axis defines the axis to use
  64420. * @param size defines the size along the axis
  64421. * @returns the clip factor
  64422. */
  64423. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  64424. /**
  64425. * Get angle between two vectors
  64426. * @param vector0 angle between vector0 and vector1
  64427. * @param vector1 angle between vector0 and vector1
  64428. * @param normal direction of the normal
  64429. * @return the angle between vector0 and vector1
  64430. */
  64431. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  64432. /**
  64433. * Returns a new Vector3 set from the index "offset" of the given array
  64434. * @param array defines the source array
  64435. * @param offset defines the offset in the source array
  64436. * @returns the new Vector3
  64437. */
  64438. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  64439. /**
  64440. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  64441. * This function is deprecated. Use FromArray instead
  64442. * @param array defines the source array
  64443. * @param offset defines the offset in the source array
  64444. * @returns the new Vector3
  64445. */
  64446. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  64447. /**
  64448. * Sets the given vector "result" with the element values from the index "offset" of the given array
  64449. * @param array defines the source array
  64450. * @param offset defines the offset in the source array
  64451. * @param result defines the Vector3 where to store the result
  64452. */
  64453. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  64454. /**
  64455. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  64456. * This function is deprecated. Use FromArrayToRef instead.
  64457. * @param array defines the source array
  64458. * @param offset defines the offset in the source array
  64459. * @param result defines the Vector3 where to store the result
  64460. */
  64461. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  64462. /**
  64463. * Sets the given vector "result" with the given floats.
  64464. * @param x defines the x coordinate of the source
  64465. * @param y defines the y coordinate of the source
  64466. * @param z defines the z coordinate of the source
  64467. * @param result defines the Vector3 where to store the result
  64468. */
  64469. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  64470. /**
  64471. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  64472. * @returns a new empty Vector3
  64473. */
  64474. static Zero(): Vector3;
  64475. /**
  64476. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  64477. * @returns a new unit Vector3
  64478. */
  64479. static One(): Vector3;
  64480. /**
  64481. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  64482. * @returns a new up Vector3
  64483. */
  64484. static Up(): Vector3;
  64485. /**
  64486. * Gets a up Vector3 that must not be updated
  64487. */
  64488. static readonly UpReadOnly: DeepImmutable<Vector3>;
  64489. /**
  64490. * Gets a zero Vector3 that must not be updated
  64491. */
  64492. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  64493. /**
  64494. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  64495. * @returns a new down Vector3
  64496. */
  64497. static Down(): Vector3;
  64498. /**
  64499. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  64500. * @returns a new forward Vector3
  64501. */
  64502. static Forward(): Vector3;
  64503. /**
  64504. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  64505. * @returns a new forward Vector3
  64506. */
  64507. static Backward(): Vector3;
  64508. /**
  64509. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  64510. * @returns a new right Vector3
  64511. */
  64512. static Right(): Vector3;
  64513. /**
  64514. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  64515. * @returns a new left Vector3
  64516. */
  64517. static Left(): Vector3;
  64518. /**
  64519. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  64520. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64521. * @param vector defines the Vector3 to transform
  64522. * @param transformation defines the transformation matrix
  64523. * @returns the transformed Vector3
  64524. */
  64525. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64526. /**
  64527. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  64528. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64529. * @param vector defines the Vector3 to transform
  64530. * @param transformation defines the transformation matrix
  64531. * @param result defines the Vector3 where to store the result
  64532. */
  64533. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64534. /**
  64535. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  64536. * This method computes tranformed coordinates only, not transformed direction vectors
  64537. * @param x define the x coordinate of the source vector
  64538. * @param y define the y coordinate of the source vector
  64539. * @param z define the z coordinate of the source vector
  64540. * @param transformation defines the transformation matrix
  64541. * @param result defines the Vector3 where to store the result
  64542. */
  64543. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64544. /**
  64545. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  64546. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64547. * @param vector defines the Vector3 to transform
  64548. * @param transformation defines the transformation matrix
  64549. * @returns the new Vector3
  64550. */
  64551. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64552. /**
  64553. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  64554. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64555. * @param vector defines the Vector3 to transform
  64556. * @param transformation defines the transformation matrix
  64557. * @param result defines the Vector3 where to store the result
  64558. */
  64559. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64560. /**
  64561. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  64562. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64563. * @param x define the x coordinate of the source vector
  64564. * @param y define the y coordinate of the source vector
  64565. * @param z define the z coordinate of the source vector
  64566. * @param transformation defines the transformation matrix
  64567. * @param result defines the Vector3 where to store the result
  64568. */
  64569. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64570. /**
  64571. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  64572. * @param value1 defines the first control point
  64573. * @param value2 defines the second control point
  64574. * @param value3 defines the third control point
  64575. * @param value4 defines the fourth control point
  64576. * @param amount defines the amount on the spline to use
  64577. * @returns the new Vector3
  64578. */
  64579. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  64580. /**
  64581. * 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"
  64582. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64583. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64584. * @param value defines the current value
  64585. * @param min defines the lower range value
  64586. * @param max defines the upper range value
  64587. * @returns the new Vector3
  64588. */
  64589. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  64590. /**
  64591. * 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"
  64592. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64593. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64594. * @param value defines the current value
  64595. * @param min defines the lower range value
  64596. * @param max defines the upper range value
  64597. * @param result defines the Vector3 where to store the result
  64598. */
  64599. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  64600. /**
  64601. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  64602. * @param value1 defines the first control point
  64603. * @param tangent1 defines the first tangent vector
  64604. * @param value2 defines the second control point
  64605. * @param tangent2 defines the second tangent vector
  64606. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  64607. * @returns the new Vector3
  64608. */
  64609. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  64610. /**
  64611. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  64612. * @param start defines the start value
  64613. * @param end defines the end value
  64614. * @param amount max defines amount between both (between 0 and 1)
  64615. * @returns the new Vector3
  64616. */
  64617. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  64618. /**
  64619. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  64620. * @param start defines the start value
  64621. * @param end defines the end value
  64622. * @param amount max defines amount between both (between 0 and 1)
  64623. * @param result defines the Vector3 where to store the result
  64624. */
  64625. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  64626. /**
  64627. * Returns the dot product (float) between the vectors "left" and "right"
  64628. * @param left defines the left operand
  64629. * @param right defines the right operand
  64630. * @returns the dot product
  64631. */
  64632. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  64633. /**
  64634. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  64635. * The cross product is then orthogonal to both "left" and "right"
  64636. * @param left defines the left operand
  64637. * @param right defines the right operand
  64638. * @returns the cross product
  64639. */
  64640. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64641. /**
  64642. * Sets the given vector "result" with the cross product of "left" and "right"
  64643. * The cross product is then orthogonal to both "left" and "right"
  64644. * @param left defines the left operand
  64645. * @param right defines the right operand
  64646. * @param result defines the Vector3 where to store the result
  64647. */
  64648. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  64649. /**
  64650. * Returns a new Vector3 as the normalization of the given vector
  64651. * @param vector defines the Vector3 to normalize
  64652. * @returns the new Vector3
  64653. */
  64654. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  64655. /**
  64656. * Sets the given vector "result" with the normalization of the given first vector
  64657. * @param vector defines the Vector3 to normalize
  64658. * @param result defines the Vector3 where to store the result
  64659. */
  64660. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  64661. /**
  64662. * Project a Vector3 onto screen space
  64663. * @param vector defines the Vector3 to project
  64664. * @param world defines the world matrix to use
  64665. * @param transform defines the transform (view x projection) matrix to use
  64666. * @param viewport defines the screen viewport to use
  64667. * @returns the new Vector3
  64668. */
  64669. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  64670. /** @hidden */
  64671. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  64672. /**
  64673. * Unproject from screen space to object space
  64674. * @param source defines the screen space Vector3 to use
  64675. * @param viewportWidth defines the current width of the viewport
  64676. * @param viewportHeight defines the current height of the viewport
  64677. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64678. * @param transform defines the transform (view x projection) matrix to use
  64679. * @returns the new Vector3
  64680. */
  64681. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  64682. /**
  64683. * Unproject from screen space to object space
  64684. * @param source defines the screen space Vector3 to use
  64685. * @param viewportWidth defines the current width of the viewport
  64686. * @param viewportHeight defines the current height of the viewport
  64687. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64688. * @param view defines the view matrix to use
  64689. * @param projection defines the projection matrix to use
  64690. * @returns the new Vector3
  64691. */
  64692. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  64693. /**
  64694. * Unproject from screen space to object space
  64695. * @param source defines the screen space Vector3 to use
  64696. * @param viewportWidth defines the current width of the viewport
  64697. * @param viewportHeight defines the current height of the viewport
  64698. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64699. * @param view defines the view matrix to use
  64700. * @param projection defines the projection matrix to use
  64701. * @param result defines the Vector3 where to store the result
  64702. */
  64703. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64704. /**
  64705. * Unproject from screen space to object space
  64706. * @param sourceX defines the screen space x coordinate to use
  64707. * @param sourceY defines the screen space y coordinate to use
  64708. * @param sourceZ defines the screen space z coordinate to use
  64709. * @param viewportWidth defines the current width of the viewport
  64710. * @param viewportHeight defines the current height of the viewport
  64711. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64712. * @param view defines the view matrix to use
  64713. * @param projection defines the projection matrix to use
  64714. * @param result defines the Vector3 where to store the result
  64715. */
  64716. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64717. /**
  64718. * Gets the minimal coordinate values between two Vector3
  64719. * @param left defines the first operand
  64720. * @param right defines the second operand
  64721. * @returns the new Vector3
  64722. */
  64723. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64724. /**
  64725. * Gets the maximal coordinate values between two Vector3
  64726. * @param left defines the first operand
  64727. * @param right defines the second operand
  64728. * @returns the new Vector3
  64729. */
  64730. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64731. /**
  64732. * Returns the distance between the vectors "value1" and "value2"
  64733. * @param value1 defines the first operand
  64734. * @param value2 defines the second operand
  64735. * @returns the distance
  64736. */
  64737. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64738. /**
  64739. * Returns the squared distance between the vectors "value1" and "value2"
  64740. * @param value1 defines the first operand
  64741. * @param value2 defines the second operand
  64742. * @returns the squared distance
  64743. */
  64744. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64745. /**
  64746. * Returns a new Vector3 located at the center between "value1" and "value2"
  64747. * @param value1 defines the first operand
  64748. * @param value2 defines the second operand
  64749. * @returns the new Vector3
  64750. */
  64751. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  64752. /**
  64753. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  64754. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  64755. * to something in order to rotate it from its local system to the given target system
  64756. * Note: axis1, axis2 and axis3 are normalized during this operation
  64757. * @param axis1 defines the first axis
  64758. * @param axis2 defines the second axis
  64759. * @param axis3 defines the third axis
  64760. * @returns a new Vector3
  64761. */
  64762. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  64763. /**
  64764. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  64765. * @param axis1 defines the first axis
  64766. * @param axis2 defines the second axis
  64767. * @param axis3 defines the third axis
  64768. * @param ref defines the Vector3 where to store the result
  64769. */
  64770. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  64771. }
  64772. /**
  64773. * Vector4 class created for EulerAngle class conversion to Quaternion
  64774. */
  64775. export class Vector4 {
  64776. /** x value of the vector */
  64777. x: number;
  64778. /** y value of the vector */
  64779. y: number;
  64780. /** z value of the vector */
  64781. z: number;
  64782. /** w value of the vector */
  64783. w: number;
  64784. /**
  64785. * Creates a Vector4 object from the given floats.
  64786. * @param x x value of the vector
  64787. * @param y y value of the vector
  64788. * @param z z value of the vector
  64789. * @param w w value of the vector
  64790. */
  64791. constructor(
  64792. /** x value of the vector */
  64793. x: number,
  64794. /** y value of the vector */
  64795. y: number,
  64796. /** z value of the vector */
  64797. z: number,
  64798. /** w value of the vector */
  64799. w: number);
  64800. /**
  64801. * Returns the string with the Vector4 coordinates.
  64802. * @returns a string containing all the vector values
  64803. */
  64804. toString(): string;
  64805. /**
  64806. * Returns the string "Vector4".
  64807. * @returns "Vector4"
  64808. */
  64809. getClassName(): string;
  64810. /**
  64811. * Returns the Vector4 hash code.
  64812. * @returns a unique hash code
  64813. */
  64814. getHashCode(): number;
  64815. /**
  64816. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  64817. * @returns the resulting array
  64818. */
  64819. asArray(): number[];
  64820. /**
  64821. * Populates the given array from the given index with the Vector4 coordinates.
  64822. * @param array array to populate
  64823. * @param index index of the array to start at (default: 0)
  64824. * @returns the Vector4.
  64825. */
  64826. toArray(array: FloatArray, index?: number): Vector4;
  64827. /**
  64828. * Adds the given vector to the current Vector4.
  64829. * @param otherVector the vector to add
  64830. * @returns the updated Vector4.
  64831. */
  64832. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64833. /**
  64834. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  64835. * @param otherVector the vector to add
  64836. * @returns the resulting vector
  64837. */
  64838. add(otherVector: DeepImmutable<Vector4>): Vector4;
  64839. /**
  64840. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  64841. * @param otherVector the vector to add
  64842. * @param result the vector to store the result
  64843. * @returns the current Vector4.
  64844. */
  64845. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64846. /**
  64847. * Subtract in place the given vector from the current Vector4.
  64848. * @param otherVector the vector to subtract
  64849. * @returns the updated Vector4.
  64850. */
  64851. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64852. /**
  64853. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  64854. * @param otherVector the vector to add
  64855. * @returns the new vector with the result
  64856. */
  64857. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  64858. /**
  64859. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  64860. * @param otherVector the vector to subtract
  64861. * @param result the vector to store the result
  64862. * @returns the current Vector4.
  64863. */
  64864. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64865. /**
  64866. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64867. */
  64868. /**
  64869. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64870. * @param x value to subtract
  64871. * @param y value to subtract
  64872. * @param z value to subtract
  64873. * @param w value to subtract
  64874. * @returns new vector containing the result
  64875. */
  64876. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64877. /**
  64878. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64879. * @param x value to subtract
  64880. * @param y value to subtract
  64881. * @param z value to subtract
  64882. * @param w value to subtract
  64883. * @param result the vector to store the result in
  64884. * @returns the current Vector4.
  64885. */
  64886. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  64887. /**
  64888. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  64889. * @returns a new vector with the negated values
  64890. */
  64891. negate(): Vector4;
  64892. /**
  64893. * Multiplies the current Vector4 coordinates by scale (float).
  64894. * @param scale the number to scale with
  64895. * @returns the updated Vector4.
  64896. */
  64897. scaleInPlace(scale: number): Vector4;
  64898. /**
  64899. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  64900. * @param scale the number to scale with
  64901. * @returns a new vector with the result
  64902. */
  64903. scale(scale: number): Vector4;
  64904. /**
  64905. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  64906. * @param scale the number to scale with
  64907. * @param result a vector to store the result in
  64908. * @returns the current Vector4.
  64909. */
  64910. scaleToRef(scale: number, result: Vector4): Vector4;
  64911. /**
  64912. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  64913. * @param scale defines the scale factor
  64914. * @param result defines the Vector4 object where to store the result
  64915. * @returns the unmodified current Vector4
  64916. */
  64917. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  64918. /**
  64919. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  64920. * @param otherVector the vector to compare against
  64921. * @returns true if they are equal
  64922. */
  64923. equals(otherVector: DeepImmutable<Vector4>): boolean;
  64924. /**
  64925. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  64926. * @param otherVector vector to compare against
  64927. * @param epsilon (Default: very small number)
  64928. * @returns true if they are equal
  64929. */
  64930. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  64931. /**
  64932. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  64933. * @param x x value to compare against
  64934. * @param y y value to compare against
  64935. * @param z z value to compare against
  64936. * @param w w value to compare against
  64937. * @returns true if equal
  64938. */
  64939. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  64940. /**
  64941. * Multiplies in place the current Vector4 by the given one.
  64942. * @param otherVector vector to multiple with
  64943. * @returns the updated Vector4.
  64944. */
  64945. multiplyInPlace(otherVector: Vector4): Vector4;
  64946. /**
  64947. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  64948. * @param otherVector vector to multiple with
  64949. * @returns resulting new vector
  64950. */
  64951. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  64952. /**
  64953. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  64954. * @param otherVector vector to multiple with
  64955. * @param result vector to store the result
  64956. * @returns the current Vector4.
  64957. */
  64958. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64959. /**
  64960. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  64961. * @param x x value multiply with
  64962. * @param y y value multiply with
  64963. * @param z z value multiply with
  64964. * @param w w value multiply with
  64965. * @returns resulting new vector
  64966. */
  64967. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  64968. /**
  64969. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  64970. * @param otherVector vector to devide with
  64971. * @returns resulting new vector
  64972. */
  64973. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  64974. /**
  64975. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  64976. * @param otherVector vector to devide with
  64977. * @param result vector to store the result
  64978. * @returns the current Vector4.
  64979. */
  64980. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64981. /**
  64982. * Divides the current Vector3 coordinates by the given ones.
  64983. * @param otherVector vector to devide with
  64984. * @returns the updated Vector3.
  64985. */
  64986. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64987. /**
  64988. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  64989. * @param other defines the second operand
  64990. * @returns the current updated Vector4
  64991. */
  64992. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64993. /**
  64994. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  64995. * @param other defines the second operand
  64996. * @returns the current updated Vector4
  64997. */
  64998. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64999. /**
  65000. * Gets a new Vector4 from current Vector4 floored values
  65001. * @returns a new Vector4
  65002. */
  65003. floor(): Vector4;
  65004. /**
  65005. * Gets a new Vector4 from current Vector3 floored values
  65006. * @returns a new Vector4
  65007. */
  65008. fract(): Vector4;
  65009. /**
  65010. * Returns the Vector4 length (float).
  65011. * @returns the length
  65012. */
  65013. length(): number;
  65014. /**
  65015. * Returns the Vector4 squared length (float).
  65016. * @returns the length squared
  65017. */
  65018. lengthSquared(): number;
  65019. /**
  65020. * Normalizes in place the Vector4.
  65021. * @returns the updated Vector4.
  65022. */
  65023. normalize(): Vector4;
  65024. /**
  65025. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  65026. * @returns this converted to a new vector3
  65027. */
  65028. toVector3(): Vector3;
  65029. /**
  65030. * Returns a new Vector4 copied from the current one.
  65031. * @returns the new cloned vector
  65032. */
  65033. clone(): Vector4;
  65034. /**
  65035. * Updates the current Vector4 with the given one coordinates.
  65036. * @param source the source vector to copy from
  65037. * @returns the updated Vector4.
  65038. */
  65039. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  65040. /**
  65041. * Updates the current Vector4 coordinates with the given floats.
  65042. * @param x float to copy from
  65043. * @param y float to copy from
  65044. * @param z float to copy from
  65045. * @param w float to copy from
  65046. * @returns the updated Vector4.
  65047. */
  65048. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  65049. /**
  65050. * Updates the current Vector4 coordinates with the given floats.
  65051. * @param x float to set from
  65052. * @param y float to set from
  65053. * @param z float to set from
  65054. * @param w float to set from
  65055. * @returns the updated Vector4.
  65056. */
  65057. set(x: number, y: number, z: number, w: number): Vector4;
  65058. /**
  65059. * Copies the given float to the current Vector3 coordinates
  65060. * @param v defines the x, y, z and w coordinates of the operand
  65061. * @returns the current updated Vector3
  65062. */
  65063. setAll(v: number): Vector4;
  65064. /**
  65065. * Returns a new Vector4 set from the starting index of the given array.
  65066. * @param array the array to pull values from
  65067. * @param offset the offset into the array to start at
  65068. * @returns the new vector
  65069. */
  65070. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  65071. /**
  65072. * Updates the given vector "result" from the starting index of the given array.
  65073. * @param array the array to pull values from
  65074. * @param offset the offset into the array to start at
  65075. * @param result the vector to store the result in
  65076. */
  65077. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  65078. /**
  65079. * Updates the given vector "result" from the starting index of the given Float32Array.
  65080. * @param array the array to pull values from
  65081. * @param offset the offset into the array to start at
  65082. * @param result the vector to store the result in
  65083. */
  65084. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  65085. /**
  65086. * Updates the given vector "result" coordinates from the given floats.
  65087. * @param x float to set from
  65088. * @param y float to set from
  65089. * @param z float to set from
  65090. * @param w float to set from
  65091. * @param result the vector to the floats in
  65092. */
  65093. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  65094. /**
  65095. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  65096. * @returns the new vector
  65097. */
  65098. static Zero(): Vector4;
  65099. /**
  65100. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  65101. * @returns the new vector
  65102. */
  65103. static One(): Vector4;
  65104. /**
  65105. * Returns a new normalized Vector4 from the given one.
  65106. * @param vector the vector to normalize
  65107. * @returns the vector
  65108. */
  65109. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  65110. /**
  65111. * Updates the given vector "result" from the normalization of the given one.
  65112. * @param vector the vector to normalize
  65113. * @param result the vector to store the result in
  65114. */
  65115. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  65116. /**
  65117. * Returns a vector with the minimum values from the left and right vectors
  65118. * @param left left vector to minimize
  65119. * @param right right vector to minimize
  65120. * @returns a new vector with the minimum of the left and right vector values
  65121. */
  65122. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  65123. /**
  65124. * Returns a vector with the maximum values from the left and right vectors
  65125. * @param left left vector to maximize
  65126. * @param right right vector to maximize
  65127. * @returns a new vector with the maximum of the left and right vector values
  65128. */
  65129. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  65130. /**
  65131. * Returns the distance (float) between the vectors "value1" and "value2".
  65132. * @param value1 value to calulate the distance between
  65133. * @param value2 value to calulate the distance between
  65134. * @return the distance between the two vectors
  65135. */
  65136. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  65137. /**
  65138. * Returns the squared distance (float) between the vectors "value1" and "value2".
  65139. * @param value1 value to calulate the distance between
  65140. * @param value2 value to calulate the distance between
  65141. * @return the distance between the two vectors squared
  65142. */
  65143. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  65144. /**
  65145. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  65146. * @param value1 value to calulate the center between
  65147. * @param value2 value to calulate the center between
  65148. * @return the center between the two vectors
  65149. */
  65150. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  65151. /**
  65152. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  65153. * This methods computes transformed normalized direction vectors only.
  65154. * @param vector the vector to transform
  65155. * @param transformation the transformation matrix to apply
  65156. * @returns the new vector
  65157. */
  65158. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  65159. /**
  65160. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  65161. * This methods computes transformed normalized direction vectors only.
  65162. * @param vector the vector to transform
  65163. * @param transformation the transformation matrix to apply
  65164. * @param result the vector to store the result in
  65165. */
  65166. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  65167. /**
  65168. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  65169. * This methods computes transformed normalized direction vectors only.
  65170. * @param x value to transform
  65171. * @param y value to transform
  65172. * @param z value to transform
  65173. * @param w value to transform
  65174. * @param transformation the transformation matrix to apply
  65175. * @param result the vector to store the results in
  65176. */
  65177. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  65178. /**
  65179. * Creates a new Vector4 from a Vector3
  65180. * @param source defines the source data
  65181. * @param w defines the 4th component (default is 0)
  65182. * @returns a new Vector4
  65183. */
  65184. static FromVector3(source: Vector3, w?: number): Vector4;
  65185. }
  65186. /**
  65187. * Interface for the size containing width and height
  65188. */
  65189. export interface ISize {
  65190. /**
  65191. * Width
  65192. */
  65193. width: number;
  65194. /**
  65195. * Heighht
  65196. */
  65197. height: number;
  65198. }
  65199. /**
  65200. * Size containing widht and height
  65201. */
  65202. export class Size implements ISize {
  65203. /**
  65204. * Width
  65205. */
  65206. width: number;
  65207. /**
  65208. * Height
  65209. */
  65210. height: number;
  65211. /**
  65212. * Creates a Size object from the given width and height (floats).
  65213. * @param width width of the new size
  65214. * @param height height of the new size
  65215. */
  65216. constructor(width: number, height: number);
  65217. /**
  65218. * Returns a string with the Size width and height
  65219. * @returns a string with the Size width and height
  65220. */
  65221. toString(): string;
  65222. /**
  65223. * "Size"
  65224. * @returns the string "Size"
  65225. */
  65226. getClassName(): string;
  65227. /**
  65228. * Returns the Size hash code.
  65229. * @returns a hash code for a unique width and height
  65230. */
  65231. getHashCode(): number;
  65232. /**
  65233. * Updates the current size from the given one.
  65234. * @param src the given size
  65235. */
  65236. copyFrom(src: Size): void;
  65237. /**
  65238. * Updates in place the current Size from the given floats.
  65239. * @param width width of the new size
  65240. * @param height height of the new size
  65241. * @returns the updated Size.
  65242. */
  65243. copyFromFloats(width: number, height: number): Size;
  65244. /**
  65245. * Updates in place the current Size from the given floats.
  65246. * @param width width to set
  65247. * @param height height to set
  65248. * @returns the updated Size.
  65249. */
  65250. set(width: number, height: number): Size;
  65251. /**
  65252. * Multiplies the width and height by numbers
  65253. * @param w factor to multiple the width by
  65254. * @param h factor to multiple the height by
  65255. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  65256. */
  65257. multiplyByFloats(w: number, h: number): Size;
  65258. /**
  65259. * Clones the size
  65260. * @returns a new Size copied from the given one.
  65261. */
  65262. clone(): Size;
  65263. /**
  65264. * True if the current Size and the given one width and height are strictly equal.
  65265. * @param other the other size to compare against
  65266. * @returns True if the current Size and the given one width and height are strictly equal.
  65267. */
  65268. equals(other: Size): boolean;
  65269. /**
  65270. * The surface of the Size : width * height (float).
  65271. */
  65272. readonly surface: number;
  65273. /**
  65274. * Create a new size of zero
  65275. * @returns a new Size set to (0.0, 0.0)
  65276. */
  65277. static Zero(): Size;
  65278. /**
  65279. * Sums the width and height of two sizes
  65280. * @param otherSize size to add to this size
  65281. * @returns a new Size set as the addition result of the current Size and the given one.
  65282. */
  65283. add(otherSize: Size): Size;
  65284. /**
  65285. * Subtracts the width and height of two
  65286. * @param otherSize size to subtract to this size
  65287. * @returns a new Size set as the subtraction result of the given one from the current Size.
  65288. */
  65289. subtract(otherSize: Size): Size;
  65290. /**
  65291. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  65292. * @param start starting size to lerp between
  65293. * @param end end size to lerp between
  65294. * @param amount amount to lerp between the start and end values
  65295. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  65296. */
  65297. static Lerp(start: Size, end: Size, amount: number): Size;
  65298. }
  65299. /**
  65300. * Class used to store quaternion data
  65301. * @see https://en.wikipedia.org/wiki/Quaternion
  65302. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  65303. */
  65304. export class Quaternion {
  65305. /** defines the first component (0 by default) */
  65306. x: number;
  65307. /** defines the second component (0 by default) */
  65308. y: number;
  65309. /** defines the third component (0 by default) */
  65310. z: number;
  65311. /** defines the fourth component (1.0 by default) */
  65312. w: number;
  65313. /**
  65314. * Creates a new Quaternion from the given floats
  65315. * @param x defines the first component (0 by default)
  65316. * @param y defines the second component (0 by default)
  65317. * @param z defines the third component (0 by default)
  65318. * @param w defines the fourth component (1.0 by default)
  65319. */
  65320. constructor(
  65321. /** defines the first component (0 by default) */
  65322. x?: number,
  65323. /** defines the second component (0 by default) */
  65324. y?: number,
  65325. /** defines the third component (0 by default) */
  65326. z?: number,
  65327. /** defines the fourth component (1.0 by default) */
  65328. w?: number);
  65329. /**
  65330. * Gets a string representation for the current quaternion
  65331. * @returns a string with the Quaternion coordinates
  65332. */
  65333. toString(): string;
  65334. /**
  65335. * Gets the class name of the quaternion
  65336. * @returns the string "Quaternion"
  65337. */
  65338. getClassName(): string;
  65339. /**
  65340. * Gets a hash code for this quaternion
  65341. * @returns the quaternion hash code
  65342. */
  65343. getHashCode(): number;
  65344. /**
  65345. * Copy the quaternion to an array
  65346. * @returns a new array populated with 4 elements from the quaternion coordinates
  65347. */
  65348. asArray(): number[];
  65349. /**
  65350. * Check if two quaternions are equals
  65351. * @param otherQuaternion defines the second operand
  65352. * @return true if the current quaternion and the given one coordinates are strictly equals
  65353. */
  65354. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  65355. /**
  65356. * Clone the current quaternion
  65357. * @returns a new quaternion copied from the current one
  65358. */
  65359. clone(): Quaternion;
  65360. /**
  65361. * Copy a quaternion to the current one
  65362. * @param other defines the other quaternion
  65363. * @returns the updated current quaternion
  65364. */
  65365. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  65366. /**
  65367. * Updates the current quaternion with the given float coordinates
  65368. * @param x defines the x coordinate
  65369. * @param y defines the y coordinate
  65370. * @param z defines the z coordinate
  65371. * @param w defines the w coordinate
  65372. * @returns the updated current quaternion
  65373. */
  65374. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  65375. /**
  65376. * Updates the current quaternion from the given float coordinates
  65377. * @param x defines the x coordinate
  65378. * @param y defines the y coordinate
  65379. * @param z defines the z coordinate
  65380. * @param w defines the w coordinate
  65381. * @returns the updated current quaternion
  65382. */
  65383. set(x: number, y: number, z: number, w: number): Quaternion;
  65384. /**
  65385. * Adds two quaternions
  65386. * @param other defines the second operand
  65387. * @returns a new quaternion as the addition result of the given one and the current quaternion
  65388. */
  65389. add(other: DeepImmutable<Quaternion>): Quaternion;
  65390. /**
  65391. * Add a quaternion to the current one
  65392. * @param other defines the quaternion to add
  65393. * @returns the current quaternion
  65394. */
  65395. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  65396. /**
  65397. * Subtract two quaternions
  65398. * @param other defines the second operand
  65399. * @returns a new quaternion as the subtraction result of the given one from the current one
  65400. */
  65401. subtract(other: Quaternion): Quaternion;
  65402. /**
  65403. * Multiplies the current quaternion by a scale factor
  65404. * @param value defines the scale factor
  65405. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  65406. */
  65407. scale(value: number): Quaternion;
  65408. /**
  65409. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  65410. * @param scale defines the scale factor
  65411. * @param result defines the Quaternion object where to store the result
  65412. * @returns the unmodified current quaternion
  65413. */
  65414. scaleToRef(scale: number, result: Quaternion): Quaternion;
  65415. /**
  65416. * Multiplies in place the current quaternion by a scale factor
  65417. * @param value defines the scale factor
  65418. * @returns the current modified quaternion
  65419. */
  65420. scaleInPlace(value: number): Quaternion;
  65421. /**
  65422. * Scale the current quaternion values by a factor and add the result to a given quaternion
  65423. * @param scale defines the scale factor
  65424. * @param result defines the Quaternion object where to store the result
  65425. * @returns the unmodified current quaternion
  65426. */
  65427. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  65428. /**
  65429. * Multiplies two quaternions
  65430. * @param q1 defines the second operand
  65431. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  65432. */
  65433. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  65434. /**
  65435. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  65436. * @param q1 defines the second operand
  65437. * @param result defines the target quaternion
  65438. * @returns the current quaternion
  65439. */
  65440. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  65441. /**
  65442. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  65443. * @param q1 defines the second operand
  65444. * @returns the currentupdated quaternion
  65445. */
  65446. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  65447. /**
  65448. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  65449. * @param ref defines the target quaternion
  65450. * @returns the current quaternion
  65451. */
  65452. conjugateToRef(ref: Quaternion): Quaternion;
  65453. /**
  65454. * Conjugates in place (1-q) the current quaternion
  65455. * @returns the current updated quaternion
  65456. */
  65457. conjugateInPlace(): Quaternion;
  65458. /**
  65459. * Conjugates in place (1-q) the current quaternion
  65460. * @returns a new quaternion
  65461. */
  65462. conjugate(): Quaternion;
  65463. /**
  65464. * Gets length of current quaternion
  65465. * @returns the quaternion length (float)
  65466. */
  65467. length(): number;
  65468. /**
  65469. * Normalize in place the current quaternion
  65470. * @returns the current updated quaternion
  65471. */
  65472. normalize(): Quaternion;
  65473. /**
  65474. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  65475. * @param order is a reserved parameter and is ignore for now
  65476. * @returns a new Vector3 containing the Euler angles
  65477. */
  65478. toEulerAngles(order?: string): Vector3;
  65479. /**
  65480. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  65481. * @param result defines the vector which will be filled with the Euler angles
  65482. * @param order is a reserved parameter and is ignore for now
  65483. * @returns the current unchanged quaternion
  65484. */
  65485. toEulerAnglesToRef(result: Vector3): Quaternion;
  65486. /**
  65487. * Updates the given rotation matrix with the current quaternion values
  65488. * @param result defines the target matrix
  65489. * @returns the current unchanged quaternion
  65490. */
  65491. toRotationMatrix(result: Matrix): Quaternion;
  65492. /**
  65493. * Updates the current quaternion from the given rotation matrix values
  65494. * @param matrix defines the source matrix
  65495. * @returns the current updated quaternion
  65496. */
  65497. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65498. /**
  65499. * Creates a new quaternion from a rotation matrix
  65500. * @param matrix defines the source matrix
  65501. * @returns a new quaternion created from the given rotation matrix values
  65502. */
  65503. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65504. /**
  65505. * Updates the given quaternion with the given rotation matrix values
  65506. * @param matrix defines the source matrix
  65507. * @param result defines the target quaternion
  65508. */
  65509. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  65510. /**
  65511. * Returns the dot product (float) between the quaternions "left" and "right"
  65512. * @param left defines the left operand
  65513. * @param right defines the right operand
  65514. * @returns the dot product
  65515. */
  65516. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  65517. /**
  65518. * Checks if the two quaternions are close to each other
  65519. * @param quat0 defines the first quaternion to check
  65520. * @param quat1 defines the second quaternion to check
  65521. * @returns true if the two quaternions are close to each other
  65522. */
  65523. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  65524. /**
  65525. * Creates an empty quaternion
  65526. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  65527. */
  65528. static Zero(): Quaternion;
  65529. /**
  65530. * Inverse a given quaternion
  65531. * @param q defines the source quaternion
  65532. * @returns a new quaternion as the inverted current quaternion
  65533. */
  65534. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  65535. /**
  65536. * Inverse a given quaternion
  65537. * @param q defines the source quaternion
  65538. * @param result the quaternion the result will be stored in
  65539. * @returns the result quaternion
  65540. */
  65541. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  65542. /**
  65543. * Creates an identity quaternion
  65544. * @returns the identity quaternion
  65545. */
  65546. static Identity(): Quaternion;
  65547. /**
  65548. * Gets a boolean indicating if the given quaternion is identity
  65549. * @param quaternion defines the quaternion to check
  65550. * @returns true if the quaternion is identity
  65551. */
  65552. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  65553. /**
  65554. * Creates a quaternion from a rotation around an axis
  65555. * @param axis defines the axis to use
  65556. * @param angle defines the angle to use
  65557. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  65558. */
  65559. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  65560. /**
  65561. * Creates a rotation around an axis and stores it into the given quaternion
  65562. * @param axis defines the axis to use
  65563. * @param angle defines the angle to use
  65564. * @param result defines the target quaternion
  65565. * @returns the target quaternion
  65566. */
  65567. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  65568. /**
  65569. * Creates a new quaternion from data stored into an array
  65570. * @param array defines the data source
  65571. * @param offset defines the offset in the source array where the data starts
  65572. * @returns a new quaternion
  65573. */
  65574. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  65575. /**
  65576. * Create a quaternion from Euler rotation angles
  65577. * @param x Pitch
  65578. * @param y Yaw
  65579. * @param z Roll
  65580. * @returns the new Quaternion
  65581. */
  65582. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  65583. /**
  65584. * Updates a quaternion from Euler rotation angles
  65585. * @param x Pitch
  65586. * @param y Yaw
  65587. * @param z Roll
  65588. * @param result the quaternion to store the result
  65589. * @returns the updated quaternion
  65590. */
  65591. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  65592. /**
  65593. * Create a quaternion from Euler rotation vector
  65594. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65595. * @returns the new Quaternion
  65596. */
  65597. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  65598. /**
  65599. * Updates a quaternion from Euler rotation vector
  65600. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65601. * @param result the quaternion to store the result
  65602. * @returns the updated quaternion
  65603. */
  65604. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  65605. /**
  65606. * Creates a new quaternion from the given Euler float angles (y, x, z)
  65607. * @param yaw defines the rotation around Y axis
  65608. * @param pitch defines the rotation around X axis
  65609. * @param roll defines the rotation around Z axis
  65610. * @returns the new quaternion
  65611. */
  65612. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  65613. /**
  65614. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  65615. * @param yaw defines the rotation around Y axis
  65616. * @param pitch defines the rotation around X axis
  65617. * @param roll defines the rotation around Z axis
  65618. * @param result defines the target quaternion
  65619. */
  65620. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  65621. /**
  65622. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  65623. * @param alpha defines the rotation around first axis
  65624. * @param beta defines the rotation around second axis
  65625. * @param gamma defines the rotation around third axis
  65626. * @returns the new quaternion
  65627. */
  65628. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  65629. /**
  65630. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  65631. * @param alpha defines the rotation around first axis
  65632. * @param beta defines the rotation around second axis
  65633. * @param gamma defines the rotation around third axis
  65634. * @param result defines the target quaternion
  65635. */
  65636. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  65637. /**
  65638. * 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)
  65639. * @param axis1 defines the first axis
  65640. * @param axis2 defines the second axis
  65641. * @param axis3 defines the third axis
  65642. * @returns the new quaternion
  65643. */
  65644. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  65645. /**
  65646. * 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
  65647. * @param axis1 defines the first axis
  65648. * @param axis2 defines the second axis
  65649. * @param axis3 defines the third axis
  65650. * @param ref defines the target quaternion
  65651. */
  65652. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  65653. /**
  65654. * Interpolates between two quaternions
  65655. * @param left defines first quaternion
  65656. * @param right defines second quaternion
  65657. * @param amount defines the gradient to use
  65658. * @returns the new interpolated quaternion
  65659. */
  65660. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65661. /**
  65662. * Interpolates between two quaternions and stores it into a target quaternion
  65663. * @param left defines first quaternion
  65664. * @param right defines second quaternion
  65665. * @param amount defines the gradient to use
  65666. * @param result defines the target quaternion
  65667. */
  65668. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  65669. /**
  65670. * Interpolate between two quaternions using Hermite interpolation
  65671. * @param value1 defines first quaternion
  65672. * @param tangent1 defines the incoming tangent
  65673. * @param value2 defines second quaternion
  65674. * @param tangent2 defines the outgoing tangent
  65675. * @param amount defines the target quaternion
  65676. * @returns the new interpolated quaternion
  65677. */
  65678. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65679. }
  65680. /**
  65681. * Class used to store matrix data (4x4)
  65682. */
  65683. export class Matrix {
  65684. private static _updateFlagSeed;
  65685. private static _identityReadOnly;
  65686. private _isIdentity;
  65687. private _isIdentityDirty;
  65688. private _isIdentity3x2;
  65689. private _isIdentity3x2Dirty;
  65690. /**
  65691. * Gets the update flag of the matrix which is an unique number for the matrix.
  65692. * It will be incremented every time the matrix data change.
  65693. * You can use it to speed the comparison between two versions of the same matrix.
  65694. */
  65695. updateFlag: number;
  65696. private readonly _m;
  65697. /**
  65698. * Gets the internal data of the matrix
  65699. */
  65700. readonly m: DeepImmutable<Float32Array>;
  65701. /** @hidden */
  65702. _markAsUpdated(): void;
  65703. /** @hidden */
  65704. private _updateIdentityStatus;
  65705. /**
  65706. * Creates an empty matrix (filled with zeros)
  65707. */
  65708. constructor();
  65709. /**
  65710. * Check if the current matrix is identity
  65711. * @returns true is the matrix is the identity matrix
  65712. */
  65713. isIdentity(): boolean;
  65714. /**
  65715. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  65716. * @returns true is the matrix is the identity matrix
  65717. */
  65718. isIdentityAs3x2(): boolean;
  65719. /**
  65720. * Gets the determinant of the matrix
  65721. * @returns the matrix determinant
  65722. */
  65723. determinant(): number;
  65724. /**
  65725. * Returns the matrix as a Float32Array
  65726. * @returns the matrix underlying array
  65727. */
  65728. toArray(): DeepImmutable<Float32Array>;
  65729. /**
  65730. * Returns the matrix as a Float32Array
  65731. * @returns the matrix underlying array.
  65732. */
  65733. asArray(): DeepImmutable<Float32Array>;
  65734. /**
  65735. * Inverts the current matrix in place
  65736. * @returns the current inverted matrix
  65737. */
  65738. invert(): Matrix;
  65739. /**
  65740. * Sets all the matrix elements to zero
  65741. * @returns the current matrix
  65742. */
  65743. reset(): Matrix;
  65744. /**
  65745. * Adds the current matrix with a second one
  65746. * @param other defines the matrix to add
  65747. * @returns a new matrix as the addition of the current matrix and the given one
  65748. */
  65749. add(other: DeepImmutable<Matrix>): Matrix;
  65750. /**
  65751. * Sets the given matrix "result" to the addition of the current matrix and the given one
  65752. * @param other defines the matrix to add
  65753. * @param result defines the target matrix
  65754. * @returns the current matrix
  65755. */
  65756. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65757. /**
  65758. * Adds in place the given matrix to the current matrix
  65759. * @param other defines the second operand
  65760. * @returns the current updated matrix
  65761. */
  65762. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  65763. /**
  65764. * Sets the given matrix to the current inverted Matrix
  65765. * @param other defines the target matrix
  65766. * @returns the unmodified current matrix
  65767. */
  65768. invertToRef(other: Matrix): Matrix;
  65769. /**
  65770. * add a value at the specified position in the current Matrix
  65771. * @param index the index of the value within the matrix. between 0 and 15.
  65772. * @param value the value to be added
  65773. * @returns the current updated matrix
  65774. */
  65775. addAtIndex(index: number, value: number): Matrix;
  65776. /**
  65777. * mutiply the specified position in the current Matrix by a value
  65778. * @param index the index of the value within the matrix. between 0 and 15.
  65779. * @param value the value to be added
  65780. * @returns the current updated matrix
  65781. */
  65782. multiplyAtIndex(index: number, value: number): Matrix;
  65783. /**
  65784. * Inserts the translation vector (using 3 floats) in the current matrix
  65785. * @param x defines the 1st component of the translation
  65786. * @param y defines the 2nd component of the translation
  65787. * @param z defines the 3rd component of the translation
  65788. * @returns the current updated matrix
  65789. */
  65790. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65791. /**
  65792. * Adds the translation vector (using 3 floats) in the current matrix
  65793. * @param x defines the 1st component of the translation
  65794. * @param y defines the 2nd component of the translation
  65795. * @param z defines the 3rd component of the translation
  65796. * @returns the current updated matrix
  65797. */
  65798. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65799. /**
  65800. * Inserts the translation vector in the current matrix
  65801. * @param vector3 defines the translation to insert
  65802. * @returns the current updated matrix
  65803. */
  65804. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  65805. /**
  65806. * Gets the translation value of the current matrix
  65807. * @returns a new Vector3 as the extracted translation from the matrix
  65808. */
  65809. getTranslation(): Vector3;
  65810. /**
  65811. * Fill a Vector3 with the extracted translation from the matrix
  65812. * @param result defines the Vector3 where to store the translation
  65813. * @returns the current matrix
  65814. */
  65815. getTranslationToRef(result: Vector3): Matrix;
  65816. /**
  65817. * Remove rotation and scaling part from the matrix
  65818. * @returns the updated matrix
  65819. */
  65820. removeRotationAndScaling(): Matrix;
  65821. /**
  65822. * Multiply two matrices
  65823. * @param other defines the second operand
  65824. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  65825. */
  65826. multiply(other: DeepImmutable<Matrix>): Matrix;
  65827. /**
  65828. * Copy the current matrix from the given one
  65829. * @param other defines the source matrix
  65830. * @returns the current updated matrix
  65831. */
  65832. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  65833. /**
  65834. * Populates the given array from the starting index with the current matrix values
  65835. * @param array defines the target array
  65836. * @param offset defines the offset in the target array where to start storing values
  65837. * @returns the current matrix
  65838. */
  65839. copyToArray(array: Float32Array, offset?: number): Matrix;
  65840. /**
  65841. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  65842. * @param other defines the second operand
  65843. * @param result defines the matrix where to store the multiplication
  65844. * @returns the current matrix
  65845. */
  65846. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65847. /**
  65848. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  65849. * @param other defines the second operand
  65850. * @param result defines the array where to store the multiplication
  65851. * @param offset defines the offset in the target array where to start storing values
  65852. * @returns the current matrix
  65853. */
  65854. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  65855. /**
  65856. * Check equality between this matrix and a second one
  65857. * @param value defines the second matrix to compare
  65858. * @returns true is the current matrix and the given one values are strictly equal
  65859. */
  65860. equals(value: DeepImmutable<Matrix>): boolean;
  65861. /**
  65862. * Clone the current matrix
  65863. * @returns a new matrix from the current matrix
  65864. */
  65865. clone(): Matrix;
  65866. /**
  65867. * Returns the name of the current matrix class
  65868. * @returns the string "Matrix"
  65869. */
  65870. getClassName(): string;
  65871. /**
  65872. * Gets the hash code of the current matrix
  65873. * @returns the hash code
  65874. */
  65875. getHashCode(): number;
  65876. /**
  65877. * Decomposes the current Matrix into a translation, rotation and scaling components
  65878. * @param scale defines the scale vector3 given as a reference to update
  65879. * @param rotation defines the rotation quaternion given as a reference to update
  65880. * @param translation defines the translation vector3 given as a reference to update
  65881. * @returns true if operation was successful
  65882. */
  65883. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  65884. /**
  65885. * Gets specific row of the matrix
  65886. * @param index defines the number of the row to get
  65887. * @returns the index-th row of the current matrix as a new Vector4
  65888. */
  65889. getRow(index: number): Nullable<Vector4>;
  65890. /**
  65891. * Sets the index-th row of the current matrix to the vector4 values
  65892. * @param index defines the number of the row to set
  65893. * @param row defines the target vector4
  65894. * @returns the updated current matrix
  65895. */
  65896. setRow(index: number, row: Vector4): Matrix;
  65897. /**
  65898. * Compute the transpose of the matrix
  65899. * @returns the new transposed matrix
  65900. */
  65901. transpose(): Matrix;
  65902. /**
  65903. * Compute the transpose of the matrix and store it in a given matrix
  65904. * @param result defines the target matrix
  65905. * @returns the current matrix
  65906. */
  65907. transposeToRef(result: Matrix): Matrix;
  65908. /**
  65909. * Sets the index-th row of the current matrix with the given 4 x float values
  65910. * @param index defines the row index
  65911. * @param x defines the x component to set
  65912. * @param y defines the y component to set
  65913. * @param z defines the z component to set
  65914. * @param w defines the w component to set
  65915. * @returns the updated current matrix
  65916. */
  65917. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  65918. /**
  65919. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  65920. * @param scale defines the scale factor
  65921. * @returns a new matrix
  65922. */
  65923. scale(scale: number): Matrix;
  65924. /**
  65925. * Scale the current matrix values by a factor to a given result matrix
  65926. * @param scale defines the scale factor
  65927. * @param result defines the matrix to store the result
  65928. * @returns the current matrix
  65929. */
  65930. scaleToRef(scale: number, result: Matrix): Matrix;
  65931. /**
  65932. * Scale the current matrix values by a factor and add the result to a given matrix
  65933. * @param scale defines the scale factor
  65934. * @param result defines the Matrix to store the result
  65935. * @returns the current matrix
  65936. */
  65937. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  65938. /**
  65939. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  65940. * @param ref matrix to store the result
  65941. */
  65942. toNormalMatrix(ref: Matrix): void;
  65943. /**
  65944. * Gets only rotation part of the current matrix
  65945. * @returns a new matrix sets to the extracted rotation matrix from the current one
  65946. */
  65947. getRotationMatrix(): Matrix;
  65948. /**
  65949. * Extracts the rotation matrix from the current one and sets it as the given "result"
  65950. * @param result defines the target matrix to store data to
  65951. * @returns the current matrix
  65952. */
  65953. getRotationMatrixToRef(result: Matrix): Matrix;
  65954. /**
  65955. * Toggles model matrix from being right handed to left handed in place and vice versa
  65956. */
  65957. toggleModelMatrixHandInPlace(): void;
  65958. /**
  65959. * Toggles projection matrix from being right handed to left handed in place and vice versa
  65960. */
  65961. toggleProjectionMatrixHandInPlace(): void;
  65962. /**
  65963. * Creates a matrix from an array
  65964. * @param array defines the source array
  65965. * @param offset defines an offset in the source array
  65966. * @returns a new Matrix set from the starting index of the given array
  65967. */
  65968. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  65969. /**
  65970. * Copy the content of an array into a given matrix
  65971. * @param array defines the source array
  65972. * @param offset defines an offset in the source array
  65973. * @param result defines the target matrix
  65974. */
  65975. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  65976. /**
  65977. * Stores an array into a matrix after having multiplied each component by a given factor
  65978. * @param array defines the source array
  65979. * @param offset defines the offset in the source array
  65980. * @param scale defines the scaling factor
  65981. * @param result defines the target matrix
  65982. */
  65983. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  65984. /**
  65985. * Gets an identity matrix that must not be updated
  65986. */
  65987. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  65988. /**
  65989. * Stores a list of values (16) inside a given matrix
  65990. * @param initialM11 defines 1st value of 1st row
  65991. * @param initialM12 defines 2nd value of 1st row
  65992. * @param initialM13 defines 3rd value of 1st row
  65993. * @param initialM14 defines 4th value of 1st row
  65994. * @param initialM21 defines 1st value of 2nd row
  65995. * @param initialM22 defines 2nd value of 2nd row
  65996. * @param initialM23 defines 3rd value of 2nd row
  65997. * @param initialM24 defines 4th value of 2nd row
  65998. * @param initialM31 defines 1st value of 3rd row
  65999. * @param initialM32 defines 2nd value of 3rd row
  66000. * @param initialM33 defines 3rd value of 3rd row
  66001. * @param initialM34 defines 4th value of 3rd row
  66002. * @param initialM41 defines 1st value of 4th row
  66003. * @param initialM42 defines 2nd value of 4th row
  66004. * @param initialM43 defines 3rd value of 4th row
  66005. * @param initialM44 defines 4th value of 4th row
  66006. * @param result defines the target matrix
  66007. */
  66008. 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;
  66009. /**
  66010. * Creates new matrix from a list of values (16)
  66011. * @param initialM11 defines 1st value of 1st row
  66012. * @param initialM12 defines 2nd value of 1st row
  66013. * @param initialM13 defines 3rd value of 1st row
  66014. * @param initialM14 defines 4th value of 1st row
  66015. * @param initialM21 defines 1st value of 2nd row
  66016. * @param initialM22 defines 2nd value of 2nd row
  66017. * @param initialM23 defines 3rd value of 2nd row
  66018. * @param initialM24 defines 4th value of 2nd row
  66019. * @param initialM31 defines 1st value of 3rd row
  66020. * @param initialM32 defines 2nd value of 3rd row
  66021. * @param initialM33 defines 3rd value of 3rd row
  66022. * @param initialM34 defines 4th value of 3rd row
  66023. * @param initialM41 defines 1st value of 4th row
  66024. * @param initialM42 defines 2nd value of 4th row
  66025. * @param initialM43 defines 3rd value of 4th row
  66026. * @param initialM44 defines 4th value of 4th row
  66027. * @returns the new matrix
  66028. */
  66029. 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;
  66030. /**
  66031. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  66032. * @param scale defines the scale vector3
  66033. * @param rotation defines the rotation quaternion
  66034. * @param translation defines the translation vector3
  66035. * @returns a new matrix
  66036. */
  66037. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  66038. /**
  66039. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  66040. * @param scale defines the scale vector3
  66041. * @param rotation defines the rotation quaternion
  66042. * @param translation defines the translation vector3
  66043. * @param result defines the target matrix
  66044. */
  66045. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  66046. /**
  66047. * Creates a new identity matrix
  66048. * @returns a new identity matrix
  66049. */
  66050. static Identity(): Matrix;
  66051. /**
  66052. * Creates a new identity matrix and stores the result in a given matrix
  66053. * @param result defines the target matrix
  66054. */
  66055. static IdentityToRef(result: Matrix): void;
  66056. /**
  66057. * Creates a new zero matrix
  66058. * @returns a new zero matrix
  66059. */
  66060. static Zero(): Matrix;
  66061. /**
  66062. * Creates a new rotation matrix for "angle" radians around the X axis
  66063. * @param angle defines the angle (in radians) to use
  66064. * @return the new matrix
  66065. */
  66066. static RotationX(angle: number): Matrix;
  66067. /**
  66068. * Creates a new matrix as the invert of a given matrix
  66069. * @param source defines the source matrix
  66070. * @returns the new matrix
  66071. */
  66072. static Invert(source: DeepImmutable<Matrix>): Matrix;
  66073. /**
  66074. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  66075. * @param angle defines the angle (in radians) to use
  66076. * @param result defines the target matrix
  66077. */
  66078. static RotationXToRef(angle: number, result: Matrix): void;
  66079. /**
  66080. * Creates a new rotation matrix for "angle" radians around the Y axis
  66081. * @param angle defines the angle (in radians) to use
  66082. * @return the new matrix
  66083. */
  66084. static RotationY(angle: number): Matrix;
  66085. /**
  66086. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  66087. * @param angle defines the angle (in radians) to use
  66088. * @param result defines the target matrix
  66089. */
  66090. static RotationYToRef(angle: number, result: Matrix): void;
  66091. /**
  66092. * Creates a new rotation matrix for "angle" radians around the Z axis
  66093. * @param angle defines the angle (in radians) to use
  66094. * @return the new matrix
  66095. */
  66096. static RotationZ(angle: number): Matrix;
  66097. /**
  66098. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  66099. * @param angle defines the angle (in radians) to use
  66100. * @param result defines the target matrix
  66101. */
  66102. static RotationZToRef(angle: number, result: Matrix): void;
  66103. /**
  66104. * Creates a new rotation matrix for "angle" radians around the given axis
  66105. * @param axis defines the axis to use
  66106. * @param angle defines the angle (in radians) to use
  66107. * @return the new matrix
  66108. */
  66109. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  66110. /**
  66111. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  66112. * @param axis defines the axis to use
  66113. * @param angle defines the angle (in radians) to use
  66114. * @param result defines the target matrix
  66115. */
  66116. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  66117. /**
  66118. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  66119. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  66120. * @param from defines the vector to align
  66121. * @param to defines the vector to align to
  66122. * @param result defines the target matrix
  66123. */
  66124. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  66125. /**
  66126. * Creates a rotation matrix
  66127. * @param yaw defines the yaw angle in radians (Y axis)
  66128. * @param pitch defines the pitch angle in radians (X axis)
  66129. * @param roll defines the roll angle in radians (X axis)
  66130. * @returns the new rotation matrix
  66131. */
  66132. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  66133. /**
  66134. * Creates a rotation matrix and stores it in a given matrix
  66135. * @param yaw defines the yaw angle in radians (Y axis)
  66136. * @param pitch defines the pitch angle in radians (X axis)
  66137. * @param roll defines the roll angle in radians (X axis)
  66138. * @param result defines the target matrix
  66139. */
  66140. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  66141. /**
  66142. * Creates a scaling matrix
  66143. * @param x defines the scale factor on X axis
  66144. * @param y defines the scale factor on Y axis
  66145. * @param z defines the scale factor on Z axis
  66146. * @returns the new matrix
  66147. */
  66148. static Scaling(x: number, y: number, z: number): Matrix;
  66149. /**
  66150. * Creates a scaling matrix and stores it in a given matrix
  66151. * @param x defines the scale factor on X axis
  66152. * @param y defines the scale factor on Y axis
  66153. * @param z defines the scale factor on Z axis
  66154. * @param result defines the target matrix
  66155. */
  66156. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  66157. /**
  66158. * Creates a translation matrix
  66159. * @param x defines the translation on X axis
  66160. * @param y defines the translation on Y axis
  66161. * @param z defines the translationon Z axis
  66162. * @returns the new matrix
  66163. */
  66164. static Translation(x: number, y: number, z: number): Matrix;
  66165. /**
  66166. * Creates a translation matrix and stores it in a given matrix
  66167. * @param x defines the translation on X axis
  66168. * @param y defines the translation on Y axis
  66169. * @param z defines the translationon Z axis
  66170. * @param result defines the target matrix
  66171. */
  66172. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  66173. /**
  66174. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  66175. * @param startValue defines the start value
  66176. * @param endValue defines the end value
  66177. * @param gradient defines the gradient factor
  66178. * @returns the new matrix
  66179. */
  66180. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  66181. /**
  66182. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  66183. * @param startValue defines the start value
  66184. * @param endValue defines the end value
  66185. * @param gradient defines the gradient factor
  66186. * @param result defines the Matrix object where to store data
  66187. */
  66188. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  66189. /**
  66190. * Builds a new matrix whose values are computed by:
  66191. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  66192. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  66193. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  66194. * @param startValue defines the first matrix
  66195. * @param endValue defines the second matrix
  66196. * @param gradient defines the gradient between the two matrices
  66197. * @returns the new matrix
  66198. */
  66199. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  66200. /**
  66201. * Update a matrix to values which are computed by:
  66202. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  66203. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  66204. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  66205. * @param startValue defines the first matrix
  66206. * @param endValue defines the second matrix
  66207. * @param gradient defines the gradient between the two matrices
  66208. * @param result defines the target matrix
  66209. */
  66210. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  66211. /**
  66212. * 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"
  66213. * This function works in left handed mode
  66214. * @param eye defines the final position of the entity
  66215. * @param target defines where the entity should look at
  66216. * @param up defines the up vector for the entity
  66217. * @returns the new matrix
  66218. */
  66219. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  66220. /**
  66221. * 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".
  66222. * This function works in left handed mode
  66223. * @param eye defines the final position of the entity
  66224. * @param target defines where the entity should look at
  66225. * @param up defines the up vector for the entity
  66226. * @param result defines the target matrix
  66227. */
  66228. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  66229. /**
  66230. * 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"
  66231. * This function works in right handed mode
  66232. * @param eye defines the final position of the entity
  66233. * @param target defines where the entity should look at
  66234. * @param up defines the up vector for the entity
  66235. * @returns the new matrix
  66236. */
  66237. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  66238. /**
  66239. * 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".
  66240. * This function works in right handed mode
  66241. * @param eye defines the final position of the entity
  66242. * @param target defines where the entity should look at
  66243. * @param up defines the up vector for the entity
  66244. * @param result defines the target matrix
  66245. */
  66246. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  66247. /**
  66248. * Create a left-handed orthographic projection matrix
  66249. * @param width defines the viewport width
  66250. * @param height defines the viewport height
  66251. * @param znear defines the near clip plane
  66252. * @param zfar defines the far clip plane
  66253. * @returns a new matrix as a left-handed orthographic projection matrix
  66254. */
  66255. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66256. /**
  66257. * Store a left-handed orthographic projection to a given matrix
  66258. * @param width defines the viewport width
  66259. * @param height defines the viewport height
  66260. * @param znear defines the near clip plane
  66261. * @param zfar defines the far clip plane
  66262. * @param result defines the target matrix
  66263. */
  66264. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  66265. /**
  66266. * Create a left-handed orthographic projection matrix
  66267. * @param left defines the viewport left coordinate
  66268. * @param right defines the viewport right coordinate
  66269. * @param bottom defines the viewport bottom coordinate
  66270. * @param top defines the viewport top coordinate
  66271. * @param znear defines the near clip plane
  66272. * @param zfar defines the far clip plane
  66273. * @returns a new matrix as a left-handed orthographic projection matrix
  66274. */
  66275. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66276. /**
  66277. * Stores a left-handed orthographic projection into a given matrix
  66278. * @param left defines the viewport left coordinate
  66279. * @param right defines the viewport right coordinate
  66280. * @param bottom defines the viewport bottom coordinate
  66281. * @param top defines the viewport top coordinate
  66282. * @param znear defines the near clip plane
  66283. * @param zfar defines the far clip plane
  66284. * @param result defines the target matrix
  66285. */
  66286. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66287. /**
  66288. * Creates a right-handed orthographic projection matrix
  66289. * @param left defines the viewport left coordinate
  66290. * @param right defines the viewport right coordinate
  66291. * @param bottom defines the viewport bottom coordinate
  66292. * @param top defines the viewport top coordinate
  66293. * @param znear defines the near clip plane
  66294. * @param zfar defines the far clip plane
  66295. * @returns a new matrix as a right-handed orthographic projection matrix
  66296. */
  66297. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66298. /**
  66299. * Stores a right-handed orthographic projection into a given matrix
  66300. * @param left defines the viewport left coordinate
  66301. * @param right defines the viewport right coordinate
  66302. * @param bottom defines the viewport bottom coordinate
  66303. * @param top defines the viewport top coordinate
  66304. * @param znear defines the near clip plane
  66305. * @param zfar defines the far clip plane
  66306. * @param result defines the target matrix
  66307. */
  66308. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66309. /**
  66310. * Creates a left-handed perspective projection matrix
  66311. * @param width defines the viewport width
  66312. * @param height defines the viewport height
  66313. * @param znear defines the near clip plane
  66314. * @param zfar defines the far clip plane
  66315. * @returns a new matrix as a left-handed perspective projection matrix
  66316. */
  66317. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66318. /**
  66319. * Creates a left-handed perspective projection matrix
  66320. * @param fov defines the horizontal field of view
  66321. * @param aspect defines the aspect ratio
  66322. * @param znear defines the near clip plane
  66323. * @param zfar defines the far clip plane
  66324. * @returns a new matrix as a left-handed perspective projection matrix
  66325. */
  66326. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66327. /**
  66328. * Stores a left-handed perspective projection into a given matrix
  66329. * @param fov defines the horizontal field of view
  66330. * @param aspect defines the aspect ratio
  66331. * @param znear defines the near clip plane
  66332. * @param zfar defines the far clip plane
  66333. * @param result defines the target matrix
  66334. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66335. */
  66336. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66337. /**
  66338. * Creates a right-handed perspective projection matrix
  66339. * @param fov defines the horizontal field of view
  66340. * @param aspect defines the aspect ratio
  66341. * @param znear defines the near clip plane
  66342. * @param zfar defines the far clip plane
  66343. * @returns a new matrix as a right-handed perspective projection matrix
  66344. */
  66345. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66346. /**
  66347. * Stores a right-handed perspective projection into a given matrix
  66348. * @param fov defines the horizontal field of view
  66349. * @param aspect defines the aspect ratio
  66350. * @param znear defines the near clip plane
  66351. * @param zfar defines the far clip plane
  66352. * @param result defines the target matrix
  66353. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66354. */
  66355. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66356. /**
  66357. * Stores a perspective projection for WebVR info a given matrix
  66358. * @param fov defines the field of view
  66359. * @param znear defines the near clip plane
  66360. * @param zfar defines the far clip plane
  66361. * @param result defines the target matrix
  66362. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  66363. */
  66364. static PerspectiveFovWebVRToRef(fov: {
  66365. upDegrees: number;
  66366. downDegrees: number;
  66367. leftDegrees: number;
  66368. rightDegrees: number;
  66369. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  66370. /**
  66371. * Computes a complete transformation matrix
  66372. * @param viewport defines the viewport to use
  66373. * @param world defines the world matrix
  66374. * @param view defines the view matrix
  66375. * @param projection defines the projection matrix
  66376. * @param zmin defines the near clip plane
  66377. * @param zmax defines the far clip plane
  66378. * @returns the transformation matrix
  66379. */
  66380. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  66381. /**
  66382. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  66383. * @param matrix defines the matrix to use
  66384. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  66385. */
  66386. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  66387. /**
  66388. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  66389. * @param matrix defines the matrix to use
  66390. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  66391. */
  66392. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  66393. /**
  66394. * Compute the transpose of a given matrix
  66395. * @param matrix defines the matrix to transpose
  66396. * @returns the new matrix
  66397. */
  66398. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  66399. /**
  66400. * Compute the transpose of a matrix and store it in a target matrix
  66401. * @param matrix defines the matrix to transpose
  66402. * @param result defines the target matrix
  66403. */
  66404. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  66405. /**
  66406. * Computes a reflection matrix from a plane
  66407. * @param plane defines the reflection plane
  66408. * @returns a new matrix
  66409. */
  66410. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  66411. /**
  66412. * Computes a reflection matrix from a plane
  66413. * @param plane defines the reflection plane
  66414. * @param result defines the target matrix
  66415. */
  66416. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  66417. /**
  66418. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  66419. * @param xaxis defines the value of the 1st axis
  66420. * @param yaxis defines the value of the 2nd axis
  66421. * @param zaxis defines the value of the 3rd axis
  66422. * @param result defines the target matrix
  66423. */
  66424. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  66425. /**
  66426. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  66427. * @param quat defines the quaternion to use
  66428. * @param result defines the target matrix
  66429. */
  66430. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  66431. }
  66432. /**
  66433. * Represens a plane by the equation ax + by + cz + d = 0
  66434. */
  66435. export class Plane {
  66436. /**
  66437. * Normal of the plane (a,b,c)
  66438. */
  66439. normal: Vector3;
  66440. /**
  66441. * d component of the plane
  66442. */
  66443. d: number;
  66444. /**
  66445. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  66446. * @param a a component of the plane
  66447. * @param b b component of the plane
  66448. * @param c c component of the plane
  66449. * @param d d component of the plane
  66450. */
  66451. constructor(a: number, b: number, c: number, d: number);
  66452. /**
  66453. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  66454. */
  66455. asArray(): number[];
  66456. /**
  66457. * @returns a new plane copied from the current Plane.
  66458. */
  66459. clone(): Plane;
  66460. /**
  66461. * @returns the string "Plane".
  66462. */
  66463. getClassName(): string;
  66464. /**
  66465. * @returns the Plane hash code.
  66466. */
  66467. getHashCode(): number;
  66468. /**
  66469. * Normalize the current Plane in place.
  66470. * @returns the updated Plane.
  66471. */
  66472. normalize(): Plane;
  66473. /**
  66474. * Applies a transformation the plane and returns the result
  66475. * @param transformation the transformation matrix to be applied to the plane
  66476. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  66477. */
  66478. transform(transformation: DeepImmutable<Matrix>): Plane;
  66479. /**
  66480. * Calcualtte the dot product between the point and the plane normal
  66481. * @param point point to calculate the dot product with
  66482. * @returns the dot product (float) of the point coordinates and the plane normal.
  66483. */
  66484. dotCoordinate(point: DeepImmutable<Vector3>): number;
  66485. /**
  66486. * Updates the current Plane from the plane defined by the three given points.
  66487. * @param point1 one of the points used to contruct the plane
  66488. * @param point2 one of the points used to contruct the plane
  66489. * @param point3 one of the points used to contruct the plane
  66490. * @returns the updated Plane.
  66491. */
  66492. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66493. /**
  66494. * Checks if the plane is facing a given direction
  66495. * @param direction the direction to check if the plane is facing
  66496. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  66497. * @returns True is the vector "direction" is the same side than the plane normal.
  66498. */
  66499. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  66500. /**
  66501. * Calculates the distance to a point
  66502. * @param point point to calculate distance to
  66503. * @returns the signed distance (float) from the given point to the Plane.
  66504. */
  66505. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  66506. /**
  66507. * Creates a plane from an array
  66508. * @param array the array to create a plane from
  66509. * @returns a new Plane from the given array.
  66510. */
  66511. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  66512. /**
  66513. * Creates a plane from three points
  66514. * @param point1 point used to create the plane
  66515. * @param point2 point used to create the plane
  66516. * @param point3 point used to create the plane
  66517. * @returns a new Plane defined by the three given points.
  66518. */
  66519. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66520. /**
  66521. * Creates a plane from an origin point and a normal
  66522. * @param origin origin of the plane to be constructed
  66523. * @param normal normal of the plane to be constructed
  66524. * @returns a new Plane the normal vector to this plane at the given origin point.
  66525. * Note : the vector "normal" is updated because normalized.
  66526. */
  66527. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  66528. /**
  66529. * Calculates the distance from a plane and a point
  66530. * @param origin origin of the plane to be constructed
  66531. * @param normal normal of the plane to be constructed
  66532. * @param point point to calculate distance to
  66533. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  66534. */
  66535. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  66536. }
  66537. /**
  66538. * Class used to represent a viewport on screen
  66539. */
  66540. export class Viewport {
  66541. /** viewport left coordinate */
  66542. x: number;
  66543. /** viewport top coordinate */
  66544. y: number;
  66545. /**viewport width */
  66546. width: number;
  66547. /** viewport height */
  66548. height: number;
  66549. /**
  66550. * Creates a Viewport object located at (x, y) and sized (width, height)
  66551. * @param x defines viewport left coordinate
  66552. * @param y defines viewport top coordinate
  66553. * @param width defines the viewport width
  66554. * @param height defines the viewport height
  66555. */
  66556. constructor(
  66557. /** viewport left coordinate */
  66558. x: number,
  66559. /** viewport top coordinate */
  66560. y: number,
  66561. /**viewport width */
  66562. width: number,
  66563. /** viewport height */
  66564. height: number);
  66565. /**
  66566. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66567. * @param renderWidth defines the rendering width
  66568. * @param renderHeight defines the rendering height
  66569. * @returns a new Viewport
  66570. */
  66571. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66572. /**
  66573. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66574. * @param renderWidth defines the rendering width
  66575. * @param renderHeight defines the rendering height
  66576. * @param ref defines the target viewport
  66577. * @returns the current viewport
  66578. */
  66579. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66580. /**
  66581. * Returns a new Viewport copied from the current one
  66582. * @returns a new Viewport
  66583. */
  66584. clone(): Viewport;
  66585. }
  66586. /**
  66587. * Reprasents a camera frustum
  66588. */
  66589. export class Frustum {
  66590. /**
  66591. * Gets the planes representing the frustum
  66592. * @param transform matrix to be applied to the returned planes
  66593. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  66594. */
  66595. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  66596. /**
  66597. * Gets the near frustum plane transformed by the transform matrix
  66598. * @param transform transformation matrix to be applied to the resulting frustum plane
  66599. * @param frustumPlane the resuling frustum plane
  66600. */
  66601. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66602. /**
  66603. * Gets the far frustum plane transformed by the transform matrix
  66604. * @param transform transformation matrix to be applied to the resulting frustum plane
  66605. * @param frustumPlane the resuling frustum plane
  66606. */
  66607. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66608. /**
  66609. * Gets the left frustum plane transformed by the transform matrix
  66610. * @param transform transformation matrix to be applied to the resulting frustum plane
  66611. * @param frustumPlane the resuling frustum plane
  66612. */
  66613. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66614. /**
  66615. * Gets the right frustum plane transformed by the transform matrix
  66616. * @param transform transformation matrix to be applied to the resulting frustum plane
  66617. * @param frustumPlane the resuling frustum plane
  66618. */
  66619. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66620. /**
  66621. * Gets the top frustum plane transformed by the transform matrix
  66622. * @param transform transformation matrix to be applied to the resulting frustum plane
  66623. * @param frustumPlane the resuling frustum plane
  66624. */
  66625. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66626. /**
  66627. * Gets the bottom frustum plane transformed by the transform matrix
  66628. * @param transform transformation matrix to be applied to the resulting frustum plane
  66629. * @param frustumPlane the resuling frustum plane
  66630. */
  66631. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66632. /**
  66633. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  66634. * @param transform transformation matrix to be applied to the resulting frustum planes
  66635. * @param frustumPlanes the resuling frustum planes
  66636. */
  66637. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  66638. }
  66639. /** Defines supported spaces */
  66640. export enum Space {
  66641. /** Local (object) space */
  66642. LOCAL = 0,
  66643. /** World space */
  66644. WORLD = 1,
  66645. /** Bone space */
  66646. BONE = 2
  66647. }
  66648. /** Defines the 3 main axes */
  66649. export class Axis {
  66650. /** X axis */
  66651. static X: Vector3;
  66652. /** Y axis */
  66653. static Y: Vector3;
  66654. /** Z axis */
  66655. static Z: Vector3;
  66656. }
  66657. /** Class used to represent a Bezier curve */
  66658. export class BezierCurve {
  66659. /**
  66660. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  66661. * @param t defines the time
  66662. * @param x1 defines the left coordinate on X axis
  66663. * @param y1 defines the left coordinate on Y axis
  66664. * @param x2 defines the right coordinate on X axis
  66665. * @param y2 defines the right coordinate on Y axis
  66666. * @returns the interpolated value
  66667. */
  66668. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  66669. }
  66670. /**
  66671. * Defines potential orientation for back face culling
  66672. */
  66673. export enum Orientation {
  66674. /**
  66675. * Clockwise
  66676. */
  66677. CW = 0,
  66678. /** Counter clockwise */
  66679. CCW = 1
  66680. }
  66681. /**
  66682. * Defines angle representation
  66683. */
  66684. export class Angle {
  66685. private _radians;
  66686. /**
  66687. * Creates an Angle object of "radians" radians (float).
  66688. * @param radians the angle in radians
  66689. */
  66690. constructor(radians: number);
  66691. /**
  66692. * Get value in degrees
  66693. * @returns the Angle value in degrees (float)
  66694. */
  66695. degrees(): number;
  66696. /**
  66697. * Get value in radians
  66698. * @returns the Angle value in radians (float)
  66699. */
  66700. radians(): number;
  66701. /**
  66702. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  66703. * @param a defines first vector
  66704. * @param b defines second vector
  66705. * @returns a new Angle
  66706. */
  66707. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  66708. /**
  66709. * Gets a new Angle object from the given float in radians
  66710. * @param radians defines the angle value in radians
  66711. * @returns a new Angle
  66712. */
  66713. static FromRadians(radians: number): Angle;
  66714. /**
  66715. * Gets a new Angle object from the given float in degrees
  66716. * @param degrees defines the angle value in degrees
  66717. * @returns a new Angle
  66718. */
  66719. static FromDegrees(degrees: number): Angle;
  66720. }
  66721. /**
  66722. * This represents an arc in a 2d space.
  66723. */
  66724. export class Arc2 {
  66725. /** Defines the start point of the arc */
  66726. startPoint: Vector2;
  66727. /** Defines the mid point of the arc */
  66728. midPoint: Vector2;
  66729. /** Defines the end point of the arc */
  66730. endPoint: Vector2;
  66731. /**
  66732. * Defines the center point of the arc.
  66733. */
  66734. centerPoint: Vector2;
  66735. /**
  66736. * Defines the radius of the arc.
  66737. */
  66738. radius: number;
  66739. /**
  66740. * Defines the angle of the arc (from mid point to end point).
  66741. */
  66742. angle: Angle;
  66743. /**
  66744. * Defines the start angle of the arc (from start point to middle point).
  66745. */
  66746. startAngle: Angle;
  66747. /**
  66748. * Defines the orientation of the arc (clock wise/counter clock wise).
  66749. */
  66750. orientation: Orientation;
  66751. /**
  66752. * Creates an Arc object from the three given points : start, middle and end.
  66753. * @param startPoint Defines the start point of the arc
  66754. * @param midPoint Defines the midlle point of the arc
  66755. * @param endPoint Defines the end point of the arc
  66756. */
  66757. constructor(
  66758. /** Defines the start point of the arc */
  66759. startPoint: Vector2,
  66760. /** Defines the mid point of the arc */
  66761. midPoint: Vector2,
  66762. /** Defines the end point of the arc */
  66763. endPoint: Vector2);
  66764. }
  66765. /**
  66766. * Represents a 2D path made up of multiple 2D points
  66767. */
  66768. export class Path2 {
  66769. private _points;
  66770. private _length;
  66771. /**
  66772. * If the path start and end point are the same
  66773. */
  66774. closed: boolean;
  66775. /**
  66776. * Creates a Path2 object from the starting 2D coordinates x and y.
  66777. * @param x the starting points x value
  66778. * @param y the starting points y value
  66779. */
  66780. constructor(x: number, y: number);
  66781. /**
  66782. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  66783. * @param x the added points x value
  66784. * @param y the added points y value
  66785. * @returns the updated Path2.
  66786. */
  66787. addLineTo(x: number, y: number): Path2;
  66788. /**
  66789. * 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.
  66790. * @param midX middle point x value
  66791. * @param midY middle point y value
  66792. * @param endX end point x value
  66793. * @param endY end point y value
  66794. * @param numberOfSegments (default: 36)
  66795. * @returns the updated Path2.
  66796. */
  66797. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  66798. /**
  66799. * Closes the Path2.
  66800. * @returns the Path2.
  66801. */
  66802. close(): Path2;
  66803. /**
  66804. * Gets the sum of the distance between each sequential point in the path
  66805. * @returns the Path2 total length (float).
  66806. */
  66807. length(): number;
  66808. /**
  66809. * Gets the points which construct the path
  66810. * @returns the Path2 internal array of points.
  66811. */
  66812. getPoints(): Vector2[];
  66813. /**
  66814. * Retreives the point at the distance aways from the starting point
  66815. * @param normalizedLengthPosition the length along the path to retreive the point from
  66816. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  66817. */
  66818. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  66819. /**
  66820. * Creates a new path starting from an x and y position
  66821. * @param x starting x value
  66822. * @param y starting y value
  66823. * @returns a new Path2 starting at the coordinates (x, y).
  66824. */
  66825. static StartingAt(x: number, y: number): Path2;
  66826. }
  66827. /**
  66828. * Represents a 3D path made up of multiple 3D points
  66829. */
  66830. export class Path3D {
  66831. /**
  66832. * an array of Vector3, the curve axis of the Path3D
  66833. */
  66834. path: Vector3[];
  66835. private _curve;
  66836. private _distances;
  66837. private _tangents;
  66838. private _normals;
  66839. private _binormals;
  66840. private _raw;
  66841. /**
  66842. * new Path3D(path, normal, raw)
  66843. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  66844. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  66845. * @param path an array of Vector3, the curve axis of the Path3D
  66846. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  66847. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  66848. */
  66849. constructor(
  66850. /**
  66851. * an array of Vector3, the curve axis of the Path3D
  66852. */
  66853. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  66854. /**
  66855. * Returns the Path3D array of successive Vector3 designing its curve.
  66856. * @returns the Path3D array of successive Vector3 designing its curve.
  66857. */
  66858. getCurve(): Vector3[];
  66859. /**
  66860. * Returns an array populated with tangent vectors on each Path3D curve point.
  66861. * @returns an array populated with tangent vectors on each Path3D curve point.
  66862. */
  66863. getTangents(): Vector3[];
  66864. /**
  66865. * Returns an array populated with normal vectors on each Path3D curve point.
  66866. * @returns an array populated with normal vectors on each Path3D curve point.
  66867. */
  66868. getNormals(): Vector3[];
  66869. /**
  66870. * Returns an array populated with binormal vectors on each Path3D curve point.
  66871. * @returns an array populated with binormal vectors on each Path3D curve point.
  66872. */
  66873. getBinormals(): Vector3[];
  66874. /**
  66875. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  66876. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  66877. */
  66878. getDistances(): number[];
  66879. /**
  66880. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  66881. * @param path path which all values are copied into the curves points
  66882. * @param firstNormal which should be projected onto the curve
  66883. * @returns the same object updated.
  66884. */
  66885. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  66886. private _compute;
  66887. private _getFirstNonNullVector;
  66888. private _getLastNonNullVector;
  66889. private _normalVector;
  66890. }
  66891. /**
  66892. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66893. * A Curve3 is designed from a series of successive Vector3.
  66894. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  66895. */
  66896. export class Curve3 {
  66897. private _points;
  66898. private _length;
  66899. /**
  66900. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  66901. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  66902. * @param v1 (Vector3) the control point
  66903. * @param v2 (Vector3) the end point of the Quadratic Bezier
  66904. * @param nbPoints (integer) the wanted number of points in the curve
  66905. * @returns the created Curve3
  66906. */
  66907. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66908. /**
  66909. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  66910. * @param v0 (Vector3) the origin point of the Cubic Bezier
  66911. * @param v1 (Vector3) the first control point
  66912. * @param v2 (Vector3) the second control point
  66913. * @param v3 (Vector3) the end point of the Cubic Bezier
  66914. * @param nbPoints (integer) the wanted number of points in the curve
  66915. * @returns the created Curve3
  66916. */
  66917. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66918. /**
  66919. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  66920. * @param p1 (Vector3) the origin point of the Hermite Spline
  66921. * @param t1 (Vector3) the tangent vector at the origin point
  66922. * @param p2 (Vector3) the end point of the Hermite Spline
  66923. * @param t2 (Vector3) the tangent vector at the end point
  66924. * @param nbPoints (integer) the wanted number of points in the curve
  66925. * @returns the created Curve3
  66926. */
  66927. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66928. /**
  66929. * Returns a Curve3 object along a CatmullRom Spline curve :
  66930. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  66931. * @param nbPoints (integer) the wanted number of points between each curve control points
  66932. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  66933. * @returns the created Curve3
  66934. */
  66935. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  66936. /**
  66937. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66938. * A Curve3 is designed from a series of successive Vector3.
  66939. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  66940. * @param points points which make up the curve
  66941. */
  66942. constructor(points: Vector3[]);
  66943. /**
  66944. * @returns the Curve3 stored array of successive Vector3
  66945. */
  66946. getPoints(): Vector3[];
  66947. /**
  66948. * @returns the computed length (float) of the curve.
  66949. */
  66950. length(): number;
  66951. /**
  66952. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  66953. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  66954. * curveA and curveB keep unchanged.
  66955. * @param curve the curve to continue from this curve
  66956. * @returns the newly constructed curve
  66957. */
  66958. continue(curve: DeepImmutable<Curve3>): Curve3;
  66959. private _computeLength;
  66960. }
  66961. /**
  66962. * Contains position and normal vectors for a vertex
  66963. */
  66964. export class PositionNormalVertex {
  66965. /** the position of the vertex (defaut: 0,0,0) */
  66966. position: Vector3;
  66967. /** the normal of the vertex (defaut: 0,1,0) */
  66968. normal: Vector3;
  66969. /**
  66970. * Creates a PositionNormalVertex
  66971. * @param position the position of the vertex (defaut: 0,0,0)
  66972. * @param normal the normal of the vertex (defaut: 0,1,0)
  66973. */
  66974. constructor(
  66975. /** the position of the vertex (defaut: 0,0,0) */
  66976. position?: Vector3,
  66977. /** the normal of the vertex (defaut: 0,1,0) */
  66978. normal?: Vector3);
  66979. /**
  66980. * Clones the PositionNormalVertex
  66981. * @returns the cloned PositionNormalVertex
  66982. */
  66983. clone(): PositionNormalVertex;
  66984. }
  66985. /**
  66986. * Contains position, normal and uv vectors for a vertex
  66987. */
  66988. export class PositionNormalTextureVertex {
  66989. /** the position of the vertex (defaut: 0,0,0) */
  66990. position: Vector3;
  66991. /** the normal of the vertex (defaut: 0,1,0) */
  66992. normal: Vector3;
  66993. /** the uv of the vertex (default: 0,0) */
  66994. uv: Vector2;
  66995. /**
  66996. * Creates a PositionNormalTextureVertex
  66997. * @param position the position of the vertex (defaut: 0,0,0)
  66998. * @param normal the normal of the vertex (defaut: 0,1,0)
  66999. * @param uv the uv of the vertex (default: 0,0)
  67000. */
  67001. constructor(
  67002. /** the position of the vertex (defaut: 0,0,0) */
  67003. position?: Vector3,
  67004. /** the normal of the vertex (defaut: 0,1,0) */
  67005. normal?: Vector3,
  67006. /** the uv of the vertex (default: 0,0) */
  67007. uv?: Vector2);
  67008. /**
  67009. * Clones the PositionNormalTextureVertex
  67010. * @returns the cloned PositionNormalTextureVertex
  67011. */
  67012. clone(): PositionNormalTextureVertex;
  67013. }
  67014. /**
  67015. * @hidden
  67016. */
  67017. export class Tmp {
  67018. static Color3: Color3[];
  67019. static Color4: Color4[];
  67020. static Vector2: Vector2[];
  67021. static Vector3: Vector3[];
  67022. static Vector4: Vector4[];
  67023. static Quaternion: Quaternion[];
  67024. static Matrix: Matrix[];
  67025. }
  67026. }
  67027. declare module BABYLON {
  67028. /**
  67029. * Class used to enable access to offline support
  67030. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67031. */
  67032. export interface IOfflineProvider {
  67033. /**
  67034. * Gets a boolean indicating if scene must be saved in the database
  67035. */
  67036. enableSceneOffline: boolean;
  67037. /**
  67038. * Gets a boolean indicating if textures must be saved in the database
  67039. */
  67040. enableTexturesOffline: boolean;
  67041. /**
  67042. * Open the offline support and make it available
  67043. * @param successCallback defines the callback to call on success
  67044. * @param errorCallback defines the callback to call on error
  67045. */
  67046. open(successCallback: () => void, errorCallback: () => void): void;
  67047. /**
  67048. * Loads an image from the offline support
  67049. * @param url defines the url to load from
  67050. * @param image defines the target DOM image
  67051. */
  67052. loadImage(url: string, image: HTMLImageElement): void;
  67053. /**
  67054. * Loads a file from offline support
  67055. * @param url defines the URL to load from
  67056. * @param sceneLoaded defines a callback to call on success
  67057. * @param progressCallBack defines a callback to call when progress changed
  67058. * @param errorCallback defines a callback to call on error
  67059. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67060. */
  67061. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67062. }
  67063. }
  67064. declare module BABYLON {
  67065. /**
  67066. * A class serves as a medium between the observable and its observers
  67067. */
  67068. export class EventState {
  67069. /**
  67070. * Create a new EventState
  67071. * @param mask defines the mask associated with this state
  67072. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67073. * @param target defines the original target of the state
  67074. * @param currentTarget defines the current target of the state
  67075. */
  67076. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  67077. /**
  67078. * Initialize the current event state
  67079. * @param mask defines the mask associated with this state
  67080. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67081. * @param target defines the original target of the state
  67082. * @param currentTarget defines the current target of the state
  67083. * @returns the current event state
  67084. */
  67085. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  67086. /**
  67087. * An Observer can set this property to true to prevent subsequent observers of being notified
  67088. */
  67089. skipNextObservers: boolean;
  67090. /**
  67091. * Get the mask value that were used to trigger the event corresponding to this EventState object
  67092. */
  67093. mask: number;
  67094. /**
  67095. * The object that originally notified the event
  67096. */
  67097. target?: any;
  67098. /**
  67099. * The current object in the bubbling phase
  67100. */
  67101. currentTarget?: any;
  67102. /**
  67103. * This will be populated with the return value of the last function that was executed.
  67104. * If it is the first function in the callback chain it will be the event data.
  67105. */
  67106. lastReturnValue?: any;
  67107. }
  67108. /**
  67109. * Represent an Observer registered to a given Observable object.
  67110. */
  67111. export class Observer<T> {
  67112. /**
  67113. * Defines the callback to call when the observer is notified
  67114. */
  67115. callback: (eventData: T, eventState: EventState) => void;
  67116. /**
  67117. * Defines the mask of the observer (used to filter notifications)
  67118. */
  67119. mask: number;
  67120. /**
  67121. * Defines the current scope used to restore the JS context
  67122. */
  67123. scope: any;
  67124. /** @hidden */
  67125. _willBeUnregistered: boolean;
  67126. /**
  67127. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  67128. */
  67129. unregisterOnNextCall: boolean;
  67130. /**
  67131. * Creates a new observer
  67132. * @param callback defines the callback to call when the observer is notified
  67133. * @param mask defines the mask of the observer (used to filter notifications)
  67134. * @param scope defines the current scope used to restore the JS context
  67135. */
  67136. constructor(
  67137. /**
  67138. * Defines the callback to call when the observer is notified
  67139. */
  67140. callback: (eventData: T, eventState: EventState) => void,
  67141. /**
  67142. * Defines the mask of the observer (used to filter notifications)
  67143. */
  67144. mask: number,
  67145. /**
  67146. * Defines the current scope used to restore the JS context
  67147. */
  67148. scope?: any);
  67149. }
  67150. /**
  67151. * Represent a list of observers registered to multiple Observables object.
  67152. */
  67153. export class MultiObserver<T> {
  67154. private _observers;
  67155. private _observables;
  67156. /**
  67157. * Release associated resources
  67158. */
  67159. dispose(): void;
  67160. /**
  67161. * Raise a callback when one of the observable will notify
  67162. * @param observables defines a list of observables to watch
  67163. * @param callback defines the callback to call on notification
  67164. * @param mask defines the mask used to filter notifications
  67165. * @param scope defines the current scope used to restore the JS context
  67166. * @returns the new MultiObserver
  67167. */
  67168. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  67169. }
  67170. /**
  67171. * The Observable class is a simple implementation of the Observable pattern.
  67172. *
  67173. * 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.
  67174. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  67175. * 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).
  67176. * 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.
  67177. */
  67178. export class Observable<T> {
  67179. private _observers;
  67180. private _eventState;
  67181. private _onObserverAdded;
  67182. /**
  67183. * Gets the list of observers
  67184. */
  67185. readonly observers: Array<Observer<T>>;
  67186. /**
  67187. * Creates a new observable
  67188. * @param onObserverAdded defines a callback to call when a new observer is added
  67189. */
  67190. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  67191. /**
  67192. * Create a new Observer with the specified callback
  67193. * @param callback the callback that will be executed for that Observer
  67194. * @param mask the mask used to filter observers
  67195. * @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.
  67196. * @param scope optional scope for the callback to be called from
  67197. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  67198. * @returns the new observer created for the callback
  67199. */
  67200. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  67201. /**
  67202. * Create a new Observer with the specified callback and unregisters after the next notification
  67203. * @param callback the callback that will be executed for that Observer
  67204. * @returns the new observer created for the callback
  67205. */
  67206. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  67207. /**
  67208. * Remove an Observer from the Observable object
  67209. * @param observer the instance of the Observer to remove
  67210. * @returns false if it doesn't belong to this Observable
  67211. */
  67212. remove(observer: Nullable<Observer<T>>): boolean;
  67213. /**
  67214. * Remove a callback from the Observable object
  67215. * @param callback the callback to remove
  67216. * @param scope optional scope. If used only the callbacks with this scope will be removed
  67217. * @returns false if it doesn't belong to this Observable
  67218. */
  67219. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67220. private _deferUnregister;
  67221. private _remove;
  67222. /**
  67223. * Moves the observable to the top of the observer list making it get called first when notified
  67224. * @param observer the observer to move
  67225. */
  67226. makeObserverTopPriority(observer: Observer<T>): void;
  67227. /**
  67228. * Moves the observable to the bottom of the observer list making it get called last when notified
  67229. * @param observer the observer to move
  67230. */
  67231. makeObserverBottomPriority(observer: Observer<T>): void;
  67232. /**
  67233. * Notify all Observers by calling their respective callback with the given data
  67234. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67235. * @param eventData defines the data to send to all observers
  67236. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67237. * @param target defines the original target of the state
  67238. * @param currentTarget defines the current target of the state
  67239. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67240. */
  67241. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67242. /**
  67243. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67244. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67245. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67246. * and it is crucial that all callbacks will be executed.
  67247. * The order of the callbacks is kept, callbacks are not executed parallel.
  67248. *
  67249. * @param eventData The data to be sent to each callback
  67250. * @param mask is used to filter observers defaults to -1
  67251. * @param target defines the callback target (see EventState)
  67252. * @param currentTarget defines he current object in the bubbling phase
  67253. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67254. */
  67255. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67256. /**
  67257. * Notify a specific observer
  67258. * @param observer defines the observer to notify
  67259. * @param eventData defines the data to be sent to each callback
  67260. * @param mask is used to filter observers defaults to -1
  67261. */
  67262. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67263. /**
  67264. * Gets a boolean indicating if the observable has at least one observer
  67265. * @returns true is the Observable has at least one Observer registered
  67266. */
  67267. hasObservers(): boolean;
  67268. /**
  67269. * Clear the list of observers
  67270. */
  67271. clear(): void;
  67272. /**
  67273. * Clone the current observable
  67274. * @returns a new observable
  67275. */
  67276. clone(): Observable<T>;
  67277. /**
  67278. * Does this observable handles observer registered with a given mask
  67279. * @param mask defines the mask to be tested
  67280. * @return whether or not one observer registered with the given mask is handeled
  67281. **/
  67282. hasSpecificMask(mask?: number): boolean;
  67283. }
  67284. }
  67285. declare module BABYLON {
  67286. /**
  67287. * Class used to help managing file picking and drag'n'drop
  67288. * File Storage
  67289. */
  67290. export class FilesInputStore {
  67291. /**
  67292. * List of files ready to be loaded
  67293. */
  67294. static FilesToLoad: {
  67295. [key: string]: File;
  67296. };
  67297. }
  67298. }
  67299. declare module BABYLON {
  67300. /** Defines the cross module used constants to avoid circular dependncies */
  67301. export class Constants {
  67302. /** Defines that alpha blending is disabled */
  67303. static readonly ALPHA_DISABLE: number;
  67304. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67305. static readonly ALPHA_ADD: number;
  67306. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67307. static readonly ALPHA_COMBINE: number;
  67308. /** Defines that alpha blending to DEST - SRC * DEST */
  67309. static readonly ALPHA_SUBTRACT: number;
  67310. /** Defines that alpha blending to SRC * DEST */
  67311. static readonly ALPHA_MULTIPLY: number;
  67312. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67313. static readonly ALPHA_MAXIMIZED: number;
  67314. /** Defines that alpha blending to SRC + DEST */
  67315. static readonly ALPHA_ONEONE: number;
  67316. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67317. static readonly ALPHA_PREMULTIPLIED: number;
  67318. /**
  67319. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67320. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67321. */
  67322. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67323. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67324. static readonly ALPHA_INTERPOLATE: number;
  67325. /**
  67326. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67327. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67328. */
  67329. static readonly ALPHA_SCREENMODE: number;
  67330. /** Defines that the ressource is not delayed*/
  67331. static readonly DELAYLOADSTATE_NONE: number;
  67332. /** Defines that the ressource was successfully delay loaded */
  67333. static readonly DELAYLOADSTATE_LOADED: number;
  67334. /** Defines that the ressource is currently delay loading */
  67335. static readonly DELAYLOADSTATE_LOADING: number;
  67336. /** Defines that the ressource is delayed and has not started loading */
  67337. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67338. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67339. static readonly NEVER: number;
  67340. /** 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 */
  67341. static readonly ALWAYS: number;
  67342. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67343. static readonly LESS: number;
  67344. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67345. static readonly EQUAL: number;
  67346. /** 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 */
  67347. static readonly LEQUAL: number;
  67348. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67349. static readonly GREATER: number;
  67350. /** 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 */
  67351. static readonly GEQUAL: number;
  67352. /** 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 */
  67353. static readonly NOTEQUAL: number;
  67354. /** Passed to stencilOperation to specify that stencil value must be kept */
  67355. static readonly KEEP: number;
  67356. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67357. static readonly REPLACE: number;
  67358. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67359. static readonly INCR: number;
  67360. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67361. static readonly DECR: number;
  67362. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67363. static readonly INVERT: number;
  67364. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67365. static readonly INCR_WRAP: number;
  67366. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67367. static readonly DECR_WRAP: number;
  67368. /** Texture is not repeating outside of 0..1 UVs */
  67369. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67370. /** Texture is repeating outside of 0..1 UVs */
  67371. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67372. /** Texture is repeating and mirrored */
  67373. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67374. /** ALPHA */
  67375. static readonly TEXTUREFORMAT_ALPHA: number;
  67376. /** LUMINANCE */
  67377. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67378. /** LUMINANCE_ALPHA */
  67379. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67380. /** RGB */
  67381. static readonly TEXTUREFORMAT_RGB: number;
  67382. /** RGBA */
  67383. static readonly TEXTUREFORMAT_RGBA: number;
  67384. /** RED */
  67385. static readonly TEXTUREFORMAT_RED: number;
  67386. /** RED (2nd reference) */
  67387. static readonly TEXTUREFORMAT_R: number;
  67388. /** RG */
  67389. static readonly TEXTUREFORMAT_RG: number;
  67390. /** RED_INTEGER */
  67391. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67392. /** RED_INTEGER (2nd reference) */
  67393. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67394. /** RG_INTEGER */
  67395. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67396. /** RGB_INTEGER */
  67397. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67398. /** RGBA_INTEGER */
  67399. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67400. /** UNSIGNED_BYTE */
  67401. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67402. /** UNSIGNED_BYTE (2nd reference) */
  67403. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67404. /** FLOAT */
  67405. static readonly TEXTURETYPE_FLOAT: number;
  67406. /** HALF_FLOAT */
  67407. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67408. /** BYTE */
  67409. static readonly TEXTURETYPE_BYTE: number;
  67410. /** SHORT */
  67411. static readonly TEXTURETYPE_SHORT: number;
  67412. /** UNSIGNED_SHORT */
  67413. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67414. /** INT */
  67415. static readonly TEXTURETYPE_INT: number;
  67416. /** UNSIGNED_INT */
  67417. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67418. /** UNSIGNED_SHORT_4_4_4_4 */
  67419. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67420. /** UNSIGNED_SHORT_5_5_5_1 */
  67421. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67422. /** UNSIGNED_SHORT_5_6_5 */
  67423. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67424. /** UNSIGNED_INT_2_10_10_10_REV */
  67425. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67426. /** UNSIGNED_INT_24_8 */
  67427. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67428. /** UNSIGNED_INT_10F_11F_11F_REV */
  67429. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67430. /** UNSIGNED_INT_5_9_9_9_REV */
  67431. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67432. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67433. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67434. /** nearest is mag = nearest and min = nearest and mip = linear */
  67435. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67436. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67437. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67438. /** Trilinear is mag = linear and min = linear and mip = linear */
  67439. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67440. /** nearest is mag = nearest and min = nearest and mip = linear */
  67441. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67442. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67443. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67444. /** Trilinear is mag = linear and min = linear and mip = linear */
  67445. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67446. /** mag = nearest and min = nearest and mip = nearest */
  67447. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67448. /** mag = nearest and min = linear and mip = nearest */
  67449. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67450. /** mag = nearest and min = linear and mip = linear */
  67451. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67452. /** mag = nearest and min = linear and mip = none */
  67453. static readonly TEXTURE_NEAREST_LINEAR: number;
  67454. /** mag = nearest and min = nearest and mip = none */
  67455. static readonly TEXTURE_NEAREST_NEAREST: number;
  67456. /** mag = linear and min = nearest and mip = nearest */
  67457. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67458. /** mag = linear and min = nearest and mip = linear */
  67459. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67460. /** mag = linear and min = linear and mip = none */
  67461. static readonly TEXTURE_LINEAR_LINEAR: number;
  67462. /** mag = linear and min = nearest and mip = none */
  67463. static readonly TEXTURE_LINEAR_NEAREST: number;
  67464. /** Explicit coordinates mode */
  67465. static readonly TEXTURE_EXPLICIT_MODE: number;
  67466. /** Spherical coordinates mode */
  67467. static readonly TEXTURE_SPHERICAL_MODE: number;
  67468. /** Planar coordinates mode */
  67469. static readonly TEXTURE_PLANAR_MODE: number;
  67470. /** Cubic coordinates mode */
  67471. static readonly TEXTURE_CUBIC_MODE: number;
  67472. /** Projection coordinates mode */
  67473. static readonly TEXTURE_PROJECTION_MODE: number;
  67474. /** Skybox coordinates mode */
  67475. static readonly TEXTURE_SKYBOX_MODE: number;
  67476. /** Inverse Cubic coordinates mode */
  67477. static readonly TEXTURE_INVCUBIC_MODE: number;
  67478. /** Equirectangular coordinates mode */
  67479. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67480. /** Equirectangular Fixed coordinates mode */
  67481. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67482. /** Equirectangular Fixed Mirrored coordinates mode */
  67483. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67484. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67485. static readonly SCALEMODE_FLOOR: number;
  67486. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67487. static readonly SCALEMODE_NEAREST: number;
  67488. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67489. static readonly SCALEMODE_CEILING: number;
  67490. /**
  67491. * The dirty texture flag value
  67492. */
  67493. static readonly MATERIAL_TextureDirtyFlag: number;
  67494. /**
  67495. * The dirty light flag value
  67496. */
  67497. static readonly MATERIAL_LightDirtyFlag: number;
  67498. /**
  67499. * The dirty fresnel flag value
  67500. */
  67501. static readonly MATERIAL_FresnelDirtyFlag: number;
  67502. /**
  67503. * The dirty attribute flag value
  67504. */
  67505. static readonly MATERIAL_AttributesDirtyFlag: number;
  67506. /**
  67507. * The dirty misc flag value
  67508. */
  67509. static readonly MATERIAL_MiscDirtyFlag: number;
  67510. /**
  67511. * The all dirty flag value
  67512. */
  67513. static readonly MATERIAL_AllDirtyFlag: number;
  67514. /**
  67515. * Returns the triangle fill mode
  67516. */
  67517. static readonly MATERIAL_TriangleFillMode: number;
  67518. /**
  67519. * Returns the wireframe mode
  67520. */
  67521. static readonly MATERIAL_WireFrameFillMode: number;
  67522. /**
  67523. * Returns the point fill mode
  67524. */
  67525. static readonly MATERIAL_PointFillMode: number;
  67526. /**
  67527. * Returns the point list draw mode
  67528. */
  67529. static readonly MATERIAL_PointListDrawMode: number;
  67530. /**
  67531. * Returns the line list draw mode
  67532. */
  67533. static readonly MATERIAL_LineListDrawMode: number;
  67534. /**
  67535. * Returns the line loop draw mode
  67536. */
  67537. static readonly MATERIAL_LineLoopDrawMode: number;
  67538. /**
  67539. * Returns the line strip draw mode
  67540. */
  67541. static readonly MATERIAL_LineStripDrawMode: number;
  67542. /**
  67543. * Returns the triangle strip draw mode
  67544. */
  67545. static readonly MATERIAL_TriangleStripDrawMode: number;
  67546. /**
  67547. * Returns the triangle fan draw mode
  67548. */
  67549. static readonly MATERIAL_TriangleFanDrawMode: number;
  67550. /**
  67551. * Stores the clock-wise side orientation
  67552. */
  67553. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67554. /**
  67555. * Stores the counter clock-wise side orientation
  67556. */
  67557. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67558. /**
  67559. * Nothing
  67560. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67561. */
  67562. static readonly ACTION_NothingTrigger: number;
  67563. /**
  67564. * On pick
  67565. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67566. */
  67567. static readonly ACTION_OnPickTrigger: number;
  67568. /**
  67569. * On left pick
  67570. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67571. */
  67572. static readonly ACTION_OnLeftPickTrigger: number;
  67573. /**
  67574. * On right pick
  67575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67576. */
  67577. static readonly ACTION_OnRightPickTrigger: number;
  67578. /**
  67579. * On center pick
  67580. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67581. */
  67582. static readonly ACTION_OnCenterPickTrigger: number;
  67583. /**
  67584. * On pick down
  67585. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67586. */
  67587. static readonly ACTION_OnPickDownTrigger: number;
  67588. /**
  67589. * On double pick
  67590. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67591. */
  67592. static readonly ACTION_OnDoublePickTrigger: number;
  67593. /**
  67594. * On pick up
  67595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67596. */
  67597. static readonly ACTION_OnPickUpTrigger: number;
  67598. /**
  67599. * On pick out.
  67600. * This trigger will only be raised if you also declared a OnPickDown
  67601. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67602. */
  67603. static readonly ACTION_OnPickOutTrigger: number;
  67604. /**
  67605. * On long press
  67606. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67607. */
  67608. static readonly ACTION_OnLongPressTrigger: number;
  67609. /**
  67610. * On pointer over
  67611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67612. */
  67613. static readonly ACTION_OnPointerOverTrigger: number;
  67614. /**
  67615. * On pointer out
  67616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67617. */
  67618. static readonly ACTION_OnPointerOutTrigger: number;
  67619. /**
  67620. * On every frame
  67621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67622. */
  67623. static readonly ACTION_OnEveryFrameTrigger: number;
  67624. /**
  67625. * On intersection enter
  67626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67627. */
  67628. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67629. /**
  67630. * On intersection exit
  67631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67632. */
  67633. static readonly ACTION_OnIntersectionExitTrigger: number;
  67634. /**
  67635. * On key down
  67636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67637. */
  67638. static readonly ACTION_OnKeyDownTrigger: number;
  67639. /**
  67640. * On key up
  67641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67642. */
  67643. static readonly ACTION_OnKeyUpTrigger: number;
  67644. /**
  67645. * Billboard mode will only apply to Y axis
  67646. */
  67647. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67648. /**
  67649. * Billboard mode will apply to all axes
  67650. */
  67651. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67652. /**
  67653. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67654. */
  67655. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67656. /**
  67657. * Gets or sets base Assets URL
  67658. */
  67659. static PARTICLES_BaseAssetsUrl: string;
  67660. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67661. * Test order :
  67662. * Is the bounding sphere outside the frustum ?
  67663. * If not, are the bounding box vertices outside the frustum ?
  67664. * It not, then the cullable object is in the frustum.
  67665. */
  67666. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67667. /** Culling strategy : Bounding Sphere Only.
  67668. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67669. * It's also less accurate than the standard because some not visible objects can still be selected.
  67670. * Test : is the bounding sphere outside the frustum ?
  67671. * If not, then the cullable object is in the frustum.
  67672. */
  67673. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67674. /** Culling strategy : Optimistic Inclusion.
  67675. * This in an inclusion test first, then the standard exclusion test.
  67676. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67677. * 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.
  67678. * Anyway, it's as accurate as the standard strategy.
  67679. * Test :
  67680. * Is the cullable object bounding sphere center in the frustum ?
  67681. * If not, apply the default culling strategy.
  67682. */
  67683. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67684. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67685. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67686. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67687. * 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.
  67688. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67689. * Test :
  67690. * Is the cullable object bounding sphere center in the frustum ?
  67691. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67692. */
  67693. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67694. /**
  67695. * No logging while loading
  67696. */
  67697. static readonly SCENELOADER_NO_LOGGING: number;
  67698. /**
  67699. * Minimal logging while loading
  67700. */
  67701. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67702. /**
  67703. * Summary logging while loading
  67704. */
  67705. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67706. /**
  67707. * Detailled logging while loading
  67708. */
  67709. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67710. }
  67711. }
  67712. declare module BABYLON {
  67713. /**
  67714. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67715. * Babylon.js
  67716. */
  67717. export class DomManagement {
  67718. /**
  67719. * Checks if the window object exists
  67720. * @returns true if the window object exists
  67721. */
  67722. static IsWindowObjectExist(): boolean;
  67723. /**
  67724. * Extracts text content from a DOM element hierarchy
  67725. * @param element defines the root element
  67726. * @returns a string
  67727. */
  67728. static GetDOMTextContent(element: HTMLElement): string;
  67729. }
  67730. }
  67731. declare module BABYLON {
  67732. /**
  67733. * Logger used througouht the application to allow configuration of
  67734. * the log level required for the messages.
  67735. */
  67736. export class Logger {
  67737. /**
  67738. * No log
  67739. */
  67740. static readonly NoneLogLevel: number;
  67741. /**
  67742. * Only message logs
  67743. */
  67744. static readonly MessageLogLevel: number;
  67745. /**
  67746. * Only warning logs
  67747. */
  67748. static readonly WarningLogLevel: number;
  67749. /**
  67750. * Only error logs
  67751. */
  67752. static readonly ErrorLogLevel: number;
  67753. /**
  67754. * All logs
  67755. */
  67756. static readonly AllLogLevel: number;
  67757. private static _LogCache;
  67758. /**
  67759. * Gets a value indicating the number of loading errors
  67760. * @ignorenaming
  67761. */
  67762. static errorsCount: number;
  67763. /**
  67764. * Callback called when a new log is added
  67765. */
  67766. static OnNewCacheEntry: (entry: string) => void;
  67767. private static _AddLogEntry;
  67768. private static _FormatMessage;
  67769. private static _LogDisabled;
  67770. private static _LogEnabled;
  67771. private static _WarnDisabled;
  67772. private static _WarnEnabled;
  67773. private static _ErrorDisabled;
  67774. private static _ErrorEnabled;
  67775. /**
  67776. * Log a message to the console
  67777. */
  67778. static Log: (message: string) => void;
  67779. /**
  67780. * Write a warning message to the console
  67781. */
  67782. static Warn: (message: string) => void;
  67783. /**
  67784. * Write an error message to the console
  67785. */
  67786. static Error: (message: string) => void;
  67787. /**
  67788. * Gets current log cache (list of logs)
  67789. */
  67790. static readonly LogCache: string;
  67791. /**
  67792. * Clears the log cache
  67793. */
  67794. static ClearLogCache(): void;
  67795. /**
  67796. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67797. */
  67798. static LogLevels: number;
  67799. }
  67800. }
  67801. declare module BABYLON {
  67802. /** @hidden */
  67803. export class _TypeStore {
  67804. /** @hidden */
  67805. static RegisteredTypes: {
  67806. [key: string]: Object;
  67807. };
  67808. /** @hidden */
  67809. static GetClass(fqdn: string): any;
  67810. }
  67811. }
  67812. declare module BABYLON {
  67813. /**
  67814. * Class containing a set of static utilities functions for deep copy.
  67815. */
  67816. export class DeepCopier {
  67817. /**
  67818. * Tries to copy an object by duplicating every property
  67819. * @param source defines the source object
  67820. * @param destination defines the target object
  67821. * @param doNotCopyList defines a list of properties to avoid
  67822. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67823. */
  67824. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67825. }
  67826. }
  67827. declare module BABYLON {
  67828. /**
  67829. * Class containing a set of static utilities functions for precision date
  67830. */
  67831. export class PrecisionDate {
  67832. /**
  67833. * Gets either window.performance.now() if supported or Date.now() else
  67834. */
  67835. static readonly Now: number;
  67836. }
  67837. }
  67838. declare module BABYLON {
  67839. /** @hidden */
  67840. export class _DevTools {
  67841. static WarnImport(name: string): string;
  67842. }
  67843. }
  67844. declare module BABYLON {
  67845. /**
  67846. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67847. */
  67848. export class WebRequest {
  67849. private _xhr;
  67850. /**
  67851. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67852. * i.e. when loading files, where the server/service expects an Authorization header
  67853. */
  67854. static CustomRequestHeaders: {
  67855. [key: string]: string;
  67856. };
  67857. /**
  67858. * Add callback functions in this array to update all the requests before they get sent to the network
  67859. */
  67860. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67861. private _injectCustomRequestHeaders;
  67862. /**
  67863. * Gets or sets a function to be called when loading progress changes
  67864. */
  67865. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67866. /**
  67867. * Returns client's state
  67868. */
  67869. readonly readyState: number;
  67870. /**
  67871. * Returns client's status
  67872. */
  67873. readonly status: number;
  67874. /**
  67875. * Returns client's status as a text
  67876. */
  67877. readonly statusText: string;
  67878. /**
  67879. * Returns client's response
  67880. */
  67881. readonly response: any;
  67882. /**
  67883. * Returns client's response url
  67884. */
  67885. readonly responseURL: string;
  67886. /**
  67887. * Returns client's response as text
  67888. */
  67889. readonly responseText: string;
  67890. /**
  67891. * Gets or sets the expected response type
  67892. */
  67893. responseType: XMLHttpRequestResponseType;
  67894. /** @hidden */
  67895. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67896. /** @hidden */
  67897. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67898. /**
  67899. * Cancels any network activity
  67900. */
  67901. abort(): void;
  67902. /**
  67903. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67904. * @param body defines an optional request body
  67905. */
  67906. send(body?: Document | BodyInit | null): void;
  67907. /**
  67908. * Sets the request method, request URL
  67909. * @param method defines the method to use (GET, POST, etc..)
  67910. * @param url defines the url to connect with
  67911. */
  67912. open(method: string, url: string): void;
  67913. }
  67914. }
  67915. declare module BABYLON {
  67916. /**
  67917. * Class used to evalaute queries containing `and` and `or` operators
  67918. */
  67919. export class AndOrNotEvaluator {
  67920. /**
  67921. * Evaluate a query
  67922. * @param query defines the query to evaluate
  67923. * @param evaluateCallback defines the callback used to filter result
  67924. * @returns true if the query matches
  67925. */
  67926. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  67927. private static _HandleParenthesisContent;
  67928. private static _SimplifyNegation;
  67929. }
  67930. }
  67931. declare module BABYLON {
  67932. /**
  67933. * Class used to store custom tags
  67934. */
  67935. export class Tags {
  67936. /**
  67937. * Adds support for tags on the given object
  67938. * @param obj defines the object to use
  67939. */
  67940. static EnableFor(obj: any): void;
  67941. /**
  67942. * Removes tags support
  67943. * @param obj defines the object to use
  67944. */
  67945. static DisableFor(obj: any): void;
  67946. /**
  67947. * Gets a boolean indicating if the given object has tags
  67948. * @param obj defines the object to use
  67949. * @returns a boolean
  67950. */
  67951. static HasTags(obj: any): boolean;
  67952. /**
  67953. * Gets the tags available on a given object
  67954. * @param obj defines the object to use
  67955. * @param asString defines if the tags must be returned as a string instead of an array of strings
  67956. * @returns the tags
  67957. */
  67958. static GetTags(obj: any, asString?: boolean): any;
  67959. /**
  67960. * Adds tags to an object
  67961. * @param obj defines the object to use
  67962. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  67963. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  67964. */
  67965. static AddTagsTo(obj: any, tagsString: string): void;
  67966. /**
  67967. * @hidden
  67968. */
  67969. static _AddTagTo(obj: any, tag: string): void;
  67970. /**
  67971. * Removes specific tags from a specific object
  67972. * @param obj defines the object to use
  67973. * @param tagsString defines the tags to remove
  67974. */
  67975. static RemoveTagsFrom(obj: any, tagsString: string): void;
  67976. /**
  67977. * @hidden
  67978. */
  67979. static _RemoveTagFrom(obj: any, tag: string): void;
  67980. /**
  67981. * Defines if tags hosted on an object match a given query
  67982. * @param obj defines the object to use
  67983. * @param tagsQuery defines the tag query
  67984. * @returns a boolean
  67985. */
  67986. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  67987. }
  67988. }
  67989. declare module BABYLON {
  67990. /**
  67991. * Manages the defines for the Material
  67992. */
  67993. export class MaterialDefines {
  67994. /** @hidden */
  67995. protected _keys: string[];
  67996. private _isDirty;
  67997. /** @hidden */
  67998. _renderId: number;
  67999. /** @hidden */
  68000. _areLightsDirty: boolean;
  68001. /** @hidden */
  68002. _areAttributesDirty: boolean;
  68003. /** @hidden */
  68004. _areTexturesDirty: boolean;
  68005. /** @hidden */
  68006. _areFresnelDirty: boolean;
  68007. /** @hidden */
  68008. _areMiscDirty: boolean;
  68009. /** @hidden */
  68010. _areImageProcessingDirty: boolean;
  68011. /** @hidden */
  68012. _normals: boolean;
  68013. /** @hidden */
  68014. _uvs: boolean;
  68015. /** @hidden */
  68016. _needNormals: boolean;
  68017. /** @hidden */
  68018. _needUVs: boolean;
  68019. [id: string]: any;
  68020. /**
  68021. * Specifies if the material needs to be re-calculated
  68022. */
  68023. readonly isDirty: boolean;
  68024. /**
  68025. * Marks the material to indicate that it has been re-calculated
  68026. */
  68027. markAsProcessed(): void;
  68028. /**
  68029. * Marks the material to indicate that it needs to be re-calculated
  68030. */
  68031. markAsUnprocessed(): void;
  68032. /**
  68033. * Marks the material to indicate all of its defines need to be re-calculated
  68034. */
  68035. markAllAsDirty(): void;
  68036. /**
  68037. * Marks the material to indicate that image processing needs to be re-calculated
  68038. */
  68039. markAsImageProcessingDirty(): void;
  68040. /**
  68041. * Marks the material to indicate the lights need to be re-calculated
  68042. */
  68043. markAsLightDirty(): void;
  68044. /**
  68045. * Marks the attribute state as changed
  68046. */
  68047. markAsAttributesDirty(): void;
  68048. /**
  68049. * Marks the texture state as changed
  68050. */
  68051. markAsTexturesDirty(): void;
  68052. /**
  68053. * Marks the fresnel state as changed
  68054. */
  68055. markAsFresnelDirty(): void;
  68056. /**
  68057. * Marks the misc state as changed
  68058. */
  68059. markAsMiscDirty(): void;
  68060. /**
  68061. * Rebuilds the material defines
  68062. */
  68063. rebuild(): void;
  68064. /**
  68065. * Specifies if two material defines are equal
  68066. * @param other - A material define instance to compare to
  68067. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  68068. */
  68069. isEqual(other: MaterialDefines): boolean;
  68070. /**
  68071. * Clones this instance's defines to another instance
  68072. * @param other - material defines to clone values to
  68073. */
  68074. cloneTo(other: MaterialDefines): void;
  68075. /**
  68076. * Resets the material define values
  68077. */
  68078. reset(): void;
  68079. /**
  68080. * Converts the material define values to a string
  68081. * @returns - String of material define information
  68082. */
  68083. toString(): string;
  68084. }
  68085. }
  68086. declare module BABYLON {
  68087. /**
  68088. * Class used to store and describe the pipeline context associated with an effect
  68089. */
  68090. export interface IPipelineContext {
  68091. /**
  68092. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68093. */
  68094. isAsync: boolean;
  68095. /**
  68096. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68097. */
  68098. isReady: boolean;
  68099. /** @hidden */
  68100. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68101. }
  68102. }
  68103. declare module BABYLON {
  68104. /**
  68105. * Class used to store gfx data (like WebGLBuffer)
  68106. */
  68107. export class DataBuffer {
  68108. /**
  68109. * Gets or sets the number of objects referencing this buffer
  68110. */
  68111. references: number;
  68112. /** Gets or sets the size of the underlying buffer */
  68113. capacity: number;
  68114. /**
  68115. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  68116. */
  68117. is32Bits: boolean;
  68118. /**
  68119. * Gets the underlying buffer
  68120. */
  68121. readonly underlyingResource: any;
  68122. }
  68123. }
  68124. declare module BABYLON {
  68125. /** @hidden */
  68126. export interface IShaderProcessor {
  68127. attributeProcessor?: (attribute: string) => string;
  68128. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68129. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68130. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68131. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68132. lineProcessor?: (line: string, isFragment: boolean) => string;
  68133. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68134. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68135. }
  68136. }
  68137. declare module BABYLON {
  68138. /** @hidden */
  68139. export interface ProcessingOptions {
  68140. defines: string[];
  68141. indexParameters: any;
  68142. isFragment: boolean;
  68143. shouldUseHighPrecisionShader: boolean;
  68144. supportsUniformBuffers: boolean;
  68145. shadersRepository: string;
  68146. includesShadersStore: {
  68147. [key: string]: string;
  68148. };
  68149. processor?: IShaderProcessor;
  68150. version: string;
  68151. platformName: string;
  68152. lookForClosingBracketForUniformBuffer?: boolean;
  68153. }
  68154. }
  68155. declare module BABYLON {
  68156. /** @hidden */
  68157. export class ShaderCodeNode {
  68158. line: string;
  68159. children: ShaderCodeNode[];
  68160. additionalDefineKey?: string;
  68161. additionalDefineValue?: string;
  68162. isValid(preprocessors: {
  68163. [key: string]: string;
  68164. }): boolean;
  68165. process(preprocessors: {
  68166. [key: string]: string;
  68167. }, options: ProcessingOptions): string;
  68168. }
  68169. }
  68170. declare module BABYLON {
  68171. /** @hidden */
  68172. export class ShaderCodeCursor {
  68173. private _lines;
  68174. lineIndex: number;
  68175. readonly currentLine: string;
  68176. readonly canRead: boolean;
  68177. lines: string[];
  68178. }
  68179. }
  68180. declare module BABYLON {
  68181. /** @hidden */
  68182. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68183. process(preprocessors: {
  68184. [key: string]: string;
  68185. }, options: ProcessingOptions): string;
  68186. }
  68187. }
  68188. declare module BABYLON {
  68189. /** @hidden */
  68190. export class ShaderDefineExpression {
  68191. isTrue(preprocessors: {
  68192. [key: string]: string;
  68193. }): boolean;
  68194. }
  68195. }
  68196. declare module BABYLON {
  68197. /** @hidden */
  68198. export class ShaderCodeTestNode extends ShaderCodeNode {
  68199. testExpression: ShaderDefineExpression;
  68200. isValid(preprocessors: {
  68201. [key: string]: string;
  68202. }): boolean;
  68203. }
  68204. }
  68205. declare module BABYLON {
  68206. /** @hidden */
  68207. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68208. define: string;
  68209. not: boolean;
  68210. constructor(define: string, not?: boolean);
  68211. isTrue(preprocessors: {
  68212. [key: string]: string;
  68213. }): boolean;
  68214. }
  68215. }
  68216. declare module BABYLON {
  68217. /** @hidden */
  68218. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68219. leftOperand: ShaderDefineExpression;
  68220. rightOperand: ShaderDefineExpression;
  68221. isTrue(preprocessors: {
  68222. [key: string]: string;
  68223. }): boolean;
  68224. }
  68225. }
  68226. declare module BABYLON {
  68227. /** @hidden */
  68228. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68229. leftOperand: ShaderDefineExpression;
  68230. rightOperand: ShaderDefineExpression;
  68231. isTrue(preprocessors: {
  68232. [key: string]: string;
  68233. }): boolean;
  68234. }
  68235. }
  68236. declare module BABYLON {
  68237. /** @hidden */
  68238. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68239. define: string;
  68240. operand: string;
  68241. testValue: string;
  68242. constructor(define: string, operand: string, testValue: string);
  68243. isTrue(preprocessors: {
  68244. [key: string]: string;
  68245. }): boolean;
  68246. }
  68247. }
  68248. declare module BABYLON {
  68249. /** @hidden */
  68250. export class ShaderProcessor {
  68251. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68252. private static _ProcessPrecision;
  68253. private static _ExtractOperation;
  68254. private static _BuildSubExpression;
  68255. private static _BuildExpression;
  68256. private static _MoveCursorWithinIf;
  68257. private static _MoveCursor;
  68258. private static _EvaluatePreProcessors;
  68259. private static _PreparePreProcessors;
  68260. private static _ProcessShaderConversion;
  68261. private static _ProcessIncludes;
  68262. }
  68263. }
  68264. declare module BABYLON {
  68265. /**
  68266. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  68267. */
  68268. export class PerformanceMonitor {
  68269. private _enabled;
  68270. private _rollingFrameTime;
  68271. private _lastFrameTimeMs;
  68272. /**
  68273. * constructor
  68274. * @param frameSampleSize The number of samples required to saturate the sliding window
  68275. */
  68276. constructor(frameSampleSize?: number);
  68277. /**
  68278. * Samples current frame
  68279. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  68280. */
  68281. sampleFrame(timeMs?: number): void;
  68282. /**
  68283. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68284. */
  68285. readonly averageFrameTime: number;
  68286. /**
  68287. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68288. */
  68289. readonly averageFrameTimeVariance: number;
  68290. /**
  68291. * Returns the frame time of the most recent frame
  68292. */
  68293. readonly instantaneousFrameTime: number;
  68294. /**
  68295. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  68296. */
  68297. readonly averageFPS: number;
  68298. /**
  68299. * Returns the average framerate in frames per second using the most recent frame time
  68300. */
  68301. readonly instantaneousFPS: number;
  68302. /**
  68303. * Returns true if enough samples have been taken to completely fill the sliding window
  68304. */
  68305. readonly isSaturated: boolean;
  68306. /**
  68307. * Enables contributions to the sliding window sample set
  68308. */
  68309. enable(): void;
  68310. /**
  68311. * Disables contributions to the sliding window sample set
  68312. * Samples will not be interpolated over the disabled period
  68313. */
  68314. disable(): void;
  68315. /**
  68316. * Returns true if sampling is enabled
  68317. */
  68318. readonly isEnabled: boolean;
  68319. /**
  68320. * Resets performance monitor
  68321. */
  68322. reset(): void;
  68323. }
  68324. /**
  68325. * RollingAverage
  68326. *
  68327. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  68328. */
  68329. export class RollingAverage {
  68330. /**
  68331. * Current average
  68332. */
  68333. average: number;
  68334. /**
  68335. * Current variance
  68336. */
  68337. variance: number;
  68338. protected _samples: Array<number>;
  68339. protected _sampleCount: number;
  68340. protected _pos: number;
  68341. protected _m2: number;
  68342. /**
  68343. * constructor
  68344. * @param length The number of samples required to saturate the sliding window
  68345. */
  68346. constructor(length: number);
  68347. /**
  68348. * Adds a sample to the sample set
  68349. * @param v The sample value
  68350. */
  68351. add(v: number): void;
  68352. /**
  68353. * Returns previously added values or null if outside of history or outside the sliding window domain
  68354. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  68355. * @return Value previously recorded with add() or null if outside of range
  68356. */
  68357. history(i: number): number;
  68358. /**
  68359. * Returns true if enough samples have been taken to completely fill the sliding window
  68360. * @return true if sample-set saturated
  68361. */
  68362. isSaturated(): boolean;
  68363. /**
  68364. * Resets the rolling average (equivalent to 0 samples taken so far)
  68365. */
  68366. reset(): void;
  68367. /**
  68368. * Wraps a value around the sample range boundaries
  68369. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  68370. * @return Wrapped position in sample range
  68371. */
  68372. protected _wrapPosition(i: number): number;
  68373. }
  68374. }
  68375. declare module BABYLON {
  68376. /**
  68377. * This class implement a typical dictionary using a string as key and the generic type T as value.
  68378. * The underlying implementation relies on an associative array to ensure the best performances.
  68379. * The value can be anything including 'null' but except 'undefined'
  68380. */
  68381. export class StringDictionary<T> {
  68382. /**
  68383. * This will clear this dictionary and copy the content from the 'source' one.
  68384. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  68385. * @param source the dictionary to take the content from and copy to this dictionary
  68386. */
  68387. copyFrom(source: StringDictionary<T>): void;
  68388. /**
  68389. * Get a value based from its key
  68390. * @param key the given key to get the matching value from
  68391. * @return the value if found, otherwise undefined is returned
  68392. */
  68393. get(key: string): T | undefined;
  68394. /**
  68395. * Get a value from its key or add it if it doesn't exist.
  68396. * This method will ensure you that a given key/data will be present in the dictionary.
  68397. * @param key the given key to get the matching value from
  68398. * @param factory the factory that will create the value if the key is not present in the dictionary.
  68399. * The factory will only be invoked if there's no data for the given key.
  68400. * @return the value corresponding to the key.
  68401. */
  68402. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  68403. /**
  68404. * Get a value from its key if present in the dictionary otherwise add it
  68405. * @param key the key to get the value from
  68406. * @param val if there's no such key/value pair in the dictionary add it with this value
  68407. * @return the value corresponding to the key
  68408. */
  68409. getOrAdd(key: string, val: T): T;
  68410. /**
  68411. * Check if there's a given key in the dictionary
  68412. * @param key the key to check for
  68413. * @return true if the key is present, false otherwise
  68414. */
  68415. contains(key: string): boolean;
  68416. /**
  68417. * Add a new key and its corresponding value
  68418. * @param key the key to add
  68419. * @param value the value corresponding to the key
  68420. * @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
  68421. */
  68422. add(key: string, value: T): boolean;
  68423. /**
  68424. * Update a specific value associated to a key
  68425. * @param key defines the key to use
  68426. * @param value defines the value to store
  68427. * @returns true if the value was updated (or false if the key was not found)
  68428. */
  68429. set(key: string, value: T): boolean;
  68430. /**
  68431. * Get the element of the given key and remove it from the dictionary
  68432. * @param key defines the key to search
  68433. * @returns the value associated with the key or null if not found
  68434. */
  68435. getAndRemove(key: string): Nullable<T>;
  68436. /**
  68437. * Remove a key/value from the dictionary.
  68438. * @param key the key to remove
  68439. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  68440. */
  68441. remove(key: string): boolean;
  68442. /**
  68443. * Clear the whole content of the dictionary
  68444. */
  68445. clear(): void;
  68446. /**
  68447. * Gets the current count
  68448. */
  68449. readonly count: number;
  68450. /**
  68451. * Execute a callback on each key/val of the dictionary.
  68452. * Note that you can remove any element in this dictionary in the callback implementation
  68453. * @param callback the callback to execute on a given key/value pair
  68454. */
  68455. forEach(callback: (key: string, val: T) => void): void;
  68456. /**
  68457. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  68458. * If the callback returns null or undefined the method will iterate to the next key/value pair
  68459. * Note that you can remove any element in this dictionary in the callback implementation
  68460. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  68461. * @returns the first item
  68462. */
  68463. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  68464. private _count;
  68465. private _data;
  68466. }
  68467. }
  68468. declare module BABYLON {
  68469. /**
  68470. * Helper class that provides a small promise polyfill
  68471. */
  68472. export class PromisePolyfill {
  68473. /**
  68474. * Static function used to check if the polyfill is required
  68475. * If this is the case then the function will inject the polyfill to window.Promise
  68476. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  68477. */
  68478. static Apply(force?: boolean): void;
  68479. }
  68480. }
  68481. declare module BABYLON {
  68482. /**
  68483. * Class used to store data that will be store in GPU memory
  68484. */
  68485. export class Buffer {
  68486. private _engine;
  68487. private _buffer;
  68488. /** @hidden */
  68489. _data: Nullable<DataArray>;
  68490. private _updatable;
  68491. private _instanced;
  68492. /**
  68493. * Gets the byte stride.
  68494. */
  68495. readonly byteStride: number;
  68496. /**
  68497. * Constructor
  68498. * @param engine the engine
  68499. * @param data the data to use for this buffer
  68500. * @param updatable whether the data is updatable
  68501. * @param stride the stride (optional)
  68502. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68503. * @param instanced whether the buffer is instanced (optional)
  68504. * @param useBytes set to true if the stride in in bytes (optional)
  68505. */
  68506. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  68507. /**
  68508. * Create a new VertexBuffer based on the current buffer
  68509. * @param kind defines the vertex buffer kind (position, normal, etc.)
  68510. * @param offset defines offset in the buffer (0 by default)
  68511. * @param size defines the size in floats of attributes (position is 3 for instance)
  68512. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  68513. * @param instanced defines if the vertex buffer contains indexed data
  68514. * @param useBytes defines if the offset and stride are in bytes
  68515. * @returns the new vertex buffer
  68516. */
  68517. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  68518. /**
  68519. * Gets a boolean indicating if the Buffer is updatable?
  68520. * @returns true if the buffer is updatable
  68521. */
  68522. isUpdatable(): boolean;
  68523. /**
  68524. * Gets current buffer's data
  68525. * @returns a DataArray or null
  68526. */
  68527. getData(): Nullable<DataArray>;
  68528. /**
  68529. * Gets underlying native buffer
  68530. * @returns underlying native buffer
  68531. */
  68532. getBuffer(): Nullable<DataBuffer>;
  68533. /**
  68534. * Gets the stride in float32 units (i.e. byte stride / 4).
  68535. * May not be an integer if the byte stride is not divisible by 4.
  68536. * DEPRECATED. Use byteStride instead.
  68537. * @returns the stride in float32 units
  68538. */
  68539. getStrideSize(): number;
  68540. /**
  68541. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68542. * @param data defines the data to store
  68543. */
  68544. create(data?: Nullable<DataArray>): void;
  68545. /** @hidden */
  68546. _rebuild(): void;
  68547. /**
  68548. * Update current buffer data
  68549. * @param data defines the data to store
  68550. */
  68551. update(data: DataArray): void;
  68552. /**
  68553. * Updates the data directly.
  68554. * @param data the new data
  68555. * @param offset the new offset
  68556. * @param vertexCount the vertex count (optional)
  68557. * @param useBytes set to true if the offset is in bytes
  68558. */
  68559. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  68560. /**
  68561. * Release all resources
  68562. */
  68563. dispose(): void;
  68564. }
  68565. /**
  68566. * Specialized buffer used to store vertex data
  68567. */
  68568. export class VertexBuffer {
  68569. /** @hidden */
  68570. _buffer: Buffer;
  68571. private _kind;
  68572. private _size;
  68573. private _ownsBuffer;
  68574. private _instanced;
  68575. private _instanceDivisor;
  68576. /**
  68577. * The byte type.
  68578. */
  68579. static readonly BYTE: number;
  68580. /**
  68581. * The unsigned byte type.
  68582. */
  68583. static readonly UNSIGNED_BYTE: number;
  68584. /**
  68585. * The short type.
  68586. */
  68587. static readonly SHORT: number;
  68588. /**
  68589. * The unsigned short type.
  68590. */
  68591. static readonly UNSIGNED_SHORT: number;
  68592. /**
  68593. * The integer type.
  68594. */
  68595. static readonly INT: number;
  68596. /**
  68597. * The unsigned integer type.
  68598. */
  68599. static readonly UNSIGNED_INT: number;
  68600. /**
  68601. * The float type.
  68602. */
  68603. static readonly FLOAT: number;
  68604. /**
  68605. * Gets or sets the instance divisor when in instanced mode
  68606. */
  68607. instanceDivisor: number;
  68608. /**
  68609. * Gets the byte stride.
  68610. */
  68611. readonly byteStride: number;
  68612. /**
  68613. * Gets the byte offset.
  68614. */
  68615. readonly byteOffset: number;
  68616. /**
  68617. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  68618. */
  68619. readonly normalized: boolean;
  68620. /**
  68621. * Gets the data type of each component in the array.
  68622. */
  68623. readonly type: number;
  68624. /**
  68625. * Constructor
  68626. * @param engine the engine
  68627. * @param data the data to use for this vertex buffer
  68628. * @param kind the vertex buffer kind
  68629. * @param updatable whether the data is updatable
  68630. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68631. * @param stride the stride (optional)
  68632. * @param instanced whether the buffer is instanced (optional)
  68633. * @param offset the offset of the data (optional)
  68634. * @param size the number of components (optional)
  68635. * @param type the type of the component (optional)
  68636. * @param normalized whether the data contains normalized data (optional)
  68637. * @param useBytes set to true if stride and offset are in bytes (optional)
  68638. */
  68639. 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);
  68640. /** @hidden */
  68641. _rebuild(): void;
  68642. /**
  68643. * Returns the kind of the VertexBuffer (string)
  68644. * @returns a string
  68645. */
  68646. getKind(): string;
  68647. /**
  68648. * Gets a boolean indicating if the VertexBuffer is updatable?
  68649. * @returns true if the buffer is updatable
  68650. */
  68651. isUpdatable(): boolean;
  68652. /**
  68653. * Gets current buffer's data
  68654. * @returns a DataArray or null
  68655. */
  68656. getData(): Nullable<DataArray>;
  68657. /**
  68658. * Gets underlying native buffer
  68659. * @returns underlying native buffer
  68660. */
  68661. getBuffer(): Nullable<DataBuffer>;
  68662. /**
  68663. * Gets the stride in float32 units (i.e. byte stride / 4).
  68664. * May not be an integer if the byte stride is not divisible by 4.
  68665. * DEPRECATED. Use byteStride instead.
  68666. * @returns the stride in float32 units
  68667. */
  68668. getStrideSize(): number;
  68669. /**
  68670. * Returns the offset as a multiple of the type byte length.
  68671. * DEPRECATED. Use byteOffset instead.
  68672. * @returns the offset in bytes
  68673. */
  68674. getOffset(): number;
  68675. /**
  68676. * Returns the number of components per vertex attribute (integer)
  68677. * @returns the size in float
  68678. */
  68679. getSize(): number;
  68680. /**
  68681. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  68682. * @returns true if this buffer is instanced
  68683. */
  68684. getIsInstanced(): boolean;
  68685. /**
  68686. * Returns the instancing divisor, zero for non-instanced (integer).
  68687. * @returns a number
  68688. */
  68689. getInstanceDivisor(): number;
  68690. /**
  68691. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68692. * @param data defines the data to store
  68693. */
  68694. create(data?: DataArray): void;
  68695. /**
  68696. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  68697. * This function will create a new buffer if the current one is not updatable
  68698. * @param data defines the data to store
  68699. */
  68700. update(data: DataArray): void;
  68701. /**
  68702. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  68703. * Returns the directly updated WebGLBuffer.
  68704. * @param data the new data
  68705. * @param offset the new offset
  68706. * @param useBytes set to true if the offset is in bytes
  68707. */
  68708. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  68709. /**
  68710. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  68711. */
  68712. dispose(): void;
  68713. /**
  68714. * Enumerates each value of this vertex buffer as numbers.
  68715. * @param count the number of values to enumerate
  68716. * @param callback the callback function called for each value
  68717. */
  68718. forEach(count: number, callback: (value: number, index: number) => void): void;
  68719. /**
  68720. * Positions
  68721. */
  68722. static readonly PositionKind: string;
  68723. /**
  68724. * Normals
  68725. */
  68726. static readonly NormalKind: string;
  68727. /**
  68728. * Tangents
  68729. */
  68730. static readonly TangentKind: string;
  68731. /**
  68732. * Texture coordinates
  68733. */
  68734. static readonly UVKind: string;
  68735. /**
  68736. * Texture coordinates 2
  68737. */
  68738. static readonly UV2Kind: string;
  68739. /**
  68740. * Texture coordinates 3
  68741. */
  68742. static readonly UV3Kind: string;
  68743. /**
  68744. * Texture coordinates 4
  68745. */
  68746. static readonly UV4Kind: string;
  68747. /**
  68748. * Texture coordinates 5
  68749. */
  68750. static readonly UV5Kind: string;
  68751. /**
  68752. * Texture coordinates 6
  68753. */
  68754. static readonly UV6Kind: string;
  68755. /**
  68756. * Colors
  68757. */
  68758. static readonly ColorKind: string;
  68759. /**
  68760. * Matrix indices (for bones)
  68761. */
  68762. static readonly MatricesIndicesKind: string;
  68763. /**
  68764. * Matrix weights (for bones)
  68765. */
  68766. static readonly MatricesWeightsKind: string;
  68767. /**
  68768. * Additional matrix indices (for bones)
  68769. */
  68770. static readonly MatricesIndicesExtraKind: string;
  68771. /**
  68772. * Additional matrix weights (for bones)
  68773. */
  68774. static readonly MatricesWeightsExtraKind: string;
  68775. /**
  68776. * Deduces the stride given a kind.
  68777. * @param kind The kind string to deduce
  68778. * @returns The deduced stride
  68779. */
  68780. static DeduceStride(kind: string): number;
  68781. /**
  68782. * Gets the byte length of the given type.
  68783. * @param type the type
  68784. * @returns the number of bytes
  68785. */
  68786. static GetTypeByteLength(type: number): number;
  68787. /**
  68788. * Enumerates each value of the given parameters as numbers.
  68789. * @param data the data to enumerate
  68790. * @param byteOffset the byte offset of the data
  68791. * @param byteStride the byte stride of the data
  68792. * @param componentCount the number of components per element
  68793. * @param componentType the type of the component
  68794. * @param count the number of values to enumerate
  68795. * @param normalized whether the data is normalized
  68796. * @param callback the callback function called for each value
  68797. */
  68798. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  68799. private static _GetFloatValue;
  68800. }
  68801. }
  68802. declare module BABYLON {
  68803. /**
  68804. * Class representing spherical harmonics coefficients to the 3rd degree
  68805. */
  68806. export class SphericalHarmonics {
  68807. /**
  68808. * Defines whether or not the harmonics have been prescaled for rendering.
  68809. */
  68810. preScaled: boolean;
  68811. /**
  68812. * The l0,0 coefficients of the spherical harmonics
  68813. */
  68814. l00: Vector3;
  68815. /**
  68816. * The l1,-1 coefficients of the spherical harmonics
  68817. */
  68818. l1_1: Vector3;
  68819. /**
  68820. * The l1,0 coefficients of the spherical harmonics
  68821. */
  68822. l10: Vector3;
  68823. /**
  68824. * The l1,1 coefficients of the spherical harmonics
  68825. */
  68826. l11: Vector3;
  68827. /**
  68828. * The l2,-2 coefficients of the spherical harmonics
  68829. */
  68830. l2_2: Vector3;
  68831. /**
  68832. * The l2,-1 coefficients of the spherical harmonics
  68833. */
  68834. l2_1: Vector3;
  68835. /**
  68836. * The l2,0 coefficients of the spherical harmonics
  68837. */
  68838. l20: Vector3;
  68839. /**
  68840. * The l2,1 coefficients of the spherical harmonics
  68841. */
  68842. l21: Vector3;
  68843. /**
  68844. * The l2,2 coefficients of the spherical harmonics
  68845. */
  68846. l22: Vector3;
  68847. /**
  68848. * Adds a light to the spherical harmonics
  68849. * @param direction the direction of the light
  68850. * @param color the color of the light
  68851. * @param deltaSolidAngle the delta solid angle of the light
  68852. */
  68853. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  68854. /**
  68855. * Scales the spherical harmonics by the given amount
  68856. * @param scale the amount to scale
  68857. */
  68858. scaleInPlace(scale: number): void;
  68859. /**
  68860. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  68861. *
  68862. * ```
  68863. * E_lm = A_l * L_lm
  68864. * ```
  68865. *
  68866. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  68867. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  68868. * the scaling factors are given in equation 9.
  68869. */
  68870. convertIncidentRadianceToIrradiance(): void;
  68871. /**
  68872. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  68873. *
  68874. * ```
  68875. * L = (1/pi) * E * rho
  68876. * ```
  68877. *
  68878. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  68879. */
  68880. convertIrradianceToLambertianRadiance(): void;
  68881. /**
  68882. * Integrates the reconstruction coefficients directly in to the SH preventing further
  68883. * required operations at run time.
  68884. *
  68885. * This is simply done by scaling back the SH with Ylm constants parameter.
  68886. * The trigonometric part being applied by the shader at run time.
  68887. */
  68888. preScaleForRendering(): void;
  68889. /**
  68890. * Constructs a spherical harmonics from an array.
  68891. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  68892. * @returns the spherical harmonics
  68893. */
  68894. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  68895. /**
  68896. * Gets the spherical harmonics from polynomial
  68897. * @param polynomial the spherical polynomial
  68898. * @returns the spherical harmonics
  68899. */
  68900. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  68901. }
  68902. /**
  68903. * Class representing spherical polynomial coefficients to the 3rd degree
  68904. */
  68905. export class SphericalPolynomial {
  68906. private _harmonics;
  68907. /**
  68908. * The spherical harmonics used to create the polynomials.
  68909. */
  68910. readonly preScaledHarmonics: SphericalHarmonics;
  68911. /**
  68912. * The x coefficients of the spherical polynomial
  68913. */
  68914. x: Vector3;
  68915. /**
  68916. * The y coefficients of the spherical polynomial
  68917. */
  68918. y: Vector3;
  68919. /**
  68920. * The z coefficients of the spherical polynomial
  68921. */
  68922. z: Vector3;
  68923. /**
  68924. * The xx coefficients of the spherical polynomial
  68925. */
  68926. xx: Vector3;
  68927. /**
  68928. * The yy coefficients of the spherical polynomial
  68929. */
  68930. yy: Vector3;
  68931. /**
  68932. * The zz coefficients of the spherical polynomial
  68933. */
  68934. zz: Vector3;
  68935. /**
  68936. * The xy coefficients of the spherical polynomial
  68937. */
  68938. xy: Vector3;
  68939. /**
  68940. * The yz coefficients of the spherical polynomial
  68941. */
  68942. yz: Vector3;
  68943. /**
  68944. * The zx coefficients of the spherical polynomial
  68945. */
  68946. zx: Vector3;
  68947. /**
  68948. * Adds an ambient color to the spherical polynomial
  68949. * @param color the color to add
  68950. */
  68951. addAmbient(color: Color3): void;
  68952. /**
  68953. * Scales the spherical polynomial by the given amount
  68954. * @param scale the amount to scale
  68955. */
  68956. scaleInPlace(scale: number): void;
  68957. /**
  68958. * Gets the spherical polynomial from harmonics
  68959. * @param harmonics the spherical harmonics
  68960. * @returns the spherical polynomial
  68961. */
  68962. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  68963. /**
  68964. * Constructs a spherical polynomial from an array.
  68965. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  68966. * @returns the spherical polynomial
  68967. */
  68968. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  68969. }
  68970. }
  68971. declare module BABYLON {
  68972. /**
  68973. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  68974. */
  68975. export interface CubeMapInfo {
  68976. /**
  68977. * The pixel array for the front face.
  68978. * This is stored in format, left to right, up to down format.
  68979. */
  68980. front: Nullable<ArrayBufferView>;
  68981. /**
  68982. * The pixel array for the back face.
  68983. * This is stored in format, left to right, up to down format.
  68984. */
  68985. back: Nullable<ArrayBufferView>;
  68986. /**
  68987. * The pixel array for the left face.
  68988. * This is stored in format, left to right, up to down format.
  68989. */
  68990. left: Nullable<ArrayBufferView>;
  68991. /**
  68992. * The pixel array for the right face.
  68993. * This is stored in format, left to right, up to down format.
  68994. */
  68995. right: Nullable<ArrayBufferView>;
  68996. /**
  68997. * The pixel array for the up face.
  68998. * This is stored in format, left to right, up to down format.
  68999. */
  69000. up: Nullable<ArrayBufferView>;
  69001. /**
  69002. * The pixel array for the down face.
  69003. * This is stored in format, left to right, up to down format.
  69004. */
  69005. down: Nullable<ArrayBufferView>;
  69006. /**
  69007. * The size of the cubemap stored.
  69008. *
  69009. * Each faces will be size * size pixels.
  69010. */
  69011. size: number;
  69012. /**
  69013. * The format of the texture.
  69014. *
  69015. * RGBA, RGB.
  69016. */
  69017. format: number;
  69018. /**
  69019. * The type of the texture data.
  69020. *
  69021. * UNSIGNED_INT, FLOAT.
  69022. */
  69023. type: number;
  69024. /**
  69025. * Specifies whether the texture is in gamma space.
  69026. */
  69027. gammaSpace: boolean;
  69028. }
  69029. /**
  69030. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  69031. */
  69032. export class PanoramaToCubeMapTools {
  69033. private static FACE_FRONT;
  69034. private static FACE_BACK;
  69035. private static FACE_RIGHT;
  69036. private static FACE_LEFT;
  69037. private static FACE_DOWN;
  69038. private static FACE_UP;
  69039. /**
  69040. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  69041. *
  69042. * @param float32Array The source data.
  69043. * @param inputWidth The width of the input panorama.
  69044. * @param inputHeight The height of the input panorama.
  69045. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  69046. * @return The cubemap data
  69047. */
  69048. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  69049. private static CreateCubemapTexture;
  69050. private static CalcProjectionSpherical;
  69051. }
  69052. }
  69053. declare module BABYLON {
  69054. /**
  69055. * Helper class dealing with the extraction of spherical polynomial dataArray
  69056. * from a cube map.
  69057. */
  69058. export class CubeMapToSphericalPolynomialTools {
  69059. private static FileFaces;
  69060. /**
  69061. * Converts a texture to the according Spherical Polynomial data.
  69062. * This extracts the first 3 orders only as they are the only one used in the lighting.
  69063. *
  69064. * @param texture The texture to extract the information from.
  69065. * @return The Spherical Polynomial data.
  69066. */
  69067. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  69068. /**
  69069. * Converts a cubemap to the according Spherical Polynomial data.
  69070. * This extracts the first 3 orders only as they are the only one used in the lighting.
  69071. *
  69072. * @param cubeInfo The Cube map to extract the information from.
  69073. * @return The Spherical Polynomial data.
  69074. */
  69075. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  69076. }
  69077. }
  69078. declare module BABYLON {
  69079. /**
  69080. * The engine store class is responsible to hold all the instances of Engine and Scene created
  69081. * during the life time of the application.
  69082. */
  69083. export class EngineStore {
  69084. /** Gets the list of created engines */
  69085. static Instances: Engine[];
  69086. /** @hidden */
  69087. static _LastCreatedScene: Nullable<Scene>;
  69088. /**
  69089. * Gets the latest created engine
  69090. */
  69091. static readonly LastCreatedEngine: Nullable<Engine>;
  69092. /**
  69093. * Gets the latest created scene
  69094. */
  69095. static readonly LastCreatedScene: Nullable<Scene>;
  69096. }
  69097. }
  69098. declare module BABYLON {
  69099. /**
  69100. * Define options used to create a render target texture
  69101. */
  69102. export class RenderTargetCreationOptions {
  69103. /**
  69104. * Specifies is mipmaps must be generated
  69105. */
  69106. generateMipMaps?: boolean;
  69107. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69108. generateDepthBuffer?: boolean;
  69109. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69110. generateStencilBuffer?: boolean;
  69111. /** Defines texture type (int by default) */
  69112. type?: number;
  69113. /** Defines sampling mode (trilinear by default) */
  69114. samplingMode?: number;
  69115. /** Defines format (RGBA by default) */
  69116. format?: number;
  69117. }
  69118. }
  69119. declare module BABYLON {
  69120. /**
  69121. * @hidden
  69122. **/
  69123. export class _AlphaState {
  69124. private _isAlphaBlendDirty;
  69125. private _isBlendFunctionParametersDirty;
  69126. private _isBlendEquationParametersDirty;
  69127. private _isBlendConstantsDirty;
  69128. private _alphaBlend;
  69129. private _blendFunctionParameters;
  69130. private _blendEquationParameters;
  69131. private _blendConstants;
  69132. /**
  69133. * Initializes the state.
  69134. */
  69135. constructor();
  69136. readonly isDirty: boolean;
  69137. alphaBlend: boolean;
  69138. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  69139. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  69140. setAlphaEquationParameters(rgb: number, alpha: number): void;
  69141. reset(): void;
  69142. apply(gl: WebGLRenderingContext): void;
  69143. }
  69144. }
  69145. declare module BABYLON {
  69146. /**
  69147. * @hidden
  69148. **/
  69149. export class _DepthCullingState {
  69150. private _isDepthTestDirty;
  69151. private _isDepthMaskDirty;
  69152. private _isDepthFuncDirty;
  69153. private _isCullFaceDirty;
  69154. private _isCullDirty;
  69155. private _isZOffsetDirty;
  69156. private _isFrontFaceDirty;
  69157. private _depthTest;
  69158. private _depthMask;
  69159. private _depthFunc;
  69160. private _cull;
  69161. private _cullFace;
  69162. private _zOffset;
  69163. private _frontFace;
  69164. /**
  69165. * Initializes the state.
  69166. */
  69167. constructor();
  69168. readonly isDirty: boolean;
  69169. zOffset: number;
  69170. cullFace: Nullable<number>;
  69171. cull: Nullable<boolean>;
  69172. depthFunc: Nullable<number>;
  69173. depthMask: boolean;
  69174. depthTest: boolean;
  69175. frontFace: Nullable<number>;
  69176. reset(): void;
  69177. apply(gl: WebGLRenderingContext): void;
  69178. }
  69179. }
  69180. declare module BABYLON {
  69181. /**
  69182. * @hidden
  69183. **/
  69184. export class _StencilState {
  69185. /** 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 */
  69186. static readonly ALWAYS: number;
  69187. /** Passed to stencilOperation to specify that stencil value must be kept */
  69188. static readonly KEEP: number;
  69189. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69190. static readonly REPLACE: number;
  69191. private _isStencilTestDirty;
  69192. private _isStencilMaskDirty;
  69193. private _isStencilFuncDirty;
  69194. private _isStencilOpDirty;
  69195. private _stencilTest;
  69196. private _stencilMask;
  69197. private _stencilFunc;
  69198. private _stencilFuncRef;
  69199. private _stencilFuncMask;
  69200. private _stencilOpStencilFail;
  69201. private _stencilOpDepthFail;
  69202. private _stencilOpStencilDepthPass;
  69203. readonly isDirty: boolean;
  69204. stencilFunc: number;
  69205. stencilFuncRef: number;
  69206. stencilFuncMask: number;
  69207. stencilOpStencilFail: number;
  69208. stencilOpDepthFail: number;
  69209. stencilOpStencilDepthPass: number;
  69210. stencilMask: number;
  69211. stencilTest: boolean;
  69212. constructor();
  69213. reset(): void;
  69214. apply(gl: WebGLRenderingContext): void;
  69215. }
  69216. }
  69217. declare module BABYLON {
  69218. /**
  69219. * @hidden
  69220. **/
  69221. export class _TimeToken {
  69222. _startTimeQuery: Nullable<WebGLQuery>;
  69223. _endTimeQuery: Nullable<WebGLQuery>;
  69224. _timeElapsedQuery: Nullable<WebGLQuery>;
  69225. _timeElapsedQueryEnded: boolean;
  69226. }
  69227. }
  69228. declare module BABYLON {
  69229. /**
  69230. * Class used to store data associated with WebGL texture data for the engine
  69231. * This class should not be used directly
  69232. */
  69233. export class InternalTexture {
  69234. /** @hidden */
  69235. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  69236. /**
  69237. * The source of the texture data is unknown
  69238. */
  69239. static DATASOURCE_UNKNOWN: number;
  69240. /**
  69241. * Texture data comes from an URL
  69242. */
  69243. static DATASOURCE_URL: number;
  69244. /**
  69245. * Texture data is only used for temporary storage
  69246. */
  69247. static DATASOURCE_TEMP: number;
  69248. /**
  69249. * Texture data comes from raw data (ArrayBuffer)
  69250. */
  69251. static DATASOURCE_RAW: number;
  69252. /**
  69253. * Texture content is dynamic (video or dynamic texture)
  69254. */
  69255. static DATASOURCE_DYNAMIC: number;
  69256. /**
  69257. * Texture content is generated by rendering to it
  69258. */
  69259. static DATASOURCE_RENDERTARGET: number;
  69260. /**
  69261. * Texture content is part of a multi render target process
  69262. */
  69263. static DATASOURCE_MULTIRENDERTARGET: number;
  69264. /**
  69265. * Texture data comes from a cube data file
  69266. */
  69267. static DATASOURCE_CUBE: number;
  69268. /**
  69269. * Texture data comes from a raw cube data
  69270. */
  69271. static DATASOURCE_CUBERAW: number;
  69272. /**
  69273. * Texture data come from a prefiltered cube data file
  69274. */
  69275. static DATASOURCE_CUBEPREFILTERED: number;
  69276. /**
  69277. * Texture content is raw 3D data
  69278. */
  69279. static DATASOURCE_RAW3D: number;
  69280. /**
  69281. * Texture content is a depth texture
  69282. */
  69283. static DATASOURCE_DEPTHTEXTURE: number;
  69284. /**
  69285. * Texture data comes from a raw cube data encoded with RGBD
  69286. */
  69287. static DATASOURCE_CUBERAW_RGBD: number;
  69288. /**
  69289. * Defines if the texture is ready
  69290. */
  69291. isReady: boolean;
  69292. /**
  69293. * Defines if the texture is a cube texture
  69294. */
  69295. isCube: boolean;
  69296. /**
  69297. * Defines if the texture contains 3D data
  69298. */
  69299. is3D: boolean;
  69300. /**
  69301. * Defines if the texture contains multiview data
  69302. */
  69303. isMultiview: boolean;
  69304. /**
  69305. * Gets the URL used to load this texture
  69306. */
  69307. url: string;
  69308. /**
  69309. * Gets the sampling mode of the texture
  69310. */
  69311. samplingMode: number;
  69312. /**
  69313. * Gets a boolean indicating if the texture needs mipmaps generation
  69314. */
  69315. generateMipMaps: boolean;
  69316. /**
  69317. * Gets the number of samples used by the texture (WebGL2+ only)
  69318. */
  69319. samples: number;
  69320. /**
  69321. * Gets the type of the texture (int, float...)
  69322. */
  69323. type: number;
  69324. /**
  69325. * Gets the format of the texture (RGB, RGBA...)
  69326. */
  69327. format: number;
  69328. /**
  69329. * Observable called when the texture is loaded
  69330. */
  69331. onLoadedObservable: Observable<InternalTexture>;
  69332. /**
  69333. * Gets the width of the texture
  69334. */
  69335. width: number;
  69336. /**
  69337. * Gets the height of the texture
  69338. */
  69339. height: number;
  69340. /**
  69341. * Gets the depth of the texture
  69342. */
  69343. depth: number;
  69344. /**
  69345. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  69346. */
  69347. baseWidth: number;
  69348. /**
  69349. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  69350. */
  69351. baseHeight: number;
  69352. /**
  69353. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  69354. */
  69355. baseDepth: number;
  69356. /**
  69357. * Gets a boolean indicating if the texture is inverted on Y axis
  69358. */
  69359. invertY: boolean;
  69360. /** @hidden */
  69361. _invertVScale: boolean;
  69362. /** @hidden */
  69363. _associatedChannel: number;
  69364. /** @hidden */
  69365. _dataSource: number;
  69366. /** @hidden */
  69367. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  69368. /** @hidden */
  69369. _bufferView: Nullable<ArrayBufferView>;
  69370. /** @hidden */
  69371. _bufferViewArray: Nullable<ArrayBufferView[]>;
  69372. /** @hidden */
  69373. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  69374. /** @hidden */
  69375. _size: number;
  69376. /** @hidden */
  69377. _extension: string;
  69378. /** @hidden */
  69379. _files: Nullable<string[]>;
  69380. /** @hidden */
  69381. _workingCanvas: Nullable<HTMLCanvasElement>;
  69382. /** @hidden */
  69383. _workingContext: Nullable<CanvasRenderingContext2D>;
  69384. /** @hidden */
  69385. _framebuffer: Nullable<WebGLFramebuffer>;
  69386. /** @hidden */
  69387. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  69388. /** @hidden */
  69389. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  69390. /** @hidden */
  69391. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  69392. /** @hidden */
  69393. _attachments: Nullable<number[]>;
  69394. /** @hidden */
  69395. _cachedCoordinatesMode: Nullable<number>;
  69396. /** @hidden */
  69397. _cachedWrapU: Nullable<number>;
  69398. /** @hidden */
  69399. _cachedWrapV: Nullable<number>;
  69400. /** @hidden */
  69401. _cachedWrapR: Nullable<number>;
  69402. /** @hidden */
  69403. _cachedAnisotropicFilteringLevel: Nullable<number>;
  69404. /** @hidden */
  69405. _isDisabled: boolean;
  69406. /** @hidden */
  69407. _compression: Nullable<string>;
  69408. /** @hidden */
  69409. _generateStencilBuffer: boolean;
  69410. /** @hidden */
  69411. _generateDepthBuffer: boolean;
  69412. /** @hidden */
  69413. _comparisonFunction: number;
  69414. /** @hidden */
  69415. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  69416. /** @hidden */
  69417. _lodGenerationScale: number;
  69418. /** @hidden */
  69419. _lodGenerationOffset: number;
  69420. /** @hidden */
  69421. _colorTextureArray: Nullable<WebGLTexture>;
  69422. /** @hidden */
  69423. _depthStencilTextureArray: Nullable<WebGLTexture>;
  69424. /** @hidden */
  69425. _lodTextureHigh: Nullable<BaseTexture>;
  69426. /** @hidden */
  69427. _lodTextureMid: Nullable<BaseTexture>;
  69428. /** @hidden */
  69429. _lodTextureLow: Nullable<BaseTexture>;
  69430. /** @hidden */
  69431. _isRGBD: boolean;
  69432. /** @hidden */
  69433. _linearSpecularLOD: boolean;
  69434. /** @hidden */
  69435. _irradianceTexture: Nullable<BaseTexture>;
  69436. /** @hidden */
  69437. _webGLTexture: Nullable<WebGLTexture>;
  69438. /** @hidden */
  69439. _references: number;
  69440. private _engine;
  69441. /**
  69442. * Gets the Engine the texture belongs to.
  69443. * @returns The babylon engine
  69444. */
  69445. getEngine(): Engine;
  69446. /**
  69447. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  69448. */
  69449. readonly dataSource: number;
  69450. /**
  69451. * Creates a new InternalTexture
  69452. * @param engine defines the engine to use
  69453. * @param dataSource defines the type of data that will be used
  69454. * @param delayAllocation if the texture allocation should be delayed (default: false)
  69455. */
  69456. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  69457. /**
  69458. * Increments the number of references (ie. the number of Texture that point to it)
  69459. */
  69460. incrementReferences(): void;
  69461. /**
  69462. * Change the size of the texture (not the size of the content)
  69463. * @param width defines the new width
  69464. * @param height defines the new height
  69465. * @param depth defines the new depth (1 by default)
  69466. */
  69467. updateSize(width: int, height: int, depth?: int): void;
  69468. /** @hidden */
  69469. _rebuild(): void;
  69470. /** @hidden */
  69471. _swapAndDie(target: InternalTexture): void;
  69472. /**
  69473. * Dispose the current allocated resources
  69474. */
  69475. dispose(): void;
  69476. }
  69477. }
  69478. declare module BABYLON {
  69479. /**
  69480. * This represents the main contract an easing function should follow.
  69481. * Easing functions are used throughout the animation system.
  69482. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69483. */
  69484. export interface IEasingFunction {
  69485. /**
  69486. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69487. * of the easing function.
  69488. * The link below provides some of the most common examples of easing functions.
  69489. * @see https://easings.net/
  69490. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69491. * @returns the corresponding value on the curve defined by the easing function
  69492. */
  69493. ease(gradient: number): number;
  69494. }
  69495. /**
  69496. * Base class used for every default easing function.
  69497. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69498. */
  69499. export class EasingFunction implements IEasingFunction {
  69500. /**
  69501. * Interpolation follows the mathematical formula associated with the easing function.
  69502. */
  69503. static readonly EASINGMODE_EASEIN: number;
  69504. /**
  69505. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  69506. */
  69507. static readonly EASINGMODE_EASEOUT: number;
  69508. /**
  69509. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  69510. */
  69511. static readonly EASINGMODE_EASEINOUT: number;
  69512. private _easingMode;
  69513. /**
  69514. * Sets the easing mode of the current function.
  69515. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  69516. */
  69517. setEasingMode(easingMode: number): void;
  69518. /**
  69519. * Gets the current easing mode.
  69520. * @returns the easing mode
  69521. */
  69522. getEasingMode(): number;
  69523. /**
  69524. * @hidden
  69525. */
  69526. easeInCore(gradient: number): number;
  69527. /**
  69528. * Given an input gradient between 0 and 1, this returns the corresponding value
  69529. * of the easing function.
  69530. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69531. * @returns the corresponding value on the curve defined by the easing function
  69532. */
  69533. ease(gradient: number): number;
  69534. }
  69535. /**
  69536. * Easing function with a circle shape (see link below).
  69537. * @see https://easings.net/#easeInCirc
  69538. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69539. */
  69540. export class CircleEase extends EasingFunction implements IEasingFunction {
  69541. /** @hidden */
  69542. easeInCore(gradient: number): number;
  69543. }
  69544. /**
  69545. * Easing function with a ease back shape (see link below).
  69546. * @see https://easings.net/#easeInBack
  69547. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69548. */
  69549. export class BackEase extends EasingFunction implements IEasingFunction {
  69550. /** Defines the amplitude of the function */
  69551. amplitude: number;
  69552. /**
  69553. * Instantiates a back ease easing
  69554. * @see https://easings.net/#easeInBack
  69555. * @param amplitude Defines the amplitude of the function
  69556. */
  69557. constructor(
  69558. /** Defines the amplitude of the function */
  69559. amplitude?: number);
  69560. /** @hidden */
  69561. easeInCore(gradient: number): number;
  69562. }
  69563. /**
  69564. * Easing function with a bouncing shape (see link below).
  69565. * @see https://easings.net/#easeInBounce
  69566. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69567. */
  69568. export class BounceEase extends EasingFunction implements IEasingFunction {
  69569. /** Defines the number of bounces */
  69570. bounces: number;
  69571. /** Defines the amplitude of the bounce */
  69572. bounciness: number;
  69573. /**
  69574. * Instantiates a bounce easing
  69575. * @see https://easings.net/#easeInBounce
  69576. * @param bounces Defines the number of bounces
  69577. * @param bounciness Defines the amplitude of the bounce
  69578. */
  69579. constructor(
  69580. /** Defines the number of bounces */
  69581. bounces?: number,
  69582. /** Defines the amplitude of the bounce */
  69583. bounciness?: number);
  69584. /** @hidden */
  69585. easeInCore(gradient: number): number;
  69586. }
  69587. /**
  69588. * Easing function with a power of 3 shape (see link below).
  69589. * @see https://easings.net/#easeInCubic
  69590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69591. */
  69592. export class CubicEase extends EasingFunction implements IEasingFunction {
  69593. /** @hidden */
  69594. easeInCore(gradient: number): number;
  69595. }
  69596. /**
  69597. * Easing function with an elastic shape (see link below).
  69598. * @see https://easings.net/#easeInElastic
  69599. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69600. */
  69601. export class ElasticEase extends EasingFunction implements IEasingFunction {
  69602. /** Defines the number of oscillations*/
  69603. oscillations: number;
  69604. /** Defines the amplitude of the oscillations*/
  69605. springiness: number;
  69606. /**
  69607. * Instantiates an elastic easing function
  69608. * @see https://easings.net/#easeInElastic
  69609. * @param oscillations Defines the number of oscillations
  69610. * @param springiness Defines the amplitude of the oscillations
  69611. */
  69612. constructor(
  69613. /** Defines the number of oscillations*/
  69614. oscillations?: number,
  69615. /** Defines the amplitude of the oscillations*/
  69616. springiness?: number);
  69617. /** @hidden */
  69618. easeInCore(gradient: number): number;
  69619. }
  69620. /**
  69621. * Easing function with an exponential shape (see link below).
  69622. * @see https://easings.net/#easeInExpo
  69623. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69624. */
  69625. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  69626. /** Defines the exponent of the function */
  69627. exponent: number;
  69628. /**
  69629. * Instantiates an exponential easing function
  69630. * @see https://easings.net/#easeInExpo
  69631. * @param exponent Defines the exponent of the function
  69632. */
  69633. constructor(
  69634. /** Defines the exponent of the function */
  69635. exponent?: number);
  69636. /** @hidden */
  69637. easeInCore(gradient: number): number;
  69638. }
  69639. /**
  69640. * Easing function with a power shape (see link below).
  69641. * @see https://easings.net/#easeInQuad
  69642. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69643. */
  69644. export class PowerEase extends EasingFunction implements IEasingFunction {
  69645. /** Defines the power of the function */
  69646. power: number;
  69647. /**
  69648. * Instantiates an power base easing function
  69649. * @see https://easings.net/#easeInQuad
  69650. * @param power Defines the power of the function
  69651. */
  69652. constructor(
  69653. /** Defines the power of the function */
  69654. power?: number);
  69655. /** @hidden */
  69656. easeInCore(gradient: number): number;
  69657. }
  69658. /**
  69659. * Easing function with a power of 2 shape (see link below).
  69660. * @see https://easings.net/#easeInQuad
  69661. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69662. */
  69663. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  69664. /** @hidden */
  69665. easeInCore(gradient: number): number;
  69666. }
  69667. /**
  69668. * Easing function with a power of 4 shape (see link below).
  69669. * @see https://easings.net/#easeInQuart
  69670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69671. */
  69672. export class QuarticEase extends EasingFunction implements IEasingFunction {
  69673. /** @hidden */
  69674. easeInCore(gradient: number): number;
  69675. }
  69676. /**
  69677. * Easing function with a power of 5 shape (see link below).
  69678. * @see https://easings.net/#easeInQuint
  69679. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69680. */
  69681. export class QuinticEase extends EasingFunction implements IEasingFunction {
  69682. /** @hidden */
  69683. easeInCore(gradient: number): number;
  69684. }
  69685. /**
  69686. * Easing function with a sin shape (see link below).
  69687. * @see https://easings.net/#easeInSine
  69688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69689. */
  69690. export class SineEase extends EasingFunction implements IEasingFunction {
  69691. /** @hidden */
  69692. easeInCore(gradient: number): number;
  69693. }
  69694. /**
  69695. * Easing function with a bezier shape (see link below).
  69696. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69697. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69698. */
  69699. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  69700. /** Defines the x component of the start tangent in the bezier curve */
  69701. x1: number;
  69702. /** Defines the y component of the start tangent in the bezier curve */
  69703. y1: number;
  69704. /** Defines the x component of the end tangent in the bezier curve */
  69705. x2: number;
  69706. /** Defines the y component of the end tangent in the bezier curve */
  69707. y2: number;
  69708. /**
  69709. * Instantiates a bezier function
  69710. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69711. * @param x1 Defines the x component of the start tangent in the bezier curve
  69712. * @param y1 Defines the y component of the start tangent in the bezier curve
  69713. * @param x2 Defines the x component of the end tangent in the bezier curve
  69714. * @param y2 Defines the y component of the end tangent in the bezier curve
  69715. */
  69716. constructor(
  69717. /** Defines the x component of the start tangent in the bezier curve */
  69718. x1?: number,
  69719. /** Defines the y component of the start tangent in the bezier curve */
  69720. y1?: number,
  69721. /** Defines the x component of the end tangent in the bezier curve */
  69722. x2?: number,
  69723. /** Defines the y component of the end tangent in the bezier curve */
  69724. y2?: number);
  69725. /** @hidden */
  69726. easeInCore(gradient: number): number;
  69727. }
  69728. }
  69729. declare module BABYLON {
  69730. /**
  69731. * Defines an interface which represents an animation key frame
  69732. */
  69733. export interface IAnimationKey {
  69734. /**
  69735. * Frame of the key frame
  69736. */
  69737. frame: number;
  69738. /**
  69739. * Value at the specifies key frame
  69740. */
  69741. value: any;
  69742. /**
  69743. * The input tangent for the cubic hermite spline
  69744. */
  69745. inTangent?: any;
  69746. /**
  69747. * The output tangent for the cubic hermite spline
  69748. */
  69749. outTangent?: any;
  69750. /**
  69751. * The animation interpolation type
  69752. */
  69753. interpolation?: AnimationKeyInterpolation;
  69754. }
  69755. /**
  69756. * Enum for the animation key frame interpolation type
  69757. */
  69758. export enum AnimationKeyInterpolation {
  69759. /**
  69760. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  69761. */
  69762. STEP = 1
  69763. }
  69764. }
  69765. declare module BABYLON {
  69766. /**
  69767. * Represents the range of an animation
  69768. */
  69769. export class AnimationRange {
  69770. /**The name of the animation range**/
  69771. name: string;
  69772. /**The starting frame of the animation */
  69773. from: number;
  69774. /**The ending frame of the animation*/
  69775. to: number;
  69776. /**
  69777. * Initializes the range of an animation
  69778. * @param name The name of the animation range
  69779. * @param from The starting frame of the animation
  69780. * @param to The ending frame of the animation
  69781. */
  69782. constructor(
  69783. /**The name of the animation range**/
  69784. name: string,
  69785. /**The starting frame of the animation */
  69786. from: number,
  69787. /**The ending frame of the animation*/
  69788. to: number);
  69789. /**
  69790. * Makes a copy of the animation range
  69791. * @returns A copy of the animation range
  69792. */
  69793. clone(): AnimationRange;
  69794. }
  69795. }
  69796. declare module BABYLON {
  69797. /**
  69798. * Composed of a frame, and an action function
  69799. */
  69800. export class AnimationEvent {
  69801. /** The frame for which the event is triggered **/
  69802. frame: number;
  69803. /** The event to perform when triggered **/
  69804. action: (currentFrame: number) => void;
  69805. /** Specifies if the event should be triggered only once**/
  69806. onlyOnce?: boolean | undefined;
  69807. /**
  69808. * Specifies if the animation event is done
  69809. */
  69810. isDone: boolean;
  69811. /**
  69812. * Initializes the animation event
  69813. * @param frame The frame for which the event is triggered
  69814. * @param action The event to perform when triggered
  69815. * @param onlyOnce Specifies if the event should be triggered only once
  69816. */
  69817. constructor(
  69818. /** The frame for which the event is triggered **/
  69819. frame: number,
  69820. /** The event to perform when triggered **/
  69821. action: (currentFrame: number) => void,
  69822. /** Specifies if the event should be triggered only once**/
  69823. onlyOnce?: boolean | undefined);
  69824. /** @hidden */
  69825. _clone(): AnimationEvent;
  69826. }
  69827. }
  69828. declare module BABYLON {
  69829. /**
  69830. * Interface used to define a behavior
  69831. */
  69832. export interface Behavior<T> {
  69833. /** gets or sets behavior's name */
  69834. name: string;
  69835. /**
  69836. * Function called when the behavior needs to be initialized (after attaching it to a target)
  69837. */
  69838. init(): void;
  69839. /**
  69840. * Called when the behavior is attached to a target
  69841. * @param target defines the target where the behavior is attached to
  69842. */
  69843. attach(target: T): void;
  69844. /**
  69845. * Called when the behavior is detached from its target
  69846. */
  69847. detach(): void;
  69848. }
  69849. /**
  69850. * Interface implemented by classes supporting behaviors
  69851. */
  69852. export interface IBehaviorAware<T> {
  69853. /**
  69854. * Attach a behavior
  69855. * @param behavior defines the behavior to attach
  69856. * @returns the current host
  69857. */
  69858. addBehavior(behavior: Behavior<T>): T;
  69859. /**
  69860. * Remove a behavior from the current object
  69861. * @param behavior defines the behavior to detach
  69862. * @returns the current host
  69863. */
  69864. removeBehavior(behavior: Behavior<T>): T;
  69865. /**
  69866. * Gets a behavior using its name to search
  69867. * @param name defines the name to search
  69868. * @returns the behavior or null if not found
  69869. */
  69870. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  69871. }
  69872. }
  69873. declare module BABYLON {
  69874. /**
  69875. * @hidden
  69876. */
  69877. export class IntersectionInfo {
  69878. bu: Nullable<number>;
  69879. bv: Nullable<number>;
  69880. distance: number;
  69881. faceId: number;
  69882. subMeshId: number;
  69883. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  69884. }
  69885. }
  69886. declare module BABYLON {
  69887. /**
  69888. * Class used to store bounding sphere information
  69889. */
  69890. export class BoundingSphere {
  69891. /**
  69892. * Gets the center of the bounding sphere in local space
  69893. */
  69894. readonly center: Vector3;
  69895. /**
  69896. * Radius of the bounding sphere in local space
  69897. */
  69898. radius: number;
  69899. /**
  69900. * Gets the center of the bounding sphere in world space
  69901. */
  69902. readonly centerWorld: Vector3;
  69903. /**
  69904. * Radius of the bounding sphere in world space
  69905. */
  69906. radiusWorld: number;
  69907. /**
  69908. * Gets the minimum vector in local space
  69909. */
  69910. readonly minimum: Vector3;
  69911. /**
  69912. * Gets the maximum vector in local space
  69913. */
  69914. readonly maximum: Vector3;
  69915. private _worldMatrix;
  69916. private static readonly TmpVector3;
  69917. /**
  69918. * Creates a new bounding sphere
  69919. * @param min defines the minimum vector (in local space)
  69920. * @param max defines the maximum vector (in local space)
  69921. * @param worldMatrix defines the new world matrix
  69922. */
  69923. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69924. /**
  69925. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  69926. * @param min defines the new minimum vector (in local space)
  69927. * @param max defines the new maximum vector (in local space)
  69928. * @param worldMatrix defines the new world matrix
  69929. */
  69930. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69931. /**
  69932. * Scale the current bounding sphere by applying a scale factor
  69933. * @param factor defines the scale factor to apply
  69934. * @returns the current bounding box
  69935. */
  69936. scale(factor: number): BoundingSphere;
  69937. /**
  69938. * Gets the world matrix of the bounding box
  69939. * @returns a matrix
  69940. */
  69941. getWorldMatrix(): DeepImmutable<Matrix>;
  69942. /** @hidden */
  69943. _update(worldMatrix: DeepImmutable<Matrix>): void;
  69944. /**
  69945. * Tests if the bounding sphere is intersecting the frustum planes
  69946. * @param frustumPlanes defines the frustum planes to test
  69947. * @returns true if there is an intersection
  69948. */
  69949. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69950. /**
  69951. * Tests if the bounding sphere center is in between the frustum planes.
  69952. * Used for optimistic fast inclusion.
  69953. * @param frustumPlanes defines the frustum planes to test
  69954. * @returns true if the sphere center is in between the frustum planes
  69955. */
  69956. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69957. /**
  69958. * Tests if a point is inside the bounding sphere
  69959. * @param point defines the point to test
  69960. * @returns true if the point is inside the bounding sphere
  69961. */
  69962. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69963. /**
  69964. * Checks if two sphere intersct
  69965. * @param sphere0 sphere 0
  69966. * @param sphere1 sphere 1
  69967. * @returns true if the speres intersect
  69968. */
  69969. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  69970. }
  69971. }
  69972. declare module BABYLON {
  69973. /**
  69974. * Class used to store bounding box information
  69975. */
  69976. export class BoundingBox implements ICullable {
  69977. /**
  69978. * Gets the 8 vectors representing the bounding box in local space
  69979. */
  69980. readonly vectors: Vector3[];
  69981. /**
  69982. * Gets the center of the bounding box in local space
  69983. */
  69984. readonly center: Vector3;
  69985. /**
  69986. * Gets the center of the bounding box in world space
  69987. */
  69988. readonly centerWorld: Vector3;
  69989. /**
  69990. * Gets the extend size in local space
  69991. */
  69992. readonly extendSize: Vector3;
  69993. /**
  69994. * Gets the extend size in world space
  69995. */
  69996. readonly extendSizeWorld: Vector3;
  69997. /**
  69998. * Gets the OBB (object bounding box) directions
  69999. */
  70000. readonly directions: Vector3[];
  70001. /**
  70002. * Gets the 8 vectors representing the bounding box in world space
  70003. */
  70004. readonly vectorsWorld: Vector3[];
  70005. /**
  70006. * Gets the minimum vector in world space
  70007. */
  70008. readonly minimumWorld: Vector3;
  70009. /**
  70010. * Gets the maximum vector in world space
  70011. */
  70012. readonly maximumWorld: Vector3;
  70013. /**
  70014. * Gets the minimum vector in local space
  70015. */
  70016. readonly minimum: Vector3;
  70017. /**
  70018. * Gets the maximum vector in local space
  70019. */
  70020. readonly maximum: Vector3;
  70021. private _worldMatrix;
  70022. private static readonly TmpVector3;
  70023. /**
  70024. * @hidden
  70025. */
  70026. _tag: number;
  70027. /**
  70028. * Creates a new bounding box
  70029. * @param min defines the minimum vector (in local space)
  70030. * @param max defines the maximum vector (in local space)
  70031. * @param worldMatrix defines the new world matrix
  70032. */
  70033. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70034. /**
  70035. * Recreates the entire bounding box from scratch as if we call the constructor in place
  70036. * @param min defines the new minimum vector (in local space)
  70037. * @param max defines the new maximum vector (in local space)
  70038. * @param worldMatrix defines the new world matrix
  70039. */
  70040. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70041. /**
  70042. * Scale the current bounding box by applying a scale factor
  70043. * @param factor defines the scale factor to apply
  70044. * @returns the current bounding box
  70045. */
  70046. scale(factor: number): BoundingBox;
  70047. /**
  70048. * Gets the world matrix of the bounding box
  70049. * @returns a matrix
  70050. */
  70051. getWorldMatrix(): DeepImmutable<Matrix>;
  70052. /** @hidden */
  70053. _update(world: DeepImmutable<Matrix>): void;
  70054. /**
  70055. * Tests if the bounding box is intersecting the frustum planes
  70056. * @param frustumPlanes defines the frustum planes to test
  70057. * @returns true if there is an intersection
  70058. */
  70059. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70060. /**
  70061. * Tests if the bounding box is entirely inside the frustum planes
  70062. * @param frustumPlanes defines the frustum planes to test
  70063. * @returns true if there is an inclusion
  70064. */
  70065. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70066. /**
  70067. * Tests if a point is inside the bounding box
  70068. * @param point defines the point to test
  70069. * @returns true if the point is inside the bounding box
  70070. */
  70071. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70072. /**
  70073. * Tests if the bounding box intersects with a bounding sphere
  70074. * @param sphere defines the sphere to test
  70075. * @returns true if there is an intersection
  70076. */
  70077. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  70078. /**
  70079. * Tests if the bounding box intersects with a box defined by a min and max vectors
  70080. * @param min defines the min vector to use
  70081. * @param max defines the max vector to use
  70082. * @returns true if there is an intersection
  70083. */
  70084. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  70085. /**
  70086. * Tests if two bounding boxes are intersections
  70087. * @param box0 defines the first box to test
  70088. * @param box1 defines the second box to test
  70089. * @returns true if there is an intersection
  70090. */
  70091. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  70092. /**
  70093. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  70094. * @param minPoint defines the minimum vector of the bounding box
  70095. * @param maxPoint defines the maximum vector of the bounding box
  70096. * @param sphereCenter defines the sphere center
  70097. * @param sphereRadius defines the sphere radius
  70098. * @returns true if there is an intersection
  70099. */
  70100. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  70101. /**
  70102. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  70103. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70104. * @param frustumPlanes defines the frustum planes to test
  70105. * @return true if there is an inclusion
  70106. */
  70107. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70108. /**
  70109. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  70110. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70111. * @param frustumPlanes defines the frustum planes to test
  70112. * @return true if there is an intersection
  70113. */
  70114. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70115. }
  70116. }
  70117. declare module BABYLON {
  70118. /** @hidden */
  70119. export class Collider {
  70120. /** Define if a collision was found */
  70121. collisionFound: boolean;
  70122. /**
  70123. * Define last intersection point in local space
  70124. */
  70125. intersectionPoint: Vector3;
  70126. /**
  70127. * Define last collided mesh
  70128. */
  70129. collidedMesh: Nullable<AbstractMesh>;
  70130. private _collisionPoint;
  70131. private _planeIntersectionPoint;
  70132. private _tempVector;
  70133. private _tempVector2;
  70134. private _tempVector3;
  70135. private _tempVector4;
  70136. private _edge;
  70137. private _baseToVertex;
  70138. private _destinationPoint;
  70139. private _slidePlaneNormal;
  70140. private _displacementVector;
  70141. /** @hidden */
  70142. _radius: Vector3;
  70143. /** @hidden */
  70144. _retry: number;
  70145. private _velocity;
  70146. private _basePoint;
  70147. private _epsilon;
  70148. /** @hidden */
  70149. _velocityWorldLength: number;
  70150. /** @hidden */
  70151. _basePointWorld: Vector3;
  70152. private _velocityWorld;
  70153. private _normalizedVelocity;
  70154. /** @hidden */
  70155. _initialVelocity: Vector3;
  70156. /** @hidden */
  70157. _initialPosition: Vector3;
  70158. private _nearestDistance;
  70159. private _collisionMask;
  70160. collisionMask: number;
  70161. /**
  70162. * Gets the plane normal used to compute the sliding response (in local space)
  70163. */
  70164. readonly slidePlaneNormal: Vector3;
  70165. /** @hidden */
  70166. _initialize(source: Vector3, dir: Vector3, e: number): void;
  70167. /** @hidden */
  70168. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  70169. /** @hidden */
  70170. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  70171. /** @hidden */
  70172. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  70173. /** @hidden */
  70174. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  70175. /** @hidden */
  70176. _getResponse(pos: Vector3, vel: Vector3): void;
  70177. }
  70178. }
  70179. declare module BABYLON {
  70180. /**
  70181. * Interface for cullable objects
  70182. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  70183. */
  70184. export interface ICullable {
  70185. /**
  70186. * Checks if the object or part of the object is in the frustum
  70187. * @param frustumPlanes Camera near/planes
  70188. * @returns true if the object is in frustum otherwise false
  70189. */
  70190. isInFrustum(frustumPlanes: Plane[]): boolean;
  70191. /**
  70192. * Checks if a cullable object (mesh...) is in the camera frustum
  70193. * Unlike isInFrustum this cheks the full bounding box
  70194. * @param frustumPlanes Camera near/planes
  70195. * @returns true if the object is in frustum otherwise false
  70196. */
  70197. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  70198. }
  70199. /**
  70200. * Info for a bounding data of a mesh
  70201. */
  70202. export class BoundingInfo implements ICullable {
  70203. /**
  70204. * Bounding box for the mesh
  70205. */
  70206. readonly boundingBox: BoundingBox;
  70207. /**
  70208. * Bounding sphere for the mesh
  70209. */
  70210. readonly boundingSphere: BoundingSphere;
  70211. private _isLocked;
  70212. private static readonly TmpVector3;
  70213. /**
  70214. * Constructs bounding info
  70215. * @param minimum min vector of the bounding box/sphere
  70216. * @param maximum max vector of the bounding box/sphere
  70217. * @param worldMatrix defines the new world matrix
  70218. */
  70219. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70220. /**
  70221. * Recreates the entire bounding info from scratch as if we call the constructor in place
  70222. * @param min defines the new minimum vector (in local space)
  70223. * @param max defines the new maximum vector (in local space)
  70224. * @param worldMatrix defines the new world matrix
  70225. */
  70226. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70227. /**
  70228. * min vector of the bounding box/sphere
  70229. */
  70230. readonly minimum: Vector3;
  70231. /**
  70232. * max vector of the bounding box/sphere
  70233. */
  70234. readonly maximum: Vector3;
  70235. /**
  70236. * If the info is locked and won't be updated to avoid perf overhead
  70237. */
  70238. isLocked: boolean;
  70239. /**
  70240. * Updates the bounding sphere and box
  70241. * @param world world matrix to be used to update
  70242. */
  70243. update(world: DeepImmutable<Matrix>): void;
  70244. /**
  70245. * Recreate the bounding info to be centered around a specific point given a specific extend.
  70246. * @param center New center of the bounding info
  70247. * @param extend New extend of the bounding info
  70248. * @returns the current bounding info
  70249. */
  70250. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  70251. /**
  70252. * Scale the current bounding info by applying a scale factor
  70253. * @param factor defines the scale factor to apply
  70254. * @returns the current bounding info
  70255. */
  70256. scale(factor: number): BoundingInfo;
  70257. /**
  70258. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  70259. * @param frustumPlanes defines the frustum to test
  70260. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  70261. * @returns true if the bounding info is in the frustum planes
  70262. */
  70263. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  70264. /**
  70265. * Gets the world distance between the min and max points of the bounding box
  70266. */
  70267. readonly diagonalLength: number;
  70268. /**
  70269. * Checks if a cullable object (mesh...) is in the camera frustum
  70270. * Unlike isInFrustum this cheks the full bounding box
  70271. * @param frustumPlanes Camera near/planes
  70272. * @returns true if the object is in frustum otherwise false
  70273. */
  70274. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70275. /** @hidden */
  70276. _checkCollision(collider: Collider): boolean;
  70277. /**
  70278. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  70279. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70280. * @param point the point to check intersection with
  70281. * @returns if the point intersects
  70282. */
  70283. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70284. /**
  70285. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  70286. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70287. * @param boundingInfo the bounding info to check intersection with
  70288. * @param precise if the intersection should be done using OBB
  70289. * @returns if the bounding info intersects
  70290. */
  70291. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  70292. }
  70293. }
  70294. declare module BABYLON {
  70295. /**
  70296. * Defines an array and its length.
  70297. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70298. */
  70299. export interface ISmartArrayLike<T> {
  70300. /**
  70301. * The data of the array.
  70302. */
  70303. data: Array<T>;
  70304. /**
  70305. * The active length of the array.
  70306. */
  70307. length: number;
  70308. }
  70309. /**
  70310. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70311. */
  70312. export class SmartArray<T> implements ISmartArrayLike<T> {
  70313. /**
  70314. * The full set of data from the array.
  70315. */
  70316. data: Array<T>;
  70317. /**
  70318. * The active length of the array.
  70319. */
  70320. length: number;
  70321. protected _id: number;
  70322. /**
  70323. * Instantiates a Smart Array.
  70324. * @param capacity defines the default capacity of the array.
  70325. */
  70326. constructor(capacity: number);
  70327. /**
  70328. * Pushes a value at the end of the active data.
  70329. * @param value defines the object to push in the array.
  70330. */
  70331. push(value: T): void;
  70332. /**
  70333. * Iterates over the active data and apply the lambda to them.
  70334. * @param func defines the action to apply on each value.
  70335. */
  70336. forEach(func: (content: T) => void): void;
  70337. /**
  70338. * Sorts the full sets of data.
  70339. * @param compareFn defines the comparison function to apply.
  70340. */
  70341. sort(compareFn: (a: T, b: T) => number): void;
  70342. /**
  70343. * Resets the active data to an empty array.
  70344. */
  70345. reset(): void;
  70346. /**
  70347. * Releases all the data from the array as well as the array.
  70348. */
  70349. dispose(): void;
  70350. /**
  70351. * Concats the active data with a given array.
  70352. * @param array defines the data to concatenate with.
  70353. */
  70354. concat(array: any): void;
  70355. /**
  70356. * Returns the position of a value in the active data.
  70357. * @param value defines the value to find the index for
  70358. * @returns the index if found in the active data otherwise -1
  70359. */
  70360. indexOf(value: T): number;
  70361. /**
  70362. * Returns whether an element is part of the active data.
  70363. * @param value defines the value to look for
  70364. * @returns true if found in the active data otherwise false
  70365. */
  70366. contains(value: T): boolean;
  70367. private static _GlobalId;
  70368. }
  70369. /**
  70370. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70371. * The data in this array can only be present once
  70372. */
  70373. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  70374. private _duplicateId;
  70375. /**
  70376. * Pushes a value at the end of the active data.
  70377. * THIS DOES NOT PREVENT DUPPLICATE DATA
  70378. * @param value defines the object to push in the array.
  70379. */
  70380. push(value: T): void;
  70381. /**
  70382. * Pushes a value at the end of the active data.
  70383. * If the data is already present, it won t be added again
  70384. * @param value defines the object to push in the array.
  70385. * @returns true if added false if it was already present
  70386. */
  70387. pushNoDuplicate(value: T): boolean;
  70388. /**
  70389. * Resets the active data to an empty array.
  70390. */
  70391. reset(): void;
  70392. /**
  70393. * Concats the active data with a given array.
  70394. * This ensures no dupplicate will be present in the result.
  70395. * @param array defines the data to concatenate with.
  70396. */
  70397. concatWithNoDuplicate(array: any): void;
  70398. }
  70399. }
  70400. declare module BABYLON {
  70401. /**
  70402. * Enum that determines the text-wrapping mode to use.
  70403. */
  70404. export enum InspectableType {
  70405. /**
  70406. * Checkbox for booleans
  70407. */
  70408. Checkbox = 0,
  70409. /**
  70410. * Sliders for numbers
  70411. */
  70412. Slider = 1,
  70413. /**
  70414. * Vector3
  70415. */
  70416. Vector3 = 2,
  70417. /**
  70418. * Quaternions
  70419. */
  70420. Quaternion = 3,
  70421. /**
  70422. * Color3
  70423. */
  70424. Color3 = 4,
  70425. /**
  70426. * String
  70427. */
  70428. String = 5
  70429. }
  70430. /**
  70431. * Interface used to define custom inspectable properties.
  70432. * This interface is used by the inspector to display custom property grids
  70433. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70434. */
  70435. export interface IInspectable {
  70436. /**
  70437. * Gets the label to display
  70438. */
  70439. label: string;
  70440. /**
  70441. * Gets the name of the property to edit
  70442. */
  70443. propertyName: string;
  70444. /**
  70445. * Gets the type of the editor to use
  70446. */
  70447. type: InspectableType;
  70448. /**
  70449. * Gets the minimum value of the property when using in "slider" mode
  70450. */
  70451. min?: number;
  70452. /**
  70453. * Gets the maximum value of the property when using in "slider" mode
  70454. */
  70455. max?: number;
  70456. /**
  70457. * Gets the setp to use when using in "slider" mode
  70458. */
  70459. step?: number;
  70460. }
  70461. }
  70462. declare module BABYLON {
  70463. /**
  70464. * This represents the required contract to create a new type of texture loader.
  70465. */
  70466. export interface IInternalTextureLoader {
  70467. /**
  70468. * Defines wether the loader supports cascade loading the different faces.
  70469. */
  70470. supportCascades: boolean;
  70471. /**
  70472. * This returns if the loader support the current file information.
  70473. * @param extension defines the file extension of the file being loaded
  70474. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70475. * @param fallback defines the fallback internal texture if any
  70476. * @param isBase64 defines whether the texture is encoded as a base64
  70477. * @param isBuffer defines whether the texture data are stored as a buffer
  70478. * @returns true if the loader can load the specified file
  70479. */
  70480. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70481. /**
  70482. * Transform the url before loading if required.
  70483. * @param rootUrl the url of the texture
  70484. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70485. * @returns the transformed texture
  70486. */
  70487. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70488. /**
  70489. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70490. * @param rootUrl the url of the texture
  70491. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70492. * @returns the fallback texture
  70493. */
  70494. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70495. /**
  70496. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70497. * @param data contains the texture data
  70498. * @param texture defines the BabylonJS internal texture
  70499. * @param createPolynomials will be true if polynomials have been requested
  70500. * @param onLoad defines the callback to trigger once the texture is ready
  70501. * @param onError defines the callback to trigger in case of error
  70502. */
  70503. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70504. /**
  70505. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70506. * @param data contains the texture data
  70507. * @param texture defines the BabylonJS internal texture
  70508. * @param callback defines the method to call once ready to upload
  70509. */
  70510. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70511. }
  70512. }
  70513. declare module BABYLON {
  70514. interface Engine {
  70515. /**
  70516. * Creates a depth stencil cube texture.
  70517. * This is only available in WebGL 2.
  70518. * @param size The size of face edge in the cube texture.
  70519. * @param options The options defining the cube texture.
  70520. * @returns The cube texture
  70521. */
  70522. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  70523. /**
  70524. * Creates a cube texture
  70525. * @param rootUrl defines the url where the files to load is located
  70526. * @param scene defines the current scene
  70527. * @param files defines the list of files to load (1 per face)
  70528. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70529. * @param onLoad defines an optional callback raised when the texture is loaded
  70530. * @param onError defines an optional callback raised if there is an issue to load the texture
  70531. * @param format defines the format of the data
  70532. * @param forcedExtension defines the extension to use to pick the right loader
  70533. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70534. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70535. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70536. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  70537. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  70538. * @returns the cube texture as an InternalTexture
  70539. */
  70540. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  70541. /**
  70542. * Creates a cube texture
  70543. * @param rootUrl defines the url where the files to load is located
  70544. * @param scene defines the current scene
  70545. * @param files defines the list of files to load (1 per face)
  70546. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70547. * @param onLoad defines an optional callback raised when the texture is loaded
  70548. * @param onError defines an optional callback raised if there is an issue to load the texture
  70549. * @param format defines the format of the data
  70550. * @param forcedExtension defines the extension to use to pick the right loader
  70551. * @returns the cube texture as an InternalTexture
  70552. */
  70553. 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;
  70554. /**
  70555. * Creates a cube texture
  70556. * @param rootUrl defines the url where the files to load is located
  70557. * @param scene defines the current scene
  70558. * @param files defines the list of files to load (1 per face)
  70559. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70560. * @param onLoad defines an optional callback raised when the texture is loaded
  70561. * @param onError defines an optional callback raised if there is an issue to load the texture
  70562. * @param format defines the format of the data
  70563. * @param forcedExtension defines the extension to use to pick the right loader
  70564. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70565. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70566. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70567. * @returns the cube texture as an InternalTexture
  70568. */
  70569. 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;
  70570. /** @hidden */
  70571. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70572. /** @hidden */
  70573. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70574. /** @hidden */
  70575. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70576. /** @hidden */
  70577. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70578. }
  70579. }
  70580. declare module BABYLON {
  70581. /**
  70582. * Class for creating a cube texture
  70583. */
  70584. export class CubeTexture extends BaseTexture {
  70585. private _delayedOnLoad;
  70586. /**
  70587. * The url of the texture
  70588. */
  70589. url: string;
  70590. /**
  70591. * Gets or sets the center of the bounding box associated with the cube texture.
  70592. * It must define where the camera used to render the texture was set
  70593. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70594. */
  70595. boundingBoxPosition: Vector3;
  70596. private _boundingBoxSize;
  70597. /**
  70598. * Gets or sets the size of the bounding box associated with the cube texture
  70599. * When defined, the cubemap will switch to local mode
  70600. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  70601. * @example https://www.babylonjs-playground.com/#RNASML
  70602. */
  70603. /**
  70604. * Returns the bounding box size
  70605. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70606. */
  70607. boundingBoxSize: Vector3;
  70608. protected _rotationY: number;
  70609. /**
  70610. * Sets texture matrix rotation angle around Y axis in radians.
  70611. */
  70612. /**
  70613. * Gets texture matrix rotation angle around Y axis radians.
  70614. */
  70615. rotationY: number;
  70616. /**
  70617. * Are mip maps generated for this texture or not.
  70618. */
  70619. readonly noMipmap: boolean;
  70620. private _noMipmap;
  70621. private _files;
  70622. private _extensions;
  70623. private _textureMatrix;
  70624. private _format;
  70625. private _createPolynomials;
  70626. /** @hidden */
  70627. _prefiltered: boolean;
  70628. /**
  70629. * Creates a cube texture from an array of image urls
  70630. * @param files defines an array of image urls
  70631. * @param scene defines the hosting scene
  70632. * @param noMipmap specifies if mip maps are not used
  70633. * @returns a cube texture
  70634. */
  70635. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  70636. /**
  70637. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  70638. * @param url defines the url of the prefiltered texture
  70639. * @param scene defines the scene the texture is attached to
  70640. * @param forcedExtension defines the extension of the file if different from the url
  70641. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70642. * @return the prefiltered texture
  70643. */
  70644. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  70645. /**
  70646. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  70647. * as prefiltered data.
  70648. * @param rootUrl defines the url of the texture or the root name of the six images
  70649. * @param scene defines the scene the texture is attached to
  70650. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  70651. * @param noMipmap defines if mipmaps should be created or not
  70652. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  70653. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  70654. * @param onError defines a callback triggered in case of error during load
  70655. * @param format defines the internal format to use for the texture once loaded
  70656. * @param prefiltered defines whether or not the texture is created from prefiltered data
  70657. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  70658. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70659. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70660. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70661. * @return the cube texture
  70662. */
  70663. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  70664. /**
  70665. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  70666. */
  70667. readonly isPrefiltered: boolean;
  70668. /**
  70669. * Get the current class name of the texture useful for serialization or dynamic coding.
  70670. * @returns "CubeTexture"
  70671. */
  70672. getClassName(): string;
  70673. /**
  70674. * Update the url (and optional buffer) of this texture if url was null during construction.
  70675. * @param url the url of the texture
  70676. * @param forcedExtension defines the extension to use
  70677. * @param onLoad callback called when the texture is loaded (defaults to null)
  70678. */
  70679. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  70680. /**
  70681. * Delays loading of the cube texture
  70682. * @param forcedExtension defines the extension to use
  70683. */
  70684. delayLoad(forcedExtension?: string): void;
  70685. /**
  70686. * Returns the reflection texture matrix
  70687. * @returns the reflection texture matrix
  70688. */
  70689. getReflectionTextureMatrix(): Matrix;
  70690. /**
  70691. * Sets the reflection texture matrix
  70692. * @param value Reflection texture matrix
  70693. */
  70694. setReflectionTextureMatrix(value: Matrix): void;
  70695. /**
  70696. * Parses text to create a cube texture
  70697. * @param parsedTexture define the serialized text to read from
  70698. * @param scene defines the hosting scene
  70699. * @param rootUrl defines the root url of the cube texture
  70700. * @returns a cube texture
  70701. */
  70702. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  70703. /**
  70704. * Makes a clone, or deep copy, of the cube texture
  70705. * @returns a new cube texture
  70706. */
  70707. clone(): CubeTexture;
  70708. }
  70709. }
  70710. declare module BABYLON {
  70711. /** @hidden */
  70712. export var postprocessVertexShader: {
  70713. name: string;
  70714. shader: string;
  70715. };
  70716. }
  70717. declare module BABYLON {
  70718. /**
  70719. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  70720. * This is the base of the follow, arc rotate cameras and Free camera
  70721. * @see http://doc.babylonjs.com/features/cameras
  70722. */
  70723. export class TargetCamera extends Camera {
  70724. private static _RigCamTransformMatrix;
  70725. private static _TargetTransformMatrix;
  70726. private static _TargetFocalPoint;
  70727. /**
  70728. * Define the current direction the camera is moving to
  70729. */
  70730. cameraDirection: Vector3;
  70731. /**
  70732. * Define the current rotation the camera is rotating to
  70733. */
  70734. cameraRotation: Vector2;
  70735. /**
  70736. * When set, the up vector of the camera will be updated by the rotation of the camera
  70737. */
  70738. updateUpVectorFromRotation: boolean;
  70739. private _tmpQuaternion;
  70740. /**
  70741. * Define the current rotation of the camera
  70742. */
  70743. rotation: Vector3;
  70744. /**
  70745. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  70746. */
  70747. rotationQuaternion: Quaternion;
  70748. /**
  70749. * Define the current speed of the camera
  70750. */
  70751. speed: number;
  70752. /**
  70753. * Add cconstraint to the camera to prevent it to move freely in all directions and
  70754. * around all axis.
  70755. */
  70756. noRotationConstraint: boolean;
  70757. /**
  70758. * Define the current target of the camera as an object or a position.
  70759. */
  70760. lockedTarget: any;
  70761. /** @hidden */
  70762. _currentTarget: Vector3;
  70763. /** @hidden */
  70764. _initialFocalDistance: number;
  70765. /** @hidden */
  70766. _viewMatrix: Matrix;
  70767. /** @hidden */
  70768. _camMatrix: Matrix;
  70769. /** @hidden */
  70770. _cameraTransformMatrix: Matrix;
  70771. /** @hidden */
  70772. _cameraRotationMatrix: Matrix;
  70773. /** @hidden */
  70774. _referencePoint: Vector3;
  70775. /** @hidden */
  70776. _transformedReferencePoint: Vector3;
  70777. protected _globalCurrentTarget: Vector3;
  70778. protected _globalCurrentUpVector: Vector3;
  70779. /** @hidden */
  70780. _reset: () => void;
  70781. private _defaultUp;
  70782. /**
  70783. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  70784. * This is the base of the follow, arc rotate cameras and Free camera
  70785. * @see http://doc.babylonjs.com/features/cameras
  70786. * @param name Defines the name of the camera in the scene
  70787. * @param position Defines the start position of the camera in the scene
  70788. * @param scene Defines the scene the camera belongs to
  70789. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70790. */
  70791. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70792. /**
  70793. * Gets the position in front of the camera at a given distance.
  70794. * @param distance The distance from the camera we want the position to be
  70795. * @returns the position
  70796. */
  70797. getFrontPosition(distance: number): Vector3;
  70798. /** @hidden */
  70799. _getLockedTargetPosition(): Nullable<Vector3>;
  70800. private _storedPosition;
  70801. private _storedRotation;
  70802. private _storedRotationQuaternion;
  70803. /**
  70804. * Store current camera state of the camera (fov, position, rotation, etc..)
  70805. * @returns the camera
  70806. */
  70807. storeState(): Camera;
  70808. /**
  70809. * Restored camera state. You must call storeState() first
  70810. * @returns whether it was successful or not
  70811. * @hidden
  70812. */
  70813. _restoreStateValues(): boolean;
  70814. /** @hidden */
  70815. _initCache(): void;
  70816. /** @hidden */
  70817. _updateCache(ignoreParentClass?: boolean): void;
  70818. /** @hidden */
  70819. _isSynchronizedViewMatrix(): boolean;
  70820. /** @hidden */
  70821. _computeLocalCameraSpeed(): number;
  70822. /**
  70823. * Defines the target the camera should look at.
  70824. * @param target Defines the new target as a Vector or a mesh
  70825. */
  70826. setTarget(target: Vector3): void;
  70827. /**
  70828. * Return the current target position of the camera. This value is expressed in local space.
  70829. * @returns the target position
  70830. */
  70831. getTarget(): Vector3;
  70832. /** @hidden */
  70833. _decideIfNeedsToMove(): boolean;
  70834. /** @hidden */
  70835. _updatePosition(): void;
  70836. /** @hidden */
  70837. _checkInputs(): void;
  70838. protected _updateCameraRotationMatrix(): void;
  70839. /**
  70840. * 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)
  70841. * @returns the current camera
  70842. */
  70843. private _rotateUpVectorWithCameraRotationMatrix;
  70844. private _cachedRotationZ;
  70845. private _cachedQuaternionRotationZ;
  70846. /** @hidden */
  70847. _getViewMatrix(): Matrix;
  70848. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  70849. /**
  70850. * @hidden
  70851. */
  70852. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  70853. /**
  70854. * @hidden
  70855. */
  70856. _updateRigCameras(): void;
  70857. private _getRigCamPositionAndTarget;
  70858. /**
  70859. * Gets the current object class name.
  70860. * @return the class name
  70861. */
  70862. getClassName(): string;
  70863. }
  70864. }
  70865. declare module BABYLON {
  70866. /**
  70867. * @ignore
  70868. * This is a list of all the different input types that are available in the application.
  70869. * Fo instance: ArcRotateCameraGamepadInput...
  70870. */
  70871. export var CameraInputTypes: {};
  70872. /**
  70873. * This is the contract to implement in order to create a new input class.
  70874. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  70875. */
  70876. export interface ICameraInput<TCamera extends Camera> {
  70877. /**
  70878. * Defines the camera the input is attached to.
  70879. */
  70880. camera: Nullable<TCamera>;
  70881. /**
  70882. * Gets the class name of the current intput.
  70883. * @returns the class name
  70884. */
  70885. getClassName(): string;
  70886. /**
  70887. * Get the friendly name associated with the input class.
  70888. * @returns the input friendly name
  70889. */
  70890. getSimpleName(): string;
  70891. /**
  70892. * Attach the input controls to a specific dom element to get the input from.
  70893. * @param element Defines the element the controls should be listened from
  70894. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70895. */
  70896. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70897. /**
  70898. * Detach the current controls from the specified dom element.
  70899. * @param element Defines the element to stop listening the inputs from
  70900. */
  70901. detachControl(element: Nullable<HTMLElement>): void;
  70902. /**
  70903. * Update the current camera state depending on the inputs that have been used this frame.
  70904. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70905. */
  70906. checkInputs?: () => void;
  70907. }
  70908. /**
  70909. * Represents a map of input types to input instance or input index to input instance.
  70910. */
  70911. export interface CameraInputsMap<TCamera extends Camera> {
  70912. /**
  70913. * Accessor to the input by input type.
  70914. */
  70915. [name: string]: ICameraInput<TCamera>;
  70916. /**
  70917. * Accessor to the input by input index.
  70918. */
  70919. [idx: number]: ICameraInput<TCamera>;
  70920. }
  70921. /**
  70922. * This represents the input manager used within a camera.
  70923. * It helps dealing with all the different kind of input attached to a camera.
  70924. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70925. */
  70926. export class CameraInputsManager<TCamera extends Camera> {
  70927. /**
  70928. * Defines the list of inputs attahed to the camera.
  70929. */
  70930. attached: CameraInputsMap<TCamera>;
  70931. /**
  70932. * Defines the dom element the camera is collecting inputs from.
  70933. * This is null if the controls have not been attached.
  70934. */
  70935. attachedElement: Nullable<HTMLElement>;
  70936. /**
  70937. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70938. */
  70939. noPreventDefault: boolean;
  70940. /**
  70941. * Defined the camera the input manager belongs to.
  70942. */
  70943. camera: TCamera;
  70944. /**
  70945. * Update the current camera state depending on the inputs that have been used this frame.
  70946. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70947. */
  70948. checkInputs: () => void;
  70949. /**
  70950. * Instantiate a new Camera Input Manager.
  70951. * @param camera Defines the camera the input manager blongs to
  70952. */
  70953. constructor(camera: TCamera);
  70954. /**
  70955. * Add an input method to a camera
  70956. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70957. * @param input camera input method
  70958. */
  70959. add(input: ICameraInput<TCamera>): void;
  70960. /**
  70961. * Remove a specific input method from a camera
  70962. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  70963. * @param inputToRemove camera input method
  70964. */
  70965. remove(inputToRemove: ICameraInput<TCamera>): void;
  70966. /**
  70967. * Remove a specific input type from a camera
  70968. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  70969. * @param inputType the type of the input to remove
  70970. */
  70971. removeByType(inputType: string): void;
  70972. private _addCheckInputs;
  70973. /**
  70974. * Attach the input controls to the currently attached dom element to listen the events from.
  70975. * @param input Defines the input to attach
  70976. */
  70977. attachInput(input: ICameraInput<TCamera>): void;
  70978. /**
  70979. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  70980. * @param element Defines the dom element to collect the events from
  70981. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70982. */
  70983. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  70984. /**
  70985. * Detach the current manager inputs controls from a specific dom element.
  70986. * @param element Defines the dom element to collect the events from
  70987. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  70988. */
  70989. detachElement(element: HTMLElement, disconnect?: boolean): void;
  70990. /**
  70991. * Rebuild the dynamic inputCheck function from the current list of
  70992. * defined inputs in the manager.
  70993. */
  70994. rebuildInputCheck(): void;
  70995. /**
  70996. * Remove all attached input methods from a camera
  70997. */
  70998. clear(): void;
  70999. /**
  71000. * Serialize the current input manager attached to a camera.
  71001. * This ensures than once parsed,
  71002. * the input associated to the camera will be identical to the current ones
  71003. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  71004. */
  71005. serialize(serializedCamera: any): void;
  71006. /**
  71007. * Parses an input manager serialized JSON to restore the previous list of inputs
  71008. * and states associated to a camera.
  71009. * @param parsedCamera Defines the JSON to parse
  71010. */
  71011. parse(parsedCamera: any): void;
  71012. }
  71013. }
  71014. declare module BABYLON {
  71015. /**
  71016. * Gather the list of keyboard event types as constants.
  71017. */
  71018. export class KeyboardEventTypes {
  71019. /**
  71020. * The keydown event is fired when a key becomes active (pressed).
  71021. */
  71022. static readonly KEYDOWN: number;
  71023. /**
  71024. * The keyup event is fired when a key has been released.
  71025. */
  71026. static readonly KEYUP: number;
  71027. }
  71028. /**
  71029. * This class is used to store keyboard related info for the onKeyboardObservable event.
  71030. */
  71031. export class KeyboardInfo {
  71032. /**
  71033. * Defines the type of event (KeyboardEventTypes)
  71034. */
  71035. type: number;
  71036. /**
  71037. * Defines the related dom event
  71038. */
  71039. event: KeyboardEvent;
  71040. /**
  71041. * Instantiates a new keyboard info.
  71042. * This class is used to store keyboard related info for the onKeyboardObservable event.
  71043. * @param type Defines the type of event (KeyboardEventTypes)
  71044. * @param event Defines the related dom event
  71045. */
  71046. constructor(
  71047. /**
  71048. * Defines the type of event (KeyboardEventTypes)
  71049. */
  71050. type: number,
  71051. /**
  71052. * Defines the related dom event
  71053. */
  71054. event: KeyboardEvent);
  71055. }
  71056. /**
  71057. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  71058. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  71059. */
  71060. export class KeyboardInfoPre extends KeyboardInfo {
  71061. /**
  71062. * Defines the type of event (KeyboardEventTypes)
  71063. */
  71064. type: number;
  71065. /**
  71066. * Defines the related dom event
  71067. */
  71068. event: KeyboardEvent;
  71069. /**
  71070. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  71071. */
  71072. skipOnPointerObservable: boolean;
  71073. /**
  71074. * Instantiates a new keyboard pre info.
  71075. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  71076. * @param type Defines the type of event (KeyboardEventTypes)
  71077. * @param event Defines the related dom event
  71078. */
  71079. constructor(
  71080. /**
  71081. * Defines the type of event (KeyboardEventTypes)
  71082. */
  71083. type: number,
  71084. /**
  71085. * Defines the related dom event
  71086. */
  71087. event: KeyboardEvent);
  71088. }
  71089. }
  71090. declare module BABYLON {
  71091. /**
  71092. * Manage the keyboard inputs to control the movement of a free camera.
  71093. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71094. */
  71095. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  71096. /**
  71097. * Defines the camera the input is attached to.
  71098. */
  71099. camera: FreeCamera;
  71100. /**
  71101. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  71102. */
  71103. keysUp: number[];
  71104. /**
  71105. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  71106. */
  71107. keysDown: number[];
  71108. /**
  71109. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  71110. */
  71111. keysLeft: number[];
  71112. /**
  71113. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  71114. */
  71115. keysRight: number[];
  71116. private _keys;
  71117. private _onCanvasBlurObserver;
  71118. private _onKeyboardObserver;
  71119. private _engine;
  71120. private _scene;
  71121. /**
  71122. * Attach the input controls to a specific dom element to get the input from.
  71123. * @param element Defines the element the controls should be listened from
  71124. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71125. */
  71126. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71127. /**
  71128. * Detach the current controls from the specified dom element.
  71129. * @param element Defines the element to stop listening the inputs from
  71130. */
  71131. detachControl(element: Nullable<HTMLElement>): void;
  71132. /**
  71133. * Update the current camera state depending on the inputs that have been used this frame.
  71134. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71135. */
  71136. checkInputs(): void;
  71137. /**
  71138. * Gets the class name of the current intput.
  71139. * @returns the class name
  71140. */
  71141. getClassName(): string;
  71142. /** @hidden */
  71143. _onLostFocus(): void;
  71144. /**
  71145. * Get the friendly name associated with the input class.
  71146. * @returns the input friendly name
  71147. */
  71148. getSimpleName(): string;
  71149. }
  71150. }
  71151. declare module BABYLON {
  71152. /**
  71153. * A multi-material is used to apply different materials to different parts of the same object without the need of
  71154. * separate meshes. This can be use to improve performances.
  71155. * @see http://doc.babylonjs.com/how_to/multi_materials
  71156. */
  71157. export class MultiMaterial extends Material {
  71158. private _subMaterials;
  71159. /**
  71160. * Gets or Sets the list of Materials used within the multi material.
  71161. * They need to be ordered according to the submeshes order in the associated mesh
  71162. */
  71163. subMaterials: Nullable<Material>[];
  71164. /**
  71165. * Function used to align with Node.getChildren()
  71166. * @returns the list of Materials used within the multi material
  71167. */
  71168. getChildren(): Nullable<Material>[];
  71169. /**
  71170. * Instantiates a new Multi Material
  71171. * A multi-material is used to apply different materials to different parts of the same object without the need of
  71172. * separate meshes. This can be use to improve performances.
  71173. * @see http://doc.babylonjs.com/how_to/multi_materials
  71174. * @param name Define the name in the scene
  71175. * @param scene Define the scene the material belongs to
  71176. */
  71177. constructor(name: string, scene: Scene);
  71178. private _hookArray;
  71179. /**
  71180. * Get one of the submaterial by its index in the submaterials array
  71181. * @param index The index to look the sub material at
  71182. * @returns The Material if the index has been defined
  71183. */
  71184. getSubMaterial(index: number): Nullable<Material>;
  71185. /**
  71186. * Get the list of active textures for the whole sub materials list.
  71187. * @returns All the textures that will be used during the rendering
  71188. */
  71189. getActiveTextures(): BaseTexture[];
  71190. /**
  71191. * Gets the current class name of the material e.g. "MultiMaterial"
  71192. * Mainly use in serialization.
  71193. * @returns the class name
  71194. */
  71195. getClassName(): string;
  71196. /**
  71197. * Checks if the material is ready to render the requested sub mesh
  71198. * @param mesh Define the mesh the submesh belongs to
  71199. * @param subMesh Define the sub mesh to look readyness for
  71200. * @param useInstances Define whether or not the material is used with instances
  71201. * @returns true if ready, otherwise false
  71202. */
  71203. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  71204. /**
  71205. * Clones the current material and its related sub materials
  71206. * @param name Define the name of the newly cloned material
  71207. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  71208. * @returns the cloned material
  71209. */
  71210. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  71211. /**
  71212. * Serializes the materials into a JSON representation.
  71213. * @returns the JSON representation
  71214. */
  71215. serialize(): any;
  71216. /**
  71217. * Dispose the material and release its associated resources
  71218. * @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)
  71219. * @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)
  71220. * @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)
  71221. */
  71222. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  71223. /**
  71224. * Creates a MultiMaterial from parsed MultiMaterial data.
  71225. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  71226. * @param scene defines the hosting scene
  71227. * @returns a new MultiMaterial
  71228. */
  71229. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  71230. }
  71231. }
  71232. declare module BABYLON {
  71233. /**
  71234. * Class used to represent data loading progression
  71235. */
  71236. export class SceneLoaderFlags {
  71237. private static _ForceFullSceneLoadingForIncremental;
  71238. private static _ShowLoadingScreen;
  71239. private static _CleanBoneMatrixWeights;
  71240. private static _loggingLevel;
  71241. /**
  71242. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  71243. */
  71244. static ForceFullSceneLoadingForIncremental: boolean;
  71245. /**
  71246. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  71247. */
  71248. static ShowLoadingScreen: boolean;
  71249. /**
  71250. * Defines the current logging level (while loading the scene)
  71251. * @ignorenaming
  71252. */
  71253. static loggingLevel: number;
  71254. /**
  71255. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  71256. */
  71257. static CleanBoneMatrixWeights: boolean;
  71258. }
  71259. }
  71260. declare module BABYLON {
  71261. /**
  71262. * 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.
  71263. * @see https://doc.babylonjs.com/how_to/transformnode
  71264. */
  71265. export class TransformNode extends Node {
  71266. /**
  71267. * Object will not rotate to face the camera
  71268. */
  71269. static BILLBOARDMODE_NONE: number;
  71270. /**
  71271. * Object will rotate to face the camera but only on the x axis
  71272. */
  71273. static BILLBOARDMODE_X: number;
  71274. /**
  71275. * Object will rotate to face the camera but only on the y axis
  71276. */
  71277. static BILLBOARDMODE_Y: number;
  71278. /**
  71279. * Object will rotate to face the camera but only on the z axis
  71280. */
  71281. static BILLBOARDMODE_Z: number;
  71282. /**
  71283. * Object will rotate to face the camera
  71284. */
  71285. static BILLBOARDMODE_ALL: number;
  71286. private _forward;
  71287. private _forwardInverted;
  71288. private _up;
  71289. private _right;
  71290. private _rightInverted;
  71291. private _position;
  71292. private _rotation;
  71293. private _rotationQuaternion;
  71294. protected _scaling: Vector3;
  71295. protected _isDirty: boolean;
  71296. private _transformToBoneReferal;
  71297. private _billboardMode;
  71298. /**
  71299. * Gets or sets the billboard mode. Default is 0.
  71300. *
  71301. * | Value | Type | Description |
  71302. * | --- | --- | --- |
  71303. * | 0 | BILLBOARDMODE_NONE | |
  71304. * | 1 | BILLBOARDMODE_X | |
  71305. * | 2 | BILLBOARDMODE_Y | |
  71306. * | 4 | BILLBOARDMODE_Z | |
  71307. * | 7 | BILLBOARDMODE_ALL | |
  71308. *
  71309. */
  71310. billboardMode: number;
  71311. private _preserveParentRotationForBillboard;
  71312. /**
  71313. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  71314. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  71315. */
  71316. preserveParentRotationForBillboard: boolean;
  71317. /**
  71318. * 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
  71319. */
  71320. scalingDeterminant: number;
  71321. private _infiniteDistance;
  71322. /**
  71323. * Gets or sets the distance of the object to max, often used by skybox
  71324. */
  71325. infiniteDistance: boolean;
  71326. /**
  71327. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  71328. * By default the system will update normals to compensate
  71329. */
  71330. ignoreNonUniformScaling: boolean;
  71331. /**
  71332. * 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
  71333. */
  71334. reIntegrateRotationIntoRotationQuaternion: boolean;
  71335. /** @hidden */
  71336. _poseMatrix: Nullable<Matrix>;
  71337. /** @hidden */
  71338. _localMatrix: Matrix;
  71339. private _usePivotMatrix;
  71340. private _absolutePosition;
  71341. private _pivotMatrix;
  71342. private _pivotMatrixInverse;
  71343. protected _postMultiplyPivotMatrix: boolean;
  71344. protected _isWorldMatrixFrozen: boolean;
  71345. /** @hidden */
  71346. _indexInSceneTransformNodesArray: number;
  71347. /**
  71348. * An event triggered after the world matrix is updated
  71349. */
  71350. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  71351. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  71352. /**
  71353. * Gets a string identifying the name of the class
  71354. * @returns "TransformNode" string
  71355. */
  71356. getClassName(): string;
  71357. /**
  71358. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  71359. */
  71360. position: Vector3;
  71361. /**
  71362. * 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)).
  71363. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  71364. */
  71365. rotation: Vector3;
  71366. /**
  71367. * 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)).
  71368. */
  71369. scaling: Vector3;
  71370. /**
  71371. * 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).
  71372. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  71373. */
  71374. rotationQuaternion: Nullable<Quaternion>;
  71375. /**
  71376. * The forward direction of that transform in world space.
  71377. */
  71378. readonly forward: Vector3;
  71379. /**
  71380. * The up direction of that transform in world space.
  71381. */
  71382. readonly up: Vector3;
  71383. /**
  71384. * The right direction of that transform in world space.
  71385. */
  71386. readonly right: Vector3;
  71387. /**
  71388. * Copies the parameter passed Matrix into the mesh Pose matrix.
  71389. * @param matrix the matrix to copy the pose from
  71390. * @returns this TransformNode.
  71391. */
  71392. updatePoseMatrix(matrix: Matrix): TransformNode;
  71393. /**
  71394. * Returns the mesh Pose matrix.
  71395. * @returns the pose matrix
  71396. */
  71397. getPoseMatrix(): Matrix;
  71398. /** @hidden */
  71399. _isSynchronized(): boolean;
  71400. /** @hidden */
  71401. _initCache(): void;
  71402. /**
  71403. * Flag the transform node as dirty (Forcing it to update everything)
  71404. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  71405. * @returns this transform node
  71406. */
  71407. markAsDirty(property: string): TransformNode;
  71408. /**
  71409. * Returns the current mesh absolute position.
  71410. * Returns a Vector3.
  71411. */
  71412. readonly absolutePosition: Vector3;
  71413. /**
  71414. * Sets a new matrix to apply before all other transformation
  71415. * @param matrix defines the transform matrix
  71416. * @returns the current TransformNode
  71417. */
  71418. setPreTransformMatrix(matrix: Matrix): TransformNode;
  71419. /**
  71420. * Sets a new pivot matrix to the current node
  71421. * @param matrix defines the new pivot matrix to use
  71422. * @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
  71423. * @returns the current TransformNode
  71424. */
  71425. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  71426. /**
  71427. * Returns the mesh pivot matrix.
  71428. * Default : Identity.
  71429. * @returns the matrix
  71430. */
  71431. getPivotMatrix(): Matrix;
  71432. /**
  71433. * Prevents the World matrix to be computed any longer.
  71434. * @returns the TransformNode.
  71435. */
  71436. freezeWorldMatrix(): TransformNode;
  71437. /**
  71438. * Allows back the World matrix computation.
  71439. * @returns the TransformNode.
  71440. */
  71441. unfreezeWorldMatrix(): this;
  71442. /**
  71443. * True if the World matrix has been frozen.
  71444. */
  71445. readonly isWorldMatrixFrozen: boolean;
  71446. /**
  71447. * Retuns the mesh absolute position in the World.
  71448. * @returns a Vector3.
  71449. */
  71450. getAbsolutePosition(): Vector3;
  71451. /**
  71452. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  71453. * @param absolutePosition the absolute position to set
  71454. * @returns the TransformNode.
  71455. */
  71456. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  71457. /**
  71458. * Sets the mesh position in its local space.
  71459. * @param vector3 the position to set in localspace
  71460. * @returns the TransformNode.
  71461. */
  71462. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  71463. /**
  71464. * Returns the mesh position in the local space from the current World matrix values.
  71465. * @returns a new Vector3.
  71466. */
  71467. getPositionExpressedInLocalSpace(): Vector3;
  71468. /**
  71469. * Translates the mesh along the passed Vector3 in its local space.
  71470. * @param vector3 the distance to translate in localspace
  71471. * @returns the TransformNode.
  71472. */
  71473. locallyTranslate(vector3: Vector3): TransformNode;
  71474. private static _lookAtVectorCache;
  71475. /**
  71476. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  71477. * @param targetPoint the position (must be in same space as current mesh) to look at
  71478. * @param yawCor optional yaw (y-axis) correction in radians
  71479. * @param pitchCor optional pitch (x-axis) correction in radians
  71480. * @param rollCor optional roll (z-axis) correction in radians
  71481. * @param space the choosen space of the target
  71482. * @returns the TransformNode.
  71483. */
  71484. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  71485. /**
  71486. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71487. * This Vector3 is expressed in the World space.
  71488. * @param localAxis axis to rotate
  71489. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71490. */
  71491. getDirection(localAxis: Vector3): Vector3;
  71492. /**
  71493. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  71494. * localAxis is expressed in the mesh local space.
  71495. * result is computed in the Wordl space from the mesh World matrix.
  71496. * @param localAxis axis to rotate
  71497. * @param result the resulting transformnode
  71498. * @returns this TransformNode.
  71499. */
  71500. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  71501. /**
  71502. * Sets this transform node rotation to the given local axis.
  71503. * @param localAxis the axis in local space
  71504. * @param yawCor optional yaw (y-axis) correction in radians
  71505. * @param pitchCor optional pitch (x-axis) correction in radians
  71506. * @param rollCor optional roll (z-axis) correction in radians
  71507. * @returns this TransformNode
  71508. */
  71509. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  71510. /**
  71511. * Sets a new pivot point to the current node
  71512. * @param point defines the new pivot point to use
  71513. * @param space defines if the point is in world or local space (local by default)
  71514. * @returns the current TransformNode
  71515. */
  71516. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  71517. /**
  71518. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  71519. * @returns the pivot point
  71520. */
  71521. getPivotPoint(): Vector3;
  71522. /**
  71523. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  71524. * @param result the vector3 to store the result
  71525. * @returns this TransformNode.
  71526. */
  71527. getPivotPointToRef(result: Vector3): TransformNode;
  71528. /**
  71529. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  71530. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  71531. */
  71532. getAbsolutePivotPoint(): Vector3;
  71533. /**
  71534. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  71535. * @param result vector3 to store the result
  71536. * @returns this TransformNode.
  71537. */
  71538. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  71539. /**
  71540. * Defines the passed node as the parent of the current node.
  71541. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  71542. * @see https://doc.babylonjs.com/how_to/parenting
  71543. * @param node the node ot set as the parent
  71544. * @returns this TransformNode.
  71545. */
  71546. setParent(node: Nullable<Node>): TransformNode;
  71547. private _nonUniformScaling;
  71548. /**
  71549. * True if the scaling property of this object is non uniform eg. (1,2,1)
  71550. */
  71551. readonly nonUniformScaling: boolean;
  71552. /** @hidden */
  71553. _updateNonUniformScalingState(value: boolean): boolean;
  71554. /**
  71555. * Attach the current TransformNode to another TransformNode associated with a bone
  71556. * @param bone Bone affecting the TransformNode
  71557. * @param affectedTransformNode TransformNode associated with the bone
  71558. * @returns this object
  71559. */
  71560. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  71561. /**
  71562. * Detach the transform node if its associated with a bone
  71563. * @returns this object
  71564. */
  71565. detachFromBone(): TransformNode;
  71566. private static _rotationAxisCache;
  71567. /**
  71568. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  71569. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71570. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71571. * The passed axis is also normalized.
  71572. * @param axis the axis to rotate around
  71573. * @param amount the amount to rotate in radians
  71574. * @param space Space to rotate in (Default: local)
  71575. * @returns the TransformNode.
  71576. */
  71577. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  71578. /**
  71579. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  71580. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71581. * The passed axis is also normalized. .
  71582. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  71583. * @param point the point to rotate around
  71584. * @param axis the axis to rotate around
  71585. * @param amount the amount to rotate in radians
  71586. * @returns the TransformNode
  71587. */
  71588. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  71589. /**
  71590. * Translates the mesh along the axis vector for the passed distance in the given space.
  71591. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71592. * @param axis the axis to translate in
  71593. * @param distance the distance to translate
  71594. * @param space Space to rotate in (Default: local)
  71595. * @returns the TransformNode.
  71596. */
  71597. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  71598. /**
  71599. * Adds a rotation step to the mesh current rotation.
  71600. * x, y, z are Euler angles expressed in radians.
  71601. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  71602. * This means this rotation is made in the mesh local space only.
  71603. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  71604. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  71605. * ```javascript
  71606. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  71607. * ```
  71608. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  71609. * 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.
  71610. * @param x Rotation to add
  71611. * @param y Rotation to add
  71612. * @param z Rotation to add
  71613. * @returns the TransformNode.
  71614. */
  71615. addRotation(x: number, y: number, z: number): TransformNode;
  71616. /**
  71617. * @hidden
  71618. */
  71619. protected _getEffectiveParent(): Nullable<Node>;
  71620. /**
  71621. * Computes the world matrix of the node
  71622. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71623. * @returns the world matrix
  71624. */
  71625. computeWorldMatrix(force?: boolean): Matrix;
  71626. protected _afterComputeWorldMatrix(): void;
  71627. /**
  71628. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  71629. * @param func callback function to add
  71630. *
  71631. * @returns the TransformNode.
  71632. */
  71633. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71634. /**
  71635. * Removes a registered callback function.
  71636. * @param func callback function to remove
  71637. * @returns the TransformNode.
  71638. */
  71639. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71640. /**
  71641. * Gets the position of the current mesh in camera space
  71642. * @param camera defines the camera to use
  71643. * @returns a position
  71644. */
  71645. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  71646. /**
  71647. * Returns the distance from the mesh to the active camera
  71648. * @param camera defines the camera to use
  71649. * @returns the distance
  71650. */
  71651. getDistanceToCamera(camera?: Nullable<Camera>): number;
  71652. /**
  71653. * Clone the current transform node
  71654. * @param name Name of the new clone
  71655. * @param newParent New parent for the clone
  71656. * @param doNotCloneChildren Do not clone children hierarchy
  71657. * @returns the new transform node
  71658. */
  71659. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  71660. /**
  71661. * Serializes the objects information.
  71662. * @param currentSerializationObject defines the object to serialize in
  71663. * @returns the serialized object
  71664. */
  71665. serialize(currentSerializationObject?: any): any;
  71666. /**
  71667. * Returns a new TransformNode object parsed from the source provided.
  71668. * @param parsedTransformNode is the source.
  71669. * @param scene the scne the object belongs to
  71670. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  71671. * @returns a new TransformNode object parsed from the source provided.
  71672. */
  71673. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  71674. /**
  71675. * Get all child-transformNodes of this node
  71676. * @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
  71677. * @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
  71678. * @returns an array of TransformNode
  71679. */
  71680. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  71681. /**
  71682. * Releases resources associated with this transform node.
  71683. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  71684. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  71685. */
  71686. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  71687. /**
  71688. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  71689. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  71690. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  71691. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  71692. * @returns the current mesh
  71693. */
  71694. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  71695. }
  71696. }
  71697. declare module BABYLON {
  71698. /**
  71699. * Class used to override all child animations of a given target
  71700. */
  71701. export class AnimationPropertiesOverride {
  71702. /**
  71703. * Gets or sets a value indicating if animation blending must be used
  71704. */
  71705. enableBlending: boolean;
  71706. /**
  71707. * Gets or sets the blending speed to use when enableBlending is true
  71708. */
  71709. blendingSpeed: number;
  71710. /**
  71711. * Gets or sets the default loop mode to use
  71712. */
  71713. loopMode: number;
  71714. }
  71715. }
  71716. declare module BABYLON {
  71717. /**
  71718. * Class used to store bone information
  71719. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  71720. */
  71721. export class Bone extends Node {
  71722. /**
  71723. * defines the bone name
  71724. */
  71725. name: string;
  71726. private static _tmpVecs;
  71727. private static _tmpQuat;
  71728. private static _tmpMats;
  71729. /**
  71730. * Gets the list of child bones
  71731. */
  71732. children: Bone[];
  71733. /** Gets the animations associated with this bone */
  71734. animations: Animation[];
  71735. /**
  71736. * Gets or sets bone length
  71737. */
  71738. length: number;
  71739. /**
  71740. * @hidden Internal only
  71741. * Set this value to map this bone to a different index in the transform matrices
  71742. * Set this value to -1 to exclude the bone from the transform matrices
  71743. */
  71744. _index: Nullable<number>;
  71745. private _skeleton;
  71746. private _localMatrix;
  71747. private _restPose;
  71748. private _baseMatrix;
  71749. private _absoluteTransform;
  71750. private _invertedAbsoluteTransform;
  71751. private _parent;
  71752. private _scalingDeterminant;
  71753. private _worldTransform;
  71754. private _localScaling;
  71755. private _localRotation;
  71756. private _localPosition;
  71757. private _needToDecompose;
  71758. private _needToCompose;
  71759. /** @hidden */
  71760. _linkedTransformNode: Nullable<TransformNode>;
  71761. /** @hidden */
  71762. _waitingTransformNodeId: Nullable<string>;
  71763. /** @hidden */
  71764. /** @hidden */
  71765. _matrix: Matrix;
  71766. /**
  71767. * Create a new bone
  71768. * @param name defines the bone name
  71769. * @param skeleton defines the parent skeleton
  71770. * @param parentBone defines the parent (can be null if the bone is the root)
  71771. * @param localMatrix defines the local matrix
  71772. * @param restPose defines the rest pose matrix
  71773. * @param baseMatrix defines the base matrix
  71774. * @param index defines index of the bone in the hiearchy
  71775. */
  71776. constructor(
  71777. /**
  71778. * defines the bone name
  71779. */
  71780. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  71781. /**
  71782. * Gets the current object class name.
  71783. * @return the class name
  71784. */
  71785. getClassName(): string;
  71786. /**
  71787. * Gets the parent skeleton
  71788. * @returns a skeleton
  71789. */
  71790. getSkeleton(): Skeleton;
  71791. /**
  71792. * Gets parent bone
  71793. * @returns a bone or null if the bone is the root of the bone hierarchy
  71794. */
  71795. getParent(): Nullable<Bone>;
  71796. /**
  71797. * Returns an array containing the root bones
  71798. * @returns an array containing the root bones
  71799. */
  71800. getChildren(): Array<Bone>;
  71801. /**
  71802. * Sets the parent bone
  71803. * @param parent defines the parent (can be null if the bone is the root)
  71804. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71805. */
  71806. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  71807. /**
  71808. * Gets the local matrix
  71809. * @returns a matrix
  71810. */
  71811. getLocalMatrix(): Matrix;
  71812. /**
  71813. * Gets the base matrix (initial matrix which remains unchanged)
  71814. * @returns a matrix
  71815. */
  71816. getBaseMatrix(): Matrix;
  71817. /**
  71818. * Gets the rest pose matrix
  71819. * @returns a matrix
  71820. */
  71821. getRestPose(): Matrix;
  71822. /**
  71823. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  71824. */
  71825. getWorldMatrix(): Matrix;
  71826. /**
  71827. * Sets the local matrix to rest pose matrix
  71828. */
  71829. returnToRest(): void;
  71830. /**
  71831. * Gets the inverse of the absolute transform matrix.
  71832. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  71833. * @returns a matrix
  71834. */
  71835. getInvertedAbsoluteTransform(): Matrix;
  71836. /**
  71837. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  71838. * @returns a matrix
  71839. */
  71840. getAbsoluteTransform(): Matrix;
  71841. /**
  71842. * Links with the given transform node.
  71843. * The local matrix of this bone is copied from the transform node every frame.
  71844. * @param transformNode defines the transform node to link to
  71845. */
  71846. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  71847. /** Gets or sets current position (in local space) */
  71848. position: Vector3;
  71849. /** Gets or sets current rotation (in local space) */
  71850. rotation: Vector3;
  71851. /** Gets or sets current rotation quaternion (in local space) */
  71852. rotationQuaternion: Quaternion;
  71853. /** Gets or sets current scaling (in local space) */
  71854. scaling: Vector3;
  71855. /**
  71856. * Gets the animation properties override
  71857. */
  71858. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  71859. private _decompose;
  71860. private _compose;
  71861. /**
  71862. * Update the base and local matrices
  71863. * @param matrix defines the new base or local matrix
  71864. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71865. * @param updateLocalMatrix defines if the local matrix should be updated
  71866. */
  71867. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  71868. /** @hidden */
  71869. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  71870. /**
  71871. * Flag the bone as dirty (Forcing it to update everything)
  71872. */
  71873. markAsDirty(): void;
  71874. /** @hidden */
  71875. _markAsDirtyAndCompose(): void;
  71876. private _markAsDirtyAndDecompose;
  71877. /**
  71878. * Translate the bone in local or world space
  71879. * @param vec The amount to translate the bone
  71880. * @param space The space that the translation is in
  71881. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71882. */
  71883. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71884. /**
  71885. * Set the postion of the bone in local or world space
  71886. * @param position The position to set the bone
  71887. * @param space The space that the position is in
  71888. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71889. */
  71890. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71891. /**
  71892. * Set the absolute position of the bone (world space)
  71893. * @param position The position to set the bone
  71894. * @param mesh The mesh that this bone is attached to
  71895. */
  71896. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  71897. /**
  71898. * Scale the bone on the x, y and z axes (in local space)
  71899. * @param x The amount to scale the bone on the x axis
  71900. * @param y The amount to scale the bone on the y axis
  71901. * @param z The amount to scale the bone on the z axis
  71902. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  71903. */
  71904. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  71905. /**
  71906. * Set the bone scaling in local space
  71907. * @param scale defines the scaling vector
  71908. */
  71909. setScale(scale: Vector3): void;
  71910. /**
  71911. * Gets the current scaling in local space
  71912. * @returns the current scaling vector
  71913. */
  71914. getScale(): Vector3;
  71915. /**
  71916. * Gets the current scaling in local space and stores it in a target vector
  71917. * @param result defines the target vector
  71918. */
  71919. getScaleToRef(result: Vector3): void;
  71920. /**
  71921. * Set the yaw, pitch, and roll of the bone in local or world space
  71922. * @param yaw The rotation of the bone on the y axis
  71923. * @param pitch The rotation of the bone on the x axis
  71924. * @param roll The rotation of the bone on the z axis
  71925. * @param space The space that the axes of rotation are in
  71926. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71927. */
  71928. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  71929. /**
  71930. * Add a rotation to the bone on an axis in local or world space
  71931. * @param axis The axis to rotate the bone on
  71932. * @param amount The amount to rotate the bone
  71933. * @param space The space that the axis is in
  71934. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71935. */
  71936. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  71937. /**
  71938. * Set the rotation of the bone to a particular axis angle in local or world space
  71939. * @param axis The axis to rotate the bone on
  71940. * @param angle The angle that the bone should be rotated to
  71941. * @param space The space that the axis is in
  71942. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71943. */
  71944. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  71945. /**
  71946. * Set the euler rotation of the bone in local of world space
  71947. * @param rotation The euler rotation that the bone should be set to
  71948. * @param space The space that the rotation is in
  71949. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71950. */
  71951. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71952. /**
  71953. * Set the quaternion rotation of the bone in local of world space
  71954. * @param quat The quaternion rotation that the bone should be set to
  71955. * @param space The space that the rotation is in
  71956. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71957. */
  71958. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  71959. /**
  71960. * Set the rotation matrix of the bone in local of world space
  71961. * @param rotMat The rotation matrix that the bone should be set to
  71962. * @param space The space that the rotation is in
  71963. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71964. */
  71965. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  71966. private _rotateWithMatrix;
  71967. private _getNegativeRotationToRef;
  71968. /**
  71969. * Get the position of the bone in local or world space
  71970. * @param space The space that the returned position is in
  71971. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71972. * @returns The position of the bone
  71973. */
  71974. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  71975. /**
  71976. * Copy the position of the bone to a vector3 in local or world space
  71977. * @param space The space that the returned position is in
  71978. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71979. * @param result The vector3 to copy the position to
  71980. */
  71981. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  71982. /**
  71983. * Get the absolute position of the bone (world space)
  71984. * @param mesh The mesh that this bone is attached to
  71985. * @returns The absolute position of the bone
  71986. */
  71987. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  71988. /**
  71989. * Copy the absolute position of the bone (world space) to the result param
  71990. * @param mesh The mesh that this bone is attached to
  71991. * @param result The vector3 to copy the absolute position to
  71992. */
  71993. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  71994. /**
  71995. * Compute the absolute transforms of this bone and its children
  71996. */
  71997. computeAbsoluteTransforms(): void;
  71998. /**
  71999. * Get the world direction from an axis that is in the local space of the bone
  72000. * @param localAxis The local direction that is used to compute the world direction
  72001. * @param mesh The mesh that this bone is attached to
  72002. * @returns The world direction
  72003. */
  72004. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  72005. /**
  72006. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  72007. * @param localAxis The local direction that is used to compute the world direction
  72008. * @param mesh The mesh that this bone is attached to
  72009. * @param result The vector3 that the world direction will be copied to
  72010. */
  72011. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72012. /**
  72013. * Get the euler rotation of the bone in local or world space
  72014. * @param space The space that the rotation should be in
  72015. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72016. * @returns The euler rotation
  72017. */
  72018. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  72019. /**
  72020. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  72021. * @param space The space that the rotation should be in
  72022. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72023. * @param result The vector3 that the rotation should be copied to
  72024. */
  72025. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72026. /**
  72027. * Get the quaternion rotation of the bone in either local or world space
  72028. * @param space The space that the rotation should be in
  72029. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72030. * @returns The quaternion rotation
  72031. */
  72032. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  72033. /**
  72034. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  72035. * @param space The space that the rotation should be in
  72036. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72037. * @param result The quaternion that the rotation should be copied to
  72038. */
  72039. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  72040. /**
  72041. * Get the rotation matrix of the bone in local or world space
  72042. * @param space The space that the rotation should be in
  72043. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72044. * @returns The rotation matrix
  72045. */
  72046. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  72047. /**
  72048. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  72049. * @param space The space that the rotation should be in
  72050. * @param mesh The mesh that this bone is attached to. This is only used in world space
  72051. * @param result The quaternion that the rotation should be copied to
  72052. */
  72053. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  72054. /**
  72055. * Get the world position of a point that is in the local space of the bone
  72056. * @param position The local position
  72057. * @param mesh The mesh that this bone is attached to
  72058. * @returns The world position
  72059. */
  72060. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  72061. /**
  72062. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  72063. * @param position The local position
  72064. * @param mesh The mesh that this bone is attached to
  72065. * @param result The vector3 that the world position should be copied to
  72066. */
  72067. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72068. /**
  72069. * Get the local position of a point that is in world space
  72070. * @param position The world position
  72071. * @param mesh The mesh that this bone is attached to
  72072. * @returns The local position
  72073. */
  72074. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  72075. /**
  72076. * Get the local position of a point that is in world space and copy it to the result param
  72077. * @param position The world position
  72078. * @param mesh The mesh that this bone is attached to
  72079. * @param result The vector3 that the local position should be copied to
  72080. */
  72081. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  72082. }
  72083. }
  72084. declare module BABYLON {
  72085. interface Engine {
  72086. /**
  72087. * Creates a raw texture
  72088. * @param data defines the data to store in the texture
  72089. * @param width defines the width of the texture
  72090. * @param height defines the height of the texture
  72091. * @param format defines the format of the data
  72092. * @param generateMipMaps defines if the engine should generate the mip levels
  72093. * @param invertY defines if data must be stored with Y axis inverted
  72094. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  72095. * @param compression defines the compression used (null by default)
  72096. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72097. * @returns the raw texture inside an InternalTexture
  72098. */
  72099. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  72100. /**
  72101. * Update a raw texture
  72102. * @param texture defines the texture to update
  72103. * @param data defines the data to store in the texture
  72104. * @param format defines the format of the data
  72105. * @param invertY defines if data must be stored with Y axis inverted
  72106. */
  72107. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  72108. /**
  72109. * Update a raw texture
  72110. * @param texture defines the texture to update
  72111. * @param data defines the data to store in the texture
  72112. * @param format defines the format of the data
  72113. * @param invertY defines if data must be stored with Y axis inverted
  72114. * @param compression defines the compression used (null by default)
  72115. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72116. */
  72117. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  72118. /**
  72119. * Creates a new raw cube texture
  72120. * @param data defines the array of data to use to create each face
  72121. * @param size defines the size of the textures
  72122. * @param format defines the format of the data
  72123. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  72124. * @param generateMipMaps defines if the engine should generate the mip levels
  72125. * @param invertY defines if data must be stored with Y axis inverted
  72126. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  72127. * @param compression defines the compression used (null by default)
  72128. * @returns the cube texture as an InternalTexture
  72129. */
  72130. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  72131. /**
  72132. * Update a raw cube texture
  72133. * @param texture defines the texture to udpdate
  72134. * @param data defines the data to store
  72135. * @param format defines the data format
  72136. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72137. * @param invertY defines if data must be stored with Y axis inverted
  72138. */
  72139. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  72140. /**
  72141. * Update a raw cube texture
  72142. * @param texture defines the texture to udpdate
  72143. * @param data defines the data to store
  72144. * @param format defines the data format
  72145. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72146. * @param invertY defines if data must be stored with Y axis inverted
  72147. * @param compression defines the compression used (null by default)
  72148. */
  72149. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  72150. /**
  72151. * Update a raw cube texture
  72152. * @param texture defines the texture to udpdate
  72153. * @param data defines the data to store
  72154. * @param format defines the data format
  72155. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72156. * @param invertY defines if data must be stored with Y axis inverted
  72157. * @param compression defines the compression used (null by default)
  72158. * @param level defines which level of the texture to update
  72159. */
  72160. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  72161. /**
  72162. * Creates a new raw cube texture from a specified url
  72163. * @param url defines the url where the data is located
  72164. * @param scene defines the current scene
  72165. * @param size defines the size of the textures
  72166. * @param format defines the format of the data
  72167. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  72168. * @param noMipmap defines if the engine should avoid generating the mip levels
  72169. * @param callback defines a callback used to extract texture data from loaded data
  72170. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  72171. * @param onLoad defines a callback called when texture is loaded
  72172. * @param onError defines a callback called if there is an error
  72173. * @returns the cube texture as an InternalTexture
  72174. */
  72175. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  72176. /**
  72177. * Creates a new raw cube texture from a specified url
  72178. * @param url defines the url where the data is located
  72179. * @param scene defines the current scene
  72180. * @param size defines the size of the textures
  72181. * @param format defines the format of the data
  72182. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  72183. * @param noMipmap defines if the engine should avoid generating the mip levels
  72184. * @param callback defines a callback used to extract texture data from loaded data
  72185. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  72186. * @param onLoad defines a callback called when texture is loaded
  72187. * @param onError defines a callback called if there is an error
  72188. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  72189. * @param invertY defines if data must be stored with Y axis inverted
  72190. * @returns the cube texture as an InternalTexture
  72191. */
  72192. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  72193. /**
  72194. * Creates a new raw 3D texture
  72195. * @param data defines the data used to create the texture
  72196. * @param width defines the width of the texture
  72197. * @param height defines the height of the texture
  72198. * @param depth defines the depth of the texture
  72199. * @param format defines the format of the texture
  72200. * @param generateMipMaps defines if the engine must generate mip levels
  72201. * @param invertY defines if data must be stored with Y axis inverted
  72202. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  72203. * @param compression defines the compressed used (can be null)
  72204. * @param textureType defines the compressed used (can be null)
  72205. * @returns a new raw 3D texture (stored in an InternalTexture)
  72206. */
  72207. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  72208. /**
  72209. * Update a raw 3D texture
  72210. * @param texture defines the texture to update
  72211. * @param data defines the data to store
  72212. * @param format defines the data format
  72213. * @param invertY defines if data must be stored with Y axis inverted
  72214. */
  72215. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  72216. /**
  72217. * Update a raw 3D texture
  72218. * @param texture defines the texture to update
  72219. * @param data defines the data to store
  72220. * @param format defines the data format
  72221. * @param invertY defines if data must be stored with Y axis inverted
  72222. * @param compression defines the used compression (can be null)
  72223. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  72224. */
  72225. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  72226. }
  72227. }
  72228. declare module BABYLON {
  72229. /**
  72230. * Raw texture can help creating a texture directly from an array of data.
  72231. * This can be super useful if you either get the data from an uncompressed source or
  72232. * if you wish to create your texture pixel by pixel.
  72233. */
  72234. export class RawTexture extends Texture {
  72235. /**
  72236. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72237. */
  72238. format: number;
  72239. private _engine;
  72240. /**
  72241. * Instantiates a new RawTexture.
  72242. * Raw texture can help creating a texture directly from an array of data.
  72243. * This can be super useful if you either get the data from an uncompressed source or
  72244. * if you wish to create your texture pixel by pixel.
  72245. * @param data define the array of data to use to create the texture
  72246. * @param width define the width of the texture
  72247. * @param height define the height of the texture
  72248. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72249. * @param scene define the scene the texture belongs to
  72250. * @param generateMipMaps define whether mip maps should be generated or not
  72251. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72252. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72253. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72254. */
  72255. constructor(data: ArrayBufferView, width: number, height: number,
  72256. /**
  72257. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72258. */
  72259. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  72260. /**
  72261. * Updates the texture underlying data.
  72262. * @param data Define the new data of the texture
  72263. */
  72264. update(data: ArrayBufferView): void;
  72265. /**
  72266. * Creates a luminance texture from some data.
  72267. * @param data Define the texture data
  72268. * @param width Define the width of the texture
  72269. * @param height Define the height of the texture
  72270. * @param scene Define the scene the texture belongs to
  72271. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72272. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72273. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72274. * @returns the luminance texture
  72275. */
  72276. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72277. /**
  72278. * Creates a luminance alpha texture from some data.
  72279. * @param data Define the texture data
  72280. * @param width Define the width of the texture
  72281. * @param height Define the height of the texture
  72282. * @param scene Define the scene the texture belongs to
  72283. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72284. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72285. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72286. * @returns the luminance alpha texture
  72287. */
  72288. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72289. /**
  72290. * Creates an alpha texture from some data.
  72291. * @param data Define the texture data
  72292. * @param width Define the width of the texture
  72293. * @param height Define the height of the texture
  72294. * @param scene Define the scene the texture belongs to
  72295. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72296. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72297. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72298. * @returns the alpha texture
  72299. */
  72300. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72301. /**
  72302. * Creates a RGB texture from some data.
  72303. * @param data Define the texture data
  72304. * @param width Define the width of the texture
  72305. * @param height Define the height of the texture
  72306. * @param scene Define the scene the texture belongs to
  72307. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72308. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72309. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72310. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72311. * @returns the RGB alpha texture
  72312. */
  72313. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72314. /**
  72315. * Creates a RGBA texture from some data.
  72316. * @param data Define the texture data
  72317. * @param width Define the width of the texture
  72318. * @param height Define the height of the texture
  72319. * @param scene Define the scene the texture belongs to
  72320. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72321. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72322. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72323. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72324. * @returns the RGBA texture
  72325. */
  72326. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72327. /**
  72328. * Creates a R texture from some data.
  72329. * @param data Define the texture data
  72330. * @param width Define the width of the texture
  72331. * @param height Define the height of the texture
  72332. * @param scene Define the scene the texture belongs to
  72333. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72334. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72335. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72336. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72337. * @returns the R texture
  72338. */
  72339. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72340. }
  72341. }
  72342. declare module BABYLON {
  72343. /**
  72344. * Defines a runtime animation
  72345. */
  72346. export class RuntimeAnimation {
  72347. private _events;
  72348. /**
  72349. * The current frame of the runtime animation
  72350. */
  72351. private _currentFrame;
  72352. /**
  72353. * The animation used by the runtime animation
  72354. */
  72355. private _animation;
  72356. /**
  72357. * The target of the runtime animation
  72358. */
  72359. private _target;
  72360. /**
  72361. * The initiating animatable
  72362. */
  72363. private _host;
  72364. /**
  72365. * The original value of the runtime animation
  72366. */
  72367. private _originalValue;
  72368. /**
  72369. * The original blend value of the runtime animation
  72370. */
  72371. private _originalBlendValue;
  72372. /**
  72373. * The offsets cache of the runtime animation
  72374. */
  72375. private _offsetsCache;
  72376. /**
  72377. * The high limits cache of the runtime animation
  72378. */
  72379. private _highLimitsCache;
  72380. /**
  72381. * Specifies if the runtime animation has been stopped
  72382. */
  72383. private _stopped;
  72384. /**
  72385. * The blending factor of the runtime animation
  72386. */
  72387. private _blendingFactor;
  72388. /**
  72389. * The BabylonJS scene
  72390. */
  72391. private _scene;
  72392. /**
  72393. * The current value of the runtime animation
  72394. */
  72395. private _currentValue;
  72396. /** @hidden */
  72397. _animationState: _IAnimationState;
  72398. /**
  72399. * The active target of the runtime animation
  72400. */
  72401. private _activeTargets;
  72402. private _currentActiveTarget;
  72403. private _directTarget;
  72404. /**
  72405. * The target path of the runtime animation
  72406. */
  72407. private _targetPath;
  72408. /**
  72409. * The weight of the runtime animation
  72410. */
  72411. private _weight;
  72412. /**
  72413. * The ratio offset of the runtime animation
  72414. */
  72415. private _ratioOffset;
  72416. /**
  72417. * The previous delay of the runtime animation
  72418. */
  72419. private _previousDelay;
  72420. /**
  72421. * The previous ratio of the runtime animation
  72422. */
  72423. private _previousRatio;
  72424. private _enableBlending;
  72425. private _keys;
  72426. private _minFrame;
  72427. private _maxFrame;
  72428. private _minValue;
  72429. private _maxValue;
  72430. private _targetIsArray;
  72431. /**
  72432. * Gets the current frame of the runtime animation
  72433. */
  72434. readonly currentFrame: number;
  72435. /**
  72436. * Gets the weight of the runtime animation
  72437. */
  72438. readonly weight: number;
  72439. /**
  72440. * Gets the current value of the runtime animation
  72441. */
  72442. readonly currentValue: any;
  72443. /**
  72444. * Gets the target path of the runtime animation
  72445. */
  72446. readonly targetPath: string;
  72447. /**
  72448. * Gets the actual target of the runtime animation
  72449. */
  72450. readonly target: any;
  72451. /** @hidden */
  72452. _onLoop: () => void;
  72453. /**
  72454. * Create a new RuntimeAnimation object
  72455. * @param target defines the target of the animation
  72456. * @param animation defines the source animation object
  72457. * @param scene defines the hosting scene
  72458. * @param host defines the initiating Animatable
  72459. */
  72460. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  72461. private _preparePath;
  72462. /**
  72463. * Gets the animation from the runtime animation
  72464. */
  72465. readonly animation: Animation;
  72466. /**
  72467. * Resets the runtime animation to the beginning
  72468. * @param restoreOriginal defines whether to restore the target property to the original value
  72469. */
  72470. reset(restoreOriginal?: boolean): void;
  72471. /**
  72472. * Specifies if the runtime animation is stopped
  72473. * @returns Boolean specifying if the runtime animation is stopped
  72474. */
  72475. isStopped(): boolean;
  72476. /**
  72477. * Disposes of the runtime animation
  72478. */
  72479. dispose(): void;
  72480. /**
  72481. * Apply the interpolated value to the target
  72482. * @param currentValue defines the value computed by the animation
  72483. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  72484. */
  72485. setValue(currentValue: any, weight: number): void;
  72486. private _getOriginalValues;
  72487. private _setValue;
  72488. /**
  72489. * Gets the loop pmode of the runtime animation
  72490. * @returns Loop Mode
  72491. */
  72492. private _getCorrectLoopMode;
  72493. /**
  72494. * Move the current animation to a given frame
  72495. * @param frame defines the frame to move to
  72496. */
  72497. goToFrame(frame: number): void;
  72498. /**
  72499. * @hidden Internal use only
  72500. */
  72501. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  72502. /**
  72503. * Execute the current animation
  72504. * @param delay defines the delay to add to the current frame
  72505. * @param from defines the lower bound of the animation range
  72506. * @param to defines the upper bound of the animation range
  72507. * @param loop defines if the current animation must loop
  72508. * @param speedRatio defines the current speed ratio
  72509. * @param weight defines the weight of the animation (default is -1 so no weight)
  72510. * @param onLoop optional callback called when animation loops
  72511. * @returns a boolean indicating if the animation is running
  72512. */
  72513. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  72514. }
  72515. }
  72516. declare module BABYLON {
  72517. /**
  72518. * Class used to store an actual running animation
  72519. */
  72520. export class Animatable {
  72521. /** defines the target object */
  72522. target: any;
  72523. /** defines the starting frame number (default is 0) */
  72524. fromFrame: number;
  72525. /** defines the ending frame number (default is 100) */
  72526. toFrame: number;
  72527. /** defines if the animation must loop (default is false) */
  72528. loopAnimation: boolean;
  72529. /** defines a callback to call when animation ends if it is not looping */
  72530. onAnimationEnd?: (() => void) | null | undefined;
  72531. /** defines a callback to call when animation loops */
  72532. onAnimationLoop?: (() => void) | null | undefined;
  72533. private _localDelayOffset;
  72534. private _pausedDelay;
  72535. private _runtimeAnimations;
  72536. private _paused;
  72537. private _scene;
  72538. private _speedRatio;
  72539. private _weight;
  72540. private _syncRoot;
  72541. /**
  72542. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  72543. * This will only apply for non looping animation (default is true)
  72544. */
  72545. disposeOnEnd: boolean;
  72546. /**
  72547. * Gets a boolean indicating if the animation has started
  72548. */
  72549. animationStarted: boolean;
  72550. /**
  72551. * Observer raised when the animation ends
  72552. */
  72553. onAnimationEndObservable: Observable<Animatable>;
  72554. /**
  72555. * Observer raised when the animation loops
  72556. */
  72557. onAnimationLoopObservable: Observable<Animatable>;
  72558. /**
  72559. * Gets the root Animatable used to synchronize and normalize animations
  72560. */
  72561. readonly syncRoot: Nullable<Animatable>;
  72562. /**
  72563. * Gets the current frame of the first RuntimeAnimation
  72564. * Used to synchronize Animatables
  72565. */
  72566. readonly masterFrame: number;
  72567. /**
  72568. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  72569. */
  72570. weight: number;
  72571. /**
  72572. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  72573. */
  72574. speedRatio: number;
  72575. /**
  72576. * Creates a new Animatable
  72577. * @param scene defines the hosting scene
  72578. * @param target defines the target object
  72579. * @param fromFrame defines the starting frame number (default is 0)
  72580. * @param toFrame defines the ending frame number (default is 100)
  72581. * @param loopAnimation defines if the animation must loop (default is false)
  72582. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  72583. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  72584. * @param animations defines a group of animation to add to the new Animatable
  72585. * @param onAnimationLoop defines a callback to call when animation loops
  72586. */
  72587. constructor(scene: Scene,
  72588. /** defines the target object */
  72589. target: any,
  72590. /** defines the starting frame number (default is 0) */
  72591. fromFrame?: number,
  72592. /** defines the ending frame number (default is 100) */
  72593. toFrame?: number,
  72594. /** defines if the animation must loop (default is false) */
  72595. loopAnimation?: boolean, speedRatio?: number,
  72596. /** defines a callback to call when animation ends if it is not looping */
  72597. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  72598. /** defines a callback to call when animation loops */
  72599. onAnimationLoop?: (() => void) | null | undefined);
  72600. /**
  72601. * Synchronize and normalize current Animatable with a source Animatable
  72602. * This is useful when using animation weights and when animations are not of the same length
  72603. * @param root defines the root Animatable to synchronize with
  72604. * @returns the current Animatable
  72605. */
  72606. syncWith(root: Animatable): Animatable;
  72607. /**
  72608. * Gets the list of runtime animations
  72609. * @returns an array of RuntimeAnimation
  72610. */
  72611. getAnimations(): RuntimeAnimation[];
  72612. /**
  72613. * Adds more animations to the current animatable
  72614. * @param target defines the target of the animations
  72615. * @param animations defines the new animations to add
  72616. */
  72617. appendAnimations(target: any, animations: Animation[]): void;
  72618. /**
  72619. * Gets the source animation for a specific property
  72620. * @param property defines the propertyu to look for
  72621. * @returns null or the source animation for the given property
  72622. */
  72623. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  72624. /**
  72625. * Gets the runtime animation for a specific property
  72626. * @param property defines the propertyu to look for
  72627. * @returns null or the runtime animation for the given property
  72628. */
  72629. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  72630. /**
  72631. * Resets the animatable to its original state
  72632. */
  72633. reset(): void;
  72634. /**
  72635. * Allows the animatable to blend with current running animations
  72636. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72637. * @param blendingSpeed defines the blending speed to use
  72638. */
  72639. enableBlending(blendingSpeed: number): void;
  72640. /**
  72641. * Disable animation blending
  72642. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72643. */
  72644. disableBlending(): void;
  72645. /**
  72646. * Jump directly to a given frame
  72647. * @param frame defines the frame to jump to
  72648. */
  72649. goToFrame(frame: number): void;
  72650. /**
  72651. * Pause the animation
  72652. */
  72653. pause(): void;
  72654. /**
  72655. * Restart the animation
  72656. */
  72657. restart(): void;
  72658. private _raiseOnAnimationEnd;
  72659. /**
  72660. * Stop and delete the current animation
  72661. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  72662. * @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)
  72663. */
  72664. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  72665. /**
  72666. * Wait asynchronously for the animation to end
  72667. * @returns a promise which will be fullfilled when the animation ends
  72668. */
  72669. waitAsync(): Promise<Animatable>;
  72670. /** @hidden */
  72671. _animate(delay: number): boolean;
  72672. }
  72673. interface Scene {
  72674. /** @hidden */
  72675. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  72676. /** @hidden */
  72677. _processLateAnimationBindingsForMatrices(holder: {
  72678. totalWeight: number;
  72679. animations: RuntimeAnimation[];
  72680. originalValue: Matrix;
  72681. }): any;
  72682. /** @hidden */
  72683. _processLateAnimationBindingsForQuaternions(holder: {
  72684. totalWeight: number;
  72685. animations: RuntimeAnimation[];
  72686. originalValue: Quaternion;
  72687. }, refQuaternion: Quaternion): Quaternion;
  72688. /** @hidden */
  72689. _processLateAnimationBindings(): void;
  72690. /**
  72691. * Will start the animation sequence of a given target
  72692. * @param target defines the target
  72693. * @param from defines from which frame should animation start
  72694. * @param to defines until which frame should animation run.
  72695. * @param weight defines the weight to apply to the animation (1.0 by default)
  72696. * @param loop defines if the animation loops
  72697. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72698. * @param onAnimationEnd defines the function to be executed when the animation ends
  72699. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72700. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72701. * @param onAnimationLoop defines the callback to call when an animation loops
  72702. * @returns the animatable object created for this animation
  72703. */
  72704. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72705. /**
  72706. * Will start the animation sequence of a given target
  72707. * @param target defines the target
  72708. * @param from defines from which frame should animation start
  72709. * @param to defines until which frame should animation run.
  72710. * @param loop defines if the animation loops
  72711. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72712. * @param onAnimationEnd defines the function to be executed when the animation ends
  72713. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72714. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72715. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  72716. * @param onAnimationLoop defines the callback to call when an animation loops
  72717. * @returns the animatable object created for this animation
  72718. */
  72719. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72720. /**
  72721. * Will start the animation sequence of a given target and its hierarchy
  72722. * @param target defines the target
  72723. * @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.
  72724. * @param from defines from which frame should animation start
  72725. * @param to defines until which frame should animation run.
  72726. * @param loop defines if the animation loops
  72727. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72728. * @param onAnimationEnd defines the function to be executed when the animation ends
  72729. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72730. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72731. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72732. * @param onAnimationLoop defines the callback to call when an animation loops
  72733. * @returns the list of created animatables
  72734. */
  72735. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  72736. /**
  72737. * Begin a new animation on a given node
  72738. * @param target defines the target where the animation will take place
  72739. * @param animations defines the list of animations to start
  72740. * @param from defines the initial value
  72741. * @param to defines the final value
  72742. * @param loop defines if you want animation to loop (off by default)
  72743. * @param speedRatio defines the speed ratio to apply to all animations
  72744. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72745. * @param onAnimationLoop defines the callback to call when an animation loops
  72746. * @returns the list of created animatables
  72747. */
  72748. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  72749. /**
  72750. * Begin a new animation on a given node and its hierarchy
  72751. * @param target defines the root node where the animation will take place
  72752. * @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.
  72753. * @param animations defines the list of animations to start
  72754. * @param from defines the initial value
  72755. * @param to defines the final value
  72756. * @param loop defines if you want animation to loop (off by default)
  72757. * @param speedRatio defines the speed ratio to apply to all animations
  72758. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72759. * @param onAnimationLoop defines the callback to call when an animation loops
  72760. * @returns the list of animatables created for all nodes
  72761. */
  72762. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  72763. /**
  72764. * Gets the animatable associated with a specific target
  72765. * @param target defines the target of the animatable
  72766. * @returns the required animatable if found
  72767. */
  72768. getAnimatableByTarget(target: any): Nullable<Animatable>;
  72769. /**
  72770. * Gets all animatables associated with a given target
  72771. * @param target defines the target to look animatables for
  72772. * @returns an array of Animatables
  72773. */
  72774. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  72775. /**
  72776. * Stops and removes all animations that have been applied to the scene
  72777. */
  72778. stopAllAnimations(): void;
  72779. }
  72780. interface Bone {
  72781. /**
  72782. * Copy an animation range from another bone
  72783. * @param source defines the source bone
  72784. * @param rangeName defines the range name to copy
  72785. * @param frameOffset defines the frame offset
  72786. * @param rescaleAsRequired defines if rescaling must be applied if required
  72787. * @param skelDimensionsRatio defines the scaling ratio
  72788. * @returns true if operation was successful
  72789. */
  72790. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  72791. }
  72792. }
  72793. declare module BABYLON {
  72794. /**
  72795. * Class used to handle skinning animations
  72796. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  72797. */
  72798. export class Skeleton implements IAnimatable {
  72799. /** defines the skeleton name */
  72800. name: string;
  72801. /** defines the skeleton Id */
  72802. id: string;
  72803. /**
  72804. * Defines the list of child bones
  72805. */
  72806. bones: Bone[];
  72807. /**
  72808. * Defines an estimate of the dimension of the skeleton at rest
  72809. */
  72810. dimensionsAtRest: Vector3;
  72811. /**
  72812. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  72813. */
  72814. needInitialSkinMatrix: boolean;
  72815. /**
  72816. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  72817. */
  72818. overrideMesh: Nullable<AbstractMesh>;
  72819. /**
  72820. * Gets the list of animations attached to this skeleton
  72821. */
  72822. animations: Array<Animation>;
  72823. private _scene;
  72824. private _isDirty;
  72825. private _transformMatrices;
  72826. private _transformMatrixTexture;
  72827. private _meshesWithPoseMatrix;
  72828. private _animatables;
  72829. private _identity;
  72830. private _synchronizedWithMesh;
  72831. private _ranges;
  72832. private _lastAbsoluteTransformsUpdateId;
  72833. private _canUseTextureForBones;
  72834. private _uniqueId;
  72835. /** @hidden */
  72836. _numBonesWithLinkedTransformNode: number;
  72837. /** @hidden */
  72838. _hasWaitingData: Nullable<boolean>;
  72839. /**
  72840. * Specifies if the skeleton should be serialized
  72841. */
  72842. doNotSerialize: boolean;
  72843. private _useTextureToStoreBoneMatrices;
  72844. /**
  72845. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  72846. * Please note that this option is not available if the hardware does not support it
  72847. */
  72848. useTextureToStoreBoneMatrices: boolean;
  72849. private _animationPropertiesOverride;
  72850. /**
  72851. * Gets or sets the animation properties override
  72852. */
  72853. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  72854. /**
  72855. * List of inspectable custom properties (used by the Inspector)
  72856. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72857. */
  72858. inspectableCustomProperties: IInspectable[];
  72859. /**
  72860. * An observable triggered before computing the skeleton's matrices
  72861. */
  72862. onBeforeComputeObservable: Observable<Skeleton>;
  72863. /**
  72864. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  72865. */
  72866. readonly isUsingTextureForMatrices: boolean;
  72867. /**
  72868. * Gets the unique ID of this skeleton
  72869. */
  72870. readonly uniqueId: number;
  72871. /**
  72872. * Creates a new skeleton
  72873. * @param name defines the skeleton name
  72874. * @param id defines the skeleton Id
  72875. * @param scene defines the hosting scene
  72876. */
  72877. constructor(
  72878. /** defines the skeleton name */
  72879. name: string,
  72880. /** defines the skeleton Id */
  72881. id: string, scene: Scene);
  72882. /**
  72883. * Gets the current object class name.
  72884. * @return the class name
  72885. */
  72886. getClassName(): string;
  72887. /**
  72888. * Returns an array containing the root bones
  72889. * @returns an array containing the root bones
  72890. */
  72891. getChildren(): Array<Bone>;
  72892. /**
  72893. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  72894. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  72895. * @returns a Float32Array containing matrices data
  72896. */
  72897. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  72898. /**
  72899. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  72900. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  72901. * @returns a raw texture containing the data
  72902. */
  72903. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  72904. /**
  72905. * Gets the current hosting scene
  72906. * @returns a scene object
  72907. */
  72908. getScene(): Scene;
  72909. /**
  72910. * Gets a string representing the current skeleton data
  72911. * @param fullDetails defines a boolean indicating if we want a verbose version
  72912. * @returns a string representing the current skeleton data
  72913. */
  72914. toString(fullDetails?: boolean): string;
  72915. /**
  72916. * Get bone's index searching by name
  72917. * @param name defines bone's name to search for
  72918. * @return the indice of the bone. Returns -1 if not found
  72919. */
  72920. getBoneIndexByName(name: string): number;
  72921. /**
  72922. * Creater a new animation range
  72923. * @param name defines the name of the range
  72924. * @param from defines the start key
  72925. * @param to defines the end key
  72926. */
  72927. createAnimationRange(name: string, from: number, to: number): void;
  72928. /**
  72929. * Delete a specific animation range
  72930. * @param name defines the name of the range
  72931. * @param deleteFrames defines if frames must be removed as well
  72932. */
  72933. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  72934. /**
  72935. * Gets a specific animation range
  72936. * @param name defines the name of the range to look for
  72937. * @returns the requested animation range or null if not found
  72938. */
  72939. getAnimationRange(name: string): Nullable<AnimationRange>;
  72940. /**
  72941. * Gets the list of all animation ranges defined on this skeleton
  72942. * @returns an array
  72943. */
  72944. getAnimationRanges(): Nullable<AnimationRange>[];
  72945. /**
  72946. * Copy animation range from a source skeleton.
  72947. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  72948. * @param source defines the source skeleton
  72949. * @param name defines the name of the range to copy
  72950. * @param rescaleAsRequired defines if rescaling must be applied if required
  72951. * @returns true if operation was successful
  72952. */
  72953. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  72954. /**
  72955. * Forces the skeleton to go to rest pose
  72956. */
  72957. returnToRest(): void;
  72958. private _getHighestAnimationFrame;
  72959. /**
  72960. * Begin a specific animation range
  72961. * @param name defines the name of the range to start
  72962. * @param loop defines if looping must be turned on (false by default)
  72963. * @param speedRatio defines the speed ratio to apply (1 by default)
  72964. * @param onAnimationEnd defines a callback which will be called when animation will end
  72965. * @returns a new animatable
  72966. */
  72967. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  72968. /** @hidden */
  72969. _markAsDirty(): void;
  72970. /** @hidden */
  72971. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  72972. /** @hidden */
  72973. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  72974. private _computeTransformMatrices;
  72975. /**
  72976. * Build all resources required to render a skeleton
  72977. */
  72978. prepare(): void;
  72979. /**
  72980. * Gets the list of animatables currently running for this skeleton
  72981. * @returns an array of animatables
  72982. */
  72983. getAnimatables(): IAnimatable[];
  72984. /**
  72985. * Clone the current skeleton
  72986. * @param name defines the name of the new skeleton
  72987. * @param id defines the id of the new skeleton
  72988. * @returns the new skeleton
  72989. */
  72990. clone(name: string, id: string): Skeleton;
  72991. /**
  72992. * Enable animation blending for this skeleton
  72993. * @param blendingSpeed defines the blending speed to apply
  72994. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72995. */
  72996. enableBlending(blendingSpeed?: number): void;
  72997. /**
  72998. * Releases all resources associated with the current skeleton
  72999. */
  73000. dispose(): void;
  73001. /**
  73002. * Serialize the skeleton in a JSON object
  73003. * @returns a JSON object
  73004. */
  73005. serialize(): any;
  73006. /**
  73007. * Creates a new skeleton from serialized data
  73008. * @param parsedSkeleton defines the serialized data
  73009. * @param scene defines the hosting scene
  73010. * @returns a new skeleton
  73011. */
  73012. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  73013. /**
  73014. * Compute all node absolute transforms
  73015. * @param forceUpdate defines if computation must be done even if cache is up to date
  73016. */
  73017. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  73018. /**
  73019. * Gets the root pose matrix
  73020. * @returns a matrix
  73021. */
  73022. getPoseMatrix(): Nullable<Matrix>;
  73023. /**
  73024. * Sorts bones per internal index
  73025. */
  73026. sortBones(): void;
  73027. private _sortBones;
  73028. }
  73029. }
  73030. declare module BABYLON {
  73031. /**
  73032. * Defines a target to use with MorphTargetManager
  73033. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  73034. */
  73035. export class MorphTarget implements IAnimatable {
  73036. /** defines the name of the target */
  73037. name: string;
  73038. /**
  73039. * Gets or sets the list of animations
  73040. */
  73041. animations: Animation[];
  73042. private _scene;
  73043. private _positions;
  73044. private _normals;
  73045. private _tangents;
  73046. private _uvs;
  73047. private _influence;
  73048. /**
  73049. * Observable raised when the influence changes
  73050. */
  73051. onInfluenceChanged: Observable<boolean>;
  73052. /** @hidden */
  73053. _onDataLayoutChanged: Observable<void>;
  73054. /**
  73055. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  73056. */
  73057. influence: number;
  73058. /**
  73059. * Gets or sets the id of the morph Target
  73060. */
  73061. id: string;
  73062. private _animationPropertiesOverride;
  73063. /**
  73064. * Gets or sets the animation properties override
  73065. */
  73066. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  73067. /**
  73068. * Creates a new MorphTarget
  73069. * @param name defines the name of the target
  73070. * @param influence defines the influence to use
  73071. * @param scene defines the scene the morphtarget belongs to
  73072. */
  73073. constructor(
  73074. /** defines the name of the target */
  73075. name: string, influence?: number, scene?: Nullable<Scene>);
  73076. /**
  73077. * Gets a boolean defining if the target contains position data
  73078. */
  73079. readonly hasPositions: boolean;
  73080. /**
  73081. * Gets a boolean defining if the target contains normal data
  73082. */
  73083. readonly hasNormals: boolean;
  73084. /**
  73085. * Gets a boolean defining if the target contains tangent data
  73086. */
  73087. readonly hasTangents: boolean;
  73088. /**
  73089. * Gets a boolean defining if the target contains texture coordinates data
  73090. */
  73091. readonly hasUVs: boolean;
  73092. /**
  73093. * Affects position data to this target
  73094. * @param data defines the position data to use
  73095. */
  73096. setPositions(data: Nullable<FloatArray>): void;
  73097. /**
  73098. * Gets the position data stored in this target
  73099. * @returns a FloatArray containing the position data (or null if not present)
  73100. */
  73101. getPositions(): Nullable<FloatArray>;
  73102. /**
  73103. * Affects normal data to this target
  73104. * @param data defines the normal data to use
  73105. */
  73106. setNormals(data: Nullable<FloatArray>): void;
  73107. /**
  73108. * Gets the normal data stored in this target
  73109. * @returns a FloatArray containing the normal data (or null if not present)
  73110. */
  73111. getNormals(): Nullable<FloatArray>;
  73112. /**
  73113. * Affects tangent data to this target
  73114. * @param data defines the tangent data to use
  73115. */
  73116. setTangents(data: Nullable<FloatArray>): void;
  73117. /**
  73118. * Gets the tangent data stored in this target
  73119. * @returns a FloatArray containing the tangent data (or null if not present)
  73120. */
  73121. getTangents(): Nullable<FloatArray>;
  73122. /**
  73123. * Affects texture coordinates data to this target
  73124. * @param data defines the texture coordinates data to use
  73125. */
  73126. setUVs(data: Nullable<FloatArray>): void;
  73127. /**
  73128. * Gets the texture coordinates data stored in this target
  73129. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  73130. */
  73131. getUVs(): Nullable<FloatArray>;
  73132. /**
  73133. * Serializes the current target into a Serialization object
  73134. * @returns the serialized object
  73135. */
  73136. serialize(): any;
  73137. /**
  73138. * Returns the string "MorphTarget"
  73139. * @returns "MorphTarget"
  73140. */
  73141. getClassName(): string;
  73142. /**
  73143. * Creates a new target from serialized data
  73144. * @param serializationObject defines the serialized data to use
  73145. * @returns a new MorphTarget
  73146. */
  73147. static Parse(serializationObject: any): MorphTarget;
  73148. /**
  73149. * Creates a MorphTarget from mesh data
  73150. * @param mesh defines the source mesh
  73151. * @param name defines the name to use for the new target
  73152. * @param influence defines the influence to attach to the target
  73153. * @returns a new MorphTarget
  73154. */
  73155. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  73156. }
  73157. }
  73158. declare module BABYLON {
  73159. /**
  73160. * This class is used to deform meshes using morphing between different targets
  73161. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  73162. */
  73163. export class MorphTargetManager {
  73164. private _targets;
  73165. private _targetInfluenceChangedObservers;
  73166. private _targetDataLayoutChangedObservers;
  73167. private _activeTargets;
  73168. private _scene;
  73169. private _influences;
  73170. private _supportsNormals;
  73171. private _supportsTangents;
  73172. private _supportsUVs;
  73173. private _vertexCount;
  73174. private _uniqueId;
  73175. private _tempInfluences;
  73176. /**
  73177. * Gets or sets a boolean indicating if normals must be morphed
  73178. */
  73179. enableNormalMorphing: boolean;
  73180. /**
  73181. * Gets or sets a boolean indicating if tangents must be morphed
  73182. */
  73183. enableTangentMorphing: boolean;
  73184. /**
  73185. * Gets or sets a boolean indicating if UV must be morphed
  73186. */
  73187. enableUVMorphing: boolean;
  73188. /**
  73189. * Creates a new MorphTargetManager
  73190. * @param scene defines the current scene
  73191. */
  73192. constructor(scene?: Nullable<Scene>);
  73193. /**
  73194. * Gets the unique ID of this manager
  73195. */
  73196. readonly uniqueId: number;
  73197. /**
  73198. * Gets the number of vertices handled by this manager
  73199. */
  73200. readonly vertexCount: number;
  73201. /**
  73202. * Gets a boolean indicating if this manager supports morphing of normals
  73203. */
  73204. readonly supportsNormals: boolean;
  73205. /**
  73206. * Gets a boolean indicating if this manager supports morphing of tangents
  73207. */
  73208. readonly supportsTangents: boolean;
  73209. /**
  73210. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  73211. */
  73212. readonly supportsUVs: boolean;
  73213. /**
  73214. * Gets the number of targets stored in this manager
  73215. */
  73216. readonly numTargets: number;
  73217. /**
  73218. * Gets the number of influencers (ie. the number of targets with influences > 0)
  73219. */
  73220. readonly numInfluencers: number;
  73221. /**
  73222. * Gets the list of influences (one per target)
  73223. */
  73224. readonly influences: Float32Array;
  73225. /**
  73226. * Gets the active target at specified index. An active target is a target with an influence > 0
  73227. * @param index defines the index to check
  73228. * @returns the requested target
  73229. */
  73230. getActiveTarget(index: number): MorphTarget;
  73231. /**
  73232. * Gets the target at specified index
  73233. * @param index defines the index to check
  73234. * @returns the requested target
  73235. */
  73236. getTarget(index: number): MorphTarget;
  73237. /**
  73238. * Add a new target to this manager
  73239. * @param target defines the target to add
  73240. */
  73241. addTarget(target: MorphTarget): void;
  73242. /**
  73243. * Removes a target from the manager
  73244. * @param target defines the target to remove
  73245. */
  73246. removeTarget(target: MorphTarget): void;
  73247. /**
  73248. * Serializes the current manager into a Serialization object
  73249. * @returns the serialized object
  73250. */
  73251. serialize(): any;
  73252. private _syncActiveTargets;
  73253. /**
  73254. * Syncrhonize the targets with all the meshes using this morph target manager
  73255. */
  73256. synchronize(): void;
  73257. /**
  73258. * Creates a new MorphTargetManager from serialized data
  73259. * @param serializationObject defines the serialized data
  73260. * @param scene defines the hosting scene
  73261. * @returns the new MorphTargetManager
  73262. */
  73263. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  73264. }
  73265. }
  73266. declare module BABYLON {
  73267. /**
  73268. * Groups all the scene component constants in one place to ease maintenance.
  73269. * @hidden
  73270. */
  73271. export class SceneComponentConstants {
  73272. static readonly NAME_EFFECTLAYER: string;
  73273. static readonly NAME_LAYER: string;
  73274. static readonly NAME_LENSFLARESYSTEM: string;
  73275. static readonly NAME_BOUNDINGBOXRENDERER: string;
  73276. static readonly NAME_PARTICLESYSTEM: string;
  73277. static readonly NAME_GAMEPAD: string;
  73278. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  73279. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  73280. static readonly NAME_DEPTHRENDERER: string;
  73281. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  73282. static readonly NAME_SPRITE: string;
  73283. static readonly NAME_OUTLINERENDERER: string;
  73284. static readonly NAME_PROCEDURALTEXTURE: string;
  73285. static readonly NAME_SHADOWGENERATOR: string;
  73286. static readonly NAME_OCTREE: string;
  73287. static readonly NAME_PHYSICSENGINE: string;
  73288. static readonly NAME_AUDIO: string;
  73289. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  73290. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73291. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  73292. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73293. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  73294. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  73295. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  73296. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  73297. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  73298. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  73299. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  73300. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  73301. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  73302. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  73303. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  73304. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  73305. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  73306. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  73307. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  73308. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  73309. static readonly STEP_AFTERRENDER_AUDIO: number;
  73310. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  73311. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  73312. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  73313. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  73314. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  73315. static readonly STEP_POINTERMOVE_SPRITE: number;
  73316. static readonly STEP_POINTERDOWN_SPRITE: number;
  73317. static readonly STEP_POINTERUP_SPRITE: number;
  73318. }
  73319. /**
  73320. * This represents a scene component.
  73321. *
  73322. * This is used to decouple the dependency the scene is having on the different workloads like
  73323. * layers, post processes...
  73324. */
  73325. export interface ISceneComponent {
  73326. /**
  73327. * The name of the component. Each component must have a unique name.
  73328. */
  73329. name: string;
  73330. /**
  73331. * The scene the component belongs to.
  73332. */
  73333. scene: Scene;
  73334. /**
  73335. * Register the component to one instance of a scene.
  73336. */
  73337. register(): void;
  73338. /**
  73339. * Rebuilds the elements related to this component in case of
  73340. * context lost for instance.
  73341. */
  73342. rebuild(): void;
  73343. /**
  73344. * Disposes the component and the associated ressources.
  73345. */
  73346. dispose(): void;
  73347. }
  73348. /**
  73349. * This represents a SERIALIZABLE scene component.
  73350. *
  73351. * This extends Scene Component to add Serialization methods on top.
  73352. */
  73353. export interface ISceneSerializableComponent extends ISceneComponent {
  73354. /**
  73355. * Adds all the elements from the container to the scene
  73356. * @param container the container holding the elements
  73357. */
  73358. addFromContainer(container: AbstractScene): void;
  73359. /**
  73360. * Removes all the elements in the container from the scene
  73361. * @param container contains the elements to remove
  73362. * @param dispose if the removed element should be disposed (default: false)
  73363. */
  73364. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73365. /**
  73366. * Serializes the component data to the specified json object
  73367. * @param serializationObject The object to serialize to
  73368. */
  73369. serialize(serializationObject: any): void;
  73370. }
  73371. /**
  73372. * Strong typing of a Mesh related stage step action
  73373. */
  73374. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  73375. /**
  73376. * Strong typing of a Evaluate Sub Mesh related stage step action
  73377. */
  73378. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  73379. /**
  73380. * Strong typing of a Active Mesh related stage step action
  73381. */
  73382. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  73383. /**
  73384. * Strong typing of a Camera related stage step action
  73385. */
  73386. export type CameraStageAction = (camera: Camera) => void;
  73387. /**
  73388. * Strong typing of a Camera Frame buffer related stage step action
  73389. */
  73390. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  73391. /**
  73392. * Strong typing of a Render Target related stage step action
  73393. */
  73394. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  73395. /**
  73396. * Strong typing of a RenderingGroup related stage step action
  73397. */
  73398. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  73399. /**
  73400. * Strong typing of a Mesh Render related stage step action
  73401. */
  73402. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  73403. /**
  73404. * Strong typing of a simple stage step action
  73405. */
  73406. export type SimpleStageAction = () => void;
  73407. /**
  73408. * Strong typing of a render target action.
  73409. */
  73410. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  73411. /**
  73412. * Strong typing of a pointer move action.
  73413. */
  73414. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  73415. /**
  73416. * Strong typing of a pointer up/down action.
  73417. */
  73418. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  73419. /**
  73420. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  73421. * @hidden
  73422. */
  73423. export class Stage<T extends Function> extends Array<{
  73424. index: number;
  73425. component: ISceneComponent;
  73426. action: T;
  73427. }> {
  73428. /**
  73429. * Hide ctor from the rest of the world.
  73430. * @param items The items to add.
  73431. */
  73432. private constructor();
  73433. /**
  73434. * Creates a new Stage.
  73435. * @returns A new instance of a Stage
  73436. */
  73437. static Create<T extends Function>(): Stage<T>;
  73438. /**
  73439. * Registers a step in an ordered way in the targeted stage.
  73440. * @param index Defines the position to register the step in
  73441. * @param component Defines the component attached to the step
  73442. * @param action Defines the action to launch during the step
  73443. */
  73444. registerStep(index: number, component: ISceneComponent, action: T): void;
  73445. /**
  73446. * Clears all the steps from the stage.
  73447. */
  73448. clear(): void;
  73449. }
  73450. }
  73451. declare module BABYLON {
  73452. /**
  73453. * Class used to represent a specific level of detail of a mesh
  73454. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  73455. */
  73456. export class MeshLODLevel {
  73457. /** Defines the distance where this level should star being displayed */
  73458. distance: number;
  73459. /** Defines the mesh to use to render this level */
  73460. mesh: Nullable<Mesh>;
  73461. /**
  73462. * Creates a new LOD level
  73463. * @param distance defines the distance where this level should star being displayed
  73464. * @param mesh defines the mesh to use to render this level
  73465. */
  73466. constructor(
  73467. /** Defines the distance where this level should star being displayed */
  73468. distance: number,
  73469. /** Defines the mesh to use to render this level */
  73470. mesh: Nullable<Mesh>);
  73471. }
  73472. }
  73473. declare module BABYLON {
  73474. /**
  73475. * Interface describing all the common properties and methods a shadow light needs to implement.
  73476. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  73477. * as well as binding the different shadow properties to the effects.
  73478. */
  73479. export interface IShadowLight extends Light {
  73480. /**
  73481. * The light id in the scene (used in scene.findLighById for instance)
  73482. */
  73483. id: string;
  73484. /**
  73485. * The position the shdow will be casted from.
  73486. */
  73487. position: Vector3;
  73488. /**
  73489. * In 2d mode (needCube being false), the direction used to cast the shadow.
  73490. */
  73491. direction: Vector3;
  73492. /**
  73493. * The transformed position. Position of the light in world space taking parenting in account.
  73494. */
  73495. transformedPosition: Vector3;
  73496. /**
  73497. * The transformed direction. Direction of the light in world space taking parenting in account.
  73498. */
  73499. transformedDirection: Vector3;
  73500. /**
  73501. * The friendly name of the light in the scene.
  73502. */
  73503. name: string;
  73504. /**
  73505. * Defines the shadow projection clipping minimum z value.
  73506. */
  73507. shadowMinZ: number;
  73508. /**
  73509. * Defines the shadow projection clipping maximum z value.
  73510. */
  73511. shadowMaxZ: number;
  73512. /**
  73513. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73514. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73515. */
  73516. computeTransformedInformation(): boolean;
  73517. /**
  73518. * Gets the scene the light belongs to.
  73519. * @returns The scene
  73520. */
  73521. getScene(): Scene;
  73522. /**
  73523. * Callback defining a custom Projection Matrix Builder.
  73524. * This can be used to override the default projection matrix computation.
  73525. */
  73526. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73527. /**
  73528. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73529. * @param matrix The materix to updated with the projection information
  73530. * @param viewMatrix The transform matrix of the light
  73531. * @param renderList The list of mesh to render in the map
  73532. * @returns The current light
  73533. */
  73534. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73535. /**
  73536. * Gets the current depth scale used in ESM.
  73537. * @returns The scale
  73538. */
  73539. getDepthScale(): number;
  73540. /**
  73541. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73542. * @returns true if a cube texture needs to be use
  73543. */
  73544. needCube(): boolean;
  73545. /**
  73546. * Detects if the projection matrix requires to be recomputed this frame.
  73547. * @returns true if it requires to be recomputed otherwise, false.
  73548. */
  73549. needProjectionMatrixCompute(): boolean;
  73550. /**
  73551. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73552. */
  73553. forceProjectionMatrixCompute(): void;
  73554. /**
  73555. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73556. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73557. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73558. */
  73559. getShadowDirection(faceIndex?: number): Vector3;
  73560. /**
  73561. * Gets the minZ used for shadow according to both the scene and the light.
  73562. * @param activeCamera The camera we are returning the min for
  73563. * @returns the depth min z
  73564. */
  73565. getDepthMinZ(activeCamera: Camera): number;
  73566. /**
  73567. * Gets the maxZ used for shadow according to both the scene and the light.
  73568. * @param activeCamera The camera we are returning the max for
  73569. * @returns the depth max z
  73570. */
  73571. getDepthMaxZ(activeCamera: Camera): number;
  73572. }
  73573. /**
  73574. * Base implementation IShadowLight
  73575. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  73576. */
  73577. export abstract class ShadowLight extends Light implements IShadowLight {
  73578. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  73579. protected _position: Vector3;
  73580. protected _setPosition(value: Vector3): void;
  73581. /**
  73582. * Sets the position the shadow will be casted from. Also use as the light position for both
  73583. * point and spot lights.
  73584. */
  73585. /**
  73586. * Sets the position the shadow will be casted from. Also use as the light position for both
  73587. * point and spot lights.
  73588. */
  73589. position: Vector3;
  73590. protected _direction: Vector3;
  73591. protected _setDirection(value: Vector3): void;
  73592. /**
  73593. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  73594. * Also use as the light direction on spot and directional lights.
  73595. */
  73596. /**
  73597. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  73598. * Also use as the light direction on spot and directional lights.
  73599. */
  73600. direction: Vector3;
  73601. private _shadowMinZ;
  73602. /**
  73603. * Gets the shadow projection clipping minimum z value.
  73604. */
  73605. /**
  73606. * Sets the shadow projection clipping minimum z value.
  73607. */
  73608. shadowMinZ: number;
  73609. private _shadowMaxZ;
  73610. /**
  73611. * Sets the shadow projection clipping maximum z value.
  73612. */
  73613. /**
  73614. * Gets the shadow projection clipping maximum z value.
  73615. */
  73616. shadowMaxZ: number;
  73617. /**
  73618. * Callback defining a custom Projection Matrix Builder.
  73619. * This can be used to override the default projection matrix computation.
  73620. */
  73621. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73622. /**
  73623. * The transformed position. Position of the light in world space taking parenting in account.
  73624. */
  73625. transformedPosition: Vector3;
  73626. /**
  73627. * The transformed direction. Direction of the light in world space taking parenting in account.
  73628. */
  73629. transformedDirection: Vector3;
  73630. private _needProjectionMatrixCompute;
  73631. /**
  73632. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73633. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73634. */
  73635. computeTransformedInformation(): boolean;
  73636. /**
  73637. * Return the depth scale used for the shadow map.
  73638. * @returns the depth scale.
  73639. */
  73640. getDepthScale(): number;
  73641. /**
  73642. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73643. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73644. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73645. */
  73646. getShadowDirection(faceIndex?: number): Vector3;
  73647. /**
  73648. * Returns the ShadowLight absolute position in the World.
  73649. * @returns the position vector in world space
  73650. */
  73651. getAbsolutePosition(): Vector3;
  73652. /**
  73653. * Sets the ShadowLight direction toward the passed target.
  73654. * @param target The point to target in local space
  73655. * @returns the updated ShadowLight direction
  73656. */
  73657. setDirectionToTarget(target: Vector3): Vector3;
  73658. /**
  73659. * Returns the light rotation in euler definition.
  73660. * @returns the x y z rotation in local space.
  73661. */
  73662. getRotation(): Vector3;
  73663. /**
  73664. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73665. * @returns true if a cube texture needs to be use
  73666. */
  73667. needCube(): boolean;
  73668. /**
  73669. * Detects if the projection matrix requires to be recomputed this frame.
  73670. * @returns true if it requires to be recomputed otherwise, false.
  73671. */
  73672. needProjectionMatrixCompute(): boolean;
  73673. /**
  73674. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73675. */
  73676. forceProjectionMatrixCompute(): void;
  73677. /** @hidden */
  73678. _initCache(): void;
  73679. /** @hidden */
  73680. _isSynchronized(): boolean;
  73681. /**
  73682. * Computes the world matrix of the node
  73683. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73684. * @returns the world matrix
  73685. */
  73686. computeWorldMatrix(force?: boolean): Matrix;
  73687. /**
  73688. * Gets the minZ used for shadow according to both the scene and the light.
  73689. * @param activeCamera The camera we are returning the min for
  73690. * @returns the depth min z
  73691. */
  73692. getDepthMinZ(activeCamera: Camera): number;
  73693. /**
  73694. * Gets the maxZ used for shadow according to both the scene and the light.
  73695. * @param activeCamera The camera we are returning the max for
  73696. * @returns the depth max z
  73697. */
  73698. getDepthMaxZ(activeCamera: Camera): number;
  73699. /**
  73700. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73701. * @param matrix The materix to updated with the projection information
  73702. * @param viewMatrix The transform matrix of the light
  73703. * @param renderList The list of mesh to render in the map
  73704. * @returns The current light
  73705. */
  73706. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73707. }
  73708. }
  73709. declare module BABYLON {
  73710. /**
  73711. * "Static Class" containing the most commonly used helper while dealing with material for
  73712. * rendering purpose.
  73713. *
  73714. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  73715. *
  73716. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  73717. */
  73718. export class MaterialHelper {
  73719. /**
  73720. * Bind the current view position to an effect.
  73721. * @param effect The effect to be bound
  73722. * @param scene The scene the eyes position is used from
  73723. */
  73724. static BindEyePosition(effect: Effect, scene: Scene): void;
  73725. /**
  73726. * Helps preparing the defines values about the UVs in used in the effect.
  73727. * UVs are shared as much as we can accross channels in the shaders.
  73728. * @param texture The texture we are preparing the UVs for
  73729. * @param defines The defines to update
  73730. * @param key The channel key "diffuse", "specular"... used in the shader
  73731. */
  73732. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  73733. /**
  73734. * Binds a texture matrix value to its corrsponding uniform
  73735. * @param texture The texture to bind the matrix for
  73736. * @param uniformBuffer The uniform buffer receivin the data
  73737. * @param key The channel key "diffuse", "specular"... used in the shader
  73738. */
  73739. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  73740. /**
  73741. * Gets the current status of the fog (should it be enabled?)
  73742. * @param mesh defines the mesh to evaluate for fog support
  73743. * @param scene defines the hosting scene
  73744. * @returns true if fog must be enabled
  73745. */
  73746. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73747. /**
  73748. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73749. * @param mesh defines the current mesh
  73750. * @param scene defines the current scene
  73751. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73752. * @param pointsCloud defines if point cloud rendering has to be turned on
  73753. * @param fogEnabled defines if fog has to be turned on
  73754. * @param alphaTest defines if alpha testing has to be turned on
  73755. * @param defines defines the current list of defines
  73756. */
  73757. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73758. /**
  73759. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73760. * @param scene defines the current scene
  73761. * @param engine defines the current engine
  73762. * @param defines specifies the list of active defines
  73763. * @param useInstances defines if instances have to be turned on
  73764. * @param useClipPlane defines if clip plane have to be turned on
  73765. */
  73766. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73767. /**
  73768. * Prepares the defines for bones
  73769. * @param mesh The mesh containing the geometry data we will draw
  73770. * @param defines The defines to update
  73771. */
  73772. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73773. /**
  73774. * Prepares the defines for morph targets
  73775. * @param mesh The mesh containing the geometry data we will draw
  73776. * @param defines The defines to update
  73777. */
  73778. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73779. /**
  73780. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73781. * @param mesh The mesh containing the geometry data we will draw
  73782. * @param defines The defines to update
  73783. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73784. * @param useBones Precise whether bones should be used or not (override mesh info)
  73785. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73786. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73787. * @returns false if defines are considered not dirty and have not been checked
  73788. */
  73789. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73790. /**
  73791. * Prepares the defines related to multiview
  73792. * @param scene The scene we are intending to draw
  73793. * @param defines The defines to update
  73794. */
  73795. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73796. /**
  73797. * Prepares the defines related to the light information passed in parameter
  73798. * @param scene The scene we are intending to draw
  73799. * @param mesh The mesh the effect is compiling for
  73800. * @param light The light the effect is compiling for
  73801. * @param lightIndex The index of the light
  73802. * @param defines The defines to update
  73803. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73804. * @param state Defines the current state regarding what is needed (normals, etc...)
  73805. */
  73806. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  73807. needNormals: boolean;
  73808. needRebuild: boolean;
  73809. shadowEnabled: boolean;
  73810. specularEnabled: boolean;
  73811. lightmapMode: boolean;
  73812. }): void;
  73813. /**
  73814. * Prepares the defines related to the light information passed in parameter
  73815. * @param scene The scene we are intending to draw
  73816. * @param mesh The mesh the effect is compiling for
  73817. * @param defines The defines to update
  73818. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73819. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73820. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73821. * @returns true if normals will be required for the rest of the effect
  73822. */
  73823. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73824. /**
  73825. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  73826. * @param lightIndex defines the light index
  73827. * @param uniformsList The uniform list
  73828. * @param samplersList The sampler list
  73829. * @param projectedLightTexture defines if projected texture must be used
  73830. * @param uniformBuffersList defines an optional list of uniform buffers
  73831. */
  73832. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  73833. /**
  73834. * Prepares the uniforms and samplers list to be used in the effect
  73835. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73836. * @param samplersList The sampler list
  73837. * @param defines The defines helping in the list generation
  73838. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73839. */
  73840. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73841. /**
  73842. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73843. * @param defines The defines to update while falling back
  73844. * @param fallbacks The authorized effect fallbacks
  73845. * @param maxSimultaneousLights The maximum number of lights allowed
  73846. * @param rank the current rank of the Effect
  73847. * @returns The newly affected rank
  73848. */
  73849. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  73850. private static _TmpMorphInfluencers;
  73851. /**
  73852. * Prepares the list of attributes required for morph targets according to the effect defines.
  73853. * @param attribs The current list of supported attribs
  73854. * @param mesh The mesh to prepare the morph targets attributes for
  73855. * @param influencers The number of influencers
  73856. */
  73857. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  73858. /**
  73859. * Prepares the list of attributes required for morph targets according to the effect defines.
  73860. * @param attribs The current list of supported attribs
  73861. * @param mesh The mesh to prepare the morph targets attributes for
  73862. * @param defines The current Defines of the effect
  73863. */
  73864. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  73865. /**
  73866. * Prepares the list of attributes required for bones according to the effect defines.
  73867. * @param attribs The current list of supported attribs
  73868. * @param mesh The mesh to prepare the bones attributes for
  73869. * @param defines The current Defines of the effect
  73870. * @param fallbacks The current efffect fallback strategy
  73871. */
  73872. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  73873. /**
  73874. * Check and prepare the list of attributes required for instances according to the effect defines.
  73875. * @param attribs The current list of supported attribs
  73876. * @param defines The current MaterialDefines of the effect
  73877. */
  73878. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  73879. /**
  73880. * Add the list of attributes required for instances to the attribs array.
  73881. * @param attribs The current list of supported attribs
  73882. */
  73883. static PushAttributesForInstances(attribs: string[]): void;
  73884. /**
  73885. * Binds the light shadow information to the effect for the given mesh.
  73886. * @param light The light containing the generator
  73887. * @param scene The scene the lights belongs to
  73888. * @param mesh The mesh we are binding the information to render
  73889. * @param lightIndex The light index in the effect used to render the mesh
  73890. * @param effect The effect we are binding the data to
  73891. */
  73892. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  73893. /**
  73894. * Binds the light information to the effect.
  73895. * @param light The light containing the generator
  73896. * @param effect The effect we are binding the data to
  73897. * @param lightIndex The light index in the effect used to render
  73898. */
  73899. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  73900. /**
  73901. * Binds the lights information from the scene to the effect for the given mesh.
  73902. * @param light Light to bind
  73903. * @param lightIndex Light index
  73904. * @param scene The scene where the light belongs to
  73905. * @param mesh The mesh we are binding the information to render
  73906. * @param effect The effect we are binding the data to
  73907. * @param useSpecular Defines if specular is supported
  73908. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73909. */
  73910. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  73911. /**
  73912. * Binds the lights information from the scene to the effect for the given mesh.
  73913. * @param scene The scene the lights belongs to
  73914. * @param mesh The mesh we are binding the information to render
  73915. * @param effect The effect we are binding the data to
  73916. * @param defines The generated defines for the effect
  73917. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  73918. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73919. */
  73920. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  73921. private static _tempFogColor;
  73922. /**
  73923. * Binds the fog information from the scene to the effect for the given mesh.
  73924. * @param scene The scene the lights belongs to
  73925. * @param mesh The mesh we are binding the information to render
  73926. * @param effect The effect we are binding the data to
  73927. * @param linearSpace Defines if the fog effect is applied in linear space
  73928. */
  73929. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  73930. /**
  73931. * Binds the bones information from the mesh to the effect.
  73932. * @param mesh The mesh we are binding the information to render
  73933. * @param effect The effect we are binding the data to
  73934. */
  73935. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  73936. /**
  73937. * Binds the morph targets information from the mesh to the effect.
  73938. * @param abstractMesh The mesh we are binding the information to render
  73939. * @param effect The effect we are binding the data to
  73940. */
  73941. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  73942. /**
  73943. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  73944. * @param defines The generated defines used in the effect
  73945. * @param effect The effect we are binding the data to
  73946. * @param scene The scene we are willing to render with logarithmic scale for
  73947. */
  73948. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  73949. /**
  73950. * Binds the clip plane information from the scene to the effect.
  73951. * @param scene The scene the clip plane information are extracted from
  73952. * @param effect The effect we are binding the data to
  73953. */
  73954. static BindClipPlane(effect: Effect, scene: Scene): void;
  73955. }
  73956. }
  73957. declare module BABYLON {
  73958. /** @hidden */
  73959. export var packingFunctions: {
  73960. name: string;
  73961. shader: string;
  73962. };
  73963. }
  73964. declare module BABYLON {
  73965. /** @hidden */
  73966. export var shadowMapPixelShader: {
  73967. name: string;
  73968. shader: string;
  73969. };
  73970. }
  73971. declare module BABYLON {
  73972. /** @hidden */
  73973. export var bonesDeclaration: {
  73974. name: string;
  73975. shader: string;
  73976. };
  73977. }
  73978. declare module BABYLON {
  73979. /** @hidden */
  73980. export var morphTargetsVertexGlobalDeclaration: {
  73981. name: string;
  73982. shader: string;
  73983. };
  73984. }
  73985. declare module BABYLON {
  73986. /** @hidden */
  73987. export var morphTargetsVertexDeclaration: {
  73988. name: string;
  73989. shader: string;
  73990. };
  73991. }
  73992. declare module BABYLON {
  73993. /** @hidden */
  73994. export var instancesDeclaration: {
  73995. name: string;
  73996. shader: string;
  73997. };
  73998. }
  73999. declare module BABYLON {
  74000. /** @hidden */
  74001. export var helperFunctions: {
  74002. name: string;
  74003. shader: string;
  74004. };
  74005. }
  74006. declare module BABYLON {
  74007. /** @hidden */
  74008. export var morphTargetsVertex: {
  74009. name: string;
  74010. shader: string;
  74011. };
  74012. }
  74013. declare module BABYLON {
  74014. /** @hidden */
  74015. export var instancesVertex: {
  74016. name: string;
  74017. shader: string;
  74018. };
  74019. }
  74020. declare module BABYLON {
  74021. /** @hidden */
  74022. export var bonesVertex: {
  74023. name: string;
  74024. shader: string;
  74025. };
  74026. }
  74027. declare module BABYLON {
  74028. /** @hidden */
  74029. export var shadowMapVertexShader: {
  74030. name: string;
  74031. shader: string;
  74032. };
  74033. }
  74034. declare module BABYLON {
  74035. /** @hidden */
  74036. export var depthBoxBlurPixelShader: {
  74037. name: string;
  74038. shader: string;
  74039. };
  74040. }
  74041. declare module BABYLON {
  74042. /**
  74043. * Defines the options associated with the creation of a custom shader for a shadow generator.
  74044. */
  74045. export interface ICustomShaderOptions {
  74046. /**
  74047. * Gets or sets the custom shader name to use
  74048. */
  74049. shaderName: string;
  74050. /**
  74051. * The list of attribute names used in the shader
  74052. */
  74053. attributes?: string[];
  74054. /**
  74055. * The list of unifrom names used in the shader
  74056. */
  74057. uniforms?: string[];
  74058. /**
  74059. * The list of sampler names used in the shader
  74060. */
  74061. samplers?: string[];
  74062. /**
  74063. * The list of defines used in the shader
  74064. */
  74065. defines?: string[];
  74066. }
  74067. /**
  74068. * Interface to implement to create a shadow generator compatible with BJS.
  74069. */
  74070. export interface IShadowGenerator {
  74071. /**
  74072. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74073. * @returns The render target texture if present otherwise, null
  74074. */
  74075. getShadowMap(): Nullable<RenderTargetTexture>;
  74076. /**
  74077. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74078. * @returns The render target texture if the shadow map is present otherwise, null
  74079. */
  74080. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74081. /**
  74082. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74083. * @param subMesh The submesh we want to render in the shadow map
  74084. * @param useInstances Defines wether will draw in the map using instances
  74085. * @returns true if ready otherwise, false
  74086. */
  74087. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74088. /**
  74089. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74090. * @param defines Defines of the material we want to update
  74091. * @param lightIndex Index of the light in the enabled light list of the material
  74092. */
  74093. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  74094. /**
  74095. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74096. * defined in the generator but impacting the effect).
  74097. * It implies the unifroms available on the materials are the standard BJS ones.
  74098. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74099. * @param effect The effect we are binfing the information for
  74100. */
  74101. bindShadowLight(lightIndex: string, effect: Effect): void;
  74102. /**
  74103. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74104. * (eq to shadow prjection matrix * light transform matrix)
  74105. * @returns The transform matrix used to create the shadow map
  74106. */
  74107. getTransformMatrix(): Matrix;
  74108. /**
  74109. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74110. * Cube and 2D textures for instance.
  74111. */
  74112. recreateShadowMap(): void;
  74113. /**
  74114. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74115. * @param onCompiled Callback triggered at the and of the effects compilation
  74116. * @param options Sets of optional options forcing the compilation with different modes
  74117. */
  74118. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74119. useInstances: boolean;
  74120. }>): void;
  74121. /**
  74122. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74123. * @param options Sets of optional options forcing the compilation with different modes
  74124. * @returns A promise that resolves when the compilation completes
  74125. */
  74126. forceCompilationAsync(options?: Partial<{
  74127. useInstances: boolean;
  74128. }>): Promise<void>;
  74129. /**
  74130. * Serializes the shadow generator setup to a json object.
  74131. * @returns The serialized JSON object
  74132. */
  74133. serialize(): any;
  74134. /**
  74135. * Disposes the Shadow map and related Textures and effects.
  74136. */
  74137. dispose(): void;
  74138. }
  74139. /**
  74140. * Default implementation IShadowGenerator.
  74141. * This is the main object responsible of generating shadows in the framework.
  74142. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  74143. */
  74144. export class ShadowGenerator implements IShadowGenerator {
  74145. /**
  74146. * Shadow generator mode None: no filtering applied.
  74147. */
  74148. static readonly FILTER_NONE: number;
  74149. /**
  74150. * Shadow generator mode ESM: Exponential Shadow Mapping.
  74151. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74152. */
  74153. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  74154. /**
  74155. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  74156. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  74157. */
  74158. static readonly FILTER_POISSONSAMPLING: number;
  74159. /**
  74160. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  74161. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74162. */
  74163. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  74164. /**
  74165. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  74166. * edge artifacts on steep falloff.
  74167. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74168. */
  74169. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  74170. /**
  74171. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  74172. * edge artifacts on steep falloff.
  74173. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74174. */
  74175. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  74176. /**
  74177. * Shadow generator mode PCF: Percentage Closer Filtering
  74178. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74179. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  74180. */
  74181. static readonly FILTER_PCF: number;
  74182. /**
  74183. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  74184. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74185. * Contact Hardening
  74186. */
  74187. static readonly FILTER_PCSS: number;
  74188. /**
  74189. * Reserved for PCF and PCSS
  74190. * Highest Quality.
  74191. *
  74192. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  74193. *
  74194. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  74195. */
  74196. static readonly QUALITY_HIGH: number;
  74197. /**
  74198. * Reserved for PCF and PCSS
  74199. * Good tradeoff for quality/perf cross devices
  74200. *
  74201. * Execute PCF on a 3*3 kernel.
  74202. *
  74203. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  74204. */
  74205. static readonly QUALITY_MEDIUM: number;
  74206. /**
  74207. * Reserved for PCF and PCSS
  74208. * The lowest quality but the fastest.
  74209. *
  74210. * Execute PCF on a 1*1 kernel.
  74211. *
  74212. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  74213. */
  74214. static readonly QUALITY_LOW: number;
  74215. /** Gets or sets the custom shader name to use */
  74216. customShaderOptions: ICustomShaderOptions;
  74217. /**
  74218. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  74219. */
  74220. onBeforeShadowMapRenderObservable: Observable<Effect>;
  74221. /**
  74222. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  74223. */
  74224. onAfterShadowMapRenderObservable: Observable<Effect>;
  74225. /**
  74226. * Observable triggered before a mesh is rendered in the shadow map.
  74227. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  74228. */
  74229. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  74230. /**
  74231. * Observable triggered after a mesh is rendered in the shadow map.
  74232. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  74233. */
  74234. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  74235. private _bias;
  74236. /**
  74237. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  74238. */
  74239. /**
  74240. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  74241. */
  74242. bias: number;
  74243. private _normalBias;
  74244. /**
  74245. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74246. */
  74247. /**
  74248. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74249. */
  74250. normalBias: number;
  74251. private _blurBoxOffset;
  74252. /**
  74253. * Gets the blur box offset: offset applied during the blur pass.
  74254. * Only useful if useKernelBlur = false
  74255. */
  74256. /**
  74257. * Sets the blur box offset: offset applied during the blur pass.
  74258. * Only useful if useKernelBlur = false
  74259. */
  74260. blurBoxOffset: number;
  74261. private _blurScale;
  74262. /**
  74263. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  74264. * 2 means half of the size.
  74265. */
  74266. /**
  74267. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  74268. * 2 means half of the size.
  74269. */
  74270. blurScale: number;
  74271. private _blurKernel;
  74272. /**
  74273. * Gets the blur kernel: kernel size of the blur pass.
  74274. * Only useful if useKernelBlur = true
  74275. */
  74276. /**
  74277. * Sets the blur kernel: kernel size of the blur pass.
  74278. * Only useful if useKernelBlur = true
  74279. */
  74280. blurKernel: number;
  74281. private _useKernelBlur;
  74282. /**
  74283. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  74284. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74285. */
  74286. /**
  74287. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  74288. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74289. */
  74290. useKernelBlur: boolean;
  74291. private _depthScale;
  74292. /**
  74293. * Gets the depth scale used in ESM mode.
  74294. */
  74295. /**
  74296. * Sets the depth scale used in ESM mode.
  74297. * This can override the scale stored on the light.
  74298. */
  74299. depthScale: number;
  74300. private _filter;
  74301. /**
  74302. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  74303. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74304. */
  74305. /**
  74306. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  74307. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74308. */
  74309. filter: number;
  74310. /**
  74311. * Gets if the current filter is set to Poisson Sampling.
  74312. */
  74313. /**
  74314. * Sets the current filter to Poisson Sampling.
  74315. */
  74316. usePoissonSampling: boolean;
  74317. /**
  74318. * Gets if the current filter is set to ESM.
  74319. */
  74320. /**
  74321. * Sets the current filter is to ESM.
  74322. */
  74323. useExponentialShadowMap: boolean;
  74324. /**
  74325. * Gets if the current filter is set to filtered ESM.
  74326. */
  74327. /**
  74328. * Gets if the current filter is set to filtered ESM.
  74329. */
  74330. useBlurExponentialShadowMap: boolean;
  74331. /**
  74332. * Gets if the current filter is set to "close ESM" (using the inverse of the
  74333. * exponential to prevent steep falloff artifacts).
  74334. */
  74335. /**
  74336. * Sets the current filter to "close ESM" (using the inverse of the
  74337. * exponential to prevent steep falloff artifacts).
  74338. */
  74339. useCloseExponentialShadowMap: boolean;
  74340. /**
  74341. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  74342. * exponential to prevent steep falloff artifacts).
  74343. */
  74344. /**
  74345. * Sets the current filter to filtered "close ESM" (using the inverse of the
  74346. * exponential to prevent steep falloff artifacts).
  74347. */
  74348. useBlurCloseExponentialShadowMap: boolean;
  74349. /**
  74350. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  74351. */
  74352. /**
  74353. * Sets the current filter to "PCF" (percentage closer filtering).
  74354. */
  74355. usePercentageCloserFiltering: boolean;
  74356. private _filteringQuality;
  74357. /**
  74358. * Gets the PCF or PCSS Quality.
  74359. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74360. */
  74361. /**
  74362. * Sets the PCF or PCSS Quality.
  74363. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74364. */
  74365. filteringQuality: number;
  74366. /**
  74367. * Gets if the current filter is set to "PCSS" (contact hardening).
  74368. */
  74369. /**
  74370. * Sets the current filter to "PCSS" (contact hardening).
  74371. */
  74372. useContactHardeningShadow: boolean;
  74373. private _contactHardeningLightSizeUVRatio;
  74374. /**
  74375. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74376. * Using a ratio helps keeping shape stability independently of the map size.
  74377. *
  74378. * It does not account for the light projection as it was having too much
  74379. * instability during the light setup or during light position changes.
  74380. *
  74381. * Only valid if useContactHardeningShadow is true.
  74382. */
  74383. /**
  74384. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74385. * Using a ratio helps keeping shape stability independently of the map size.
  74386. *
  74387. * It does not account for the light projection as it was having too much
  74388. * instability during the light setup or during light position changes.
  74389. *
  74390. * Only valid if useContactHardeningShadow is true.
  74391. */
  74392. contactHardeningLightSizeUVRatio: number;
  74393. private _darkness;
  74394. /** Gets or sets the actual darkness of a shadow */
  74395. darkness: number;
  74396. /**
  74397. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  74398. * 0 means strongest and 1 would means no shadow.
  74399. * @returns the darkness.
  74400. */
  74401. getDarkness(): number;
  74402. /**
  74403. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  74404. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  74405. * @returns the shadow generator allowing fluent coding.
  74406. */
  74407. setDarkness(darkness: number): ShadowGenerator;
  74408. private _transparencyShadow;
  74409. /** Gets or sets the ability to have transparent shadow */
  74410. transparencyShadow: boolean;
  74411. /**
  74412. * Sets the ability to have transparent shadow (boolean).
  74413. * @param transparent True if transparent else False
  74414. * @returns the shadow generator allowing fluent coding
  74415. */
  74416. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  74417. private _shadowMap;
  74418. private _shadowMap2;
  74419. /**
  74420. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74421. * @returns The render target texture if present otherwise, null
  74422. */
  74423. getShadowMap(): Nullable<RenderTargetTexture>;
  74424. /**
  74425. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74426. * @returns The render target texture if the shadow map is present otherwise, null
  74427. */
  74428. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74429. /**
  74430. * Gets the class name of that object
  74431. * @returns "ShadowGenerator"
  74432. */
  74433. getClassName(): string;
  74434. /**
  74435. * Helper function to add a mesh and its descendants to the list of shadow casters.
  74436. * @param mesh Mesh to add
  74437. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  74438. * @returns the Shadow Generator itself
  74439. */
  74440. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74441. /**
  74442. * Helper function to remove a mesh and its descendants from the list of shadow casters
  74443. * @param mesh Mesh to remove
  74444. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  74445. * @returns the Shadow Generator itself
  74446. */
  74447. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74448. /**
  74449. * Controls the extent to which the shadows fade out at the edge of the frustum
  74450. * Used only by directionals and spots
  74451. */
  74452. frustumEdgeFalloff: number;
  74453. private _light;
  74454. /**
  74455. * Returns the associated light object.
  74456. * @returns the light generating the shadow
  74457. */
  74458. getLight(): IShadowLight;
  74459. /**
  74460. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  74461. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  74462. * It might on the other hand introduce peter panning.
  74463. */
  74464. forceBackFacesOnly: boolean;
  74465. private _scene;
  74466. private _lightDirection;
  74467. private _effect;
  74468. private _viewMatrix;
  74469. private _projectionMatrix;
  74470. private _transformMatrix;
  74471. private _cachedPosition;
  74472. private _cachedDirection;
  74473. private _cachedDefines;
  74474. private _currentRenderID;
  74475. private _boxBlurPostprocess;
  74476. private _kernelBlurXPostprocess;
  74477. private _kernelBlurYPostprocess;
  74478. private _blurPostProcesses;
  74479. private _mapSize;
  74480. private _currentFaceIndex;
  74481. private _currentFaceIndexCache;
  74482. private _textureType;
  74483. private _defaultTextureMatrix;
  74484. /** @hidden */
  74485. static _SceneComponentInitialization: (scene: Scene) => void;
  74486. /**
  74487. * Creates a ShadowGenerator object.
  74488. * A ShadowGenerator is the required tool to use the shadows.
  74489. * Each light casting shadows needs to use its own ShadowGenerator.
  74490. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  74491. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  74492. * @param light The light object generating the shadows.
  74493. * @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.
  74494. */
  74495. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  74496. private _initializeGenerator;
  74497. private _initializeShadowMap;
  74498. private _initializeBlurRTTAndPostProcesses;
  74499. private _renderForShadowMap;
  74500. private _renderSubMeshForShadowMap;
  74501. private _applyFilterValues;
  74502. /**
  74503. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74504. * @param onCompiled Callback triggered at the and of the effects compilation
  74505. * @param options Sets of optional options forcing the compilation with different modes
  74506. */
  74507. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74508. useInstances: boolean;
  74509. }>): void;
  74510. /**
  74511. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74512. * @param options Sets of optional options forcing the compilation with different modes
  74513. * @returns A promise that resolves when the compilation completes
  74514. */
  74515. forceCompilationAsync(options?: Partial<{
  74516. useInstances: boolean;
  74517. }>): Promise<void>;
  74518. /**
  74519. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74520. * @param subMesh The submesh we want to render in the shadow map
  74521. * @param useInstances Defines wether will draw in the map using instances
  74522. * @returns true if ready otherwise, false
  74523. */
  74524. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74525. /**
  74526. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74527. * @param defines Defines of the material we want to update
  74528. * @param lightIndex Index of the light in the enabled light list of the material
  74529. */
  74530. prepareDefines(defines: any, lightIndex: number): void;
  74531. /**
  74532. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74533. * defined in the generator but impacting the effect).
  74534. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74535. * @param effect The effect we are binfing the information for
  74536. */
  74537. bindShadowLight(lightIndex: string, effect: Effect): void;
  74538. /**
  74539. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74540. * (eq to shadow prjection matrix * light transform matrix)
  74541. * @returns The transform matrix used to create the shadow map
  74542. */
  74543. getTransformMatrix(): Matrix;
  74544. /**
  74545. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74546. * Cube and 2D textures for instance.
  74547. */
  74548. recreateShadowMap(): void;
  74549. private _disposeBlurPostProcesses;
  74550. private _disposeRTTandPostProcesses;
  74551. /**
  74552. * Disposes the ShadowGenerator.
  74553. * Returns nothing.
  74554. */
  74555. dispose(): void;
  74556. /**
  74557. * Serializes the shadow generator setup to a json object.
  74558. * @returns The serialized JSON object
  74559. */
  74560. serialize(): any;
  74561. /**
  74562. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  74563. * @param parsedShadowGenerator The JSON object to parse
  74564. * @param scene The scene to create the shadow map for
  74565. * @returns The parsed shadow generator
  74566. */
  74567. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  74568. }
  74569. }
  74570. declare module BABYLON {
  74571. /**
  74572. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  74573. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  74574. * 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.
  74575. */
  74576. export abstract class Light extends Node {
  74577. /**
  74578. * Falloff Default: light is falling off following the material specification:
  74579. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  74580. */
  74581. static readonly FALLOFF_DEFAULT: number;
  74582. /**
  74583. * Falloff Physical: light is falling off following the inverse squared distance law.
  74584. */
  74585. static readonly FALLOFF_PHYSICAL: number;
  74586. /**
  74587. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  74588. * to enhance interoperability with other engines.
  74589. */
  74590. static readonly FALLOFF_GLTF: number;
  74591. /**
  74592. * Falloff Standard: light is falling off like in the standard material
  74593. * to enhance interoperability with other materials.
  74594. */
  74595. static readonly FALLOFF_STANDARD: number;
  74596. /**
  74597. * If every light affecting the material is in this lightmapMode,
  74598. * material.lightmapTexture adds or multiplies
  74599. * (depends on material.useLightmapAsShadowmap)
  74600. * after every other light calculations.
  74601. */
  74602. static readonly LIGHTMAP_DEFAULT: number;
  74603. /**
  74604. * material.lightmapTexture as only diffuse lighting from this light
  74605. * adds only specular lighting from this light
  74606. * adds dynamic shadows
  74607. */
  74608. static readonly LIGHTMAP_SPECULAR: number;
  74609. /**
  74610. * material.lightmapTexture as only lighting
  74611. * no light calculation from this light
  74612. * only adds dynamic shadows from this light
  74613. */
  74614. static readonly LIGHTMAP_SHADOWSONLY: number;
  74615. /**
  74616. * Each light type uses the default quantity according to its type:
  74617. * point/spot lights use luminous intensity
  74618. * directional lights use illuminance
  74619. */
  74620. static readonly INTENSITYMODE_AUTOMATIC: number;
  74621. /**
  74622. * lumen (lm)
  74623. */
  74624. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  74625. /**
  74626. * candela (lm/sr)
  74627. */
  74628. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  74629. /**
  74630. * lux (lm/m^2)
  74631. */
  74632. static readonly INTENSITYMODE_ILLUMINANCE: number;
  74633. /**
  74634. * nit (cd/m^2)
  74635. */
  74636. static readonly INTENSITYMODE_LUMINANCE: number;
  74637. /**
  74638. * Light type const id of the point light.
  74639. */
  74640. static readonly LIGHTTYPEID_POINTLIGHT: number;
  74641. /**
  74642. * Light type const id of the directional light.
  74643. */
  74644. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  74645. /**
  74646. * Light type const id of the spot light.
  74647. */
  74648. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  74649. /**
  74650. * Light type const id of the hemispheric light.
  74651. */
  74652. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  74653. /**
  74654. * Diffuse gives the basic color to an object.
  74655. */
  74656. diffuse: Color3;
  74657. /**
  74658. * Specular produces a highlight color on an object.
  74659. * Note: This is note affecting PBR materials.
  74660. */
  74661. specular: Color3;
  74662. /**
  74663. * Defines the falloff type for this light. This lets overrriding how punctual light are
  74664. * falling off base on range or angle.
  74665. * This can be set to any values in Light.FALLOFF_x.
  74666. *
  74667. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  74668. * other types of materials.
  74669. */
  74670. falloffType: number;
  74671. /**
  74672. * Strength of the light.
  74673. * Note: By default it is define in the framework own unit.
  74674. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  74675. */
  74676. intensity: number;
  74677. private _range;
  74678. protected _inverseSquaredRange: number;
  74679. /**
  74680. * Defines how far from the source the light is impacting in scene units.
  74681. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74682. */
  74683. /**
  74684. * Defines how far from the source the light is impacting in scene units.
  74685. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74686. */
  74687. range: number;
  74688. /**
  74689. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  74690. * of light.
  74691. */
  74692. private _photometricScale;
  74693. private _intensityMode;
  74694. /**
  74695. * Gets the photometric scale used to interpret the intensity.
  74696. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74697. */
  74698. /**
  74699. * Sets the photometric scale used to interpret the intensity.
  74700. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74701. */
  74702. intensityMode: number;
  74703. private _radius;
  74704. /**
  74705. * Gets the light radius used by PBR Materials to simulate soft area lights.
  74706. */
  74707. /**
  74708. * sets the light radius used by PBR Materials to simulate soft area lights.
  74709. */
  74710. radius: number;
  74711. private _renderPriority;
  74712. /**
  74713. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  74714. * exceeding the number allowed of the materials.
  74715. */
  74716. renderPriority: number;
  74717. private _shadowEnabled;
  74718. /**
  74719. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74720. * the current shadow generator.
  74721. */
  74722. /**
  74723. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74724. * the current shadow generator.
  74725. */
  74726. shadowEnabled: boolean;
  74727. private _includedOnlyMeshes;
  74728. /**
  74729. * Gets the only meshes impacted by this light.
  74730. */
  74731. /**
  74732. * Sets the only meshes impacted by this light.
  74733. */
  74734. includedOnlyMeshes: AbstractMesh[];
  74735. private _excludedMeshes;
  74736. /**
  74737. * Gets the meshes not impacted by this light.
  74738. */
  74739. /**
  74740. * Sets the meshes not impacted by this light.
  74741. */
  74742. excludedMeshes: AbstractMesh[];
  74743. private _excludeWithLayerMask;
  74744. /**
  74745. * Gets the layer id use to find what meshes are not impacted by the light.
  74746. * Inactive if 0
  74747. */
  74748. /**
  74749. * Sets the layer id use to find what meshes are not impacted by the light.
  74750. * Inactive if 0
  74751. */
  74752. excludeWithLayerMask: number;
  74753. private _includeOnlyWithLayerMask;
  74754. /**
  74755. * Gets the layer id use to find what meshes are impacted by the light.
  74756. * Inactive if 0
  74757. */
  74758. /**
  74759. * Sets the layer id use to find what meshes are impacted by the light.
  74760. * Inactive if 0
  74761. */
  74762. includeOnlyWithLayerMask: number;
  74763. private _lightmapMode;
  74764. /**
  74765. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74766. */
  74767. /**
  74768. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74769. */
  74770. lightmapMode: number;
  74771. /**
  74772. * Shadow generator associted to the light.
  74773. * @hidden Internal use only.
  74774. */
  74775. _shadowGenerator: Nullable<IShadowGenerator>;
  74776. /**
  74777. * @hidden Internal use only.
  74778. */
  74779. _excludedMeshesIds: string[];
  74780. /**
  74781. * @hidden Internal use only.
  74782. */
  74783. _includedOnlyMeshesIds: string[];
  74784. /**
  74785. * The current light unifom buffer.
  74786. * @hidden Internal use only.
  74787. */
  74788. _uniformBuffer: UniformBuffer;
  74789. /**
  74790. * Creates a Light object in the scene.
  74791. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74792. * @param name The firendly name of the light
  74793. * @param scene The scene the light belongs too
  74794. */
  74795. constructor(name: string, scene: Scene);
  74796. protected abstract _buildUniformLayout(): void;
  74797. /**
  74798. * Sets the passed Effect "effect" with the Light information.
  74799. * @param effect The effect to update
  74800. * @param lightIndex The index of the light in the effect to update
  74801. * @returns The light
  74802. */
  74803. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74804. /**
  74805. * Returns the string "Light".
  74806. * @returns the class name
  74807. */
  74808. getClassName(): string;
  74809. /** @hidden */
  74810. readonly _isLight: boolean;
  74811. /**
  74812. * Converts the light information to a readable string for debug purpose.
  74813. * @param fullDetails Supports for multiple levels of logging within scene loading
  74814. * @returns the human readable light info
  74815. */
  74816. toString(fullDetails?: boolean): string;
  74817. /** @hidden */
  74818. protected _syncParentEnabledState(): void;
  74819. /**
  74820. * Set the enabled state of this node.
  74821. * @param value - the new enabled state
  74822. */
  74823. setEnabled(value: boolean): void;
  74824. /**
  74825. * Returns the Light associated shadow generator if any.
  74826. * @return the associated shadow generator.
  74827. */
  74828. getShadowGenerator(): Nullable<IShadowGenerator>;
  74829. /**
  74830. * Returns a Vector3, the absolute light position in the World.
  74831. * @returns the world space position of the light
  74832. */
  74833. getAbsolutePosition(): Vector3;
  74834. /**
  74835. * Specifies if the light will affect the passed mesh.
  74836. * @param mesh The mesh to test against the light
  74837. * @return true the mesh is affected otherwise, false.
  74838. */
  74839. canAffectMesh(mesh: AbstractMesh): boolean;
  74840. /**
  74841. * Sort function to order lights for rendering.
  74842. * @param a First Light object to compare to second.
  74843. * @param b Second Light object to compare first.
  74844. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74845. */
  74846. static CompareLightsPriority(a: Light, b: Light): number;
  74847. /**
  74848. * Releases resources associated with this node.
  74849. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74850. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74851. */
  74852. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74853. /**
  74854. * Returns the light type ID (integer).
  74855. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  74856. */
  74857. getTypeID(): number;
  74858. /**
  74859. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  74860. * @returns the scaled intensity in intensity mode unit
  74861. */
  74862. getScaledIntensity(): number;
  74863. /**
  74864. * Returns a new Light object, named "name", from the current one.
  74865. * @param name The name of the cloned light
  74866. * @returns the new created light
  74867. */
  74868. clone(name: string): Nullable<Light>;
  74869. /**
  74870. * Serializes the current light into a Serialization object.
  74871. * @returns the serialized object.
  74872. */
  74873. serialize(): any;
  74874. /**
  74875. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  74876. * This new light is named "name" and added to the passed scene.
  74877. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  74878. * @param name The friendly name of the light
  74879. * @param scene The scene the new light will belong to
  74880. * @returns the constructor function
  74881. */
  74882. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  74883. /**
  74884. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  74885. * @param parsedLight The JSON representation of the light
  74886. * @param scene The scene to create the parsed light in
  74887. * @returns the created light after parsing
  74888. */
  74889. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  74890. private _hookArrayForExcluded;
  74891. private _hookArrayForIncludedOnly;
  74892. private _resyncMeshes;
  74893. /**
  74894. * Forces the meshes to update their light related information in their rendering used effects
  74895. * @hidden Internal Use Only
  74896. */
  74897. _markMeshesAsLightDirty(): void;
  74898. /**
  74899. * Recomputes the cached photometric scale if needed.
  74900. */
  74901. private _computePhotometricScale;
  74902. /**
  74903. * Returns the Photometric Scale according to the light type and intensity mode.
  74904. */
  74905. private _getPhotometricScale;
  74906. /**
  74907. * Reorder the light in the scene according to their defined priority.
  74908. * @hidden Internal Use Only
  74909. */
  74910. _reorderLightsInScene(): void;
  74911. /**
  74912. * Prepares the list of defines specific to the light type.
  74913. * @param defines the list of defines
  74914. * @param lightIndex defines the index of the light for the effect
  74915. */
  74916. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  74917. }
  74918. }
  74919. declare module BABYLON {
  74920. /**
  74921. * Creates an instance based on a source mesh.
  74922. */
  74923. export class InstancedMesh extends AbstractMesh {
  74924. private _sourceMesh;
  74925. private _currentLOD;
  74926. /** @hidden */
  74927. _indexInSourceMeshInstanceArray: number;
  74928. constructor(name: string, source: Mesh);
  74929. /**
  74930. * Returns the string "InstancedMesh".
  74931. */
  74932. getClassName(): string;
  74933. /** Gets the list of lights affecting that mesh */
  74934. readonly lightSources: Light[];
  74935. _resyncLightSources(): void;
  74936. _resyncLighSource(light: Light): void;
  74937. _removeLightSource(light: Light): void;
  74938. /**
  74939. * If the source mesh receives shadows
  74940. */
  74941. readonly receiveShadows: boolean;
  74942. /**
  74943. * The material of the source mesh
  74944. */
  74945. readonly material: Nullable<Material>;
  74946. /**
  74947. * Visibility of the source mesh
  74948. */
  74949. readonly visibility: number;
  74950. /**
  74951. * Skeleton of the source mesh
  74952. */
  74953. readonly skeleton: Nullable<Skeleton>;
  74954. /**
  74955. * Rendering ground id of the source mesh
  74956. */
  74957. renderingGroupId: number;
  74958. /**
  74959. * Returns the total number of vertices (integer).
  74960. */
  74961. getTotalVertices(): number;
  74962. /**
  74963. * Returns a positive integer : the total number of indices in this mesh geometry.
  74964. * @returns the numner of indices or zero if the mesh has no geometry.
  74965. */
  74966. getTotalIndices(): number;
  74967. /**
  74968. * The source mesh of the instance
  74969. */
  74970. readonly sourceMesh: Mesh;
  74971. /**
  74972. * Is this node ready to be used/rendered
  74973. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  74974. * @return {boolean} is it ready
  74975. */
  74976. isReady(completeCheck?: boolean): boolean;
  74977. /**
  74978. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  74979. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  74980. * @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.
  74981. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  74982. */
  74983. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  74984. /**
  74985. * Sets the vertex data of the mesh geometry for the requested `kind`.
  74986. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  74987. * The `data` are either a numeric array either a Float32Array.
  74988. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  74989. * 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).
  74990. * Note that a new underlying VertexBuffer object is created each call.
  74991. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  74992. *
  74993. * Possible `kind` values :
  74994. * - VertexBuffer.PositionKind
  74995. * - VertexBuffer.UVKind
  74996. * - VertexBuffer.UV2Kind
  74997. * - VertexBuffer.UV3Kind
  74998. * - VertexBuffer.UV4Kind
  74999. * - VertexBuffer.UV5Kind
  75000. * - VertexBuffer.UV6Kind
  75001. * - VertexBuffer.ColorKind
  75002. * - VertexBuffer.MatricesIndicesKind
  75003. * - VertexBuffer.MatricesIndicesExtraKind
  75004. * - VertexBuffer.MatricesWeightsKind
  75005. * - VertexBuffer.MatricesWeightsExtraKind
  75006. *
  75007. * Returns the Mesh.
  75008. */
  75009. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75010. /**
  75011. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  75012. * If the mesh has no geometry, it is simply returned as it is.
  75013. * The `data` are either a numeric array either a Float32Array.
  75014. * No new underlying VertexBuffer object is created.
  75015. * 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.
  75016. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  75017. *
  75018. * Possible `kind` values :
  75019. * - VertexBuffer.PositionKind
  75020. * - VertexBuffer.UVKind
  75021. * - VertexBuffer.UV2Kind
  75022. * - VertexBuffer.UV3Kind
  75023. * - VertexBuffer.UV4Kind
  75024. * - VertexBuffer.UV5Kind
  75025. * - VertexBuffer.UV6Kind
  75026. * - VertexBuffer.ColorKind
  75027. * - VertexBuffer.MatricesIndicesKind
  75028. * - VertexBuffer.MatricesIndicesExtraKind
  75029. * - VertexBuffer.MatricesWeightsKind
  75030. * - VertexBuffer.MatricesWeightsExtraKind
  75031. *
  75032. * Returns the Mesh.
  75033. */
  75034. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  75035. /**
  75036. * Sets the mesh indices.
  75037. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  75038. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  75039. * This method creates a new index buffer each call.
  75040. * Returns the Mesh.
  75041. */
  75042. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  75043. /**
  75044. * Boolean : True if the mesh owns the requested kind of data.
  75045. */
  75046. isVerticesDataPresent(kind: string): boolean;
  75047. /**
  75048. * Returns an array of indices (IndicesArray).
  75049. */
  75050. getIndices(): Nullable<IndicesArray>;
  75051. readonly _positions: Nullable<Vector3[]>;
  75052. /**
  75053. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75054. * This means the mesh underlying bounding box and sphere are recomputed.
  75055. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75056. * @returns the current mesh
  75057. */
  75058. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  75059. /** @hidden */
  75060. _preActivate(): InstancedMesh;
  75061. /** @hidden */
  75062. _activate(renderId: number, intermediateRendering: boolean): boolean;
  75063. /** @hidden */
  75064. _postActivate(): void;
  75065. getWorldMatrix(): Matrix;
  75066. readonly isAnInstance: boolean;
  75067. /**
  75068. * Returns the current associated LOD AbstractMesh.
  75069. */
  75070. getLOD(camera: Camera): AbstractMesh;
  75071. /** @hidden */
  75072. _syncSubMeshes(): InstancedMesh;
  75073. /** @hidden */
  75074. _generatePointsArray(): boolean;
  75075. /**
  75076. * Creates a new InstancedMesh from the current mesh.
  75077. * - name (string) : the cloned mesh name
  75078. * - newParent (optional Node) : the optional Node to parent the clone to.
  75079. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  75080. *
  75081. * Returns the clone.
  75082. */
  75083. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  75084. /**
  75085. * Disposes the InstancedMesh.
  75086. * Returns nothing.
  75087. */
  75088. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75089. }
  75090. }
  75091. declare module BABYLON {
  75092. /**
  75093. * Defines the options associated with the creation of a shader material.
  75094. */
  75095. export interface IShaderMaterialOptions {
  75096. /**
  75097. * Does the material work in alpha blend mode
  75098. */
  75099. needAlphaBlending: boolean;
  75100. /**
  75101. * Does the material work in alpha test mode
  75102. */
  75103. needAlphaTesting: boolean;
  75104. /**
  75105. * The list of attribute names used in the shader
  75106. */
  75107. attributes: string[];
  75108. /**
  75109. * The list of unifrom names used in the shader
  75110. */
  75111. uniforms: string[];
  75112. /**
  75113. * The list of UBO names used in the shader
  75114. */
  75115. uniformBuffers: string[];
  75116. /**
  75117. * The list of sampler names used in the shader
  75118. */
  75119. samplers: string[];
  75120. /**
  75121. * The list of defines used in the shader
  75122. */
  75123. defines: string[];
  75124. }
  75125. /**
  75126. * 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.
  75127. *
  75128. * This returned material effects how the mesh will look based on the code in the shaders.
  75129. *
  75130. * @see http://doc.babylonjs.com/how_to/shader_material
  75131. */
  75132. export class ShaderMaterial extends Material {
  75133. private _shaderPath;
  75134. private _options;
  75135. private _textures;
  75136. private _textureArrays;
  75137. private _floats;
  75138. private _ints;
  75139. private _floatsArrays;
  75140. private _colors3;
  75141. private _colors3Arrays;
  75142. private _colors4;
  75143. private _colors4Arrays;
  75144. private _vectors2;
  75145. private _vectors3;
  75146. private _vectors4;
  75147. private _matrices;
  75148. private _matrices3x3;
  75149. private _matrices2x2;
  75150. private _vectors2Arrays;
  75151. private _vectors3Arrays;
  75152. private _vectors4Arrays;
  75153. private _cachedWorldViewMatrix;
  75154. private _cachedWorldViewProjectionMatrix;
  75155. private _renderId;
  75156. /**
  75157. * Instantiate a new shader material.
  75158. * 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.
  75159. * This returned material effects how the mesh will look based on the code in the shaders.
  75160. * @see http://doc.babylonjs.com/how_to/shader_material
  75161. * @param name Define the name of the material in the scene
  75162. * @param scene Define the scene the material belongs to
  75163. * @param shaderPath Defines the route to the shader code in one of three ways:
  75164. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  75165. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  75166. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  75167. * @param options Define the options used to create the shader
  75168. */
  75169. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  75170. /**
  75171. * Gets the options used to compile the shader.
  75172. * They can be modified to trigger a new compilation
  75173. */
  75174. readonly options: IShaderMaterialOptions;
  75175. /**
  75176. * Gets the current class name of the material e.g. "ShaderMaterial"
  75177. * Mainly use in serialization.
  75178. * @returns the class name
  75179. */
  75180. getClassName(): string;
  75181. /**
  75182. * Specifies if the material will require alpha blending
  75183. * @returns a boolean specifying if alpha blending is needed
  75184. */
  75185. needAlphaBlending(): boolean;
  75186. /**
  75187. * Specifies if this material should be rendered in alpha test mode
  75188. * @returns a boolean specifying if an alpha test is needed.
  75189. */
  75190. needAlphaTesting(): boolean;
  75191. private _checkUniform;
  75192. /**
  75193. * Set a texture in the shader.
  75194. * @param name Define the name of the uniform samplers as defined in the shader
  75195. * @param texture Define the texture to bind to this sampler
  75196. * @return the material itself allowing "fluent" like uniform updates
  75197. */
  75198. setTexture(name: string, texture: Texture): ShaderMaterial;
  75199. /**
  75200. * Set a texture array in the shader.
  75201. * @param name Define the name of the uniform sampler array as defined in the shader
  75202. * @param textures Define the list of textures to bind to this sampler
  75203. * @return the material itself allowing "fluent" like uniform updates
  75204. */
  75205. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  75206. /**
  75207. * Set a float in the shader.
  75208. * @param name Define the name of the uniform as defined in the shader
  75209. * @param value Define the value to give to the uniform
  75210. * @return the material itself allowing "fluent" like uniform updates
  75211. */
  75212. setFloat(name: string, value: number): ShaderMaterial;
  75213. /**
  75214. * Set a int in the shader.
  75215. * @param name Define the name of the uniform as defined in the shader
  75216. * @param value Define the value to give to the uniform
  75217. * @return the material itself allowing "fluent" like uniform updates
  75218. */
  75219. setInt(name: string, value: number): ShaderMaterial;
  75220. /**
  75221. * Set an array of floats in the shader.
  75222. * @param name Define the name of the uniform as defined in the shader
  75223. * @param value Define the value to give to the uniform
  75224. * @return the material itself allowing "fluent" like uniform updates
  75225. */
  75226. setFloats(name: string, value: number[]): ShaderMaterial;
  75227. /**
  75228. * Set a vec3 in the shader from a Color3.
  75229. * @param name Define the name of the uniform as defined in the shader
  75230. * @param value Define the value to give to the uniform
  75231. * @return the material itself allowing "fluent" like uniform updates
  75232. */
  75233. setColor3(name: string, value: Color3): ShaderMaterial;
  75234. /**
  75235. * Set a vec3 array in the shader from a Color3 array.
  75236. * @param name Define the name of the uniform as defined in the shader
  75237. * @param value Define the value to give to the uniform
  75238. * @return the material itself allowing "fluent" like uniform updates
  75239. */
  75240. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  75241. /**
  75242. * Set a vec4 in the shader from a Color4.
  75243. * @param name Define the name of the uniform as defined in the shader
  75244. * @param value Define the value to give to the uniform
  75245. * @return the material itself allowing "fluent" like uniform updates
  75246. */
  75247. setColor4(name: string, value: Color4): ShaderMaterial;
  75248. /**
  75249. * Set a vec4 array in the shader from a Color4 array.
  75250. * @param name Define the name of the uniform as defined in the shader
  75251. * @param value Define the value to give to the uniform
  75252. * @return the material itself allowing "fluent" like uniform updates
  75253. */
  75254. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  75255. /**
  75256. * Set a vec2 in the shader from a Vector2.
  75257. * @param name Define the name of the uniform as defined in the shader
  75258. * @param value Define the value to give to the uniform
  75259. * @return the material itself allowing "fluent" like uniform updates
  75260. */
  75261. setVector2(name: string, value: Vector2): ShaderMaterial;
  75262. /**
  75263. * Set a vec3 in the shader from a Vector3.
  75264. * @param name Define the name of the uniform as defined in the shader
  75265. * @param value Define the value to give to the uniform
  75266. * @return the material itself allowing "fluent" like uniform updates
  75267. */
  75268. setVector3(name: string, value: Vector3): ShaderMaterial;
  75269. /**
  75270. * Set a vec4 in the shader from a Vector4.
  75271. * @param name Define the name of the uniform as defined in the shader
  75272. * @param value Define the value to give to the uniform
  75273. * @return the material itself allowing "fluent" like uniform updates
  75274. */
  75275. setVector4(name: string, value: Vector4): ShaderMaterial;
  75276. /**
  75277. * Set a mat4 in the shader from a Matrix.
  75278. * @param name Define the name of the uniform as defined in the shader
  75279. * @param value Define the value to give to the uniform
  75280. * @return the material itself allowing "fluent" like uniform updates
  75281. */
  75282. setMatrix(name: string, value: Matrix): ShaderMaterial;
  75283. /**
  75284. * Set a mat3 in the shader from a Float32Array.
  75285. * @param name Define the name of the uniform as defined in the shader
  75286. * @param value Define the value to give to the uniform
  75287. * @return the material itself allowing "fluent" like uniform updates
  75288. */
  75289. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  75290. /**
  75291. * Set a mat2 in the shader from a Float32Array.
  75292. * @param name Define the name of the uniform as defined in the shader
  75293. * @param value Define the value to give to the uniform
  75294. * @return the material itself allowing "fluent" like uniform updates
  75295. */
  75296. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  75297. /**
  75298. * Set a vec2 array in the shader from a number array.
  75299. * @param name Define the name of the uniform as defined in the shader
  75300. * @param value Define the value to give to the uniform
  75301. * @return the material itself allowing "fluent" like uniform updates
  75302. */
  75303. setArray2(name: string, value: number[]): ShaderMaterial;
  75304. /**
  75305. * Set a vec3 array in the shader from a number array.
  75306. * @param name Define the name of the uniform as defined in the shader
  75307. * @param value Define the value to give to the uniform
  75308. * @return the material itself allowing "fluent" like uniform updates
  75309. */
  75310. setArray3(name: string, value: number[]): ShaderMaterial;
  75311. /**
  75312. * Set a vec4 array in the shader from a number array.
  75313. * @param name Define the name of the uniform as defined in the shader
  75314. * @param value Define the value to give to the uniform
  75315. * @return the material itself allowing "fluent" like uniform updates
  75316. */
  75317. setArray4(name: string, value: number[]): ShaderMaterial;
  75318. private _checkCache;
  75319. /**
  75320. * Specifies that the submesh is ready to be used
  75321. * @param mesh defines the mesh to check
  75322. * @param subMesh defines which submesh to check
  75323. * @param useInstances specifies that instances should be used
  75324. * @returns a boolean indicating that the submesh is ready or not
  75325. */
  75326. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  75327. /**
  75328. * Checks if the material is ready to render the requested mesh
  75329. * @param mesh Define the mesh to render
  75330. * @param useInstances Define whether or not the material is used with instances
  75331. * @returns true if ready, otherwise false
  75332. */
  75333. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  75334. /**
  75335. * Binds the world matrix to the material
  75336. * @param world defines the world transformation matrix
  75337. */
  75338. bindOnlyWorldMatrix(world: Matrix): void;
  75339. /**
  75340. * Binds the material to the mesh
  75341. * @param world defines the world transformation matrix
  75342. * @param mesh defines the mesh to bind the material to
  75343. */
  75344. bind(world: Matrix, mesh?: Mesh): void;
  75345. /**
  75346. * Gets the active textures from the material
  75347. * @returns an array of textures
  75348. */
  75349. getActiveTextures(): BaseTexture[];
  75350. /**
  75351. * Specifies if the material uses a texture
  75352. * @param texture defines the texture to check against the material
  75353. * @returns a boolean specifying if the material uses the texture
  75354. */
  75355. hasTexture(texture: BaseTexture): boolean;
  75356. /**
  75357. * Makes a duplicate of the material, and gives it a new name
  75358. * @param name defines the new name for the duplicated material
  75359. * @returns the cloned material
  75360. */
  75361. clone(name: string): ShaderMaterial;
  75362. /**
  75363. * Disposes the material
  75364. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75365. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75366. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75367. */
  75368. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  75369. /**
  75370. * Serializes this material in a JSON representation
  75371. * @returns the serialized material object
  75372. */
  75373. serialize(): any;
  75374. /**
  75375. * Creates a shader material from parsed shader material data
  75376. * @param source defines the JSON represnetation of the material
  75377. * @param scene defines the hosting scene
  75378. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75379. * @returns a new material
  75380. */
  75381. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  75382. }
  75383. }
  75384. declare module BABYLON {
  75385. /** @hidden */
  75386. export var clipPlaneFragmentDeclaration: {
  75387. name: string;
  75388. shader: string;
  75389. };
  75390. }
  75391. declare module BABYLON {
  75392. /** @hidden */
  75393. export var clipPlaneFragment: {
  75394. name: string;
  75395. shader: string;
  75396. };
  75397. }
  75398. declare module BABYLON {
  75399. /** @hidden */
  75400. export var colorPixelShader: {
  75401. name: string;
  75402. shader: string;
  75403. };
  75404. }
  75405. declare module BABYLON {
  75406. /** @hidden */
  75407. export var clipPlaneVertexDeclaration: {
  75408. name: string;
  75409. shader: string;
  75410. };
  75411. }
  75412. declare module BABYLON {
  75413. /** @hidden */
  75414. export var clipPlaneVertex: {
  75415. name: string;
  75416. shader: string;
  75417. };
  75418. }
  75419. declare module BABYLON {
  75420. /** @hidden */
  75421. export var colorVertexShader: {
  75422. name: string;
  75423. shader: string;
  75424. };
  75425. }
  75426. declare module BABYLON {
  75427. /**
  75428. * Line mesh
  75429. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  75430. */
  75431. export class LinesMesh extends Mesh {
  75432. /**
  75433. * If vertex color should be applied to the mesh
  75434. */
  75435. readonly useVertexColor?: boolean | undefined;
  75436. /**
  75437. * If vertex alpha should be applied to the mesh
  75438. */
  75439. readonly useVertexAlpha?: boolean | undefined;
  75440. /**
  75441. * Color of the line (Default: White)
  75442. */
  75443. color: Color3;
  75444. /**
  75445. * Alpha of the line (Default: 1)
  75446. */
  75447. alpha: number;
  75448. /**
  75449. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75450. * This margin is expressed in world space coordinates, so its value may vary.
  75451. * Default value is 0.1
  75452. */
  75453. intersectionThreshold: number;
  75454. private _colorShader;
  75455. private color4;
  75456. /**
  75457. * Creates a new LinesMesh
  75458. * @param name defines the name
  75459. * @param scene defines the hosting scene
  75460. * @param parent defines the parent mesh if any
  75461. * @param source defines the optional source LinesMesh used to clone data from
  75462. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75463. * When false, achieved by calling a clone(), also passing False.
  75464. * This will make creation of children, recursive.
  75465. * @param useVertexColor defines if this LinesMesh supports vertex color
  75466. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  75467. */
  75468. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  75469. /**
  75470. * If vertex color should be applied to the mesh
  75471. */
  75472. useVertexColor?: boolean | undefined,
  75473. /**
  75474. * If vertex alpha should be applied to the mesh
  75475. */
  75476. useVertexAlpha?: boolean | undefined);
  75477. private _addClipPlaneDefine;
  75478. private _removeClipPlaneDefine;
  75479. isReady(): boolean;
  75480. /**
  75481. * Returns the string "LineMesh"
  75482. */
  75483. getClassName(): string;
  75484. /**
  75485. * @hidden
  75486. */
  75487. /**
  75488. * @hidden
  75489. */
  75490. material: Material;
  75491. /**
  75492. * @hidden
  75493. */
  75494. readonly checkCollisions: boolean;
  75495. /** @hidden */
  75496. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  75497. /** @hidden */
  75498. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  75499. /**
  75500. * Disposes of the line mesh
  75501. * @param doNotRecurse If children should be disposed
  75502. */
  75503. dispose(doNotRecurse?: boolean): void;
  75504. /**
  75505. * Returns a new LineMesh object cloned from the current one.
  75506. */
  75507. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  75508. /**
  75509. * Creates a new InstancedLinesMesh object from the mesh model.
  75510. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75511. * @param name defines the name of the new instance
  75512. * @returns a new InstancedLinesMesh
  75513. */
  75514. createInstance(name: string): InstancedLinesMesh;
  75515. }
  75516. /**
  75517. * Creates an instance based on a source LinesMesh
  75518. */
  75519. export class InstancedLinesMesh extends InstancedMesh {
  75520. /**
  75521. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75522. * This margin is expressed in world space coordinates, so its value may vary.
  75523. * Initilized with the intersectionThreshold value of the source LinesMesh
  75524. */
  75525. intersectionThreshold: number;
  75526. constructor(name: string, source: LinesMesh);
  75527. /**
  75528. * Returns the string "InstancedLinesMesh".
  75529. */
  75530. getClassName(): string;
  75531. }
  75532. }
  75533. declare module BABYLON {
  75534. /**
  75535. * Mesh representing the gorund
  75536. */
  75537. export class GroundMesh extends Mesh {
  75538. /** If octree should be generated */
  75539. generateOctree: boolean;
  75540. private _heightQuads;
  75541. /** @hidden */
  75542. _subdivisionsX: number;
  75543. /** @hidden */
  75544. _subdivisionsY: number;
  75545. /** @hidden */
  75546. _width: number;
  75547. /** @hidden */
  75548. _height: number;
  75549. /** @hidden */
  75550. _minX: number;
  75551. /** @hidden */
  75552. _maxX: number;
  75553. /** @hidden */
  75554. _minZ: number;
  75555. /** @hidden */
  75556. _maxZ: number;
  75557. constructor(name: string, scene: Scene);
  75558. /**
  75559. * "GroundMesh"
  75560. * @returns "GroundMesh"
  75561. */
  75562. getClassName(): string;
  75563. /**
  75564. * The minimum of x and y subdivisions
  75565. */
  75566. readonly subdivisions: number;
  75567. /**
  75568. * X subdivisions
  75569. */
  75570. readonly subdivisionsX: number;
  75571. /**
  75572. * Y subdivisions
  75573. */
  75574. readonly subdivisionsY: number;
  75575. /**
  75576. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  75577. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  75578. * @param chunksCount the number of subdivisions for x and y
  75579. * @param octreeBlocksSize (Default: 32)
  75580. */
  75581. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  75582. /**
  75583. * Returns a height (y) value in the Worl system :
  75584. * the ground altitude at the coordinates (x, z) expressed in the World system.
  75585. * @param x x coordinate
  75586. * @param z z coordinate
  75587. * @returns the ground y position if (x, z) are outside the ground surface.
  75588. */
  75589. getHeightAtCoordinates(x: number, z: number): number;
  75590. /**
  75591. * Returns a normalized vector (Vector3) orthogonal to the ground
  75592. * at the ground coordinates (x, z) expressed in the World system.
  75593. * @param x x coordinate
  75594. * @param z z coordinate
  75595. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  75596. */
  75597. getNormalAtCoordinates(x: number, z: number): Vector3;
  75598. /**
  75599. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  75600. * at the ground coordinates (x, z) expressed in the World system.
  75601. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  75602. * @param x x coordinate
  75603. * @param z z coordinate
  75604. * @param ref vector to store the result
  75605. * @returns the GroundMesh.
  75606. */
  75607. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  75608. /**
  75609. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  75610. * if the ground has been updated.
  75611. * This can be used in the render loop.
  75612. * @returns the GroundMesh.
  75613. */
  75614. updateCoordinateHeights(): GroundMesh;
  75615. private _getFacetAt;
  75616. private _initHeightQuads;
  75617. private _computeHeightQuads;
  75618. /**
  75619. * Serializes this ground mesh
  75620. * @param serializationObject object to write serialization to
  75621. */
  75622. serialize(serializationObject: any): void;
  75623. /**
  75624. * Parses a serialized ground mesh
  75625. * @param parsedMesh the serialized mesh
  75626. * @param scene the scene to create the ground mesh in
  75627. * @returns the created ground mesh
  75628. */
  75629. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  75630. }
  75631. }
  75632. declare module BABYLON {
  75633. /**
  75634. * Interface for Physics-Joint data
  75635. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75636. */
  75637. export interface PhysicsJointData {
  75638. /**
  75639. * The main pivot of the joint
  75640. */
  75641. mainPivot?: Vector3;
  75642. /**
  75643. * The connected pivot of the joint
  75644. */
  75645. connectedPivot?: Vector3;
  75646. /**
  75647. * The main axis of the joint
  75648. */
  75649. mainAxis?: Vector3;
  75650. /**
  75651. * The connected axis of the joint
  75652. */
  75653. connectedAxis?: Vector3;
  75654. /**
  75655. * The collision of the joint
  75656. */
  75657. collision?: boolean;
  75658. /**
  75659. * Native Oimo/Cannon/Energy data
  75660. */
  75661. nativeParams?: any;
  75662. }
  75663. /**
  75664. * This is a holder class for the physics joint created by the physics plugin
  75665. * It holds a set of functions to control the underlying joint
  75666. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75667. */
  75668. export class PhysicsJoint {
  75669. /**
  75670. * The type of the physics joint
  75671. */
  75672. type: number;
  75673. /**
  75674. * The data for the physics joint
  75675. */
  75676. jointData: PhysicsJointData;
  75677. private _physicsJoint;
  75678. protected _physicsPlugin: IPhysicsEnginePlugin;
  75679. /**
  75680. * Initializes the physics joint
  75681. * @param type The type of the physics joint
  75682. * @param jointData The data for the physics joint
  75683. */
  75684. constructor(
  75685. /**
  75686. * The type of the physics joint
  75687. */
  75688. type: number,
  75689. /**
  75690. * The data for the physics joint
  75691. */
  75692. jointData: PhysicsJointData);
  75693. /**
  75694. * Gets the physics joint
  75695. */
  75696. /**
  75697. * Sets the physics joint
  75698. */
  75699. physicsJoint: any;
  75700. /**
  75701. * Sets the physics plugin
  75702. */
  75703. physicsPlugin: IPhysicsEnginePlugin;
  75704. /**
  75705. * Execute a function that is physics-plugin specific.
  75706. * @param {Function} func the function that will be executed.
  75707. * It accepts two parameters: the physics world and the physics joint
  75708. */
  75709. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  75710. /**
  75711. * Distance-Joint type
  75712. */
  75713. static DistanceJoint: number;
  75714. /**
  75715. * Hinge-Joint type
  75716. */
  75717. static HingeJoint: number;
  75718. /**
  75719. * Ball-and-Socket joint type
  75720. */
  75721. static BallAndSocketJoint: number;
  75722. /**
  75723. * Wheel-Joint type
  75724. */
  75725. static WheelJoint: number;
  75726. /**
  75727. * Slider-Joint type
  75728. */
  75729. static SliderJoint: number;
  75730. /**
  75731. * Prismatic-Joint type
  75732. */
  75733. static PrismaticJoint: number;
  75734. /**
  75735. * Universal-Joint type
  75736. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  75737. */
  75738. static UniversalJoint: number;
  75739. /**
  75740. * Hinge-Joint 2 type
  75741. */
  75742. static Hinge2Joint: number;
  75743. /**
  75744. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  75745. */
  75746. static PointToPointJoint: number;
  75747. /**
  75748. * Spring-Joint type
  75749. */
  75750. static SpringJoint: number;
  75751. /**
  75752. * Lock-Joint type
  75753. */
  75754. static LockJoint: number;
  75755. }
  75756. /**
  75757. * A class representing a physics distance joint
  75758. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75759. */
  75760. export class DistanceJoint extends PhysicsJoint {
  75761. /**
  75762. *
  75763. * @param jointData The data for the Distance-Joint
  75764. */
  75765. constructor(jointData: DistanceJointData);
  75766. /**
  75767. * Update the predefined distance.
  75768. * @param maxDistance The maximum preferred distance
  75769. * @param minDistance The minimum preferred distance
  75770. */
  75771. updateDistance(maxDistance: number, minDistance?: number): void;
  75772. }
  75773. /**
  75774. * Represents a Motor-Enabled Joint
  75775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75776. */
  75777. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  75778. /**
  75779. * Initializes the Motor-Enabled Joint
  75780. * @param type The type of the joint
  75781. * @param jointData The physica joint data for the joint
  75782. */
  75783. constructor(type: number, jointData: PhysicsJointData);
  75784. /**
  75785. * Set the motor values.
  75786. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75787. * @param force the force to apply
  75788. * @param maxForce max force for this motor.
  75789. */
  75790. setMotor(force?: number, maxForce?: number): void;
  75791. /**
  75792. * Set the motor's limits.
  75793. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75794. * @param upperLimit The upper limit of the motor
  75795. * @param lowerLimit The lower limit of the motor
  75796. */
  75797. setLimit(upperLimit: number, lowerLimit?: number): void;
  75798. }
  75799. /**
  75800. * This class represents a single physics Hinge-Joint
  75801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75802. */
  75803. export class HingeJoint extends MotorEnabledJoint {
  75804. /**
  75805. * Initializes the Hinge-Joint
  75806. * @param jointData The joint data for the Hinge-Joint
  75807. */
  75808. constructor(jointData: PhysicsJointData);
  75809. /**
  75810. * Set the motor values.
  75811. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75812. * @param {number} force the force to apply
  75813. * @param {number} maxForce max force for this motor.
  75814. */
  75815. setMotor(force?: number, maxForce?: number): void;
  75816. /**
  75817. * Set the motor's limits.
  75818. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75819. * @param upperLimit The upper limit of the motor
  75820. * @param lowerLimit The lower limit of the motor
  75821. */
  75822. setLimit(upperLimit: number, lowerLimit?: number): void;
  75823. }
  75824. /**
  75825. * This class represents a dual hinge physics joint (same as wheel joint)
  75826. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75827. */
  75828. export class Hinge2Joint extends MotorEnabledJoint {
  75829. /**
  75830. * Initializes the Hinge2-Joint
  75831. * @param jointData The joint data for the Hinge2-Joint
  75832. */
  75833. constructor(jointData: PhysicsJointData);
  75834. /**
  75835. * Set the motor values.
  75836. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75837. * @param {number} targetSpeed the speed the motor is to reach
  75838. * @param {number} maxForce max force for this motor.
  75839. * @param {motorIndex} the motor's index, 0 or 1.
  75840. */
  75841. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  75842. /**
  75843. * Set the motor limits.
  75844. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75845. * @param {number} upperLimit the upper limit
  75846. * @param {number} lowerLimit lower limit
  75847. * @param {motorIndex} the motor's index, 0 or 1.
  75848. */
  75849. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75850. }
  75851. /**
  75852. * Interface for a motor enabled joint
  75853. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75854. */
  75855. export interface IMotorEnabledJoint {
  75856. /**
  75857. * Physics joint
  75858. */
  75859. physicsJoint: any;
  75860. /**
  75861. * Sets the motor of the motor-enabled joint
  75862. * @param force The force of the motor
  75863. * @param maxForce The maximum force of the motor
  75864. * @param motorIndex The index of the motor
  75865. */
  75866. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  75867. /**
  75868. * Sets the limit of the motor
  75869. * @param upperLimit The upper limit of the motor
  75870. * @param lowerLimit The lower limit of the motor
  75871. * @param motorIndex The index of the motor
  75872. */
  75873. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75874. }
  75875. /**
  75876. * Joint data for a Distance-Joint
  75877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75878. */
  75879. export interface DistanceJointData extends PhysicsJointData {
  75880. /**
  75881. * Max distance the 2 joint objects can be apart
  75882. */
  75883. maxDistance: number;
  75884. }
  75885. /**
  75886. * Joint data from a spring joint
  75887. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75888. */
  75889. export interface SpringJointData extends PhysicsJointData {
  75890. /**
  75891. * Length of the spring
  75892. */
  75893. length: number;
  75894. /**
  75895. * Stiffness of the spring
  75896. */
  75897. stiffness: number;
  75898. /**
  75899. * Damping of the spring
  75900. */
  75901. damping: number;
  75902. /** this callback will be called when applying the force to the impostors. */
  75903. forceApplicationCallback: () => void;
  75904. }
  75905. }
  75906. declare module BABYLON {
  75907. /**
  75908. * Holds the data for the raycast result
  75909. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75910. */
  75911. export class PhysicsRaycastResult {
  75912. private _hasHit;
  75913. private _hitDistance;
  75914. private _hitNormalWorld;
  75915. private _hitPointWorld;
  75916. private _rayFromWorld;
  75917. private _rayToWorld;
  75918. /**
  75919. * Gets if there was a hit
  75920. */
  75921. readonly hasHit: boolean;
  75922. /**
  75923. * Gets the distance from the hit
  75924. */
  75925. readonly hitDistance: number;
  75926. /**
  75927. * Gets the hit normal/direction in the world
  75928. */
  75929. readonly hitNormalWorld: Vector3;
  75930. /**
  75931. * Gets the hit point in the world
  75932. */
  75933. readonly hitPointWorld: Vector3;
  75934. /**
  75935. * Gets the ray "start point" of the ray in the world
  75936. */
  75937. readonly rayFromWorld: Vector3;
  75938. /**
  75939. * Gets the ray "end point" of the ray in the world
  75940. */
  75941. readonly rayToWorld: Vector3;
  75942. /**
  75943. * Sets the hit data (normal & point in world space)
  75944. * @param hitNormalWorld defines the normal in world space
  75945. * @param hitPointWorld defines the point in world space
  75946. */
  75947. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  75948. /**
  75949. * Sets the distance from the start point to the hit point
  75950. * @param distance
  75951. */
  75952. setHitDistance(distance: number): void;
  75953. /**
  75954. * Calculates the distance manually
  75955. */
  75956. calculateHitDistance(): void;
  75957. /**
  75958. * Resets all the values to default
  75959. * @param from The from point on world space
  75960. * @param to The to point on world space
  75961. */
  75962. reset(from?: Vector3, to?: Vector3): void;
  75963. }
  75964. /**
  75965. * Interface for the size containing width and height
  75966. */
  75967. interface IXYZ {
  75968. /**
  75969. * X
  75970. */
  75971. x: number;
  75972. /**
  75973. * Y
  75974. */
  75975. y: number;
  75976. /**
  75977. * Z
  75978. */
  75979. z: number;
  75980. }
  75981. }
  75982. declare module BABYLON {
  75983. /**
  75984. * Interface used to describe a physics joint
  75985. */
  75986. export interface PhysicsImpostorJoint {
  75987. /** Defines the main impostor to which the joint is linked */
  75988. mainImpostor: PhysicsImpostor;
  75989. /** Defines the impostor that is connected to the main impostor using this joint */
  75990. connectedImpostor: PhysicsImpostor;
  75991. /** Defines the joint itself */
  75992. joint: PhysicsJoint;
  75993. }
  75994. /** @hidden */
  75995. export interface IPhysicsEnginePlugin {
  75996. world: any;
  75997. name: string;
  75998. setGravity(gravity: Vector3): void;
  75999. setTimeStep(timeStep: number): void;
  76000. getTimeStep(): number;
  76001. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  76002. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76003. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76004. generatePhysicsBody(impostor: PhysicsImpostor): void;
  76005. removePhysicsBody(impostor: PhysicsImpostor): void;
  76006. generateJoint(joint: PhysicsImpostorJoint): void;
  76007. removeJoint(joint: PhysicsImpostorJoint): void;
  76008. isSupported(): boolean;
  76009. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  76010. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  76011. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76012. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76013. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76014. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76015. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  76016. getBodyMass(impostor: PhysicsImpostor): number;
  76017. getBodyFriction(impostor: PhysicsImpostor): number;
  76018. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  76019. getBodyRestitution(impostor: PhysicsImpostor): number;
  76020. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  76021. getBodyPressure?(impostor: PhysicsImpostor): number;
  76022. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  76023. getBodyStiffness?(impostor: PhysicsImpostor): number;
  76024. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  76025. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  76026. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  76027. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  76028. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  76029. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  76030. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  76031. sleepBody(impostor: PhysicsImpostor): void;
  76032. wakeUpBody(impostor: PhysicsImpostor): void;
  76033. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  76034. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  76035. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  76036. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76037. getRadius(impostor: PhysicsImpostor): number;
  76038. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  76039. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  76040. dispose(): void;
  76041. }
  76042. /**
  76043. * Interface used to define a physics engine
  76044. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  76045. */
  76046. export interface IPhysicsEngine {
  76047. /**
  76048. * Gets the gravity vector used by the simulation
  76049. */
  76050. gravity: Vector3;
  76051. /**
  76052. * Sets the gravity vector used by the simulation
  76053. * @param gravity defines the gravity vector to use
  76054. */
  76055. setGravity(gravity: Vector3): void;
  76056. /**
  76057. * Set the time step of the physics engine.
  76058. * Default is 1/60.
  76059. * To slow it down, enter 1/600 for example.
  76060. * To speed it up, 1/30
  76061. * @param newTimeStep the new timestep to apply to this world.
  76062. */
  76063. setTimeStep(newTimeStep: number): void;
  76064. /**
  76065. * Get the time step of the physics engine.
  76066. * @returns the current time step
  76067. */
  76068. getTimeStep(): number;
  76069. /**
  76070. * Release all resources
  76071. */
  76072. dispose(): void;
  76073. /**
  76074. * Gets the name of the current physics plugin
  76075. * @returns the name of the plugin
  76076. */
  76077. getPhysicsPluginName(): string;
  76078. /**
  76079. * Adding a new impostor for the impostor tracking.
  76080. * This will be done by the impostor itself.
  76081. * @param impostor the impostor to add
  76082. */
  76083. addImpostor(impostor: PhysicsImpostor): void;
  76084. /**
  76085. * Remove an impostor from the engine.
  76086. * This impostor and its mesh will not longer be updated by the physics engine.
  76087. * @param impostor the impostor to remove
  76088. */
  76089. removeImpostor(impostor: PhysicsImpostor): void;
  76090. /**
  76091. * Add a joint to the physics engine
  76092. * @param mainImpostor defines the main impostor to which the joint is added.
  76093. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  76094. * @param joint defines the joint that will connect both impostors.
  76095. */
  76096. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76097. /**
  76098. * Removes a joint from the simulation
  76099. * @param mainImpostor defines the impostor used with the joint
  76100. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  76101. * @param joint defines the joint to remove
  76102. */
  76103. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76104. /**
  76105. * Gets the current plugin used to run the simulation
  76106. * @returns current plugin
  76107. */
  76108. getPhysicsPlugin(): IPhysicsEnginePlugin;
  76109. /**
  76110. * Gets the list of physic impostors
  76111. * @returns an array of PhysicsImpostor
  76112. */
  76113. getImpostors(): Array<PhysicsImpostor>;
  76114. /**
  76115. * Gets the impostor for a physics enabled object
  76116. * @param object defines the object impersonated by the impostor
  76117. * @returns the PhysicsImpostor or null if not found
  76118. */
  76119. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76120. /**
  76121. * Gets the impostor for a physics body object
  76122. * @param body defines physics body used by the impostor
  76123. * @returns the PhysicsImpostor or null if not found
  76124. */
  76125. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  76126. /**
  76127. * Does a raycast in the physics world
  76128. * @param from when should the ray start?
  76129. * @param to when should the ray end?
  76130. * @returns PhysicsRaycastResult
  76131. */
  76132. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  76133. /**
  76134. * Called by the scene. No need to call it.
  76135. * @param delta defines the timespam between frames
  76136. */
  76137. _step(delta: number): void;
  76138. }
  76139. }
  76140. declare module BABYLON {
  76141. /**
  76142. * The interface for the physics imposter parameters
  76143. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76144. */
  76145. export interface PhysicsImpostorParameters {
  76146. /**
  76147. * The mass of the physics imposter
  76148. */
  76149. mass: number;
  76150. /**
  76151. * The friction of the physics imposter
  76152. */
  76153. friction?: number;
  76154. /**
  76155. * The coefficient of restitution of the physics imposter
  76156. */
  76157. restitution?: number;
  76158. /**
  76159. * The native options of the physics imposter
  76160. */
  76161. nativeOptions?: any;
  76162. /**
  76163. * Specifies if the parent should be ignored
  76164. */
  76165. ignoreParent?: boolean;
  76166. /**
  76167. * Specifies if bi-directional transformations should be disabled
  76168. */
  76169. disableBidirectionalTransformation?: boolean;
  76170. /**
  76171. * The pressure inside the physics imposter, soft object only
  76172. */
  76173. pressure?: number;
  76174. /**
  76175. * The stiffness the physics imposter, soft object only
  76176. */
  76177. stiffness?: number;
  76178. /**
  76179. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  76180. */
  76181. velocityIterations?: number;
  76182. /**
  76183. * The number of iterations used in maintaining consistent vertex positions, soft object only
  76184. */
  76185. positionIterations?: number;
  76186. /**
  76187. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  76188. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  76189. * Add to fix multiple points
  76190. */
  76191. fixedPoints?: number;
  76192. /**
  76193. * The collision margin around a soft object
  76194. */
  76195. margin?: number;
  76196. /**
  76197. * The collision margin around a soft object
  76198. */
  76199. damping?: number;
  76200. /**
  76201. * The path for a rope based on an extrusion
  76202. */
  76203. path?: any;
  76204. /**
  76205. * The shape of an extrusion used for a rope based on an extrusion
  76206. */
  76207. shape?: any;
  76208. }
  76209. /**
  76210. * Interface for a physics-enabled object
  76211. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76212. */
  76213. export interface IPhysicsEnabledObject {
  76214. /**
  76215. * The position of the physics-enabled object
  76216. */
  76217. position: Vector3;
  76218. /**
  76219. * The rotation of the physics-enabled object
  76220. */
  76221. rotationQuaternion: Nullable<Quaternion>;
  76222. /**
  76223. * The scale of the physics-enabled object
  76224. */
  76225. scaling: Vector3;
  76226. /**
  76227. * The rotation of the physics-enabled object
  76228. */
  76229. rotation?: Vector3;
  76230. /**
  76231. * The parent of the physics-enabled object
  76232. */
  76233. parent?: any;
  76234. /**
  76235. * The bounding info of the physics-enabled object
  76236. * @returns The bounding info of the physics-enabled object
  76237. */
  76238. getBoundingInfo(): BoundingInfo;
  76239. /**
  76240. * Computes the world matrix
  76241. * @param force Specifies if the world matrix should be computed by force
  76242. * @returns A world matrix
  76243. */
  76244. computeWorldMatrix(force: boolean): Matrix;
  76245. /**
  76246. * Gets the world matrix
  76247. * @returns A world matrix
  76248. */
  76249. getWorldMatrix?(): Matrix;
  76250. /**
  76251. * Gets the child meshes
  76252. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  76253. * @returns An array of abstract meshes
  76254. */
  76255. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  76256. /**
  76257. * Gets the vertex data
  76258. * @param kind The type of vertex data
  76259. * @returns A nullable array of numbers, or a float32 array
  76260. */
  76261. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  76262. /**
  76263. * Gets the indices from the mesh
  76264. * @returns A nullable array of index arrays
  76265. */
  76266. getIndices?(): Nullable<IndicesArray>;
  76267. /**
  76268. * Gets the scene from the mesh
  76269. * @returns the indices array or null
  76270. */
  76271. getScene?(): Scene;
  76272. /**
  76273. * Gets the absolute position from the mesh
  76274. * @returns the absolute position
  76275. */
  76276. getAbsolutePosition(): Vector3;
  76277. /**
  76278. * Gets the absolute pivot point from the mesh
  76279. * @returns the absolute pivot point
  76280. */
  76281. getAbsolutePivotPoint(): Vector3;
  76282. /**
  76283. * Rotates the mesh
  76284. * @param axis The axis of rotation
  76285. * @param amount The amount of rotation
  76286. * @param space The space of the rotation
  76287. * @returns The rotation transform node
  76288. */
  76289. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  76290. /**
  76291. * Translates the mesh
  76292. * @param axis The axis of translation
  76293. * @param distance The distance of translation
  76294. * @param space The space of the translation
  76295. * @returns The transform node
  76296. */
  76297. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  76298. /**
  76299. * Sets the absolute position of the mesh
  76300. * @param absolutePosition The absolute position of the mesh
  76301. * @returns The transform node
  76302. */
  76303. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  76304. /**
  76305. * Gets the class name of the mesh
  76306. * @returns The class name
  76307. */
  76308. getClassName(): string;
  76309. }
  76310. /**
  76311. * Represents a physics imposter
  76312. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76313. */
  76314. export class PhysicsImpostor {
  76315. /**
  76316. * The physics-enabled object used as the physics imposter
  76317. */
  76318. object: IPhysicsEnabledObject;
  76319. /**
  76320. * The type of the physics imposter
  76321. */
  76322. type: number;
  76323. private _options;
  76324. private _scene?;
  76325. /**
  76326. * The default object size of the imposter
  76327. */
  76328. static DEFAULT_OBJECT_SIZE: Vector3;
  76329. /**
  76330. * The identity quaternion of the imposter
  76331. */
  76332. static IDENTITY_QUATERNION: Quaternion;
  76333. /** @hidden */
  76334. _pluginData: any;
  76335. private _physicsEngine;
  76336. private _physicsBody;
  76337. private _bodyUpdateRequired;
  76338. private _onBeforePhysicsStepCallbacks;
  76339. private _onAfterPhysicsStepCallbacks;
  76340. /** @hidden */
  76341. _onPhysicsCollideCallbacks: Array<{
  76342. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  76343. otherImpostors: Array<PhysicsImpostor>;
  76344. }>;
  76345. private _deltaPosition;
  76346. private _deltaRotation;
  76347. private _deltaRotationConjugated;
  76348. /** @hidden */
  76349. _isFromLine: boolean;
  76350. private _parent;
  76351. private _isDisposed;
  76352. private static _tmpVecs;
  76353. private static _tmpQuat;
  76354. /**
  76355. * Specifies if the physics imposter is disposed
  76356. */
  76357. readonly isDisposed: boolean;
  76358. /**
  76359. * Gets the mass of the physics imposter
  76360. */
  76361. mass: number;
  76362. /**
  76363. * Gets the coefficient of friction
  76364. */
  76365. /**
  76366. * Sets the coefficient of friction
  76367. */
  76368. friction: number;
  76369. /**
  76370. * Gets the coefficient of restitution
  76371. */
  76372. /**
  76373. * Sets the coefficient of restitution
  76374. */
  76375. restitution: number;
  76376. /**
  76377. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  76378. */
  76379. /**
  76380. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  76381. */
  76382. pressure: number;
  76383. /**
  76384. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76385. */
  76386. /**
  76387. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76388. */
  76389. stiffness: number;
  76390. /**
  76391. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76392. */
  76393. /**
  76394. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76395. */
  76396. velocityIterations: number;
  76397. /**
  76398. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76399. */
  76400. /**
  76401. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76402. */
  76403. positionIterations: number;
  76404. /**
  76405. * The unique id of the physics imposter
  76406. * set by the physics engine when adding this impostor to the array
  76407. */
  76408. uniqueId: number;
  76409. /**
  76410. * @hidden
  76411. */
  76412. soft: boolean;
  76413. /**
  76414. * @hidden
  76415. */
  76416. segments: number;
  76417. private _joints;
  76418. /**
  76419. * Initializes the physics imposter
  76420. * @param object The physics-enabled object used as the physics imposter
  76421. * @param type The type of the physics imposter
  76422. * @param _options The options for the physics imposter
  76423. * @param _scene The Babylon scene
  76424. */
  76425. constructor(
  76426. /**
  76427. * The physics-enabled object used as the physics imposter
  76428. */
  76429. object: IPhysicsEnabledObject,
  76430. /**
  76431. * The type of the physics imposter
  76432. */
  76433. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  76434. /**
  76435. * This function will completly initialize this impostor.
  76436. * It will create a new body - but only if this mesh has no parent.
  76437. * If it has, this impostor will not be used other than to define the impostor
  76438. * of the child mesh.
  76439. * @hidden
  76440. */
  76441. _init(): void;
  76442. private _getPhysicsParent;
  76443. /**
  76444. * Should a new body be generated.
  76445. * @returns boolean specifying if body initialization is required
  76446. */
  76447. isBodyInitRequired(): boolean;
  76448. /**
  76449. * Sets the updated scaling
  76450. * @param updated Specifies if the scaling is updated
  76451. */
  76452. setScalingUpdated(): void;
  76453. /**
  76454. * Force a regeneration of this or the parent's impostor's body.
  76455. * Use under cautious - This will remove all joints already implemented.
  76456. */
  76457. forceUpdate(): void;
  76458. /**
  76459. * Gets the body that holds this impostor. Either its own, or its parent.
  76460. */
  76461. /**
  76462. * Set the physics body. Used mainly by the physics engine/plugin
  76463. */
  76464. physicsBody: any;
  76465. /**
  76466. * Get the parent of the physics imposter
  76467. * @returns Physics imposter or null
  76468. */
  76469. /**
  76470. * Sets the parent of the physics imposter
  76471. */
  76472. parent: Nullable<PhysicsImpostor>;
  76473. /**
  76474. * Resets the update flags
  76475. */
  76476. resetUpdateFlags(): void;
  76477. /**
  76478. * Gets the object extend size
  76479. * @returns the object extend size
  76480. */
  76481. getObjectExtendSize(): Vector3;
  76482. /**
  76483. * Gets the object center
  76484. * @returns The object center
  76485. */
  76486. getObjectCenter(): Vector3;
  76487. /**
  76488. * Get a specific parametes from the options parameter
  76489. * @param paramName The object parameter name
  76490. * @returns The object parameter
  76491. */
  76492. getParam(paramName: string): any;
  76493. /**
  76494. * Sets a specific parameter in the options given to the physics plugin
  76495. * @param paramName The parameter name
  76496. * @param value The value of the parameter
  76497. */
  76498. setParam(paramName: string, value: number): void;
  76499. /**
  76500. * Specifically change the body's mass option. Won't recreate the physics body object
  76501. * @param mass The mass of the physics imposter
  76502. */
  76503. setMass(mass: number): void;
  76504. /**
  76505. * Gets the linear velocity
  76506. * @returns linear velocity or null
  76507. */
  76508. getLinearVelocity(): Nullable<Vector3>;
  76509. /**
  76510. * Sets the linear velocity
  76511. * @param velocity linear velocity or null
  76512. */
  76513. setLinearVelocity(velocity: Nullable<Vector3>): void;
  76514. /**
  76515. * Gets the angular velocity
  76516. * @returns angular velocity or null
  76517. */
  76518. getAngularVelocity(): Nullable<Vector3>;
  76519. /**
  76520. * Sets the angular velocity
  76521. * @param velocity The velocity or null
  76522. */
  76523. setAngularVelocity(velocity: Nullable<Vector3>): void;
  76524. /**
  76525. * Execute a function with the physics plugin native code
  76526. * Provide a function the will have two variables - the world object and the physics body object
  76527. * @param func The function to execute with the physics plugin native code
  76528. */
  76529. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  76530. /**
  76531. * Register a function that will be executed before the physics world is stepping forward
  76532. * @param func The function to execute before the physics world is stepped forward
  76533. */
  76534. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76535. /**
  76536. * Unregister a function that will be executed before the physics world is stepping forward
  76537. * @param func The function to execute before the physics world is stepped forward
  76538. */
  76539. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76540. /**
  76541. * Register a function that will be executed after the physics step
  76542. * @param func The function to execute after physics step
  76543. */
  76544. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76545. /**
  76546. * Unregisters a function that will be executed after the physics step
  76547. * @param func The function to execute after physics step
  76548. */
  76549. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76550. /**
  76551. * register a function that will be executed when this impostor collides against a different body
  76552. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  76553. * @param func Callback that is executed on collision
  76554. */
  76555. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  76556. /**
  76557. * Unregisters the physics imposter on contact
  76558. * @param collideAgainst The physics object to collide against
  76559. * @param func Callback to execute on collision
  76560. */
  76561. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  76562. private _tmpQuat;
  76563. private _tmpQuat2;
  76564. /**
  76565. * Get the parent rotation
  76566. * @returns The parent rotation
  76567. */
  76568. getParentsRotation(): Quaternion;
  76569. /**
  76570. * this function is executed by the physics engine.
  76571. */
  76572. beforeStep: () => void;
  76573. /**
  76574. * this function is executed by the physics engine
  76575. */
  76576. afterStep: () => void;
  76577. /**
  76578. * Legacy collision detection event support
  76579. */
  76580. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  76581. /**
  76582. * event and body object due to cannon's event-based architecture.
  76583. */
  76584. onCollide: (e: {
  76585. body: any;
  76586. }) => void;
  76587. /**
  76588. * Apply a force
  76589. * @param force The force to apply
  76590. * @param contactPoint The contact point for the force
  76591. * @returns The physics imposter
  76592. */
  76593. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76594. /**
  76595. * Apply an impulse
  76596. * @param force The impulse force
  76597. * @param contactPoint The contact point for the impulse force
  76598. * @returns The physics imposter
  76599. */
  76600. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76601. /**
  76602. * A help function to create a joint
  76603. * @param otherImpostor A physics imposter used to create a joint
  76604. * @param jointType The type of joint
  76605. * @param jointData The data for the joint
  76606. * @returns The physics imposter
  76607. */
  76608. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  76609. /**
  76610. * Add a joint to this impostor with a different impostor
  76611. * @param otherImpostor A physics imposter used to add a joint
  76612. * @param joint The joint to add
  76613. * @returns The physics imposter
  76614. */
  76615. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  76616. /**
  76617. * Add an anchor to a cloth impostor
  76618. * @param otherImpostor rigid impostor to anchor to
  76619. * @param width ratio across width from 0 to 1
  76620. * @param height ratio up height from 0 to 1
  76621. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  76622. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  76623. * @returns impostor the soft imposter
  76624. */
  76625. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76626. /**
  76627. * Add a hook to a rope impostor
  76628. * @param otherImpostor rigid impostor to anchor to
  76629. * @param length ratio across rope from 0 to 1
  76630. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  76631. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  76632. * @returns impostor the rope imposter
  76633. */
  76634. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76635. /**
  76636. * Will keep this body still, in a sleep mode.
  76637. * @returns the physics imposter
  76638. */
  76639. sleep(): PhysicsImpostor;
  76640. /**
  76641. * Wake the body up.
  76642. * @returns The physics imposter
  76643. */
  76644. wakeUp(): PhysicsImpostor;
  76645. /**
  76646. * Clones the physics imposter
  76647. * @param newObject The physics imposter clones to this physics-enabled object
  76648. * @returns A nullable physics imposter
  76649. */
  76650. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76651. /**
  76652. * Disposes the physics imposter
  76653. */
  76654. dispose(): void;
  76655. /**
  76656. * Sets the delta position
  76657. * @param position The delta position amount
  76658. */
  76659. setDeltaPosition(position: Vector3): void;
  76660. /**
  76661. * Sets the delta rotation
  76662. * @param rotation The delta rotation amount
  76663. */
  76664. setDeltaRotation(rotation: Quaternion): void;
  76665. /**
  76666. * Gets the box size of the physics imposter and stores the result in the input parameter
  76667. * @param result Stores the box size
  76668. * @returns The physics imposter
  76669. */
  76670. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  76671. /**
  76672. * Gets the radius of the physics imposter
  76673. * @returns Radius of the physics imposter
  76674. */
  76675. getRadius(): number;
  76676. /**
  76677. * Sync a bone with this impostor
  76678. * @param bone The bone to sync to the impostor.
  76679. * @param boneMesh The mesh that the bone is influencing.
  76680. * @param jointPivot The pivot of the joint / bone in local space.
  76681. * @param distToJoint Optional distance from the impostor to the joint.
  76682. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76683. */
  76684. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  76685. /**
  76686. * Sync impostor to a bone
  76687. * @param bone The bone that the impostor will be synced to.
  76688. * @param boneMesh The mesh that the bone is influencing.
  76689. * @param jointPivot The pivot of the joint / bone in local space.
  76690. * @param distToJoint Optional distance from the impostor to the joint.
  76691. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76692. * @param boneAxis Optional vector3 axis the bone is aligned with
  76693. */
  76694. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  76695. /**
  76696. * No-Imposter type
  76697. */
  76698. static NoImpostor: number;
  76699. /**
  76700. * Sphere-Imposter type
  76701. */
  76702. static SphereImpostor: number;
  76703. /**
  76704. * Box-Imposter type
  76705. */
  76706. static BoxImpostor: number;
  76707. /**
  76708. * Plane-Imposter type
  76709. */
  76710. static PlaneImpostor: number;
  76711. /**
  76712. * Mesh-imposter type
  76713. */
  76714. static MeshImpostor: number;
  76715. /**
  76716. * Capsule-Impostor type (Ammo.js plugin only)
  76717. */
  76718. static CapsuleImpostor: number;
  76719. /**
  76720. * Cylinder-Imposter type
  76721. */
  76722. static CylinderImpostor: number;
  76723. /**
  76724. * Particle-Imposter type
  76725. */
  76726. static ParticleImpostor: number;
  76727. /**
  76728. * Heightmap-Imposter type
  76729. */
  76730. static HeightmapImpostor: number;
  76731. /**
  76732. * ConvexHull-Impostor type (Ammo.js plugin only)
  76733. */
  76734. static ConvexHullImpostor: number;
  76735. /**
  76736. * Rope-Imposter type
  76737. */
  76738. static RopeImpostor: number;
  76739. /**
  76740. * Cloth-Imposter type
  76741. */
  76742. static ClothImpostor: number;
  76743. /**
  76744. * Softbody-Imposter type
  76745. */
  76746. static SoftbodyImpostor: number;
  76747. }
  76748. }
  76749. declare module BABYLON {
  76750. /**
  76751. * @hidden
  76752. **/
  76753. export class _CreationDataStorage {
  76754. closePath?: boolean;
  76755. closeArray?: boolean;
  76756. idx: number[];
  76757. dashSize: number;
  76758. gapSize: number;
  76759. path3D: Path3D;
  76760. pathArray: Vector3[][];
  76761. arc: number;
  76762. radius: number;
  76763. cap: number;
  76764. tessellation: number;
  76765. }
  76766. /**
  76767. * @hidden
  76768. **/
  76769. class _InstanceDataStorage {
  76770. visibleInstances: any;
  76771. batchCache: _InstancesBatch;
  76772. instancesBufferSize: number;
  76773. instancesBuffer: Nullable<Buffer>;
  76774. instancesData: Float32Array;
  76775. overridenInstanceCount: number;
  76776. isFrozen: boolean;
  76777. previousBatch: Nullable<_InstancesBatch>;
  76778. hardwareInstancedRendering: boolean;
  76779. sideOrientation: number;
  76780. }
  76781. /**
  76782. * @hidden
  76783. **/
  76784. export class _InstancesBatch {
  76785. mustReturn: boolean;
  76786. visibleInstances: Nullable<InstancedMesh[]>[];
  76787. renderSelf: boolean[];
  76788. hardwareInstancedRendering: boolean[];
  76789. }
  76790. /**
  76791. * Class used to represent renderable models
  76792. */
  76793. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  76794. /**
  76795. * Mesh side orientation : usually the external or front surface
  76796. */
  76797. static readonly FRONTSIDE: number;
  76798. /**
  76799. * Mesh side orientation : usually the internal or back surface
  76800. */
  76801. static readonly BACKSIDE: number;
  76802. /**
  76803. * Mesh side orientation : both internal and external or front and back surfaces
  76804. */
  76805. static readonly DOUBLESIDE: number;
  76806. /**
  76807. * Mesh side orientation : by default, `FRONTSIDE`
  76808. */
  76809. static readonly DEFAULTSIDE: number;
  76810. /**
  76811. * Mesh cap setting : no cap
  76812. */
  76813. static readonly NO_CAP: number;
  76814. /**
  76815. * Mesh cap setting : one cap at the beginning of the mesh
  76816. */
  76817. static readonly CAP_START: number;
  76818. /**
  76819. * Mesh cap setting : one cap at the end of the mesh
  76820. */
  76821. static readonly CAP_END: number;
  76822. /**
  76823. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  76824. */
  76825. static readonly CAP_ALL: number;
  76826. /**
  76827. * Mesh pattern setting : no flip or rotate
  76828. */
  76829. static readonly NO_FLIP: number;
  76830. /**
  76831. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  76832. */
  76833. static readonly FLIP_TILE: number;
  76834. /**
  76835. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  76836. */
  76837. static readonly ROTATE_TILE: number;
  76838. /**
  76839. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  76840. */
  76841. static readonly FLIP_ROW: number;
  76842. /**
  76843. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  76844. */
  76845. static readonly ROTATE_ROW: number;
  76846. /**
  76847. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  76848. */
  76849. static readonly FLIP_N_ROTATE_TILE: number;
  76850. /**
  76851. * Mesh pattern setting : rotate pattern and rotate
  76852. */
  76853. static readonly FLIP_N_ROTATE_ROW: number;
  76854. /**
  76855. * Mesh tile positioning : part tiles same on left/right or top/bottom
  76856. */
  76857. static readonly CENTER: number;
  76858. /**
  76859. * Mesh tile positioning : part tiles on left
  76860. */
  76861. static readonly LEFT: number;
  76862. /**
  76863. * Mesh tile positioning : part tiles on right
  76864. */
  76865. static readonly RIGHT: number;
  76866. /**
  76867. * Mesh tile positioning : part tiles on top
  76868. */
  76869. static readonly TOP: number;
  76870. /**
  76871. * Mesh tile positioning : part tiles on bottom
  76872. */
  76873. static readonly BOTTOM: number;
  76874. /**
  76875. * Gets the default side orientation.
  76876. * @param orientation the orientation to value to attempt to get
  76877. * @returns the default orientation
  76878. * @hidden
  76879. */
  76880. static _GetDefaultSideOrientation(orientation?: number): number;
  76881. private _internalMeshDataInfo;
  76882. /**
  76883. * An event triggered before rendering the mesh
  76884. */
  76885. readonly onBeforeRenderObservable: Observable<Mesh>;
  76886. /**
  76887. * An event triggered before binding the mesh
  76888. */
  76889. readonly onBeforeBindObservable: Observable<Mesh>;
  76890. /**
  76891. * An event triggered after rendering the mesh
  76892. */
  76893. readonly onAfterRenderObservable: Observable<Mesh>;
  76894. /**
  76895. * An event triggered before drawing the mesh
  76896. */
  76897. readonly onBeforeDrawObservable: Observable<Mesh>;
  76898. private _onBeforeDrawObserver;
  76899. /**
  76900. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  76901. */
  76902. onBeforeDraw: () => void;
  76903. /**
  76904. * Gets the delay loading state of the mesh (when delay loading is turned on)
  76905. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  76906. */
  76907. delayLoadState: number;
  76908. /**
  76909. * Gets the list of instances created from this mesh
  76910. * it is not supposed to be modified manually.
  76911. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  76912. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76913. */
  76914. instances: InstancedMesh[];
  76915. /**
  76916. * Gets the file containing delay loading data for this mesh
  76917. */
  76918. delayLoadingFile: string;
  76919. /** @hidden */
  76920. _binaryInfo: any;
  76921. /**
  76922. * User defined function used to change how LOD level selection is done
  76923. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  76924. */
  76925. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  76926. /**
  76927. * Gets or sets the morph target manager
  76928. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76929. */
  76930. morphTargetManager: Nullable<MorphTargetManager>;
  76931. /** @hidden */
  76932. _creationDataStorage: Nullable<_CreationDataStorage>;
  76933. /** @hidden */
  76934. _geometry: Nullable<Geometry>;
  76935. /** @hidden */
  76936. _delayInfo: Array<string>;
  76937. /** @hidden */
  76938. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  76939. /** @hidden */
  76940. _instanceDataStorage: _InstanceDataStorage;
  76941. private _effectiveMaterial;
  76942. /** @hidden */
  76943. _shouldGenerateFlatShading: boolean;
  76944. /** @hidden */
  76945. _originalBuilderSideOrientation: number;
  76946. /**
  76947. * Use this property to change the original side orientation defined at construction time
  76948. */
  76949. overrideMaterialSideOrientation: Nullable<number>;
  76950. /**
  76951. * Gets the source mesh (the one used to clone this one from)
  76952. */
  76953. readonly source: Nullable<Mesh>;
  76954. /**
  76955. * Gets or sets a boolean indicating that this mesh does not use index buffer
  76956. */
  76957. isUnIndexed: boolean;
  76958. /**
  76959. * @constructor
  76960. * @param name The value used by scene.getMeshByName() to do a lookup.
  76961. * @param scene The scene to add this mesh to.
  76962. * @param parent The parent of this mesh, if it has one
  76963. * @param source An optional Mesh from which geometry is shared, cloned.
  76964. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76965. * When false, achieved by calling a clone(), also passing False.
  76966. * This will make creation of children, recursive.
  76967. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  76968. */
  76969. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  76970. /**
  76971. * Gets the class name
  76972. * @returns the string "Mesh".
  76973. */
  76974. getClassName(): string;
  76975. /** @hidden */
  76976. readonly _isMesh: boolean;
  76977. /**
  76978. * Returns a description of this mesh
  76979. * @param fullDetails define if full details about this mesh must be used
  76980. * @returns a descriptive string representing this mesh
  76981. */
  76982. toString(fullDetails?: boolean): string;
  76983. /** @hidden */
  76984. _unBindEffect(): void;
  76985. /**
  76986. * Gets a boolean indicating if this mesh has LOD
  76987. */
  76988. readonly hasLODLevels: boolean;
  76989. /**
  76990. * Gets the list of MeshLODLevel associated with the current mesh
  76991. * @returns an array of MeshLODLevel
  76992. */
  76993. getLODLevels(): MeshLODLevel[];
  76994. private _sortLODLevels;
  76995. /**
  76996. * Add a mesh as LOD level triggered at the given distance.
  76997. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76998. * @param distance The distance from the center of the object to show this level
  76999. * @param mesh The mesh to be added as LOD level (can be null)
  77000. * @return This mesh (for chaining)
  77001. */
  77002. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  77003. /**
  77004. * Returns the LOD level mesh at the passed distance or null if not found.
  77005. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77006. * @param distance The distance from the center of the object to show this level
  77007. * @returns a Mesh or `null`
  77008. */
  77009. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  77010. /**
  77011. * Remove a mesh from the LOD array
  77012. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77013. * @param mesh defines the mesh to be removed
  77014. * @return This mesh (for chaining)
  77015. */
  77016. removeLODLevel(mesh: Mesh): Mesh;
  77017. /**
  77018. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  77019. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77020. * @param camera defines the camera to use to compute distance
  77021. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  77022. * @return This mesh (for chaining)
  77023. */
  77024. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  77025. /**
  77026. * Gets the mesh internal Geometry object
  77027. */
  77028. readonly geometry: Nullable<Geometry>;
  77029. /**
  77030. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  77031. * @returns the total number of vertices
  77032. */
  77033. getTotalVertices(): number;
  77034. /**
  77035. * Returns the content of an associated vertex buffer
  77036. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77037. * - VertexBuffer.PositionKind
  77038. * - VertexBuffer.UVKind
  77039. * - VertexBuffer.UV2Kind
  77040. * - VertexBuffer.UV3Kind
  77041. * - VertexBuffer.UV4Kind
  77042. * - VertexBuffer.UV5Kind
  77043. * - VertexBuffer.UV6Kind
  77044. * - VertexBuffer.ColorKind
  77045. * - VertexBuffer.MatricesIndicesKind
  77046. * - VertexBuffer.MatricesIndicesExtraKind
  77047. * - VertexBuffer.MatricesWeightsKind
  77048. * - VertexBuffer.MatricesWeightsExtraKind
  77049. * @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
  77050. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  77051. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  77052. */
  77053. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77054. /**
  77055. * Returns the mesh VertexBuffer object from the requested `kind`
  77056. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77057. * - VertexBuffer.PositionKind
  77058. * - VertexBuffer.NormalKind
  77059. * - VertexBuffer.UVKind
  77060. * - VertexBuffer.UV2Kind
  77061. * - VertexBuffer.UV3Kind
  77062. * - VertexBuffer.UV4Kind
  77063. * - VertexBuffer.UV5Kind
  77064. * - VertexBuffer.UV6Kind
  77065. * - VertexBuffer.ColorKind
  77066. * - VertexBuffer.MatricesIndicesKind
  77067. * - VertexBuffer.MatricesIndicesExtraKind
  77068. * - VertexBuffer.MatricesWeightsKind
  77069. * - VertexBuffer.MatricesWeightsExtraKind
  77070. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  77071. */
  77072. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77073. /**
  77074. * Tests if a specific vertex buffer is associated with this mesh
  77075. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77076. * - VertexBuffer.PositionKind
  77077. * - VertexBuffer.NormalKind
  77078. * - VertexBuffer.UVKind
  77079. * - VertexBuffer.UV2Kind
  77080. * - VertexBuffer.UV3Kind
  77081. * - VertexBuffer.UV4Kind
  77082. * - VertexBuffer.UV5Kind
  77083. * - VertexBuffer.UV6Kind
  77084. * - VertexBuffer.ColorKind
  77085. * - VertexBuffer.MatricesIndicesKind
  77086. * - VertexBuffer.MatricesIndicesExtraKind
  77087. * - VertexBuffer.MatricesWeightsKind
  77088. * - VertexBuffer.MatricesWeightsExtraKind
  77089. * @returns a boolean
  77090. */
  77091. isVerticesDataPresent(kind: string): boolean;
  77092. /**
  77093. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  77094. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77095. * - VertexBuffer.PositionKind
  77096. * - VertexBuffer.UVKind
  77097. * - VertexBuffer.UV2Kind
  77098. * - VertexBuffer.UV3Kind
  77099. * - VertexBuffer.UV4Kind
  77100. * - VertexBuffer.UV5Kind
  77101. * - VertexBuffer.UV6Kind
  77102. * - VertexBuffer.ColorKind
  77103. * - VertexBuffer.MatricesIndicesKind
  77104. * - VertexBuffer.MatricesIndicesExtraKind
  77105. * - VertexBuffer.MatricesWeightsKind
  77106. * - VertexBuffer.MatricesWeightsExtraKind
  77107. * @returns a boolean
  77108. */
  77109. isVertexBufferUpdatable(kind: string): boolean;
  77110. /**
  77111. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  77112. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77113. * - VertexBuffer.PositionKind
  77114. * - VertexBuffer.NormalKind
  77115. * - VertexBuffer.UVKind
  77116. * - VertexBuffer.UV2Kind
  77117. * - VertexBuffer.UV3Kind
  77118. * - VertexBuffer.UV4Kind
  77119. * - VertexBuffer.UV5Kind
  77120. * - VertexBuffer.UV6Kind
  77121. * - VertexBuffer.ColorKind
  77122. * - VertexBuffer.MatricesIndicesKind
  77123. * - VertexBuffer.MatricesIndicesExtraKind
  77124. * - VertexBuffer.MatricesWeightsKind
  77125. * - VertexBuffer.MatricesWeightsExtraKind
  77126. * @returns an array of strings
  77127. */
  77128. getVerticesDataKinds(): string[];
  77129. /**
  77130. * Returns a positive integer : the total number of indices in this mesh geometry.
  77131. * @returns the numner of indices or zero if the mesh has no geometry.
  77132. */
  77133. getTotalIndices(): number;
  77134. /**
  77135. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77136. * @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.
  77137. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77138. * @returns the indices array or an empty array if the mesh has no geometry
  77139. */
  77140. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77141. readonly isBlocked: boolean;
  77142. /**
  77143. * Determine if the current mesh is ready to be rendered
  77144. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  77145. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  77146. * @returns true if all associated assets are ready (material, textures, shaders)
  77147. */
  77148. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  77149. /**
  77150. * 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.
  77151. */
  77152. readonly areNormalsFrozen: boolean;
  77153. /**
  77154. * 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.
  77155. * @returns the current mesh
  77156. */
  77157. freezeNormals(): Mesh;
  77158. /**
  77159. * 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
  77160. * @returns the current mesh
  77161. */
  77162. unfreezeNormals(): Mesh;
  77163. /**
  77164. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  77165. */
  77166. overridenInstanceCount: number;
  77167. /** @hidden */
  77168. _preActivate(): Mesh;
  77169. /** @hidden */
  77170. _preActivateForIntermediateRendering(renderId: number): Mesh;
  77171. /** @hidden */
  77172. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  77173. /**
  77174. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  77175. * This means the mesh underlying bounding box and sphere are recomputed.
  77176. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  77177. * @returns the current mesh
  77178. */
  77179. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  77180. /** @hidden */
  77181. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  77182. /**
  77183. * This function will subdivide the mesh into multiple submeshes
  77184. * @param count defines the expected number of submeshes
  77185. */
  77186. subdivide(count: number): void;
  77187. /**
  77188. * Copy a FloatArray into a specific associated vertex buffer
  77189. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77190. * - VertexBuffer.PositionKind
  77191. * - VertexBuffer.UVKind
  77192. * - VertexBuffer.UV2Kind
  77193. * - VertexBuffer.UV3Kind
  77194. * - VertexBuffer.UV4Kind
  77195. * - VertexBuffer.UV5Kind
  77196. * - VertexBuffer.UV6Kind
  77197. * - VertexBuffer.ColorKind
  77198. * - VertexBuffer.MatricesIndicesKind
  77199. * - VertexBuffer.MatricesIndicesExtraKind
  77200. * - VertexBuffer.MatricesWeightsKind
  77201. * - VertexBuffer.MatricesWeightsExtraKind
  77202. * @param data defines the data source
  77203. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77204. * @param stride defines the data stride size (can be null)
  77205. * @returns the current mesh
  77206. */
  77207. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  77208. /**
  77209. * Flags an associated vertex buffer as updatable
  77210. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  77211. * - VertexBuffer.PositionKind
  77212. * - VertexBuffer.UVKind
  77213. * - VertexBuffer.UV2Kind
  77214. * - VertexBuffer.UV3Kind
  77215. * - VertexBuffer.UV4Kind
  77216. * - VertexBuffer.UV5Kind
  77217. * - VertexBuffer.UV6Kind
  77218. * - VertexBuffer.ColorKind
  77219. * - VertexBuffer.MatricesIndicesKind
  77220. * - VertexBuffer.MatricesIndicesExtraKind
  77221. * - VertexBuffer.MatricesWeightsKind
  77222. * - VertexBuffer.MatricesWeightsExtraKind
  77223. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77224. */
  77225. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  77226. /**
  77227. * Sets the mesh global Vertex Buffer
  77228. * @param buffer defines the buffer to use
  77229. * @returns the current mesh
  77230. */
  77231. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  77232. /**
  77233. * Update a specific associated vertex buffer
  77234. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77235. * - VertexBuffer.PositionKind
  77236. * - VertexBuffer.UVKind
  77237. * - VertexBuffer.UV2Kind
  77238. * - VertexBuffer.UV3Kind
  77239. * - VertexBuffer.UV4Kind
  77240. * - VertexBuffer.UV5Kind
  77241. * - VertexBuffer.UV6Kind
  77242. * - VertexBuffer.ColorKind
  77243. * - VertexBuffer.MatricesIndicesKind
  77244. * - VertexBuffer.MatricesIndicesExtraKind
  77245. * - VertexBuffer.MatricesWeightsKind
  77246. * - VertexBuffer.MatricesWeightsExtraKind
  77247. * @param data defines the data source
  77248. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77249. * @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)
  77250. * @returns the current mesh
  77251. */
  77252. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  77253. /**
  77254. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  77255. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  77256. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  77257. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  77258. * @returns the current mesh
  77259. */
  77260. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  77261. /**
  77262. * Creates a un-shared specific occurence of the geometry for the mesh.
  77263. * @returns the current mesh
  77264. */
  77265. makeGeometryUnique(): Mesh;
  77266. /**
  77267. * Set the index buffer of this mesh
  77268. * @param indices defines the source data
  77269. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  77270. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  77271. * @returns the current mesh
  77272. */
  77273. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  77274. /**
  77275. * Update the current index buffer
  77276. * @param indices defines the source data
  77277. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  77278. * @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)
  77279. * @returns the current mesh
  77280. */
  77281. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  77282. /**
  77283. * Invert the geometry to move from a right handed system to a left handed one.
  77284. * @returns the current mesh
  77285. */
  77286. toLeftHanded(): Mesh;
  77287. /** @hidden */
  77288. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  77289. /** @hidden */
  77290. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  77291. /**
  77292. * Registers for this mesh a javascript function called just before the rendering process
  77293. * @param func defines the function to call before rendering this mesh
  77294. * @returns the current mesh
  77295. */
  77296. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77297. /**
  77298. * Disposes a previously registered javascript function called before the rendering
  77299. * @param func defines the function to remove
  77300. * @returns the current mesh
  77301. */
  77302. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77303. /**
  77304. * Registers for this mesh a javascript function called just after the rendering is complete
  77305. * @param func defines the function to call after rendering this mesh
  77306. * @returns the current mesh
  77307. */
  77308. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77309. /**
  77310. * Disposes a previously registered javascript function called after the rendering.
  77311. * @param func defines the function to remove
  77312. * @returns the current mesh
  77313. */
  77314. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77315. /** @hidden */
  77316. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  77317. /** @hidden */
  77318. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  77319. /** @hidden */
  77320. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  77321. /** @hidden */
  77322. _rebuild(): void;
  77323. /** @hidden */
  77324. _freeze(): void;
  77325. /** @hidden */
  77326. _unFreeze(): void;
  77327. /**
  77328. * 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
  77329. * @param subMesh defines the subMesh to render
  77330. * @param enableAlphaMode defines if alpha mode can be changed
  77331. * @returns the current mesh
  77332. */
  77333. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  77334. private _onBeforeDraw;
  77335. /**
  77336. * Renormalize the mesh and patch it up if there are no weights
  77337. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  77338. * However in the case of zero weights then we set just a single influence to 1.
  77339. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  77340. */
  77341. cleanMatrixWeights(): void;
  77342. private normalizeSkinFourWeights;
  77343. private normalizeSkinWeightsAndExtra;
  77344. /**
  77345. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  77346. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  77347. * the user know there was an issue with importing the mesh
  77348. * @returns a validation object with skinned, valid and report string
  77349. */
  77350. validateSkinning(): {
  77351. skinned: boolean;
  77352. valid: boolean;
  77353. report: string;
  77354. };
  77355. /** @hidden */
  77356. _checkDelayState(): Mesh;
  77357. private _queueLoad;
  77358. /**
  77359. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  77360. * A mesh is in the frustum if its bounding box intersects the frustum
  77361. * @param frustumPlanes defines the frustum to test
  77362. * @returns true if the mesh is in the frustum planes
  77363. */
  77364. isInFrustum(frustumPlanes: Plane[]): boolean;
  77365. /**
  77366. * Sets the mesh material by the material or multiMaterial `id` property
  77367. * @param id is a string identifying the material or the multiMaterial
  77368. * @returns the current mesh
  77369. */
  77370. setMaterialByID(id: string): Mesh;
  77371. /**
  77372. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  77373. * @returns an array of IAnimatable
  77374. */
  77375. getAnimatables(): IAnimatable[];
  77376. /**
  77377. * Modifies the mesh geometry according to the passed transformation matrix.
  77378. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  77379. * The mesh normals are modified using the same transformation.
  77380. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77381. * @param transform defines the transform matrix to use
  77382. * @see http://doc.babylonjs.com/resources/baking_transformations
  77383. * @returns the current mesh
  77384. */
  77385. bakeTransformIntoVertices(transform: Matrix): Mesh;
  77386. /**
  77387. * Modifies the mesh geometry according to its own current World Matrix.
  77388. * The mesh World Matrix is then reset.
  77389. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  77390. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77391. * @see http://doc.babylonjs.com/resources/baking_transformations
  77392. * @returns the current mesh
  77393. */
  77394. bakeCurrentTransformIntoVertices(): Mesh;
  77395. /** @hidden */
  77396. readonly _positions: Nullable<Vector3[]>;
  77397. /** @hidden */
  77398. _resetPointsArrayCache(): Mesh;
  77399. /** @hidden */
  77400. _generatePointsArray(): boolean;
  77401. /**
  77402. * Returns a new Mesh object generated from the current mesh properties.
  77403. * This method must not get confused with createInstance()
  77404. * @param name is a string, the name given to the new mesh
  77405. * @param newParent can be any Node object (default `null`)
  77406. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  77407. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  77408. * @returns a new mesh
  77409. */
  77410. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  77411. /**
  77412. * Releases resources associated with this mesh.
  77413. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77414. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77415. */
  77416. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77417. /**
  77418. * Modifies the mesh geometry according to a displacement map.
  77419. * 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.
  77420. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77421. * @param url is a string, the URL from the image file is to be downloaded.
  77422. * @param minHeight is the lower limit of the displacement.
  77423. * @param maxHeight is the upper limit of the displacement.
  77424. * @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.
  77425. * @param uvOffset is an optional vector2 used to offset UV.
  77426. * @param uvScale is an optional vector2 used to scale UV.
  77427. * @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.
  77428. * @returns the Mesh.
  77429. */
  77430. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77431. /**
  77432. * Modifies the mesh geometry according to a displacementMap buffer.
  77433. * 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.
  77434. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77435. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  77436. * @param heightMapWidth is the width of the buffer image.
  77437. * @param heightMapHeight is the height of the buffer image.
  77438. * @param minHeight is the lower limit of the displacement.
  77439. * @param maxHeight is the upper limit of the displacement.
  77440. * @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.
  77441. * @param uvOffset is an optional vector2 used to offset UV.
  77442. * @param uvScale is an optional vector2 used to scale UV.
  77443. * @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.
  77444. * @returns the Mesh.
  77445. */
  77446. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77447. /**
  77448. * Modify the mesh to get a flat shading rendering.
  77449. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  77450. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  77451. * @returns current mesh
  77452. */
  77453. convertToFlatShadedMesh(): Mesh;
  77454. /**
  77455. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  77456. * In other words, more vertices, no more indices and a single bigger VBO.
  77457. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  77458. * @returns current mesh
  77459. */
  77460. convertToUnIndexedMesh(): Mesh;
  77461. /**
  77462. * Inverses facet orientations.
  77463. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77464. * @param flipNormals will also inverts the normals
  77465. * @returns current mesh
  77466. */
  77467. flipFaces(flipNormals?: boolean): Mesh;
  77468. /**
  77469. * Increase the number of facets and hence vertices in a mesh
  77470. * Vertex normals are interpolated from existing vertex normals
  77471. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77472. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  77473. */
  77474. increaseVertices(numberPerEdge: number): void;
  77475. /**
  77476. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  77477. * This will undo any application of covertToFlatShadedMesh
  77478. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77479. */
  77480. forceSharedVertices(): void;
  77481. /** @hidden */
  77482. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  77483. /** @hidden */
  77484. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  77485. /**
  77486. * Creates a new InstancedMesh object from the mesh model.
  77487. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77488. * @param name defines the name of the new instance
  77489. * @returns a new InstancedMesh
  77490. */
  77491. createInstance(name: string): InstancedMesh;
  77492. /**
  77493. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  77494. * After this call, all the mesh instances have the same submeshes than the current mesh.
  77495. * @returns the current mesh
  77496. */
  77497. synchronizeInstances(): Mesh;
  77498. /**
  77499. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  77500. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  77501. * This should be used together with the simplification to avoid disappearing triangles.
  77502. * @param successCallback an optional success callback to be called after the optimization finished.
  77503. * @returns the current mesh
  77504. */
  77505. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  77506. /**
  77507. * Serialize current mesh
  77508. * @param serializationObject defines the object which will receive the serialization data
  77509. */
  77510. serialize(serializationObject: any): void;
  77511. /** @hidden */
  77512. _syncGeometryWithMorphTargetManager(): void;
  77513. /** @hidden */
  77514. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  77515. /**
  77516. * Returns a new Mesh object parsed from the source provided.
  77517. * @param parsedMesh is the source
  77518. * @param scene defines the hosting scene
  77519. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  77520. * @returns a new Mesh
  77521. */
  77522. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  77523. /**
  77524. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  77525. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77526. * @param name defines the name of the mesh to create
  77527. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  77528. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  77529. * @param closePath creates a seam between the first and the last points of each path of the path array
  77530. * @param offset is taken in account only if the `pathArray` is containing a single path
  77531. * @param scene defines the hosting scene
  77532. * @param updatable defines if the mesh must be flagged as updatable
  77533. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77534. * @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)
  77535. * @returns a new Mesh
  77536. */
  77537. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77538. /**
  77539. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  77540. * @param name defines the name of the mesh to create
  77541. * @param radius sets the radius size (float) of the polygon (default 0.5)
  77542. * @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
  77543. * @param scene defines the hosting scene
  77544. * @param updatable defines if the mesh must be flagged as updatable
  77545. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77546. * @returns a new Mesh
  77547. */
  77548. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77549. /**
  77550. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  77551. * @param name defines the name of the mesh to create
  77552. * @param size sets the size (float) of each box side (default 1)
  77553. * @param scene defines the hosting scene
  77554. * @param updatable defines if the mesh must be flagged as updatable
  77555. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77556. * @returns a new Mesh
  77557. */
  77558. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77559. /**
  77560. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  77561. * @param name defines the name of the mesh to create
  77562. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77563. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77564. * @param scene defines the hosting scene
  77565. * @param updatable defines if the mesh must be flagged as updatable
  77566. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77567. * @returns a new Mesh
  77568. */
  77569. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77570. /**
  77571. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  77572. * @param name defines the name of the mesh to create
  77573. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77574. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77575. * @param scene defines the hosting scene
  77576. * @returns a new Mesh
  77577. */
  77578. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  77579. /**
  77580. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  77581. * @param name defines the name of the mesh to create
  77582. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  77583. * @param diameterTop set the top cap diameter (floats, default 1)
  77584. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  77585. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  77586. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  77587. * @param scene defines the hosting scene
  77588. * @param updatable defines if the mesh must be flagged as updatable
  77589. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77590. * @returns a new Mesh
  77591. */
  77592. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  77593. /**
  77594. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  77595. * @param name defines the name of the mesh to create
  77596. * @param diameter sets the diameter size (float) of the torus (default 1)
  77597. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  77598. * @param tessellation sets the number of torus sides (postive integer, default 16)
  77599. * @param scene defines the hosting scene
  77600. * @param updatable defines if the mesh must be flagged as updatable
  77601. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77602. * @returns a new Mesh
  77603. */
  77604. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77605. /**
  77606. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  77607. * @param name defines the name of the mesh to create
  77608. * @param radius sets the global radius size (float) of the torus knot (default 2)
  77609. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  77610. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  77611. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  77612. * @param p the number of windings on X axis (positive integers, default 2)
  77613. * @param q the number of windings on Y axis (positive integers, default 3)
  77614. * @param scene defines the hosting scene
  77615. * @param updatable defines if the mesh must be flagged as updatable
  77616. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77617. * @returns a new Mesh
  77618. */
  77619. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77620. /**
  77621. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  77622. * @param name defines the name of the mesh to create
  77623. * @param points is an array successive Vector3
  77624. * @param scene defines the hosting scene
  77625. * @param updatable defines if the mesh must be flagged as updatable
  77626. * @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).
  77627. * @returns a new Mesh
  77628. */
  77629. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  77630. /**
  77631. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  77632. * @param name defines the name of the mesh to create
  77633. * @param points is an array successive Vector3
  77634. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  77635. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  77636. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  77637. * @param scene defines the hosting scene
  77638. * @param updatable defines if the mesh must be flagged as updatable
  77639. * @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)
  77640. * @returns a new Mesh
  77641. */
  77642. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  77643. /**
  77644. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  77645. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  77646. * 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.
  77647. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77648. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77649. * Remember you can only change the shape positions, not their number when updating a polygon.
  77650. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  77651. * @param name defines the name of the mesh to create
  77652. * @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
  77653. * @param scene defines the hosting scene
  77654. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77655. * @param updatable defines if the mesh must be flagged as updatable
  77656. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77657. * @param earcutInjection can be used to inject your own earcut reference
  77658. * @returns a new Mesh
  77659. */
  77660. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77661. /**
  77662. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  77663. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  77664. * @param name defines the name of the mesh to create
  77665. * @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
  77666. * @param depth defines the height of extrusion
  77667. * @param scene defines the hosting scene
  77668. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77669. * @param updatable defines if the mesh must be flagged as updatable
  77670. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77671. * @param earcutInjection can be used to inject your own earcut reference
  77672. * @returns a new Mesh
  77673. */
  77674. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77675. /**
  77676. * Creates an extruded shape mesh.
  77677. * 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
  77678. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77679. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77680. * @param name defines the name of the mesh to create
  77681. * @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
  77682. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77683. * @param scale is the value to scale the shape
  77684. * @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
  77685. * @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
  77686. * @param scene defines the hosting scene
  77687. * @param updatable defines if the mesh must be flagged as updatable
  77688. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77689. * @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)
  77690. * @returns a new Mesh
  77691. */
  77692. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77693. /**
  77694. * Creates an custom extruded shape mesh.
  77695. * The custom extrusion is a parametric shape.
  77696. * It has no predefined shape. Its final shape will depend on the input parameters.
  77697. * Please consider using the same method from the MeshBuilder class instead
  77698. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77699. * @param name defines the name of the mesh to create
  77700. * @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
  77701. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77702. * @param scaleFunction is a custom Javascript function called on each path point
  77703. * @param rotationFunction is a custom Javascript function called on each path point
  77704. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  77705. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  77706. * @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
  77707. * @param scene defines the hosting scene
  77708. * @param updatable defines if the mesh must be flagged as updatable
  77709. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77710. * @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)
  77711. * @returns a new Mesh
  77712. */
  77713. 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;
  77714. /**
  77715. * Creates lathe mesh.
  77716. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  77717. * Please consider using the same method from the MeshBuilder class instead
  77718. * @param name defines the name of the mesh to create
  77719. * @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
  77720. * @param radius is the radius value of the lathe
  77721. * @param tessellation is the side number of the lathe.
  77722. * @param scene defines the hosting scene
  77723. * @param updatable defines if the mesh must be flagged as updatable
  77724. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77725. * @returns a new Mesh
  77726. */
  77727. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77728. /**
  77729. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  77730. * @param name defines the name of the mesh to create
  77731. * @param size sets the size (float) of both sides of the plane at once (default 1)
  77732. * @param scene defines the hosting scene
  77733. * @param updatable defines if the mesh must be flagged as updatable
  77734. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77735. * @returns a new Mesh
  77736. */
  77737. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77738. /**
  77739. * Creates a ground mesh.
  77740. * Please consider using the same method from the MeshBuilder class instead
  77741. * @param name defines the name of the mesh to create
  77742. * @param width set the width of the ground
  77743. * @param height set the height of the ground
  77744. * @param subdivisions sets the number of subdivisions per side
  77745. * @param scene defines the hosting scene
  77746. * @param updatable defines if the mesh must be flagged as updatable
  77747. * @returns a new Mesh
  77748. */
  77749. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  77750. /**
  77751. * Creates a tiled ground mesh.
  77752. * Please consider using the same method from the MeshBuilder class instead
  77753. * @param name defines the name of the mesh to create
  77754. * @param xmin set the ground minimum X coordinate
  77755. * @param zmin set the ground minimum Y coordinate
  77756. * @param xmax set the ground maximum X coordinate
  77757. * @param zmax set the ground maximum Z coordinate
  77758. * @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
  77759. * @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
  77760. * @param scene defines the hosting scene
  77761. * @param updatable defines if the mesh must be flagged as updatable
  77762. * @returns a new Mesh
  77763. */
  77764. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  77765. w: number;
  77766. h: number;
  77767. }, precision: {
  77768. w: number;
  77769. h: number;
  77770. }, scene: Scene, updatable?: boolean): Mesh;
  77771. /**
  77772. * Creates a ground mesh from a height map.
  77773. * Please consider using the same method from the MeshBuilder class instead
  77774. * @see http://doc.babylonjs.com/babylon101/height_map
  77775. * @param name defines the name of the mesh to create
  77776. * @param url sets the URL of the height map image resource
  77777. * @param width set the ground width size
  77778. * @param height set the ground height size
  77779. * @param subdivisions sets the number of subdivision per side
  77780. * @param minHeight is the minimum altitude on the ground
  77781. * @param maxHeight is the maximum altitude on the ground
  77782. * @param scene defines the hosting scene
  77783. * @param updatable defines if the mesh must be flagged as updatable
  77784. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  77785. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  77786. * @returns a new Mesh
  77787. */
  77788. 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;
  77789. /**
  77790. * Creates a tube mesh.
  77791. * The tube is a parametric shape.
  77792. * It has no predefined shape. Its final shape will depend on the input parameters.
  77793. * Please consider using the same method from the MeshBuilder class instead
  77794. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77795. * @param name defines the name of the mesh to create
  77796. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  77797. * @param radius sets the tube radius size
  77798. * @param tessellation is the number of sides on the tubular surface
  77799. * @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
  77800. * @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
  77801. * @param scene defines the hosting scene
  77802. * @param updatable defines if the mesh must be flagged as updatable
  77803. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77804. * @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)
  77805. * @returns a new Mesh
  77806. */
  77807. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  77808. (i: number, distance: number): number;
  77809. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77810. /**
  77811. * Creates a polyhedron mesh.
  77812. * Please consider using the same method from the MeshBuilder class instead.
  77813. * * 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
  77814. * * The parameter `size` (positive float, default 1) sets the polygon size
  77815. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  77816. * * 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`
  77817. * * 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
  77818. * * 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)`)
  77819. * * 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
  77820. * * 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
  77821. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77822. * * 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
  77823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77824. * @param name defines the name of the mesh to create
  77825. * @param options defines the options used to create the mesh
  77826. * @param scene defines the hosting scene
  77827. * @returns a new Mesh
  77828. */
  77829. static CreatePolyhedron(name: string, options: {
  77830. type?: number;
  77831. size?: number;
  77832. sizeX?: number;
  77833. sizeY?: number;
  77834. sizeZ?: number;
  77835. custom?: any;
  77836. faceUV?: Vector4[];
  77837. faceColors?: Color4[];
  77838. updatable?: boolean;
  77839. sideOrientation?: number;
  77840. }, scene: Scene): Mesh;
  77841. /**
  77842. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  77843. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  77844. * * 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`)
  77845. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  77846. * * 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
  77847. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77848. * * 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
  77849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77850. * @param name defines the name of the mesh
  77851. * @param options defines the options used to create the mesh
  77852. * @param scene defines the hosting scene
  77853. * @returns a new Mesh
  77854. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  77855. */
  77856. static CreateIcoSphere(name: string, options: {
  77857. radius?: number;
  77858. flat?: boolean;
  77859. subdivisions?: number;
  77860. sideOrientation?: number;
  77861. updatable?: boolean;
  77862. }, scene: Scene): Mesh;
  77863. /**
  77864. * Creates a decal mesh.
  77865. * Please consider using the same method from the MeshBuilder class instead.
  77866. * A decal is a mesh usually applied as a model onto the surface of another mesh
  77867. * @param name defines the name of the mesh
  77868. * @param sourceMesh defines the mesh receiving the decal
  77869. * @param position sets the position of the decal in world coordinates
  77870. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  77871. * @param size sets the decal scaling
  77872. * @param angle sets the angle to rotate the decal
  77873. * @returns a new Mesh
  77874. */
  77875. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  77876. /**
  77877. * Prepare internal position array for software CPU skinning
  77878. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  77879. */
  77880. setPositionsForCPUSkinning(): Float32Array;
  77881. /**
  77882. * Prepare internal normal array for software CPU skinning
  77883. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  77884. */
  77885. setNormalsForCPUSkinning(): Float32Array;
  77886. /**
  77887. * Updates the vertex buffer by applying transformation from the bones
  77888. * @param skeleton defines the skeleton to apply to current mesh
  77889. * @returns the current mesh
  77890. */
  77891. applySkeleton(skeleton: Skeleton): Mesh;
  77892. /**
  77893. * 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
  77894. * @param meshes defines the list of meshes to scan
  77895. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  77896. */
  77897. static MinMax(meshes: AbstractMesh[]): {
  77898. min: Vector3;
  77899. max: Vector3;
  77900. };
  77901. /**
  77902. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  77903. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  77904. * @returns a vector3
  77905. */
  77906. static Center(meshesOrMinMaxVector: {
  77907. min: Vector3;
  77908. max: Vector3;
  77909. } | AbstractMesh[]): Vector3;
  77910. /**
  77911. * Merge the array of meshes into a single mesh for performance reasons.
  77912. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  77913. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  77914. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  77915. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  77916. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  77917. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  77918. * @returns a new mesh
  77919. */
  77920. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  77921. /** @hidden */
  77922. addInstance(instance: InstancedMesh): void;
  77923. /** @hidden */
  77924. removeInstance(instance: InstancedMesh): void;
  77925. }
  77926. }
  77927. declare module BABYLON {
  77928. /**
  77929. * Interface used to define Action
  77930. */
  77931. export interface IAction {
  77932. /**
  77933. * Trigger for the action
  77934. */
  77935. trigger: number;
  77936. /** Options of the trigger */
  77937. triggerOptions: any;
  77938. /**
  77939. * Gets the trigger parameters
  77940. * @returns the trigger parameters
  77941. */
  77942. getTriggerParameter(): any;
  77943. /**
  77944. * Internal only - executes current action event
  77945. * @hidden
  77946. */
  77947. _executeCurrent(evt?: ActionEvent): void;
  77948. /**
  77949. * Serialize placeholder for child classes
  77950. * @param parent of child
  77951. * @returns the serialized object
  77952. */
  77953. serialize(parent: any): any;
  77954. /**
  77955. * Internal only
  77956. * @hidden
  77957. */
  77958. _prepare(): void;
  77959. /**
  77960. * Internal only - manager for action
  77961. * @hidden
  77962. */
  77963. _actionManager: AbstractActionManager;
  77964. /**
  77965. * Adds action to chain of actions, may be a DoNothingAction
  77966. * @param action defines the next action to execute
  77967. * @returns The action passed in
  77968. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77969. */
  77970. then(action: IAction): IAction;
  77971. }
  77972. /**
  77973. * The action to be carried out following a trigger
  77974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  77975. */
  77976. export class Action implements IAction {
  77977. /** the trigger, with or without parameters, for the action */
  77978. triggerOptions: any;
  77979. /**
  77980. * Trigger for the action
  77981. */
  77982. trigger: number;
  77983. /**
  77984. * Internal only - manager for action
  77985. * @hidden
  77986. */
  77987. _actionManager: ActionManager;
  77988. private _nextActiveAction;
  77989. private _child;
  77990. private _condition?;
  77991. private _triggerParameter;
  77992. /**
  77993. * An event triggered prior to action being executed.
  77994. */
  77995. onBeforeExecuteObservable: Observable<Action>;
  77996. /**
  77997. * Creates a new Action
  77998. * @param triggerOptions the trigger, with or without parameters, for the action
  77999. * @param condition an optional determinant of action
  78000. */
  78001. constructor(
  78002. /** the trigger, with or without parameters, for the action */
  78003. triggerOptions: any, condition?: Condition);
  78004. /**
  78005. * Internal only
  78006. * @hidden
  78007. */
  78008. _prepare(): void;
  78009. /**
  78010. * Gets the trigger parameters
  78011. * @returns the trigger parameters
  78012. */
  78013. getTriggerParameter(): any;
  78014. /**
  78015. * Internal only - executes current action event
  78016. * @hidden
  78017. */
  78018. _executeCurrent(evt?: ActionEvent): void;
  78019. /**
  78020. * Execute placeholder for child classes
  78021. * @param evt optional action event
  78022. */
  78023. execute(evt?: ActionEvent): void;
  78024. /**
  78025. * Skips to next active action
  78026. */
  78027. skipToNextActiveAction(): void;
  78028. /**
  78029. * Adds action to chain of actions, may be a DoNothingAction
  78030. * @param action defines the next action to execute
  78031. * @returns The action passed in
  78032. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78033. */
  78034. then(action: Action): Action;
  78035. /**
  78036. * Internal only
  78037. * @hidden
  78038. */
  78039. _getProperty(propertyPath: string): string;
  78040. /**
  78041. * Internal only
  78042. * @hidden
  78043. */
  78044. _getEffectiveTarget(target: any, propertyPath: string): any;
  78045. /**
  78046. * Serialize placeholder for child classes
  78047. * @param parent of child
  78048. * @returns the serialized object
  78049. */
  78050. serialize(parent: any): any;
  78051. /**
  78052. * Internal only called by serialize
  78053. * @hidden
  78054. */
  78055. protected _serialize(serializedAction: any, parent?: any): any;
  78056. /**
  78057. * Internal only
  78058. * @hidden
  78059. */
  78060. static _SerializeValueAsString: (value: any) => string;
  78061. /**
  78062. * Internal only
  78063. * @hidden
  78064. */
  78065. static _GetTargetProperty: (target: Scene | Node) => {
  78066. name: string;
  78067. targetType: string;
  78068. value: string;
  78069. };
  78070. }
  78071. }
  78072. declare module BABYLON {
  78073. /**
  78074. * A Condition applied to an Action
  78075. */
  78076. export class Condition {
  78077. /**
  78078. * Internal only - manager for action
  78079. * @hidden
  78080. */
  78081. _actionManager: ActionManager;
  78082. /**
  78083. * Internal only
  78084. * @hidden
  78085. */
  78086. _evaluationId: number;
  78087. /**
  78088. * Internal only
  78089. * @hidden
  78090. */
  78091. _currentResult: boolean;
  78092. /**
  78093. * Creates a new Condition
  78094. * @param actionManager the manager of the action the condition is applied to
  78095. */
  78096. constructor(actionManager: ActionManager);
  78097. /**
  78098. * Check if the current condition is valid
  78099. * @returns a boolean
  78100. */
  78101. isValid(): boolean;
  78102. /**
  78103. * Internal only
  78104. * @hidden
  78105. */
  78106. _getProperty(propertyPath: string): string;
  78107. /**
  78108. * Internal only
  78109. * @hidden
  78110. */
  78111. _getEffectiveTarget(target: any, propertyPath: string): any;
  78112. /**
  78113. * Serialize placeholder for child classes
  78114. * @returns the serialized object
  78115. */
  78116. serialize(): any;
  78117. /**
  78118. * Internal only
  78119. * @hidden
  78120. */
  78121. protected _serialize(serializedCondition: any): any;
  78122. }
  78123. /**
  78124. * Defines specific conditional operators as extensions of Condition
  78125. */
  78126. export class ValueCondition extends Condition {
  78127. /** path to specify the property of the target the conditional operator uses */
  78128. propertyPath: string;
  78129. /** the value compared by the conditional operator against the current value of the property */
  78130. value: any;
  78131. /** the conditional operator, default ValueCondition.IsEqual */
  78132. operator: number;
  78133. /**
  78134. * Internal only
  78135. * @hidden
  78136. */
  78137. private static _IsEqual;
  78138. /**
  78139. * Internal only
  78140. * @hidden
  78141. */
  78142. private static _IsDifferent;
  78143. /**
  78144. * Internal only
  78145. * @hidden
  78146. */
  78147. private static _IsGreater;
  78148. /**
  78149. * Internal only
  78150. * @hidden
  78151. */
  78152. private static _IsLesser;
  78153. /**
  78154. * returns the number for IsEqual
  78155. */
  78156. static readonly IsEqual: number;
  78157. /**
  78158. * Returns the number for IsDifferent
  78159. */
  78160. static readonly IsDifferent: number;
  78161. /**
  78162. * Returns the number for IsGreater
  78163. */
  78164. static readonly IsGreater: number;
  78165. /**
  78166. * Returns the number for IsLesser
  78167. */
  78168. static readonly IsLesser: number;
  78169. /**
  78170. * Internal only The action manager for the condition
  78171. * @hidden
  78172. */
  78173. _actionManager: ActionManager;
  78174. /**
  78175. * Internal only
  78176. * @hidden
  78177. */
  78178. private _target;
  78179. /**
  78180. * Internal only
  78181. * @hidden
  78182. */
  78183. private _effectiveTarget;
  78184. /**
  78185. * Internal only
  78186. * @hidden
  78187. */
  78188. private _property;
  78189. /**
  78190. * Creates a new ValueCondition
  78191. * @param actionManager manager for the action the condition applies to
  78192. * @param target for the action
  78193. * @param propertyPath path to specify the property of the target the conditional operator uses
  78194. * @param value the value compared by the conditional operator against the current value of the property
  78195. * @param operator the conditional operator, default ValueCondition.IsEqual
  78196. */
  78197. constructor(actionManager: ActionManager, target: any,
  78198. /** path to specify the property of the target the conditional operator uses */
  78199. propertyPath: string,
  78200. /** the value compared by the conditional operator against the current value of the property */
  78201. value: any,
  78202. /** the conditional operator, default ValueCondition.IsEqual */
  78203. operator?: number);
  78204. /**
  78205. * Compares the given value with the property value for the specified conditional operator
  78206. * @returns the result of the comparison
  78207. */
  78208. isValid(): boolean;
  78209. /**
  78210. * Serialize the ValueCondition into a JSON compatible object
  78211. * @returns serialization object
  78212. */
  78213. serialize(): any;
  78214. /**
  78215. * Gets the name of the conditional operator for the ValueCondition
  78216. * @param operator the conditional operator
  78217. * @returns the name
  78218. */
  78219. static GetOperatorName(operator: number): string;
  78220. }
  78221. /**
  78222. * Defines a predicate condition as an extension of Condition
  78223. */
  78224. export class PredicateCondition extends Condition {
  78225. /** defines the predicate function used to validate the condition */
  78226. predicate: () => boolean;
  78227. /**
  78228. * Internal only - manager for action
  78229. * @hidden
  78230. */
  78231. _actionManager: ActionManager;
  78232. /**
  78233. * Creates a new PredicateCondition
  78234. * @param actionManager manager for the action the condition applies to
  78235. * @param predicate defines the predicate function used to validate the condition
  78236. */
  78237. constructor(actionManager: ActionManager,
  78238. /** defines the predicate function used to validate the condition */
  78239. predicate: () => boolean);
  78240. /**
  78241. * @returns the validity of the predicate condition
  78242. */
  78243. isValid(): boolean;
  78244. }
  78245. /**
  78246. * Defines a state condition as an extension of Condition
  78247. */
  78248. export class StateCondition extends Condition {
  78249. /** Value to compare with target state */
  78250. value: string;
  78251. /**
  78252. * Internal only - manager for action
  78253. * @hidden
  78254. */
  78255. _actionManager: ActionManager;
  78256. /**
  78257. * Internal only
  78258. * @hidden
  78259. */
  78260. private _target;
  78261. /**
  78262. * Creates a new StateCondition
  78263. * @param actionManager manager for the action the condition applies to
  78264. * @param target of the condition
  78265. * @param value to compare with target state
  78266. */
  78267. constructor(actionManager: ActionManager, target: any,
  78268. /** Value to compare with target state */
  78269. value: string);
  78270. /**
  78271. * Gets a boolean indicating if the current condition is met
  78272. * @returns the validity of the state
  78273. */
  78274. isValid(): boolean;
  78275. /**
  78276. * Serialize the StateCondition into a JSON compatible object
  78277. * @returns serialization object
  78278. */
  78279. serialize(): any;
  78280. }
  78281. }
  78282. declare module BABYLON {
  78283. /**
  78284. * This defines an action responsible to toggle a boolean once triggered.
  78285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78286. */
  78287. export class SwitchBooleanAction extends Action {
  78288. /**
  78289. * The path to the boolean property in the target object
  78290. */
  78291. propertyPath: string;
  78292. private _target;
  78293. private _effectiveTarget;
  78294. private _property;
  78295. /**
  78296. * Instantiate the action
  78297. * @param triggerOptions defines the trigger options
  78298. * @param target defines the object containing the boolean
  78299. * @param propertyPath defines the path to the boolean property in the target object
  78300. * @param condition defines the trigger related conditions
  78301. */
  78302. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  78303. /** @hidden */
  78304. _prepare(): void;
  78305. /**
  78306. * Execute the action toggle the boolean value.
  78307. */
  78308. execute(): void;
  78309. /**
  78310. * Serializes the actions and its related information.
  78311. * @param parent defines the object to serialize in
  78312. * @returns the serialized object
  78313. */
  78314. serialize(parent: any): any;
  78315. }
  78316. /**
  78317. * This defines an action responsible to set a the state field of the target
  78318. * to a desired value once triggered.
  78319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78320. */
  78321. export class SetStateAction extends Action {
  78322. /**
  78323. * The value to store in the state field.
  78324. */
  78325. value: string;
  78326. private _target;
  78327. /**
  78328. * Instantiate the action
  78329. * @param triggerOptions defines the trigger options
  78330. * @param target defines the object containing the state property
  78331. * @param value defines the value to store in the state field
  78332. * @param condition defines the trigger related conditions
  78333. */
  78334. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78335. /**
  78336. * Execute the action and store the value on the target state property.
  78337. */
  78338. execute(): void;
  78339. /**
  78340. * Serializes the actions and its related information.
  78341. * @param parent defines the object to serialize in
  78342. * @returns the serialized object
  78343. */
  78344. serialize(parent: any): any;
  78345. }
  78346. /**
  78347. * This defines an action responsible to set a property of the target
  78348. * to a desired value once triggered.
  78349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78350. */
  78351. export class SetValueAction extends Action {
  78352. /**
  78353. * The path of the property to set in the target.
  78354. */
  78355. propertyPath: string;
  78356. /**
  78357. * The value to set in the property
  78358. */
  78359. value: any;
  78360. private _target;
  78361. private _effectiveTarget;
  78362. private _property;
  78363. /**
  78364. * Instantiate the action
  78365. * @param triggerOptions defines the trigger options
  78366. * @param target defines the object containing the property
  78367. * @param propertyPath defines the path of the property to set in the target
  78368. * @param value defines the value to set in the property
  78369. * @param condition defines the trigger related conditions
  78370. */
  78371. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78372. /** @hidden */
  78373. _prepare(): void;
  78374. /**
  78375. * Execute the action and set the targetted property to the desired value.
  78376. */
  78377. execute(): void;
  78378. /**
  78379. * Serializes the actions and its related information.
  78380. * @param parent defines the object to serialize in
  78381. * @returns the serialized object
  78382. */
  78383. serialize(parent: any): any;
  78384. }
  78385. /**
  78386. * This defines an action responsible to increment the target value
  78387. * to a desired value once triggered.
  78388. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78389. */
  78390. export class IncrementValueAction extends Action {
  78391. /**
  78392. * The path of the property to increment in the target.
  78393. */
  78394. propertyPath: string;
  78395. /**
  78396. * The value we should increment the property by.
  78397. */
  78398. value: any;
  78399. private _target;
  78400. private _effectiveTarget;
  78401. private _property;
  78402. /**
  78403. * Instantiate the action
  78404. * @param triggerOptions defines the trigger options
  78405. * @param target defines the object containing the property
  78406. * @param propertyPath defines the path of the property to increment in the target
  78407. * @param value defines the value value we should increment the property by
  78408. * @param condition defines the trigger related conditions
  78409. */
  78410. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78411. /** @hidden */
  78412. _prepare(): void;
  78413. /**
  78414. * Execute the action and increment the target of the value amount.
  78415. */
  78416. execute(): void;
  78417. /**
  78418. * Serializes the actions and its related information.
  78419. * @param parent defines the object to serialize in
  78420. * @returns the serialized object
  78421. */
  78422. serialize(parent: any): any;
  78423. }
  78424. /**
  78425. * This defines an action responsible to start an animation once triggered.
  78426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78427. */
  78428. export class PlayAnimationAction extends Action {
  78429. /**
  78430. * Where the animation should start (animation frame)
  78431. */
  78432. from: number;
  78433. /**
  78434. * Where the animation should stop (animation frame)
  78435. */
  78436. to: number;
  78437. /**
  78438. * Define if the animation should loop or stop after the first play.
  78439. */
  78440. loop?: boolean;
  78441. private _target;
  78442. /**
  78443. * Instantiate the action
  78444. * @param triggerOptions defines the trigger options
  78445. * @param target defines the target animation or animation name
  78446. * @param from defines from where the animation should start (animation frame)
  78447. * @param end defines where the animation should stop (animation frame)
  78448. * @param loop defines if the animation should loop or stop after the first play
  78449. * @param condition defines the trigger related conditions
  78450. */
  78451. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78452. /** @hidden */
  78453. _prepare(): void;
  78454. /**
  78455. * Execute the action and play the animation.
  78456. */
  78457. execute(): void;
  78458. /**
  78459. * Serializes the actions and its related information.
  78460. * @param parent defines the object to serialize in
  78461. * @returns the serialized object
  78462. */
  78463. serialize(parent: any): any;
  78464. }
  78465. /**
  78466. * This defines an action responsible to stop an animation once triggered.
  78467. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78468. */
  78469. export class StopAnimationAction extends Action {
  78470. private _target;
  78471. /**
  78472. * Instantiate the action
  78473. * @param triggerOptions defines the trigger options
  78474. * @param target defines the target animation or animation name
  78475. * @param condition defines the trigger related conditions
  78476. */
  78477. constructor(triggerOptions: any, target: any, condition?: Condition);
  78478. /** @hidden */
  78479. _prepare(): void;
  78480. /**
  78481. * Execute the action and stop the animation.
  78482. */
  78483. execute(): void;
  78484. /**
  78485. * Serializes the actions and its related information.
  78486. * @param parent defines the object to serialize in
  78487. * @returns the serialized object
  78488. */
  78489. serialize(parent: any): any;
  78490. }
  78491. /**
  78492. * This defines an action responsible that does nothing once triggered.
  78493. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78494. */
  78495. export class DoNothingAction extends Action {
  78496. /**
  78497. * Instantiate the action
  78498. * @param triggerOptions defines the trigger options
  78499. * @param condition defines the trigger related conditions
  78500. */
  78501. constructor(triggerOptions?: any, condition?: Condition);
  78502. /**
  78503. * Execute the action and do nothing.
  78504. */
  78505. execute(): void;
  78506. /**
  78507. * Serializes the actions and its related information.
  78508. * @param parent defines the object to serialize in
  78509. * @returns the serialized object
  78510. */
  78511. serialize(parent: any): any;
  78512. }
  78513. /**
  78514. * This defines an action responsible to trigger several actions once triggered.
  78515. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78516. */
  78517. export class CombineAction extends Action {
  78518. /**
  78519. * The list of aggregated animations to run.
  78520. */
  78521. children: Action[];
  78522. /**
  78523. * Instantiate the action
  78524. * @param triggerOptions defines the trigger options
  78525. * @param children defines the list of aggregated animations to run
  78526. * @param condition defines the trigger related conditions
  78527. */
  78528. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78529. /** @hidden */
  78530. _prepare(): void;
  78531. /**
  78532. * Execute the action and executes all the aggregated actions.
  78533. */
  78534. execute(evt: ActionEvent): void;
  78535. /**
  78536. * Serializes the actions and its related information.
  78537. * @param parent defines the object to serialize in
  78538. * @returns the serialized object
  78539. */
  78540. serialize(parent: any): any;
  78541. }
  78542. /**
  78543. * This defines an action responsible to run code (external event) once triggered.
  78544. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78545. */
  78546. export class ExecuteCodeAction extends Action {
  78547. /**
  78548. * The callback function to run.
  78549. */
  78550. func: (evt: ActionEvent) => void;
  78551. /**
  78552. * Instantiate the action
  78553. * @param triggerOptions defines the trigger options
  78554. * @param func defines the callback function to run
  78555. * @param condition defines the trigger related conditions
  78556. */
  78557. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78558. /**
  78559. * Execute the action and run the attached code.
  78560. */
  78561. execute(evt: ActionEvent): void;
  78562. }
  78563. /**
  78564. * This defines an action responsible to set the parent property of the target once triggered.
  78565. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78566. */
  78567. export class SetParentAction extends Action {
  78568. private _parent;
  78569. private _target;
  78570. /**
  78571. * Instantiate the action
  78572. * @param triggerOptions defines the trigger options
  78573. * @param target defines the target containing the parent property
  78574. * @param parent defines from where the animation should start (animation frame)
  78575. * @param condition defines the trigger related conditions
  78576. */
  78577. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78578. /** @hidden */
  78579. _prepare(): void;
  78580. /**
  78581. * Execute the action and set the parent property.
  78582. */
  78583. execute(): void;
  78584. /**
  78585. * Serializes the actions and its related information.
  78586. * @param parent defines the object to serialize in
  78587. * @returns the serialized object
  78588. */
  78589. serialize(parent: any): any;
  78590. }
  78591. }
  78592. declare module BABYLON {
  78593. /**
  78594. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78595. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78596. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78597. */
  78598. export class ActionManager extends AbstractActionManager {
  78599. /**
  78600. * Nothing
  78601. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78602. */
  78603. static readonly NothingTrigger: number;
  78604. /**
  78605. * On pick
  78606. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78607. */
  78608. static readonly OnPickTrigger: number;
  78609. /**
  78610. * On left pick
  78611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78612. */
  78613. static readonly OnLeftPickTrigger: number;
  78614. /**
  78615. * On right pick
  78616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78617. */
  78618. static readonly OnRightPickTrigger: number;
  78619. /**
  78620. * On center pick
  78621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78622. */
  78623. static readonly OnCenterPickTrigger: number;
  78624. /**
  78625. * On pick down
  78626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78627. */
  78628. static readonly OnPickDownTrigger: number;
  78629. /**
  78630. * On double pick
  78631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78632. */
  78633. static readonly OnDoublePickTrigger: number;
  78634. /**
  78635. * On pick up
  78636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78637. */
  78638. static readonly OnPickUpTrigger: number;
  78639. /**
  78640. * On pick out.
  78641. * This trigger will only be raised if you also declared a OnPickDown
  78642. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78643. */
  78644. static readonly OnPickOutTrigger: number;
  78645. /**
  78646. * On long press
  78647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78648. */
  78649. static readonly OnLongPressTrigger: number;
  78650. /**
  78651. * On pointer over
  78652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78653. */
  78654. static readonly OnPointerOverTrigger: number;
  78655. /**
  78656. * On pointer out
  78657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78658. */
  78659. static readonly OnPointerOutTrigger: number;
  78660. /**
  78661. * On every frame
  78662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78663. */
  78664. static readonly OnEveryFrameTrigger: number;
  78665. /**
  78666. * On intersection enter
  78667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78668. */
  78669. static readonly OnIntersectionEnterTrigger: number;
  78670. /**
  78671. * On intersection exit
  78672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78673. */
  78674. static readonly OnIntersectionExitTrigger: number;
  78675. /**
  78676. * On key down
  78677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78678. */
  78679. static readonly OnKeyDownTrigger: number;
  78680. /**
  78681. * On key up
  78682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78683. */
  78684. static readonly OnKeyUpTrigger: number;
  78685. private _scene;
  78686. /**
  78687. * Creates a new action manager
  78688. * @param scene defines the hosting scene
  78689. */
  78690. constructor(scene: Scene);
  78691. /**
  78692. * Releases all associated resources
  78693. */
  78694. dispose(): void;
  78695. /**
  78696. * Gets hosting scene
  78697. * @returns the hosting scene
  78698. */
  78699. getScene(): Scene;
  78700. /**
  78701. * Does this action manager handles actions of any of the given triggers
  78702. * @param triggers defines the triggers to be tested
  78703. * @return a boolean indicating whether one (or more) of the triggers is handled
  78704. */
  78705. hasSpecificTriggers(triggers: number[]): boolean;
  78706. /**
  78707. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78708. * speed.
  78709. * @param triggerA defines the trigger to be tested
  78710. * @param triggerB defines the trigger to be tested
  78711. * @return a boolean indicating whether one (or more) of the triggers is handled
  78712. */
  78713. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78714. /**
  78715. * Does this action manager handles actions of a given trigger
  78716. * @param trigger defines the trigger to be tested
  78717. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78718. * @return whether the trigger is handled
  78719. */
  78720. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78721. /**
  78722. * Does this action manager has pointer triggers
  78723. */
  78724. readonly hasPointerTriggers: boolean;
  78725. /**
  78726. * Does this action manager has pick triggers
  78727. */
  78728. readonly hasPickTriggers: boolean;
  78729. /**
  78730. * Registers an action to this action manager
  78731. * @param action defines the action to be registered
  78732. * @return the action amended (prepared) after registration
  78733. */
  78734. registerAction(action: IAction): Nullable<IAction>;
  78735. /**
  78736. * Unregisters an action to this action manager
  78737. * @param action defines the action to be unregistered
  78738. * @return a boolean indicating whether the action has been unregistered
  78739. */
  78740. unregisterAction(action: IAction): Boolean;
  78741. /**
  78742. * Process a specific trigger
  78743. * @param trigger defines the trigger to process
  78744. * @param evt defines the event details to be processed
  78745. */
  78746. processTrigger(trigger: number, evt?: IActionEvent): void;
  78747. /** @hidden */
  78748. _getEffectiveTarget(target: any, propertyPath: string): any;
  78749. /** @hidden */
  78750. _getProperty(propertyPath: string): string;
  78751. /**
  78752. * Serialize this manager to a JSON object
  78753. * @param name defines the property name to store this manager
  78754. * @returns a JSON representation of this manager
  78755. */
  78756. serialize(name: string): any;
  78757. /**
  78758. * Creates a new ActionManager from a JSON data
  78759. * @param parsedActions defines the JSON data to read from
  78760. * @param object defines the hosting mesh
  78761. * @param scene defines the hosting scene
  78762. */
  78763. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78764. /**
  78765. * Get a trigger name by index
  78766. * @param trigger defines the trigger index
  78767. * @returns a trigger name
  78768. */
  78769. static GetTriggerName(trigger: number): string;
  78770. }
  78771. }
  78772. declare module BABYLON {
  78773. /**
  78774. * Class representing a ray with position and direction
  78775. */
  78776. export class Ray {
  78777. /** origin point */
  78778. origin: Vector3;
  78779. /** direction */
  78780. direction: Vector3;
  78781. /** length of the ray */
  78782. length: number;
  78783. private static readonly TmpVector3;
  78784. private _tmpRay;
  78785. /**
  78786. * Creates a new ray
  78787. * @param origin origin point
  78788. * @param direction direction
  78789. * @param length length of the ray
  78790. */
  78791. constructor(
  78792. /** origin point */
  78793. origin: Vector3,
  78794. /** direction */
  78795. direction: Vector3,
  78796. /** length of the ray */
  78797. length?: number);
  78798. /**
  78799. * Checks if the ray intersects a box
  78800. * @param minimum bound of the box
  78801. * @param maximum bound of the box
  78802. * @param intersectionTreshold extra extend to be added to the box in all direction
  78803. * @returns if the box was hit
  78804. */
  78805. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78806. /**
  78807. * Checks if the ray intersects a box
  78808. * @param box the bounding box to check
  78809. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78810. * @returns if the box was hit
  78811. */
  78812. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78813. /**
  78814. * If the ray hits a sphere
  78815. * @param sphere the bounding sphere to check
  78816. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78817. * @returns true if it hits the sphere
  78818. */
  78819. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78820. /**
  78821. * If the ray hits a triange
  78822. * @param vertex0 triangle vertex
  78823. * @param vertex1 triangle vertex
  78824. * @param vertex2 triangle vertex
  78825. * @returns intersection information if hit
  78826. */
  78827. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78828. /**
  78829. * Checks if ray intersects a plane
  78830. * @param plane the plane to check
  78831. * @returns the distance away it was hit
  78832. */
  78833. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78834. /**
  78835. * Calculate the intercept of a ray on a given axis
  78836. * @param axis to check 'x' | 'y' | 'z'
  78837. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  78838. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  78839. */
  78840. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  78841. /**
  78842. * Checks if ray intersects a mesh
  78843. * @param mesh the mesh to check
  78844. * @param fastCheck if only the bounding box should checked
  78845. * @returns picking info of the intersecton
  78846. */
  78847. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78848. /**
  78849. * Checks if ray intersects a mesh
  78850. * @param meshes the meshes to check
  78851. * @param fastCheck if only the bounding box should checked
  78852. * @param results array to store result in
  78853. * @returns Array of picking infos
  78854. */
  78855. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78856. private _comparePickingInfo;
  78857. private static smallnum;
  78858. private static rayl;
  78859. /**
  78860. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  78861. * @param sega the first point of the segment to test the intersection against
  78862. * @param segb the second point of the segment to test the intersection against
  78863. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  78864. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  78865. */
  78866. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  78867. /**
  78868. * Update the ray from viewport position
  78869. * @param x position
  78870. * @param y y position
  78871. * @param viewportWidth viewport width
  78872. * @param viewportHeight viewport height
  78873. * @param world world matrix
  78874. * @param view view matrix
  78875. * @param projection projection matrix
  78876. * @returns this ray updated
  78877. */
  78878. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78879. /**
  78880. * Creates a ray with origin and direction of 0,0,0
  78881. * @returns the new ray
  78882. */
  78883. static Zero(): Ray;
  78884. /**
  78885. * Creates a new ray from screen space and viewport
  78886. * @param x position
  78887. * @param y y position
  78888. * @param viewportWidth viewport width
  78889. * @param viewportHeight viewport height
  78890. * @param world world matrix
  78891. * @param view view matrix
  78892. * @param projection projection matrix
  78893. * @returns new ray
  78894. */
  78895. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78896. /**
  78897. * 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
  78898. * transformed to the given world matrix.
  78899. * @param origin The origin point
  78900. * @param end The end point
  78901. * @param world a matrix to transform the ray to. Default is the identity matrix.
  78902. * @returns the new ray
  78903. */
  78904. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  78905. /**
  78906. * Transforms a ray by a matrix
  78907. * @param ray ray to transform
  78908. * @param matrix matrix to apply
  78909. * @returns the resulting new ray
  78910. */
  78911. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  78912. /**
  78913. * Transforms a ray by a matrix
  78914. * @param ray ray to transform
  78915. * @param matrix matrix to apply
  78916. * @param result ray to store result in
  78917. */
  78918. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  78919. /**
  78920. * Unproject a ray from screen space to object space
  78921. * @param sourceX defines the screen space x coordinate to use
  78922. * @param sourceY defines the screen space y coordinate to use
  78923. * @param viewportWidth defines the current width of the viewport
  78924. * @param viewportHeight defines the current height of the viewport
  78925. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78926. * @param view defines the view matrix to use
  78927. * @param projection defines the projection matrix to use
  78928. */
  78929. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  78930. }
  78931. /**
  78932. * Type used to define predicate used to select faces when a mesh intersection is detected
  78933. */
  78934. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  78935. interface Scene {
  78936. /** @hidden */
  78937. _tempPickingRay: Nullable<Ray>;
  78938. /** @hidden */
  78939. _cachedRayForTransform: Ray;
  78940. /** @hidden */
  78941. _pickWithRayInverseMatrix: Matrix;
  78942. /** @hidden */
  78943. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  78944. /** @hidden */
  78945. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  78946. }
  78947. }
  78948. declare module BABYLON {
  78949. interface Scene {
  78950. /** @hidden */
  78951. _pointerOverSprite: Nullable<Sprite>;
  78952. /** @hidden */
  78953. _pickedDownSprite: Nullable<Sprite>;
  78954. /** @hidden */
  78955. _tempSpritePickingRay: Nullable<Ray>;
  78956. /**
  78957. * All of the sprite managers added to this scene
  78958. * @see http://doc.babylonjs.com/babylon101/sprites
  78959. */
  78960. spriteManagers: Array<ISpriteManager>;
  78961. /**
  78962. * An event triggered when sprites rendering is about to start
  78963. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78964. */
  78965. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78966. /**
  78967. * An event triggered when sprites rendering is done
  78968. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78969. */
  78970. onAfterSpritesRenderingObservable: Observable<Scene>;
  78971. /** @hidden */
  78972. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78973. /** Launch a ray to try to pick a sprite in the scene
  78974. * @param x position on screen
  78975. * @param y position on screen
  78976. * @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
  78977. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78978. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78979. * @returns a PickingInfo
  78980. */
  78981. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78982. /** Use the given ray to pick a sprite in the scene
  78983. * @param ray The ray (in world space) to use to pick meshes
  78984. * @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
  78985. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78986. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78987. * @returns a PickingInfo
  78988. */
  78989. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78990. /**
  78991. * Force the sprite under the pointer
  78992. * @param sprite defines the sprite to use
  78993. */
  78994. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78995. /**
  78996. * Gets the sprite under the pointer
  78997. * @returns a Sprite or null if no sprite is under the pointer
  78998. */
  78999. getPointerOverSprite(): Nullable<Sprite>;
  79000. }
  79001. /**
  79002. * Defines the sprite scene component responsible to manage sprites
  79003. * in a given scene.
  79004. */
  79005. export class SpriteSceneComponent implements ISceneComponent {
  79006. /**
  79007. * The component name helpfull to identify the component in the list of scene components.
  79008. */
  79009. readonly name: string;
  79010. /**
  79011. * The scene the component belongs to.
  79012. */
  79013. scene: Scene;
  79014. /** @hidden */
  79015. private _spritePredicate;
  79016. /**
  79017. * Creates a new instance of the component for the given scene
  79018. * @param scene Defines the scene to register the component in
  79019. */
  79020. constructor(scene: Scene);
  79021. /**
  79022. * Registers the component in a given scene
  79023. */
  79024. register(): void;
  79025. /**
  79026. * Rebuilds the elements related to this component in case of
  79027. * context lost for instance.
  79028. */
  79029. rebuild(): void;
  79030. /**
  79031. * Disposes the component and the associated ressources.
  79032. */
  79033. dispose(): void;
  79034. private _pickSpriteButKeepRay;
  79035. private _pointerMove;
  79036. private _pointerDown;
  79037. private _pointerUp;
  79038. }
  79039. }
  79040. declare module BABYLON {
  79041. /** @hidden */
  79042. export var fogFragmentDeclaration: {
  79043. name: string;
  79044. shader: string;
  79045. };
  79046. }
  79047. declare module BABYLON {
  79048. /** @hidden */
  79049. export var fogFragment: {
  79050. name: string;
  79051. shader: string;
  79052. };
  79053. }
  79054. declare module BABYLON {
  79055. /** @hidden */
  79056. export var spritesPixelShader: {
  79057. name: string;
  79058. shader: string;
  79059. };
  79060. }
  79061. declare module BABYLON {
  79062. /** @hidden */
  79063. export var fogVertexDeclaration: {
  79064. name: string;
  79065. shader: string;
  79066. };
  79067. }
  79068. declare module BABYLON {
  79069. /** @hidden */
  79070. export var spritesVertexShader: {
  79071. name: string;
  79072. shader: string;
  79073. };
  79074. }
  79075. declare module BABYLON {
  79076. /**
  79077. * Defines the minimum interface to fullfil in order to be a sprite manager.
  79078. */
  79079. export interface ISpriteManager extends IDisposable {
  79080. /**
  79081. * Restricts the camera to viewing objects with the same layerMask.
  79082. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  79083. */
  79084. layerMask: number;
  79085. /**
  79086. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79087. */
  79088. isPickable: boolean;
  79089. /**
  79090. * Specifies the rendering group id for this mesh (0 by default)
  79091. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79092. */
  79093. renderingGroupId: number;
  79094. /**
  79095. * Defines the list of sprites managed by the manager.
  79096. */
  79097. sprites: Array<Sprite>;
  79098. /**
  79099. * Tests the intersection of a sprite with a specific ray.
  79100. * @param ray The ray we are sending to test the collision
  79101. * @param camera The camera space we are sending rays in
  79102. * @param predicate A predicate allowing excluding sprites from the list of object to test
  79103. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  79104. * @returns picking info or null.
  79105. */
  79106. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79107. /**
  79108. * Renders the list of sprites on screen.
  79109. */
  79110. render(): void;
  79111. }
  79112. /**
  79113. * Class used to manage multiple sprites on the same spritesheet
  79114. * @see http://doc.babylonjs.com/babylon101/sprites
  79115. */
  79116. export class SpriteManager implements ISpriteManager {
  79117. /** defines the manager's name */
  79118. name: string;
  79119. /** Gets the list of sprites */
  79120. sprites: Sprite[];
  79121. /** Gets or sets the rendering group id (0 by default) */
  79122. renderingGroupId: number;
  79123. /** Gets or sets camera layer mask */
  79124. layerMask: number;
  79125. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  79126. fogEnabled: boolean;
  79127. /** Gets or sets a boolean indicating if the sprites are pickable */
  79128. isPickable: boolean;
  79129. /** Defines the default width of a cell in the spritesheet */
  79130. cellWidth: number;
  79131. /** Defines the default height of a cell in the spritesheet */
  79132. cellHeight: number;
  79133. /**
  79134. * An event triggered when the manager is disposed.
  79135. */
  79136. onDisposeObservable: Observable<SpriteManager>;
  79137. private _onDisposeObserver;
  79138. /**
  79139. * Callback called when the manager is disposed
  79140. */
  79141. onDispose: () => void;
  79142. private _capacity;
  79143. private _spriteTexture;
  79144. private _epsilon;
  79145. private _scene;
  79146. private _vertexData;
  79147. private _buffer;
  79148. private _vertexBuffers;
  79149. private _indexBuffer;
  79150. private _effectBase;
  79151. private _effectFog;
  79152. /**
  79153. * Gets or sets the spritesheet texture
  79154. */
  79155. texture: Texture;
  79156. /**
  79157. * Creates a new sprite manager
  79158. * @param name defines the manager's name
  79159. * @param imgUrl defines the sprite sheet url
  79160. * @param capacity defines the maximum allowed number of sprites
  79161. * @param cellSize defines the size of a sprite cell
  79162. * @param scene defines the hosting scene
  79163. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  79164. * @param samplingMode defines the smapling mode to use with spritesheet
  79165. */
  79166. constructor(
  79167. /** defines the manager's name */
  79168. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  79169. private _appendSpriteVertex;
  79170. /**
  79171. * Intersects the sprites with a ray
  79172. * @param ray defines the ray to intersect with
  79173. * @param camera defines the current active camera
  79174. * @param predicate defines a predicate used to select candidate sprites
  79175. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  79176. * @returns null if no hit or a PickingInfo
  79177. */
  79178. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79179. /**
  79180. * Render all child sprites
  79181. */
  79182. render(): void;
  79183. /**
  79184. * Release associated resources
  79185. */
  79186. dispose(): void;
  79187. }
  79188. }
  79189. declare module BABYLON {
  79190. /**
  79191. * Class used to represent a sprite
  79192. * @see http://doc.babylonjs.com/babylon101/sprites
  79193. */
  79194. export class Sprite {
  79195. /** defines the name */
  79196. name: string;
  79197. /** Gets or sets the current world position */
  79198. position: Vector3;
  79199. /** Gets or sets the main color */
  79200. color: Color4;
  79201. /** Gets or sets the width */
  79202. width: number;
  79203. /** Gets or sets the height */
  79204. height: number;
  79205. /** Gets or sets rotation angle */
  79206. angle: number;
  79207. /** Gets or sets the cell index in the sprite sheet */
  79208. cellIndex: number;
  79209. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  79210. invertU: number;
  79211. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  79212. invertV: number;
  79213. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  79214. disposeWhenFinishedAnimating: boolean;
  79215. /** Gets the list of attached animations */
  79216. animations: Animation[];
  79217. /** Gets or sets a boolean indicating if the sprite can be picked */
  79218. isPickable: boolean;
  79219. /**
  79220. * Gets or sets the associated action manager
  79221. */
  79222. actionManager: Nullable<ActionManager>;
  79223. private _animationStarted;
  79224. private _loopAnimation;
  79225. private _fromIndex;
  79226. private _toIndex;
  79227. private _delay;
  79228. private _direction;
  79229. private _manager;
  79230. private _time;
  79231. private _onAnimationEnd;
  79232. /**
  79233. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  79234. */
  79235. isVisible: boolean;
  79236. /**
  79237. * Gets or sets the sprite size
  79238. */
  79239. size: number;
  79240. /**
  79241. * Creates a new Sprite
  79242. * @param name defines the name
  79243. * @param manager defines the manager
  79244. */
  79245. constructor(
  79246. /** defines the name */
  79247. name: string, manager: ISpriteManager);
  79248. /**
  79249. * Starts an animation
  79250. * @param from defines the initial key
  79251. * @param to defines the end key
  79252. * @param loop defines if the animation must loop
  79253. * @param delay defines the start delay (in ms)
  79254. * @param onAnimationEnd defines a callback to call when animation ends
  79255. */
  79256. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  79257. /** Stops current animation (if any) */
  79258. stopAnimation(): void;
  79259. /** @hidden */
  79260. _animate(deltaTime: number): void;
  79261. /** Release associated resources */
  79262. dispose(): void;
  79263. }
  79264. }
  79265. declare module BABYLON {
  79266. /**
  79267. * Information about the result of picking within a scene
  79268. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  79269. */
  79270. export class PickingInfo {
  79271. /** @hidden */
  79272. _pickingUnavailable: boolean;
  79273. /**
  79274. * If the pick collided with an object
  79275. */
  79276. hit: boolean;
  79277. /**
  79278. * Distance away where the pick collided
  79279. */
  79280. distance: number;
  79281. /**
  79282. * The location of pick collision
  79283. */
  79284. pickedPoint: Nullable<Vector3>;
  79285. /**
  79286. * The mesh corresponding the the pick collision
  79287. */
  79288. pickedMesh: Nullable<AbstractMesh>;
  79289. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  79290. bu: number;
  79291. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  79292. bv: number;
  79293. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  79294. faceId: number;
  79295. /** Id of the the submesh that was picked */
  79296. subMeshId: number;
  79297. /** If a sprite was picked, this will be the sprite the pick collided with */
  79298. pickedSprite: Nullable<Sprite>;
  79299. /**
  79300. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  79301. */
  79302. originMesh: Nullable<AbstractMesh>;
  79303. /**
  79304. * The ray that was used to perform the picking.
  79305. */
  79306. ray: Nullable<Ray>;
  79307. /**
  79308. * Gets the normal correspodning to the face the pick collided with
  79309. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79310. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79311. * @returns The normal correspodning to the face the pick collided with
  79312. */
  79313. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79314. /**
  79315. * Gets the texture coordinates of where the pick occured
  79316. * @returns the vector containing the coordnates of the texture
  79317. */
  79318. getTextureCoordinates(): Nullable<Vector2>;
  79319. }
  79320. }
  79321. declare module BABYLON {
  79322. /**
  79323. * Gather the list of pointer event types as constants.
  79324. */
  79325. export class PointerEventTypes {
  79326. /**
  79327. * 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.
  79328. */
  79329. static readonly POINTERDOWN: number;
  79330. /**
  79331. * The pointerup event is fired when a pointer is no longer active.
  79332. */
  79333. static readonly POINTERUP: number;
  79334. /**
  79335. * The pointermove event is fired when a pointer changes coordinates.
  79336. */
  79337. static readonly POINTERMOVE: number;
  79338. /**
  79339. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79340. */
  79341. static readonly POINTERWHEEL: number;
  79342. /**
  79343. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79344. */
  79345. static readonly POINTERPICK: number;
  79346. /**
  79347. * The pointertap event is fired when a the object has been touched and released without drag.
  79348. */
  79349. static readonly POINTERTAP: number;
  79350. /**
  79351. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79352. */
  79353. static readonly POINTERDOUBLETAP: number;
  79354. }
  79355. /**
  79356. * Base class of pointer info types.
  79357. */
  79358. export class PointerInfoBase {
  79359. /**
  79360. * Defines the type of event (PointerEventTypes)
  79361. */
  79362. type: number;
  79363. /**
  79364. * Defines the related dom event
  79365. */
  79366. event: PointerEvent | MouseWheelEvent;
  79367. /**
  79368. * Instantiates the base class of pointers info.
  79369. * @param type Defines the type of event (PointerEventTypes)
  79370. * @param event Defines the related dom event
  79371. */
  79372. constructor(
  79373. /**
  79374. * Defines the type of event (PointerEventTypes)
  79375. */
  79376. type: number,
  79377. /**
  79378. * Defines the related dom event
  79379. */
  79380. event: PointerEvent | MouseWheelEvent);
  79381. }
  79382. /**
  79383. * This class is used to store pointer related info for the onPrePointerObservable event.
  79384. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79385. */
  79386. export class PointerInfoPre extends PointerInfoBase {
  79387. /**
  79388. * Ray from a pointer if availible (eg. 6dof controller)
  79389. */
  79390. ray: Nullable<Ray>;
  79391. /**
  79392. * Defines the local position of the pointer on the canvas.
  79393. */
  79394. localPosition: Vector2;
  79395. /**
  79396. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79397. */
  79398. skipOnPointerObservable: boolean;
  79399. /**
  79400. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79401. * @param type Defines the type of event (PointerEventTypes)
  79402. * @param event Defines the related dom event
  79403. * @param localX Defines the local x coordinates of the pointer when the event occured
  79404. * @param localY Defines the local y coordinates of the pointer when the event occured
  79405. */
  79406. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79407. }
  79408. /**
  79409. * This type contains all the data related to a pointer event in Babylon.js.
  79410. * 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.
  79411. */
  79412. export class PointerInfo extends PointerInfoBase {
  79413. /**
  79414. * Defines the picking info associated to the info (if any)\
  79415. */
  79416. pickInfo: Nullable<PickingInfo>;
  79417. /**
  79418. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79419. * @param type Defines the type of event (PointerEventTypes)
  79420. * @param event Defines the related dom event
  79421. * @param pickInfo Defines the picking info associated to the info (if any)\
  79422. */
  79423. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79424. /**
  79425. * Defines the picking info associated to the info (if any)\
  79426. */
  79427. pickInfo: Nullable<PickingInfo>);
  79428. }
  79429. /**
  79430. * Data relating to a touch event on the screen.
  79431. */
  79432. export interface PointerTouch {
  79433. /**
  79434. * X coordinate of touch.
  79435. */
  79436. x: number;
  79437. /**
  79438. * Y coordinate of touch.
  79439. */
  79440. y: number;
  79441. /**
  79442. * Id of touch. Unique for each finger.
  79443. */
  79444. pointerId: number;
  79445. /**
  79446. * Event type passed from DOM.
  79447. */
  79448. type: any;
  79449. }
  79450. }
  79451. declare module BABYLON {
  79452. /**
  79453. * Manage the mouse inputs to control the movement of a free camera.
  79454. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79455. */
  79456. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79457. /**
  79458. * Define if touch is enabled in the mouse input
  79459. */
  79460. touchEnabled: boolean;
  79461. /**
  79462. * Defines the camera the input is attached to.
  79463. */
  79464. camera: FreeCamera;
  79465. /**
  79466. * Defines the buttons associated with the input to handle camera move.
  79467. */
  79468. buttons: number[];
  79469. /**
  79470. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79471. */
  79472. angularSensibility: number;
  79473. private _pointerInput;
  79474. private _onMouseMove;
  79475. private _observer;
  79476. private previousPosition;
  79477. /**
  79478. * Observable for when a pointer move event occurs containing the move offset
  79479. */
  79480. onPointerMovedObservable: Observable<{
  79481. offsetX: number;
  79482. offsetY: number;
  79483. }>;
  79484. /**
  79485. * @hidden
  79486. * If the camera should be rotated automatically based on pointer movement
  79487. */
  79488. _allowCameraRotation: boolean;
  79489. /**
  79490. * Manage the mouse inputs to control the movement of a free camera.
  79491. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79492. * @param touchEnabled Defines if touch is enabled or not
  79493. */
  79494. constructor(
  79495. /**
  79496. * Define if touch is enabled in the mouse input
  79497. */
  79498. touchEnabled?: boolean);
  79499. /**
  79500. * Attach the input controls to a specific dom element to get the input from.
  79501. * @param element Defines the element the controls should be listened from
  79502. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79503. */
  79504. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79505. /**
  79506. * Called on JS contextmenu event.
  79507. * Override this method to provide functionality.
  79508. */
  79509. protected onContextMenu(evt: PointerEvent): void;
  79510. /**
  79511. * Detach the current controls from the specified dom element.
  79512. * @param element Defines the element to stop listening the inputs from
  79513. */
  79514. detachControl(element: Nullable<HTMLElement>): void;
  79515. /**
  79516. * Gets the class name of the current intput.
  79517. * @returns the class name
  79518. */
  79519. getClassName(): string;
  79520. /**
  79521. * Get the friendly name associated with the input class.
  79522. * @returns the input friendly name
  79523. */
  79524. getSimpleName(): string;
  79525. }
  79526. }
  79527. declare module BABYLON {
  79528. /**
  79529. * Manage the touch inputs to control the movement of a free camera.
  79530. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79531. */
  79532. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79533. /**
  79534. * Defines the camera the input is attached to.
  79535. */
  79536. camera: FreeCamera;
  79537. /**
  79538. * Defines the touch sensibility for rotation.
  79539. * The higher the faster.
  79540. */
  79541. touchAngularSensibility: number;
  79542. /**
  79543. * Defines the touch sensibility for move.
  79544. * The higher the faster.
  79545. */
  79546. touchMoveSensibility: number;
  79547. private _offsetX;
  79548. private _offsetY;
  79549. private _pointerPressed;
  79550. private _pointerInput;
  79551. private _observer;
  79552. private _onLostFocus;
  79553. /**
  79554. * Attach the input controls to a specific dom element to get the input from.
  79555. * @param element Defines the element the controls should be listened from
  79556. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79557. */
  79558. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79559. /**
  79560. * Detach the current controls from the specified dom element.
  79561. * @param element Defines the element to stop listening the inputs from
  79562. */
  79563. detachControl(element: Nullable<HTMLElement>): void;
  79564. /**
  79565. * Update the current camera state depending on the inputs that have been used this frame.
  79566. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79567. */
  79568. checkInputs(): void;
  79569. /**
  79570. * Gets the class name of the current intput.
  79571. * @returns the class name
  79572. */
  79573. getClassName(): string;
  79574. /**
  79575. * Get the friendly name associated with the input class.
  79576. * @returns the input friendly name
  79577. */
  79578. getSimpleName(): string;
  79579. }
  79580. }
  79581. declare module BABYLON {
  79582. /**
  79583. * Default Inputs manager for the FreeCamera.
  79584. * It groups all the default supported inputs for ease of use.
  79585. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79586. */
  79587. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79588. /**
  79589. * @hidden
  79590. */
  79591. _mouseInput: Nullable<FreeCameraMouseInput>;
  79592. /**
  79593. * Instantiates a new FreeCameraInputsManager.
  79594. * @param camera Defines the camera the inputs belong to
  79595. */
  79596. constructor(camera: FreeCamera);
  79597. /**
  79598. * Add keyboard input support to the input manager.
  79599. * @returns the current input manager
  79600. */
  79601. addKeyboard(): FreeCameraInputsManager;
  79602. /**
  79603. * Add mouse input support to the input manager.
  79604. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79605. * @returns the current input manager
  79606. */
  79607. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79608. /**
  79609. * Removes the mouse input support from the manager
  79610. * @returns the current input manager
  79611. */
  79612. removeMouse(): FreeCameraInputsManager;
  79613. /**
  79614. * Add touch input support to the input manager.
  79615. * @returns the current input manager
  79616. */
  79617. addTouch(): FreeCameraInputsManager;
  79618. /**
  79619. * Remove all attached input methods from a camera
  79620. */
  79621. clear(): void;
  79622. }
  79623. }
  79624. declare module BABYLON {
  79625. /**
  79626. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79627. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79628. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79629. */
  79630. export class FreeCamera extends TargetCamera {
  79631. /**
  79632. * Define the collision ellipsoid of the camera.
  79633. * This is helpful to simulate a camera body like the player body around the camera
  79634. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79635. */
  79636. ellipsoid: Vector3;
  79637. /**
  79638. * Define an offset for the position of the ellipsoid around the camera.
  79639. * This can be helpful to determine the center of the body near the gravity center of the body
  79640. * instead of its head.
  79641. */
  79642. ellipsoidOffset: Vector3;
  79643. /**
  79644. * Enable or disable collisions of the camera with the rest of the scene objects.
  79645. */
  79646. checkCollisions: boolean;
  79647. /**
  79648. * Enable or disable gravity on the camera.
  79649. */
  79650. applyGravity: boolean;
  79651. /**
  79652. * Define the input manager associated to the camera.
  79653. */
  79654. inputs: FreeCameraInputsManager;
  79655. /**
  79656. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79657. * Higher values reduce sensitivity.
  79658. */
  79659. /**
  79660. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79661. * Higher values reduce sensitivity.
  79662. */
  79663. angularSensibility: number;
  79664. /**
  79665. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79666. */
  79667. keysUp: number[];
  79668. /**
  79669. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79670. */
  79671. keysDown: number[];
  79672. /**
  79673. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79674. */
  79675. keysLeft: number[];
  79676. /**
  79677. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79678. */
  79679. keysRight: number[];
  79680. /**
  79681. * Event raised when the camera collide with a mesh in the scene.
  79682. */
  79683. onCollide: (collidedMesh: AbstractMesh) => void;
  79684. private _collider;
  79685. private _needMoveForGravity;
  79686. private _oldPosition;
  79687. private _diffPosition;
  79688. private _newPosition;
  79689. /** @hidden */
  79690. _localDirection: Vector3;
  79691. /** @hidden */
  79692. _transformedDirection: Vector3;
  79693. /**
  79694. * Instantiates a Free Camera.
  79695. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79696. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79697. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79698. * @param name Define the name of the camera in the scene
  79699. * @param position Define the start position of the camera in the scene
  79700. * @param scene Define the scene the camera belongs to
  79701. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79702. */
  79703. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79704. /**
  79705. * Attached controls to the current camera.
  79706. * @param element Defines the element the controls should be listened from
  79707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79708. */
  79709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79710. /**
  79711. * Detach the current controls from the camera.
  79712. * The camera will stop reacting to inputs.
  79713. * @param element Defines the element to stop listening the inputs from
  79714. */
  79715. detachControl(element: HTMLElement): void;
  79716. private _collisionMask;
  79717. /**
  79718. * Define a collision mask to limit the list of object the camera can collide with
  79719. */
  79720. collisionMask: number;
  79721. /** @hidden */
  79722. _collideWithWorld(displacement: Vector3): void;
  79723. private _onCollisionPositionChange;
  79724. /** @hidden */
  79725. _checkInputs(): void;
  79726. /** @hidden */
  79727. _decideIfNeedsToMove(): boolean;
  79728. /** @hidden */
  79729. _updatePosition(): void;
  79730. /**
  79731. * Destroy the camera and release the current resources hold by it.
  79732. */
  79733. dispose(): void;
  79734. /**
  79735. * Gets the current object class name.
  79736. * @return the class name
  79737. */
  79738. getClassName(): string;
  79739. }
  79740. }
  79741. declare module BABYLON {
  79742. /**
  79743. * Represents a gamepad control stick position
  79744. */
  79745. export class StickValues {
  79746. /**
  79747. * The x component of the control stick
  79748. */
  79749. x: number;
  79750. /**
  79751. * The y component of the control stick
  79752. */
  79753. y: number;
  79754. /**
  79755. * Initializes the gamepad x and y control stick values
  79756. * @param x The x component of the gamepad control stick value
  79757. * @param y The y component of the gamepad control stick value
  79758. */
  79759. constructor(
  79760. /**
  79761. * The x component of the control stick
  79762. */
  79763. x: number,
  79764. /**
  79765. * The y component of the control stick
  79766. */
  79767. y: number);
  79768. }
  79769. /**
  79770. * An interface which manages callbacks for gamepad button changes
  79771. */
  79772. export interface GamepadButtonChanges {
  79773. /**
  79774. * Called when a gamepad has been changed
  79775. */
  79776. changed: boolean;
  79777. /**
  79778. * Called when a gamepad press event has been triggered
  79779. */
  79780. pressChanged: boolean;
  79781. /**
  79782. * Called when a touch event has been triggered
  79783. */
  79784. touchChanged: boolean;
  79785. /**
  79786. * Called when a value has changed
  79787. */
  79788. valueChanged: boolean;
  79789. }
  79790. /**
  79791. * Represents a gamepad
  79792. */
  79793. export class Gamepad {
  79794. /**
  79795. * The id of the gamepad
  79796. */
  79797. id: string;
  79798. /**
  79799. * The index of the gamepad
  79800. */
  79801. index: number;
  79802. /**
  79803. * The browser gamepad
  79804. */
  79805. browserGamepad: any;
  79806. /**
  79807. * Specifies what type of gamepad this represents
  79808. */
  79809. type: number;
  79810. private _leftStick;
  79811. private _rightStick;
  79812. /** @hidden */
  79813. _isConnected: boolean;
  79814. private _leftStickAxisX;
  79815. private _leftStickAxisY;
  79816. private _rightStickAxisX;
  79817. private _rightStickAxisY;
  79818. /**
  79819. * Triggered when the left control stick has been changed
  79820. */
  79821. private _onleftstickchanged;
  79822. /**
  79823. * Triggered when the right control stick has been changed
  79824. */
  79825. private _onrightstickchanged;
  79826. /**
  79827. * Represents a gamepad controller
  79828. */
  79829. static GAMEPAD: number;
  79830. /**
  79831. * Represents a generic controller
  79832. */
  79833. static GENERIC: number;
  79834. /**
  79835. * Represents an XBox controller
  79836. */
  79837. static XBOX: number;
  79838. /**
  79839. * Represents a pose-enabled controller
  79840. */
  79841. static POSE_ENABLED: number;
  79842. /**
  79843. * Specifies whether the left control stick should be Y-inverted
  79844. */
  79845. protected _invertLeftStickY: boolean;
  79846. /**
  79847. * Specifies if the gamepad has been connected
  79848. */
  79849. readonly isConnected: boolean;
  79850. /**
  79851. * Initializes the gamepad
  79852. * @param id The id of the gamepad
  79853. * @param index The index of the gamepad
  79854. * @param browserGamepad The browser gamepad
  79855. * @param leftStickX The x component of the left joystick
  79856. * @param leftStickY The y component of the left joystick
  79857. * @param rightStickX The x component of the right joystick
  79858. * @param rightStickY The y component of the right joystick
  79859. */
  79860. constructor(
  79861. /**
  79862. * The id of the gamepad
  79863. */
  79864. id: string,
  79865. /**
  79866. * The index of the gamepad
  79867. */
  79868. index: number,
  79869. /**
  79870. * The browser gamepad
  79871. */
  79872. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79873. /**
  79874. * Callback triggered when the left joystick has changed
  79875. * @param callback
  79876. */
  79877. onleftstickchanged(callback: (values: StickValues) => void): void;
  79878. /**
  79879. * Callback triggered when the right joystick has changed
  79880. * @param callback
  79881. */
  79882. onrightstickchanged(callback: (values: StickValues) => void): void;
  79883. /**
  79884. * Gets the left joystick
  79885. */
  79886. /**
  79887. * Sets the left joystick values
  79888. */
  79889. leftStick: StickValues;
  79890. /**
  79891. * Gets the right joystick
  79892. */
  79893. /**
  79894. * Sets the right joystick value
  79895. */
  79896. rightStick: StickValues;
  79897. /**
  79898. * Updates the gamepad joystick positions
  79899. */
  79900. update(): void;
  79901. /**
  79902. * Disposes the gamepad
  79903. */
  79904. dispose(): void;
  79905. }
  79906. /**
  79907. * Represents a generic gamepad
  79908. */
  79909. export class GenericPad extends Gamepad {
  79910. private _buttons;
  79911. private _onbuttondown;
  79912. private _onbuttonup;
  79913. /**
  79914. * Observable triggered when a button has been pressed
  79915. */
  79916. onButtonDownObservable: Observable<number>;
  79917. /**
  79918. * Observable triggered when a button has been released
  79919. */
  79920. onButtonUpObservable: Observable<number>;
  79921. /**
  79922. * Callback triggered when a button has been pressed
  79923. * @param callback Called when a button has been pressed
  79924. */
  79925. onbuttondown(callback: (buttonPressed: number) => void): void;
  79926. /**
  79927. * Callback triggered when a button has been released
  79928. * @param callback Called when a button has been released
  79929. */
  79930. onbuttonup(callback: (buttonReleased: number) => void): void;
  79931. /**
  79932. * Initializes the generic gamepad
  79933. * @param id The id of the generic gamepad
  79934. * @param index The index of the generic gamepad
  79935. * @param browserGamepad The browser gamepad
  79936. */
  79937. constructor(id: string, index: number, browserGamepad: any);
  79938. private _setButtonValue;
  79939. /**
  79940. * Updates the generic gamepad
  79941. */
  79942. update(): void;
  79943. /**
  79944. * Disposes the generic gamepad
  79945. */
  79946. dispose(): void;
  79947. }
  79948. }
  79949. declare module BABYLON {
  79950. /**
  79951. * Defines the types of pose enabled controllers that are supported
  79952. */
  79953. export enum PoseEnabledControllerType {
  79954. /**
  79955. * HTC Vive
  79956. */
  79957. VIVE = 0,
  79958. /**
  79959. * Oculus Rift
  79960. */
  79961. OCULUS = 1,
  79962. /**
  79963. * Windows mixed reality
  79964. */
  79965. WINDOWS = 2,
  79966. /**
  79967. * Samsung gear VR
  79968. */
  79969. GEAR_VR = 3,
  79970. /**
  79971. * Google Daydream
  79972. */
  79973. DAYDREAM = 4,
  79974. /**
  79975. * Generic
  79976. */
  79977. GENERIC = 5
  79978. }
  79979. /**
  79980. * Defines the MutableGamepadButton interface for the state of a gamepad button
  79981. */
  79982. export interface MutableGamepadButton {
  79983. /**
  79984. * Value of the button/trigger
  79985. */
  79986. value: number;
  79987. /**
  79988. * If the button/trigger is currently touched
  79989. */
  79990. touched: boolean;
  79991. /**
  79992. * If the button/trigger is currently pressed
  79993. */
  79994. pressed: boolean;
  79995. }
  79996. /**
  79997. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  79998. * @hidden
  79999. */
  80000. export interface ExtendedGamepadButton extends GamepadButton {
  80001. /**
  80002. * If the button/trigger is currently pressed
  80003. */
  80004. readonly pressed: boolean;
  80005. /**
  80006. * If the button/trigger is currently touched
  80007. */
  80008. readonly touched: boolean;
  80009. /**
  80010. * Value of the button/trigger
  80011. */
  80012. readonly value: number;
  80013. }
  80014. /** @hidden */
  80015. export interface _GamePadFactory {
  80016. /**
  80017. * Returns wether or not the current gamepad can be created for this type of controller.
  80018. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80019. * @returns true if it can be created, otherwise false
  80020. */
  80021. canCreate(gamepadInfo: any): boolean;
  80022. /**
  80023. * Creates a new instance of the Gamepad.
  80024. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80025. * @returns the new gamepad instance
  80026. */
  80027. create(gamepadInfo: any): Gamepad;
  80028. }
  80029. /**
  80030. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80031. */
  80032. export class PoseEnabledControllerHelper {
  80033. /** @hidden */
  80034. static _ControllerFactories: _GamePadFactory[];
  80035. /** @hidden */
  80036. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  80037. /**
  80038. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80039. * @param vrGamepad the gamepad to initialized
  80040. * @returns a vr controller of the type the gamepad identified as
  80041. */
  80042. static InitiateController(vrGamepad: any): Gamepad;
  80043. }
  80044. /**
  80045. * Defines the PoseEnabledController object that contains state of a vr capable controller
  80046. */
  80047. export class PoseEnabledController extends Gamepad implements PoseControlled {
  80048. /**
  80049. * If the controller is used in a webXR session
  80050. */
  80051. isXR: boolean;
  80052. private _deviceRoomPosition;
  80053. private _deviceRoomRotationQuaternion;
  80054. /**
  80055. * The device position in babylon space
  80056. */
  80057. devicePosition: Vector3;
  80058. /**
  80059. * The device rotation in babylon space
  80060. */
  80061. deviceRotationQuaternion: Quaternion;
  80062. /**
  80063. * The scale factor of the device in babylon space
  80064. */
  80065. deviceScaleFactor: number;
  80066. /**
  80067. * (Likely devicePosition should be used instead) The device position in its room space
  80068. */
  80069. position: Vector3;
  80070. /**
  80071. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  80072. */
  80073. rotationQuaternion: Quaternion;
  80074. /**
  80075. * The type of controller (Eg. Windows mixed reality)
  80076. */
  80077. controllerType: PoseEnabledControllerType;
  80078. protected _calculatedPosition: Vector3;
  80079. private _calculatedRotation;
  80080. /**
  80081. * The raw pose from the device
  80082. */
  80083. rawPose: DevicePose;
  80084. private _trackPosition;
  80085. private _maxRotationDistFromHeadset;
  80086. private _draggedRoomRotation;
  80087. /**
  80088. * @hidden
  80089. */
  80090. _disableTrackPosition(fixedPosition: Vector3): void;
  80091. /**
  80092. * Internal, the mesh attached to the controller
  80093. * @hidden
  80094. */
  80095. _mesh: Nullable<AbstractMesh>;
  80096. private _poseControlledCamera;
  80097. private _leftHandSystemQuaternion;
  80098. /**
  80099. * Internal, matrix used to convert room space to babylon space
  80100. * @hidden
  80101. */
  80102. _deviceToWorld: Matrix;
  80103. /**
  80104. * Node to be used when casting a ray from the controller
  80105. * @hidden
  80106. */
  80107. _pointingPoseNode: Nullable<TransformNode>;
  80108. /**
  80109. * Name of the child mesh that can be used to cast a ray from the controller
  80110. */
  80111. static readonly POINTING_POSE: string;
  80112. /**
  80113. * Creates a new PoseEnabledController from a gamepad
  80114. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  80115. */
  80116. constructor(browserGamepad: any);
  80117. private _workingMatrix;
  80118. /**
  80119. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  80120. */
  80121. update(): void;
  80122. /**
  80123. * Updates only the pose device and mesh without doing any button event checking
  80124. */
  80125. protected _updatePoseAndMesh(): void;
  80126. /**
  80127. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  80128. * @param poseData raw pose fromthe device
  80129. */
  80130. updateFromDevice(poseData: DevicePose): void;
  80131. /**
  80132. * @hidden
  80133. */
  80134. _meshAttachedObservable: Observable<AbstractMesh>;
  80135. /**
  80136. * Attaches a mesh to the controller
  80137. * @param mesh the mesh to be attached
  80138. */
  80139. attachToMesh(mesh: AbstractMesh): void;
  80140. /**
  80141. * Attaches the controllers mesh to a camera
  80142. * @param camera the camera the mesh should be attached to
  80143. */
  80144. attachToPoseControlledCamera(camera: TargetCamera): void;
  80145. /**
  80146. * Disposes of the controller
  80147. */
  80148. dispose(): void;
  80149. /**
  80150. * The mesh that is attached to the controller
  80151. */
  80152. readonly mesh: Nullable<AbstractMesh>;
  80153. /**
  80154. * Gets the ray of the controller in the direction the controller is pointing
  80155. * @param length the length the resulting ray should be
  80156. * @returns a ray in the direction the controller is pointing
  80157. */
  80158. getForwardRay(length?: number): Ray;
  80159. }
  80160. }
  80161. declare module BABYLON {
  80162. /**
  80163. * Defines the WebVRController object that represents controllers tracked in 3D space
  80164. */
  80165. export abstract class WebVRController extends PoseEnabledController {
  80166. /**
  80167. * Internal, the default controller model for the controller
  80168. */
  80169. protected _defaultModel: AbstractMesh;
  80170. /**
  80171. * Fired when the trigger state has changed
  80172. */
  80173. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  80174. /**
  80175. * Fired when the main button state has changed
  80176. */
  80177. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80178. /**
  80179. * Fired when the secondary button state has changed
  80180. */
  80181. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80182. /**
  80183. * Fired when the pad state has changed
  80184. */
  80185. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  80186. /**
  80187. * Fired when controllers stick values have changed
  80188. */
  80189. onPadValuesChangedObservable: Observable<StickValues>;
  80190. /**
  80191. * Array of button availible on the controller
  80192. */
  80193. protected _buttons: Array<MutableGamepadButton>;
  80194. private _onButtonStateChange;
  80195. /**
  80196. * Fired when a controller button's state has changed
  80197. * @param callback the callback containing the button that was modified
  80198. */
  80199. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  80200. /**
  80201. * X and Y axis corresponding to the controllers joystick
  80202. */
  80203. pad: StickValues;
  80204. /**
  80205. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  80206. */
  80207. hand: string;
  80208. /**
  80209. * The default controller model for the controller
  80210. */
  80211. readonly defaultModel: AbstractMesh;
  80212. /**
  80213. * Creates a new WebVRController from a gamepad
  80214. * @param vrGamepad the gamepad that the WebVRController should be created from
  80215. */
  80216. constructor(vrGamepad: any);
  80217. /**
  80218. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  80219. */
  80220. update(): void;
  80221. /**
  80222. * Function to be called when a button is modified
  80223. */
  80224. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  80225. /**
  80226. * Loads a mesh and attaches it to the controller
  80227. * @param scene the scene the mesh should be added to
  80228. * @param meshLoaded callback for when the mesh has been loaded
  80229. */
  80230. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  80231. private _setButtonValue;
  80232. private _changes;
  80233. private _checkChanges;
  80234. /**
  80235. * Disposes of th webVRCOntroller
  80236. */
  80237. dispose(): void;
  80238. }
  80239. }
  80240. declare module BABYLON {
  80241. /**
  80242. * The HemisphericLight simulates the ambient environment light,
  80243. * so the passed direction is the light reflection direction, not the incoming direction.
  80244. */
  80245. export class HemisphericLight extends Light {
  80246. /**
  80247. * The groundColor is the light in the opposite direction to the one specified during creation.
  80248. * 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.
  80249. */
  80250. groundColor: Color3;
  80251. /**
  80252. * The light reflection direction, not the incoming direction.
  80253. */
  80254. direction: Vector3;
  80255. /**
  80256. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  80257. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  80258. * The HemisphericLight can't cast shadows.
  80259. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80260. * @param name The friendly name of the light
  80261. * @param direction The direction of the light reflection
  80262. * @param scene The scene the light belongs to
  80263. */
  80264. constructor(name: string, direction: Vector3, scene: Scene);
  80265. protected _buildUniformLayout(): void;
  80266. /**
  80267. * Returns the string "HemisphericLight".
  80268. * @return The class name
  80269. */
  80270. getClassName(): string;
  80271. /**
  80272. * Sets the HemisphericLight direction towards the passed target (Vector3).
  80273. * Returns the updated direction.
  80274. * @param target The target the direction should point to
  80275. * @return The computed direction
  80276. */
  80277. setDirectionToTarget(target: Vector3): Vector3;
  80278. /**
  80279. * Returns the shadow generator associated to the light.
  80280. * @returns Always null for hemispheric lights because it does not support shadows.
  80281. */
  80282. getShadowGenerator(): Nullable<IShadowGenerator>;
  80283. /**
  80284. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  80285. * @param effect The effect to update
  80286. * @param lightIndex The index of the light in the effect to update
  80287. * @returns The hemispheric light
  80288. */
  80289. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  80290. /**
  80291. * Computes the world matrix of the node
  80292. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80293. * @param useWasUpdatedFlag defines a reserved property
  80294. * @returns the world matrix
  80295. */
  80296. computeWorldMatrix(): Matrix;
  80297. /**
  80298. * Returns the integer 3.
  80299. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80300. */
  80301. getTypeID(): number;
  80302. /**
  80303. * Prepares the list of defines specific to the light type.
  80304. * @param defines the list of defines
  80305. * @param lightIndex defines the index of the light for the effect
  80306. */
  80307. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80308. }
  80309. }
  80310. declare module BABYLON {
  80311. /** @hidden */
  80312. export var vrMultiviewToSingleviewPixelShader: {
  80313. name: string;
  80314. shader: string;
  80315. };
  80316. }
  80317. declare module BABYLON {
  80318. /**
  80319. * Renders to multiple views with a single draw call
  80320. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80321. */
  80322. export class MultiviewRenderTarget extends RenderTargetTexture {
  80323. /**
  80324. * Creates a multiview render target
  80325. * @param scene scene used with the render target
  80326. * @param size the size of the render target (used for each view)
  80327. */
  80328. constructor(scene: Scene, size?: number | {
  80329. width: number;
  80330. height: number;
  80331. } | {
  80332. ratio: number;
  80333. });
  80334. /**
  80335. * @hidden
  80336. * @param faceIndex the face index, if its a cube texture
  80337. */
  80338. _bindFrameBuffer(faceIndex?: number): void;
  80339. /**
  80340. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80341. * @returns the view count
  80342. */
  80343. getViewCount(): number;
  80344. }
  80345. }
  80346. declare module BABYLON {
  80347. interface Engine {
  80348. /**
  80349. * Creates a new multiview render target
  80350. * @param width defines the width of the texture
  80351. * @param height defines the height of the texture
  80352. * @returns the created multiview texture
  80353. */
  80354. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80355. /**
  80356. * Binds a multiview framebuffer to be drawn to
  80357. * @param multiviewTexture texture to bind
  80358. */
  80359. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80360. }
  80361. interface Camera {
  80362. /**
  80363. * @hidden
  80364. * 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)
  80365. */
  80366. _useMultiviewToSingleView: boolean;
  80367. /**
  80368. * @hidden
  80369. * 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)
  80370. */
  80371. _multiviewTexture: Nullable<RenderTargetTexture>;
  80372. /**
  80373. * @hidden
  80374. * ensures the multiview texture of the camera exists and has the specified width/height
  80375. * @param width height to set on the multiview texture
  80376. * @param height width to set on the multiview texture
  80377. */
  80378. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80379. }
  80380. interface Scene {
  80381. /** @hidden */
  80382. _transformMatrixR: Matrix;
  80383. /** @hidden */
  80384. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80385. /** @hidden */
  80386. _createMultiviewUbo(): void;
  80387. /** @hidden */
  80388. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80389. /** @hidden */
  80390. _renderMultiviewToSingleView(camera: Camera): void;
  80391. }
  80392. }
  80393. declare module BABYLON {
  80394. /**
  80395. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80396. * This will not be used for webXR as it supports displaying texture arrays directly
  80397. */
  80398. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80399. /**
  80400. * Initializes a VRMultiviewToSingleview
  80401. * @param name name of the post process
  80402. * @param camera camera to be applied to
  80403. * @param scaleFactor scaling factor to the size of the output texture
  80404. */
  80405. constructor(name: string, camera: Camera, scaleFactor: number);
  80406. }
  80407. }
  80408. declare module BABYLON {
  80409. interface Engine {
  80410. /** @hidden */
  80411. _vrDisplay: any;
  80412. /** @hidden */
  80413. _vrSupported: boolean;
  80414. /** @hidden */
  80415. _oldSize: Size;
  80416. /** @hidden */
  80417. _oldHardwareScaleFactor: number;
  80418. /** @hidden */
  80419. _vrExclusivePointerMode: boolean;
  80420. /** @hidden */
  80421. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80422. /** @hidden */
  80423. _onVRDisplayPointerRestricted: () => void;
  80424. /** @hidden */
  80425. _onVRDisplayPointerUnrestricted: () => void;
  80426. /** @hidden */
  80427. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80428. /** @hidden */
  80429. _onVrDisplayDisconnect: Nullable<() => void>;
  80430. /** @hidden */
  80431. _onVrDisplayPresentChange: Nullable<() => void>;
  80432. /**
  80433. * Observable signaled when VR display mode changes
  80434. */
  80435. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80436. /**
  80437. * Observable signaled when VR request present is complete
  80438. */
  80439. onVRRequestPresentComplete: Observable<boolean>;
  80440. /**
  80441. * Observable signaled when VR request present starts
  80442. */
  80443. onVRRequestPresentStart: Observable<Engine>;
  80444. /**
  80445. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80446. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80447. */
  80448. isInVRExclusivePointerMode: boolean;
  80449. /**
  80450. * Gets a boolean indicating if a webVR device was detected
  80451. * @returns true if a webVR device was detected
  80452. */
  80453. isVRDevicePresent(): boolean;
  80454. /**
  80455. * Gets the current webVR device
  80456. * @returns the current webVR device (or null)
  80457. */
  80458. getVRDevice(): any;
  80459. /**
  80460. * Initializes a webVR display and starts listening to display change events
  80461. * The onVRDisplayChangedObservable will be notified upon these changes
  80462. * @returns A promise containing a VRDisplay and if vr is supported
  80463. */
  80464. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80465. /** @hidden */
  80466. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80467. /**
  80468. * Call this function to switch to webVR mode
  80469. * Will do nothing if webVR is not supported or if there is no webVR device
  80470. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80471. */
  80472. enableVR(): void;
  80473. /** @hidden */
  80474. _onVRFullScreenTriggered(): void;
  80475. }
  80476. }
  80477. declare module BABYLON {
  80478. /**
  80479. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80480. * IMPORTANT!! The data is right-hand data.
  80481. * @export
  80482. * @interface DevicePose
  80483. */
  80484. export interface DevicePose {
  80485. /**
  80486. * The position of the device, values in array are [x,y,z].
  80487. */
  80488. readonly position: Nullable<Float32Array>;
  80489. /**
  80490. * The linearVelocity of the device, values in array are [x,y,z].
  80491. */
  80492. readonly linearVelocity: Nullable<Float32Array>;
  80493. /**
  80494. * The linearAcceleration of the device, values in array are [x,y,z].
  80495. */
  80496. readonly linearAcceleration: Nullable<Float32Array>;
  80497. /**
  80498. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80499. */
  80500. readonly orientation: Nullable<Float32Array>;
  80501. /**
  80502. * The angularVelocity of the device, values in array are [x,y,z].
  80503. */
  80504. readonly angularVelocity: Nullable<Float32Array>;
  80505. /**
  80506. * The angularAcceleration of the device, values in array are [x,y,z].
  80507. */
  80508. readonly angularAcceleration: Nullable<Float32Array>;
  80509. }
  80510. /**
  80511. * Interface representing a pose controlled object in Babylon.
  80512. * A pose controlled object has both regular pose values as well as pose values
  80513. * from an external device such as a VR head mounted display
  80514. */
  80515. export interface PoseControlled {
  80516. /**
  80517. * The position of the object in babylon space.
  80518. */
  80519. position: Vector3;
  80520. /**
  80521. * The rotation quaternion of the object in babylon space.
  80522. */
  80523. rotationQuaternion: Quaternion;
  80524. /**
  80525. * The position of the device in babylon space.
  80526. */
  80527. devicePosition?: Vector3;
  80528. /**
  80529. * The rotation quaternion of the device in babylon space.
  80530. */
  80531. deviceRotationQuaternion: Quaternion;
  80532. /**
  80533. * The raw pose coming from the device.
  80534. */
  80535. rawPose: Nullable<DevicePose>;
  80536. /**
  80537. * The scale of the device to be used when translating from device space to babylon space.
  80538. */
  80539. deviceScaleFactor: number;
  80540. /**
  80541. * Updates the poseControlled values based on the input device pose.
  80542. * @param poseData the pose data to update the object with
  80543. */
  80544. updateFromDevice(poseData: DevicePose): void;
  80545. }
  80546. /**
  80547. * Set of options to customize the webVRCamera
  80548. */
  80549. export interface WebVROptions {
  80550. /**
  80551. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80552. */
  80553. trackPosition?: boolean;
  80554. /**
  80555. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80556. */
  80557. positionScale?: number;
  80558. /**
  80559. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80560. */
  80561. displayName?: string;
  80562. /**
  80563. * Should the native controller meshes be initialized. (default: true)
  80564. */
  80565. controllerMeshes?: boolean;
  80566. /**
  80567. * Creating a default HemiLight only on controllers. (default: true)
  80568. */
  80569. defaultLightingOnControllers?: boolean;
  80570. /**
  80571. * If you don't want to use the default VR button of the helper. (default: false)
  80572. */
  80573. useCustomVRButton?: boolean;
  80574. /**
  80575. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80576. */
  80577. customVRButton?: HTMLButtonElement;
  80578. /**
  80579. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80580. */
  80581. rayLength?: number;
  80582. /**
  80583. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80584. */
  80585. defaultHeight?: number;
  80586. /**
  80587. * If multiview should be used if availible (default: false)
  80588. */
  80589. useMultiview?: boolean;
  80590. }
  80591. /**
  80592. * This represents a WebVR camera.
  80593. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80594. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80595. */
  80596. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80597. private webVROptions;
  80598. /**
  80599. * @hidden
  80600. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80601. */
  80602. _vrDevice: any;
  80603. /**
  80604. * The rawPose of the vrDevice.
  80605. */
  80606. rawPose: Nullable<DevicePose>;
  80607. private _onVREnabled;
  80608. private _specsVersion;
  80609. private _attached;
  80610. private _frameData;
  80611. protected _descendants: Array<Node>;
  80612. private _deviceRoomPosition;
  80613. /** @hidden */
  80614. _deviceRoomRotationQuaternion: Quaternion;
  80615. private _standingMatrix;
  80616. /**
  80617. * Represents device position in babylon space.
  80618. */
  80619. devicePosition: Vector3;
  80620. /**
  80621. * Represents device rotation in babylon space.
  80622. */
  80623. deviceRotationQuaternion: Quaternion;
  80624. /**
  80625. * The scale of the device to be used when translating from device space to babylon space.
  80626. */
  80627. deviceScaleFactor: number;
  80628. private _deviceToWorld;
  80629. private _worldToDevice;
  80630. /**
  80631. * References to the webVR controllers for the vrDevice.
  80632. */
  80633. controllers: Array<WebVRController>;
  80634. /**
  80635. * Emits an event when a controller is attached.
  80636. */
  80637. onControllersAttachedObservable: Observable<WebVRController[]>;
  80638. /**
  80639. * Emits an event when a controller's mesh has been loaded;
  80640. */
  80641. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80642. /**
  80643. * Emits an event when the HMD's pose has been updated.
  80644. */
  80645. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80646. private _poseSet;
  80647. /**
  80648. * If the rig cameras be used as parent instead of this camera.
  80649. */
  80650. rigParenting: boolean;
  80651. private _lightOnControllers;
  80652. private _defaultHeight?;
  80653. /**
  80654. * Instantiates a WebVRFreeCamera.
  80655. * @param name The name of the WebVRFreeCamera
  80656. * @param position The starting anchor position for the camera
  80657. * @param scene The scene the camera belongs to
  80658. * @param webVROptions a set of customizable options for the webVRCamera
  80659. */
  80660. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80661. /**
  80662. * Gets the device distance from the ground in meters.
  80663. * @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.
  80664. */
  80665. deviceDistanceToRoomGround(): number;
  80666. /**
  80667. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80668. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80669. */
  80670. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80671. /**
  80672. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80673. * @returns A promise with a boolean set to if the standing matrix is supported.
  80674. */
  80675. useStandingMatrixAsync(): Promise<boolean>;
  80676. /**
  80677. * Disposes the camera
  80678. */
  80679. dispose(): void;
  80680. /**
  80681. * Gets a vrController by name.
  80682. * @param name The name of the controller to retreive
  80683. * @returns the controller matching the name specified or null if not found
  80684. */
  80685. getControllerByName(name: string): Nullable<WebVRController>;
  80686. private _leftController;
  80687. /**
  80688. * The controller corresponding to the users left hand.
  80689. */
  80690. readonly leftController: Nullable<WebVRController>;
  80691. private _rightController;
  80692. /**
  80693. * The controller corresponding to the users right hand.
  80694. */
  80695. readonly rightController: Nullable<WebVRController>;
  80696. /**
  80697. * Casts a ray forward from the vrCamera's gaze.
  80698. * @param length Length of the ray (default: 100)
  80699. * @returns the ray corresponding to the gaze
  80700. */
  80701. getForwardRay(length?: number): Ray;
  80702. /**
  80703. * @hidden
  80704. * Updates the camera based on device's frame data
  80705. */
  80706. _checkInputs(): void;
  80707. /**
  80708. * Updates the poseControlled values based on the input device pose.
  80709. * @param poseData Pose coming from the device
  80710. */
  80711. updateFromDevice(poseData: DevicePose): void;
  80712. private _htmlElementAttached;
  80713. private _detachIfAttached;
  80714. /**
  80715. * WebVR's attach control will start broadcasting frames to the device.
  80716. * Note that in certain browsers (chrome for example) this function must be called
  80717. * within a user-interaction callback. Example:
  80718. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80719. *
  80720. * @param element html element to attach the vrDevice to
  80721. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80722. */
  80723. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80724. /**
  80725. * Detaches the camera from the html element and disables VR
  80726. *
  80727. * @param element html element to detach from
  80728. */
  80729. detachControl(element: HTMLElement): void;
  80730. /**
  80731. * @returns the name of this class
  80732. */
  80733. getClassName(): string;
  80734. /**
  80735. * Calls resetPose on the vrDisplay
  80736. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80737. */
  80738. resetToCurrentRotation(): void;
  80739. /**
  80740. * @hidden
  80741. * Updates the rig cameras (left and right eye)
  80742. */
  80743. _updateRigCameras(): void;
  80744. private _workingVector;
  80745. private _oneVector;
  80746. private _workingMatrix;
  80747. private updateCacheCalled;
  80748. private _correctPositionIfNotTrackPosition;
  80749. /**
  80750. * @hidden
  80751. * Updates the cached values of the camera
  80752. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80753. */
  80754. _updateCache(ignoreParentClass?: boolean): void;
  80755. /**
  80756. * @hidden
  80757. * Get current device position in babylon world
  80758. */
  80759. _computeDevicePosition(): void;
  80760. /**
  80761. * Updates the current device position and rotation in the babylon world
  80762. */
  80763. update(): void;
  80764. /**
  80765. * @hidden
  80766. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80767. * @returns an identity matrix
  80768. */
  80769. _getViewMatrix(): Matrix;
  80770. private _tmpMatrix;
  80771. /**
  80772. * This function is called by the two RIG cameras.
  80773. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80774. * @hidden
  80775. */
  80776. _getWebVRViewMatrix(): Matrix;
  80777. /** @hidden */
  80778. _getWebVRProjectionMatrix(): Matrix;
  80779. private _onGamepadConnectedObserver;
  80780. private _onGamepadDisconnectedObserver;
  80781. private _updateCacheWhenTrackingDisabledObserver;
  80782. /**
  80783. * Initializes the controllers and their meshes
  80784. */
  80785. initControllers(): void;
  80786. }
  80787. }
  80788. declare module BABYLON {
  80789. /**
  80790. * Size options for a post process
  80791. */
  80792. export type PostProcessOptions = {
  80793. width: number;
  80794. height: number;
  80795. };
  80796. /**
  80797. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80798. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80799. */
  80800. export class PostProcess {
  80801. /** Name of the PostProcess. */
  80802. name: string;
  80803. /**
  80804. * Gets or sets the unique id of the post process
  80805. */
  80806. uniqueId: number;
  80807. /**
  80808. * Width of the texture to apply the post process on
  80809. */
  80810. width: number;
  80811. /**
  80812. * Height of the texture to apply the post process on
  80813. */
  80814. height: number;
  80815. /**
  80816. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80817. * @hidden
  80818. */
  80819. _outputTexture: Nullable<InternalTexture>;
  80820. /**
  80821. * Sampling mode used by the shader
  80822. * See https://doc.babylonjs.com/classes/3.1/texture
  80823. */
  80824. renderTargetSamplingMode: number;
  80825. /**
  80826. * Clear color to use when screen clearing
  80827. */
  80828. clearColor: Color4;
  80829. /**
  80830. * If the buffer needs to be cleared before applying the post process. (default: true)
  80831. * Should be set to false if shader will overwrite all previous pixels.
  80832. */
  80833. autoClear: boolean;
  80834. /**
  80835. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80836. */
  80837. alphaMode: number;
  80838. /**
  80839. * Sets the setAlphaBlendConstants of the babylon engine
  80840. */
  80841. alphaConstants: Color4;
  80842. /**
  80843. * Animations to be used for the post processing
  80844. */
  80845. animations: Animation[];
  80846. /**
  80847. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80848. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80849. */
  80850. enablePixelPerfectMode: boolean;
  80851. /**
  80852. * Force the postprocess to be applied without taking in account viewport
  80853. */
  80854. forceFullscreenViewport: boolean;
  80855. /**
  80856. * List of inspectable custom properties (used by the Inspector)
  80857. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80858. */
  80859. inspectableCustomProperties: IInspectable[];
  80860. /**
  80861. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80862. *
  80863. * | Value | Type | Description |
  80864. * | ----- | ----------------------------------- | ----------- |
  80865. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80866. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80867. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80868. *
  80869. */
  80870. scaleMode: number;
  80871. /**
  80872. * Force textures to be a power of two (default: false)
  80873. */
  80874. alwaysForcePOT: boolean;
  80875. private _samples;
  80876. /**
  80877. * Number of sample textures (default: 1)
  80878. */
  80879. samples: number;
  80880. /**
  80881. * Modify the scale of the post process to be the same as the viewport (default: false)
  80882. */
  80883. adaptScaleToCurrentViewport: boolean;
  80884. private _camera;
  80885. private _scene;
  80886. private _engine;
  80887. private _options;
  80888. private _reusable;
  80889. private _textureType;
  80890. /**
  80891. * Smart array of input and output textures for the post process.
  80892. * @hidden
  80893. */
  80894. _textures: SmartArray<InternalTexture>;
  80895. /**
  80896. * The index in _textures that corresponds to the output texture.
  80897. * @hidden
  80898. */
  80899. _currentRenderTextureInd: number;
  80900. private _effect;
  80901. private _samplers;
  80902. private _fragmentUrl;
  80903. private _vertexUrl;
  80904. private _parameters;
  80905. private _scaleRatio;
  80906. protected _indexParameters: any;
  80907. private _shareOutputWithPostProcess;
  80908. private _texelSize;
  80909. private _forcedOutputTexture;
  80910. /**
  80911. * Returns the fragment url or shader name used in the post process.
  80912. * @returns the fragment url or name in the shader store.
  80913. */
  80914. getEffectName(): string;
  80915. /**
  80916. * An event triggered when the postprocess is activated.
  80917. */
  80918. onActivateObservable: Observable<Camera>;
  80919. private _onActivateObserver;
  80920. /**
  80921. * A function that is added to the onActivateObservable
  80922. */
  80923. onActivate: Nullable<(camera: Camera) => void>;
  80924. /**
  80925. * An event triggered when the postprocess changes its size.
  80926. */
  80927. onSizeChangedObservable: Observable<PostProcess>;
  80928. private _onSizeChangedObserver;
  80929. /**
  80930. * A function that is added to the onSizeChangedObservable
  80931. */
  80932. onSizeChanged: (postProcess: PostProcess) => void;
  80933. /**
  80934. * An event triggered when the postprocess applies its effect.
  80935. */
  80936. onApplyObservable: Observable<Effect>;
  80937. private _onApplyObserver;
  80938. /**
  80939. * A function that is added to the onApplyObservable
  80940. */
  80941. onApply: (effect: Effect) => void;
  80942. /**
  80943. * An event triggered before rendering the postprocess
  80944. */
  80945. onBeforeRenderObservable: Observable<Effect>;
  80946. private _onBeforeRenderObserver;
  80947. /**
  80948. * A function that is added to the onBeforeRenderObservable
  80949. */
  80950. onBeforeRender: (effect: Effect) => void;
  80951. /**
  80952. * An event triggered after rendering the postprocess
  80953. */
  80954. onAfterRenderObservable: Observable<Effect>;
  80955. private _onAfterRenderObserver;
  80956. /**
  80957. * A function that is added to the onAfterRenderObservable
  80958. */
  80959. onAfterRender: (efect: Effect) => void;
  80960. /**
  80961. * 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
  80962. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  80963. */
  80964. inputTexture: InternalTexture;
  80965. /**
  80966. * Gets the camera which post process is applied to.
  80967. * @returns The camera the post process is applied to.
  80968. */
  80969. getCamera(): Camera;
  80970. /**
  80971. * Gets the texel size of the postprocess.
  80972. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  80973. */
  80974. readonly texelSize: Vector2;
  80975. /**
  80976. * Creates a new instance PostProcess
  80977. * @param name The name of the PostProcess.
  80978. * @param fragmentUrl The url of the fragment shader to be used.
  80979. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  80980. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  80981. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80982. * @param camera The camera to apply the render pass to.
  80983. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80984. * @param engine The engine which the post process will be applied. (default: current engine)
  80985. * @param reusable If the post process can be reused on the same frame. (default: false)
  80986. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  80987. * @param textureType Type of textures used when performing the post process. (default: 0)
  80988. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  80989. * @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
  80990. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  80991. */
  80992. constructor(
  80993. /** Name of the PostProcess. */
  80994. 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);
  80995. /**
  80996. * Gets a string idenfifying the name of the class
  80997. * @returns "PostProcess" string
  80998. */
  80999. getClassName(): string;
  81000. /**
  81001. * Gets the engine which this post process belongs to.
  81002. * @returns The engine the post process was enabled with.
  81003. */
  81004. getEngine(): Engine;
  81005. /**
  81006. * The effect that is created when initializing the post process.
  81007. * @returns The created effect corresponding the the postprocess.
  81008. */
  81009. getEffect(): Effect;
  81010. /**
  81011. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  81012. * @param postProcess The post process to share the output with.
  81013. * @returns This post process.
  81014. */
  81015. shareOutputWith(postProcess: PostProcess): PostProcess;
  81016. /**
  81017. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  81018. * This should be called if the post process that shares output with this post process is disabled/disposed.
  81019. */
  81020. useOwnOutput(): void;
  81021. /**
  81022. * Updates the effect with the current post process compile time values and recompiles the shader.
  81023. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81024. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81025. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81026. * @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
  81027. * @param onCompiled Called when the shader has been compiled.
  81028. * @param onError Called if there is an error when compiling a shader.
  81029. */
  81030. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81031. /**
  81032. * The post process is reusable if it can be used multiple times within one frame.
  81033. * @returns If the post process is reusable
  81034. */
  81035. isReusable(): boolean;
  81036. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  81037. markTextureDirty(): void;
  81038. /**
  81039. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  81040. * 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.
  81041. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  81042. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  81043. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  81044. * @returns The target texture that was bound to be written to.
  81045. */
  81046. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  81047. /**
  81048. * If the post process is supported.
  81049. */
  81050. readonly isSupported: boolean;
  81051. /**
  81052. * The aspect ratio of the output texture.
  81053. */
  81054. readonly aspectRatio: number;
  81055. /**
  81056. * Get a value indicating if the post-process is ready to be used
  81057. * @returns true if the post-process is ready (shader is compiled)
  81058. */
  81059. isReady(): boolean;
  81060. /**
  81061. * Binds all textures and uniforms to the shader, this will be run on every pass.
  81062. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  81063. */
  81064. apply(): Nullable<Effect>;
  81065. private _disposeTextures;
  81066. /**
  81067. * Disposes the post process.
  81068. * @param camera The camera to dispose the post process on.
  81069. */
  81070. dispose(camera?: Camera): void;
  81071. }
  81072. }
  81073. declare module BABYLON {
  81074. /** @hidden */
  81075. export var kernelBlurVaryingDeclaration: {
  81076. name: string;
  81077. shader: string;
  81078. };
  81079. }
  81080. declare module BABYLON {
  81081. /** @hidden */
  81082. export var kernelBlurFragment: {
  81083. name: string;
  81084. shader: string;
  81085. };
  81086. }
  81087. declare module BABYLON {
  81088. /** @hidden */
  81089. export var kernelBlurFragment2: {
  81090. name: string;
  81091. shader: string;
  81092. };
  81093. }
  81094. declare module BABYLON {
  81095. /** @hidden */
  81096. export var kernelBlurPixelShader: {
  81097. name: string;
  81098. shader: string;
  81099. };
  81100. }
  81101. declare module BABYLON {
  81102. /** @hidden */
  81103. export var kernelBlurVertex: {
  81104. name: string;
  81105. shader: string;
  81106. };
  81107. }
  81108. declare module BABYLON {
  81109. /** @hidden */
  81110. export var kernelBlurVertexShader: {
  81111. name: string;
  81112. shader: string;
  81113. };
  81114. }
  81115. declare module BABYLON {
  81116. /**
  81117. * The Blur Post Process which blurs an image based on a kernel and direction.
  81118. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  81119. */
  81120. export class BlurPostProcess extends PostProcess {
  81121. /** The direction in which to blur the image. */
  81122. direction: Vector2;
  81123. private blockCompilation;
  81124. protected _kernel: number;
  81125. protected _idealKernel: number;
  81126. protected _packedFloat: boolean;
  81127. private _staticDefines;
  81128. /**
  81129. * Sets the length in pixels of the blur sample region
  81130. */
  81131. /**
  81132. * Gets the length in pixels of the blur sample region
  81133. */
  81134. kernel: number;
  81135. /**
  81136. * Sets wether or not the blur needs to unpack/repack floats
  81137. */
  81138. /**
  81139. * Gets wether or not the blur is unpacking/repacking floats
  81140. */
  81141. packedFloat: boolean;
  81142. /**
  81143. * Creates a new instance BlurPostProcess
  81144. * @param name The name of the effect.
  81145. * @param direction The direction in which to blur the image.
  81146. * @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.
  81147. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81148. * @param camera The camera to apply the render pass to.
  81149. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81150. * @param engine The engine which the post process will be applied. (default: current engine)
  81151. * @param reusable If the post process can be reused on the same frame. (default: false)
  81152. * @param textureType Type of textures used when performing the post process. (default: 0)
  81153. * @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)
  81154. */
  81155. constructor(name: string,
  81156. /** The direction in which to blur the image. */
  81157. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  81158. /**
  81159. * Updates the effect with the current post process compile time values and recompiles the shader.
  81160. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81161. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81162. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81163. * @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
  81164. * @param onCompiled Called when the shader has been compiled.
  81165. * @param onError Called if there is an error when compiling a shader.
  81166. */
  81167. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81168. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81169. /**
  81170. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  81171. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  81172. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  81173. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  81174. * The gaps between physical kernels are compensated for in the weighting of the samples
  81175. * @param idealKernel Ideal blur kernel.
  81176. * @return Nearest best kernel.
  81177. */
  81178. protected _nearestBestKernel(idealKernel: number): number;
  81179. /**
  81180. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  81181. * @param x The point on the Gaussian distribution to sample.
  81182. * @return the value of the Gaussian function at x.
  81183. */
  81184. protected _gaussianWeight(x: number): number;
  81185. /**
  81186. * Generates a string that can be used as a floating point number in GLSL.
  81187. * @param x Value to print.
  81188. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  81189. * @return GLSL float string.
  81190. */
  81191. protected _glslFloat(x: number, decimalFigures?: number): string;
  81192. }
  81193. }
  81194. declare module BABYLON {
  81195. /**
  81196. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81197. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81198. * You can then easily use it as a reflectionTexture on a flat surface.
  81199. * In case the surface is not a plane, please consider relying on reflection probes.
  81200. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81201. */
  81202. export class MirrorTexture extends RenderTargetTexture {
  81203. private scene;
  81204. /**
  81205. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  81206. * 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.
  81207. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81208. */
  81209. mirrorPlane: Plane;
  81210. /**
  81211. * Define the blur ratio used to blur the reflection if needed.
  81212. */
  81213. blurRatio: number;
  81214. /**
  81215. * Define the adaptive blur kernel used to blur the reflection if needed.
  81216. * This will autocompute the closest best match for the `blurKernel`
  81217. */
  81218. adaptiveBlurKernel: number;
  81219. /**
  81220. * Define the blur kernel used to blur the reflection if needed.
  81221. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81222. */
  81223. blurKernel: number;
  81224. /**
  81225. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  81226. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81227. */
  81228. blurKernelX: number;
  81229. /**
  81230. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  81231. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81232. */
  81233. blurKernelY: number;
  81234. private _autoComputeBlurKernel;
  81235. protected _onRatioRescale(): void;
  81236. private _updateGammaSpace;
  81237. private _imageProcessingConfigChangeObserver;
  81238. private _transformMatrix;
  81239. private _mirrorMatrix;
  81240. private _savedViewMatrix;
  81241. private _blurX;
  81242. private _blurY;
  81243. private _adaptiveBlurKernel;
  81244. private _blurKernelX;
  81245. private _blurKernelY;
  81246. private _blurRatio;
  81247. /**
  81248. * Instantiates a Mirror Texture.
  81249. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81250. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81251. * You can then easily use it as a reflectionTexture on a flat surface.
  81252. * In case the surface is not a plane, please consider relying on reflection probes.
  81253. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81254. * @param name
  81255. * @param size
  81256. * @param scene
  81257. * @param generateMipMaps
  81258. * @param type
  81259. * @param samplingMode
  81260. * @param generateDepthBuffer
  81261. */
  81262. constructor(name: string, size: number | {
  81263. width: number;
  81264. height: number;
  81265. } | {
  81266. ratio: number;
  81267. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  81268. private _preparePostProcesses;
  81269. /**
  81270. * Clone the mirror texture.
  81271. * @returns the cloned texture
  81272. */
  81273. clone(): MirrorTexture;
  81274. /**
  81275. * Serialize the texture to a JSON representation you could use in Parse later on
  81276. * @returns the serialized JSON representation
  81277. */
  81278. serialize(): any;
  81279. /**
  81280. * Dispose the texture and release its associated resources.
  81281. */
  81282. dispose(): void;
  81283. }
  81284. }
  81285. declare module BABYLON {
  81286. /**
  81287. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81288. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81289. */
  81290. export class Texture extends BaseTexture {
  81291. /** @hidden */
  81292. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  81293. /** @hidden */
  81294. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  81295. /** @hidden */
  81296. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  81297. /** nearest is mag = nearest and min = nearest and mip = linear */
  81298. static readonly NEAREST_SAMPLINGMODE: number;
  81299. /** nearest is mag = nearest and min = nearest and mip = linear */
  81300. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  81301. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81302. static readonly BILINEAR_SAMPLINGMODE: number;
  81303. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81304. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  81305. /** Trilinear is mag = linear and min = linear and mip = linear */
  81306. static readonly TRILINEAR_SAMPLINGMODE: number;
  81307. /** Trilinear is mag = linear and min = linear and mip = linear */
  81308. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81309. /** mag = nearest and min = nearest and mip = nearest */
  81310. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81311. /** mag = nearest and min = linear and mip = nearest */
  81312. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81313. /** mag = nearest and min = linear and mip = linear */
  81314. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81315. /** mag = nearest and min = linear and mip = none */
  81316. static readonly NEAREST_LINEAR: number;
  81317. /** mag = nearest and min = nearest and mip = none */
  81318. static readonly NEAREST_NEAREST: number;
  81319. /** mag = linear and min = nearest and mip = nearest */
  81320. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81321. /** mag = linear and min = nearest and mip = linear */
  81322. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81323. /** mag = linear and min = linear and mip = none */
  81324. static readonly LINEAR_LINEAR: number;
  81325. /** mag = linear and min = nearest and mip = none */
  81326. static readonly LINEAR_NEAREST: number;
  81327. /** Explicit coordinates mode */
  81328. static readonly EXPLICIT_MODE: number;
  81329. /** Spherical coordinates mode */
  81330. static readonly SPHERICAL_MODE: number;
  81331. /** Planar coordinates mode */
  81332. static readonly PLANAR_MODE: number;
  81333. /** Cubic coordinates mode */
  81334. static readonly CUBIC_MODE: number;
  81335. /** Projection coordinates mode */
  81336. static readonly PROJECTION_MODE: number;
  81337. /** Inverse Cubic coordinates mode */
  81338. static readonly SKYBOX_MODE: number;
  81339. /** Inverse Cubic coordinates mode */
  81340. static readonly INVCUBIC_MODE: number;
  81341. /** Equirectangular coordinates mode */
  81342. static readonly EQUIRECTANGULAR_MODE: number;
  81343. /** Equirectangular Fixed coordinates mode */
  81344. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81345. /** Equirectangular Fixed Mirrored coordinates mode */
  81346. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81347. /** Texture is not repeating outside of 0..1 UVs */
  81348. static readonly CLAMP_ADDRESSMODE: number;
  81349. /** Texture is repeating outside of 0..1 UVs */
  81350. static readonly WRAP_ADDRESSMODE: number;
  81351. /** Texture is repeating and mirrored */
  81352. static readonly MIRROR_ADDRESSMODE: number;
  81353. /**
  81354. * 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
  81355. */
  81356. static UseSerializedUrlIfAny: boolean;
  81357. /**
  81358. * Define the url of the texture.
  81359. */
  81360. url: Nullable<string>;
  81361. /**
  81362. * Define an offset on the texture to offset the u coordinates of the UVs
  81363. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81364. */
  81365. uOffset: number;
  81366. /**
  81367. * Define an offset on the texture to offset the v coordinates of the UVs
  81368. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81369. */
  81370. vOffset: number;
  81371. /**
  81372. * Define an offset on the texture to scale the u coordinates of the UVs
  81373. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81374. */
  81375. uScale: number;
  81376. /**
  81377. * Define an offset on the texture to scale the v coordinates of the UVs
  81378. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81379. */
  81380. vScale: number;
  81381. /**
  81382. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81383. * @see http://doc.babylonjs.com/how_to/more_materials
  81384. */
  81385. uAng: number;
  81386. /**
  81387. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81388. * @see http://doc.babylonjs.com/how_to/more_materials
  81389. */
  81390. vAng: number;
  81391. /**
  81392. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81393. * @see http://doc.babylonjs.com/how_to/more_materials
  81394. */
  81395. wAng: number;
  81396. /**
  81397. * Defines the center of rotation (U)
  81398. */
  81399. uRotationCenter: number;
  81400. /**
  81401. * Defines the center of rotation (V)
  81402. */
  81403. vRotationCenter: number;
  81404. /**
  81405. * Defines the center of rotation (W)
  81406. */
  81407. wRotationCenter: number;
  81408. /**
  81409. * Are mip maps generated for this texture or not.
  81410. */
  81411. readonly noMipmap: boolean;
  81412. /**
  81413. * List of inspectable custom properties (used by the Inspector)
  81414. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81415. */
  81416. inspectableCustomProperties: Nullable<IInspectable[]>;
  81417. private _noMipmap;
  81418. /** @hidden */
  81419. _invertY: boolean;
  81420. private _rowGenerationMatrix;
  81421. private _cachedTextureMatrix;
  81422. private _projectionModeMatrix;
  81423. private _t0;
  81424. private _t1;
  81425. private _t2;
  81426. private _cachedUOffset;
  81427. private _cachedVOffset;
  81428. private _cachedUScale;
  81429. private _cachedVScale;
  81430. private _cachedUAng;
  81431. private _cachedVAng;
  81432. private _cachedWAng;
  81433. private _cachedProjectionMatrixId;
  81434. private _cachedCoordinatesMode;
  81435. /** @hidden */
  81436. protected _initialSamplingMode: number;
  81437. /** @hidden */
  81438. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  81439. private _deleteBuffer;
  81440. protected _format: Nullable<number>;
  81441. private _delayedOnLoad;
  81442. private _delayedOnError;
  81443. /**
  81444. * Observable triggered once the texture has been loaded.
  81445. */
  81446. onLoadObservable: Observable<Texture>;
  81447. protected _isBlocking: boolean;
  81448. /**
  81449. * Is the texture preventing material to render while loading.
  81450. * If false, a default texture will be used instead of the loading one during the preparation step.
  81451. */
  81452. isBlocking: boolean;
  81453. /**
  81454. * Get the current sampling mode associated with the texture.
  81455. */
  81456. readonly samplingMode: number;
  81457. /**
  81458. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81459. */
  81460. readonly invertY: boolean;
  81461. /**
  81462. * Instantiates a new texture.
  81463. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81464. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81465. * @param url define the url of the picture to load as a texture
  81466. * @param scene define the scene or engine the texture will belong to
  81467. * @param noMipmap define if the texture will require mip maps or not
  81468. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81469. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81470. * @param onLoad define a callback triggered when the texture has been loaded
  81471. * @param onError define a callback triggered when an error occurred during the loading session
  81472. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81473. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81474. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81475. */
  81476. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  81477. /**
  81478. * Update the url (and optional buffer) of this texture if url was null during construction.
  81479. * @param url the url of the texture
  81480. * @param buffer the buffer of the texture (defaults to null)
  81481. * @param onLoad callback called when the texture is loaded (defaults to null)
  81482. */
  81483. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81484. /**
  81485. * Finish the loading sequence of a texture flagged as delayed load.
  81486. * @hidden
  81487. */
  81488. delayLoad(): void;
  81489. private _prepareRowForTextureGeneration;
  81490. /**
  81491. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81492. * @returns the transform matrix of the texture.
  81493. */
  81494. getTextureMatrix(): Matrix;
  81495. /**
  81496. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81497. * @returns The reflection texture transform
  81498. */
  81499. getReflectionTextureMatrix(): Matrix;
  81500. /**
  81501. * Clones the texture.
  81502. * @returns the cloned texture
  81503. */
  81504. clone(): Texture;
  81505. /**
  81506. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81507. * @returns The JSON representation of the texture
  81508. */
  81509. serialize(): any;
  81510. /**
  81511. * Get the current class name of the texture useful for serialization or dynamic coding.
  81512. * @returns "Texture"
  81513. */
  81514. getClassName(): string;
  81515. /**
  81516. * Dispose the texture and release its associated resources.
  81517. */
  81518. dispose(): void;
  81519. /**
  81520. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81521. * @param parsedTexture Define the JSON representation of the texture
  81522. * @param scene Define the scene the parsed texture should be instantiated in
  81523. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81524. * @returns The parsed texture if successful
  81525. */
  81526. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81527. /**
  81528. * Creates a texture from its base 64 representation.
  81529. * @param data Define the base64 payload without the data: prefix
  81530. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81531. * @param scene Define the scene the texture should belong to
  81532. * @param noMipmap Forces the texture to not create mip map information if true
  81533. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81534. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81535. * @param onLoad define a callback triggered when the texture has been loaded
  81536. * @param onError define a callback triggered when an error occurred during the loading session
  81537. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81538. * @returns the created texture
  81539. */
  81540. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81541. /**
  81542. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81543. * @param data Define the base64 payload without the data: prefix
  81544. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81545. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81546. * @param scene Define the scene the texture should belong to
  81547. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81548. * @param noMipmap Forces the texture to not create mip map information if true
  81549. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81550. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81551. * @param onLoad define a callback triggered when the texture has been loaded
  81552. * @param onError define a callback triggered when an error occurred during the loading session
  81553. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81554. * @returns the created texture
  81555. */
  81556. 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;
  81557. }
  81558. }
  81559. declare module BABYLON {
  81560. /**
  81561. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81562. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81563. */
  81564. export class PostProcessManager {
  81565. private _scene;
  81566. private _indexBuffer;
  81567. private _vertexBuffers;
  81568. /**
  81569. * Creates a new instance PostProcess
  81570. * @param scene The scene that the post process is associated with.
  81571. */
  81572. constructor(scene: Scene);
  81573. private _prepareBuffers;
  81574. private _buildIndexBuffer;
  81575. /**
  81576. * Rebuilds the vertex buffers of the manager.
  81577. * @hidden
  81578. */
  81579. _rebuild(): void;
  81580. /**
  81581. * Prepares a frame to be run through a post process.
  81582. * @param sourceTexture The input texture to the post procesess. (default: null)
  81583. * @param postProcesses An array of post processes to be run. (default: null)
  81584. * @returns True if the post processes were able to be run.
  81585. * @hidden
  81586. */
  81587. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81588. /**
  81589. * Manually render a set of post processes to a texture.
  81590. * @param postProcesses An array of post processes to be run.
  81591. * @param targetTexture The target texture to render to.
  81592. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81593. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81594. * @param lodLevel defines which lod of the texture to render to
  81595. */
  81596. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81597. /**
  81598. * Finalize the result of the output of the postprocesses.
  81599. * @param doNotPresent If true the result will not be displayed to the screen.
  81600. * @param targetTexture The target texture to render to.
  81601. * @param faceIndex The index of the face to bind the target texture to.
  81602. * @param postProcesses The array of post processes to render.
  81603. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81604. * @hidden
  81605. */
  81606. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81607. /**
  81608. * Disposes of the post process manager.
  81609. */
  81610. dispose(): void;
  81611. }
  81612. }
  81613. declare module BABYLON {
  81614. interface AbstractScene {
  81615. /**
  81616. * The list of procedural textures added to the scene
  81617. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81618. */
  81619. proceduralTextures: Array<ProceduralTexture>;
  81620. }
  81621. /**
  81622. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81623. * in a given scene.
  81624. */
  81625. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81626. /**
  81627. * The component name helpfull to identify the component in the list of scene components.
  81628. */
  81629. readonly name: string;
  81630. /**
  81631. * The scene the component belongs to.
  81632. */
  81633. scene: Scene;
  81634. /**
  81635. * Creates a new instance of the component for the given scene
  81636. * @param scene Defines the scene to register the component in
  81637. */
  81638. constructor(scene: Scene);
  81639. /**
  81640. * Registers the component in a given scene
  81641. */
  81642. register(): void;
  81643. /**
  81644. * Rebuilds the elements related to this component in case of
  81645. * context lost for instance.
  81646. */
  81647. rebuild(): void;
  81648. /**
  81649. * Disposes the component and the associated ressources.
  81650. */
  81651. dispose(): void;
  81652. private _beforeClear;
  81653. }
  81654. }
  81655. declare module BABYLON {
  81656. interface Engine {
  81657. /**
  81658. * Creates a new render target cube texture
  81659. * @param size defines the size of the texture
  81660. * @param options defines the options used to create the texture
  81661. * @returns a new render target cube texture stored in an InternalTexture
  81662. */
  81663. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81664. }
  81665. }
  81666. declare module BABYLON {
  81667. /** @hidden */
  81668. export var proceduralVertexShader: {
  81669. name: string;
  81670. shader: string;
  81671. };
  81672. }
  81673. declare module BABYLON {
  81674. /**
  81675. * 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.
  81676. * This is the base class of any Procedural texture and contains most of the shareable code.
  81677. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81678. */
  81679. export class ProceduralTexture extends Texture {
  81680. isCube: boolean;
  81681. /**
  81682. * Define if the texture is enabled or not (disabled texture will not render)
  81683. */
  81684. isEnabled: boolean;
  81685. /**
  81686. * Define if the texture must be cleared before rendering (default is true)
  81687. */
  81688. autoClear: boolean;
  81689. /**
  81690. * Callback called when the texture is generated
  81691. */
  81692. onGenerated: () => void;
  81693. /**
  81694. * Event raised when the texture is generated
  81695. */
  81696. onGeneratedObservable: Observable<ProceduralTexture>;
  81697. /** @hidden */
  81698. _generateMipMaps: boolean;
  81699. /** @hidden **/
  81700. _effect: Effect;
  81701. /** @hidden */
  81702. _textures: {
  81703. [key: string]: Texture;
  81704. };
  81705. private _size;
  81706. private _currentRefreshId;
  81707. private _refreshRate;
  81708. private _vertexBuffers;
  81709. private _indexBuffer;
  81710. private _uniforms;
  81711. private _samplers;
  81712. private _fragment;
  81713. private _floats;
  81714. private _ints;
  81715. private _floatsArrays;
  81716. private _colors3;
  81717. private _colors4;
  81718. private _vectors2;
  81719. private _vectors3;
  81720. private _matrices;
  81721. private _fallbackTexture;
  81722. private _fallbackTextureUsed;
  81723. private _engine;
  81724. private _cachedDefines;
  81725. private _contentUpdateId;
  81726. private _contentData;
  81727. /**
  81728. * Instantiates a new procedural texture.
  81729. * 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.
  81730. * This is the base class of any Procedural texture and contains most of the shareable code.
  81731. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81732. * @param name Define the name of the texture
  81733. * @param size Define the size of the texture to create
  81734. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81735. * @param scene Define the scene the texture belongs to
  81736. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81737. * @param generateMipMaps Define if the texture should creates mip maps or not
  81738. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81739. */
  81740. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81741. /**
  81742. * The effect that is created when initializing the post process.
  81743. * @returns The created effect corresponding the the postprocess.
  81744. */
  81745. getEffect(): Effect;
  81746. /**
  81747. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81748. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81749. */
  81750. getContent(): Nullable<ArrayBufferView>;
  81751. private _createIndexBuffer;
  81752. /** @hidden */
  81753. _rebuild(): void;
  81754. /**
  81755. * Resets the texture in order to recreate its associated resources.
  81756. * This can be called in case of context loss
  81757. */
  81758. reset(): void;
  81759. protected _getDefines(): string;
  81760. /**
  81761. * Is the texture ready to be used ? (rendered at least once)
  81762. * @returns true if ready, otherwise, false.
  81763. */
  81764. isReady(): boolean;
  81765. /**
  81766. * Resets the refresh counter of the texture and start bak from scratch.
  81767. * Could be useful to regenerate the texture if it is setup to render only once.
  81768. */
  81769. resetRefreshCounter(): void;
  81770. /**
  81771. * Set the fragment shader to use in order to render the texture.
  81772. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81773. */
  81774. setFragment(fragment: any): void;
  81775. /**
  81776. * Define the refresh rate of the texture or the rendering frequency.
  81777. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81778. */
  81779. refreshRate: number;
  81780. /** @hidden */
  81781. _shouldRender(): boolean;
  81782. /**
  81783. * Get the size the texture is rendering at.
  81784. * @returns the size (texture is always squared)
  81785. */
  81786. getRenderSize(): number;
  81787. /**
  81788. * Resize the texture to new value.
  81789. * @param size Define the new size the texture should have
  81790. * @param generateMipMaps Define whether the new texture should create mip maps
  81791. */
  81792. resize(size: number, generateMipMaps: boolean): void;
  81793. private _checkUniform;
  81794. /**
  81795. * Set a texture in the shader program used to render.
  81796. * @param name Define the name of the uniform samplers as defined in the shader
  81797. * @param texture Define the texture to bind to this sampler
  81798. * @return the texture itself allowing "fluent" like uniform updates
  81799. */
  81800. setTexture(name: string, texture: Texture): ProceduralTexture;
  81801. /**
  81802. * Set a float in the shader.
  81803. * @param name Define the name of the uniform as defined in the shader
  81804. * @param value Define the value to give to the uniform
  81805. * @return the texture itself allowing "fluent" like uniform updates
  81806. */
  81807. setFloat(name: string, value: number): ProceduralTexture;
  81808. /**
  81809. * Set a int in the shader.
  81810. * @param name Define the name of the uniform as defined in the shader
  81811. * @param value Define the value to give to the uniform
  81812. * @return the texture itself allowing "fluent" like uniform updates
  81813. */
  81814. setInt(name: string, value: number): ProceduralTexture;
  81815. /**
  81816. * Set an array of floats in the shader.
  81817. * @param name Define the name of the uniform as defined in the shader
  81818. * @param value Define the value to give to the uniform
  81819. * @return the texture itself allowing "fluent" like uniform updates
  81820. */
  81821. setFloats(name: string, value: number[]): ProceduralTexture;
  81822. /**
  81823. * Set a vec3 in the shader from a Color3.
  81824. * @param name Define the name of the uniform as defined in the shader
  81825. * @param value Define the value to give to the uniform
  81826. * @return the texture itself allowing "fluent" like uniform updates
  81827. */
  81828. setColor3(name: string, value: Color3): ProceduralTexture;
  81829. /**
  81830. * Set a vec4 in the shader from a Color4.
  81831. * @param name Define the name of the uniform as defined in the shader
  81832. * @param value Define the value to give to the uniform
  81833. * @return the texture itself allowing "fluent" like uniform updates
  81834. */
  81835. setColor4(name: string, value: Color4): ProceduralTexture;
  81836. /**
  81837. * Set a vec2 in the shader from a Vector2.
  81838. * @param name Define the name of the uniform as defined in the shader
  81839. * @param value Define the value to give to the uniform
  81840. * @return the texture itself allowing "fluent" like uniform updates
  81841. */
  81842. setVector2(name: string, value: Vector2): ProceduralTexture;
  81843. /**
  81844. * Set a vec3 in the shader from a Vector3.
  81845. * @param name Define the name of the uniform as defined in the shader
  81846. * @param value Define the value to give to the uniform
  81847. * @return the texture itself allowing "fluent" like uniform updates
  81848. */
  81849. setVector3(name: string, value: Vector3): ProceduralTexture;
  81850. /**
  81851. * Set a mat4 in the shader from a MAtrix.
  81852. * @param name Define the name of the uniform as defined in the shader
  81853. * @param value Define the value to give to the uniform
  81854. * @return the texture itself allowing "fluent" like uniform updates
  81855. */
  81856. setMatrix(name: string, value: Matrix): ProceduralTexture;
  81857. /**
  81858. * Render the texture to its associated render target.
  81859. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  81860. */
  81861. render(useCameraPostProcess?: boolean): void;
  81862. /**
  81863. * Clone the texture.
  81864. * @returns the cloned texture
  81865. */
  81866. clone(): ProceduralTexture;
  81867. /**
  81868. * Dispose the texture and release its asoociated resources.
  81869. */
  81870. dispose(): void;
  81871. }
  81872. }
  81873. declare module BABYLON {
  81874. /**
  81875. * This represents the base class for particle system in Babylon.
  81876. * 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.
  81877. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81878. * @example https://doc.babylonjs.com/babylon101/particles
  81879. */
  81880. export class BaseParticleSystem {
  81881. /**
  81882. * Source color is added to the destination color without alpha affecting the result
  81883. */
  81884. static BLENDMODE_ONEONE: number;
  81885. /**
  81886. * Blend current color and particle color using particle’s alpha
  81887. */
  81888. static BLENDMODE_STANDARD: number;
  81889. /**
  81890. * Add current color and particle color multiplied by particle’s alpha
  81891. */
  81892. static BLENDMODE_ADD: number;
  81893. /**
  81894. * Multiply current color with particle color
  81895. */
  81896. static BLENDMODE_MULTIPLY: number;
  81897. /**
  81898. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  81899. */
  81900. static BLENDMODE_MULTIPLYADD: number;
  81901. /**
  81902. * List of animations used by the particle system.
  81903. */
  81904. animations: Animation[];
  81905. /**
  81906. * The id of the Particle system.
  81907. */
  81908. id: string;
  81909. /**
  81910. * The friendly name of the Particle system.
  81911. */
  81912. name: string;
  81913. /**
  81914. * The rendering group used by the Particle system to chose when to render.
  81915. */
  81916. renderingGroupId: number;
  81917. /**
  81918. * The emitter represents the Mesh or position we are attaching the particle system to.
  81919. */
  81920. emitter: Nullable<AbstractMesh | Vector3>;
  81921. /**
  81922. * The maximum number of particles to emit per frame
  81923. */
  81924. emitRate: number;
  81925. /**
  81926. * If you want to launch only a few particles at once, that can be done, as well.
  81927. */
  81928. manualEmitCount: number;
  81929. /**
  81930. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81931. */
  81932. updateSpeed: number;
  81933. /**
  81934. * The amount of time the particle system is running (depends of the overall update speed).
  81935. */
  81936. targetStopDuration: number;
  81937. /**
  81938. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  81939. */
  81940. disposeOnStop: boolean;
  81941. /**
  81942. * Minimum power of emitting particles.
  81943. */
  81944. minEmitPower: number;
  81945. /**
  81946. * Maximum power of emitting particles.
  81947. */
  81948. maxEmitPower: number;
  81949. /**
  81950. * Minimum life time of emitting particles.
  81951. */
  81952. minLifeTime: number;
  81953. /**
  81954. * Maximum life time of emitting particles.
  81955. */
  81956. maxLifeTime: number;
  81957. /**
  81958. * Minimum Size of emitting particles.
  81959. */
  81960. minSize: number;
  81961. /**
  81962. * Maximum Size of emitting particles.
  81963. */
  81964. maxSize: number;
  81965. /**
  81966. * Minimum scale of emitting particles on X axis.
  81967. */
  81968. minScaleX: number;
  81969. /**
  81970. * Maximum scale of emitting particles on X axis.
  81971. */
  81972. maxScaleX: number;
  81973. /**
  81974. * Minimum scale of emitting particles on Y axis.
  81975. */
  81976. minScaleY: number;
  81977. /**
  81978. * Maximum scale of emitting particles on Y axis.
  81979. */
  81980. maxScaleY: number;
  81981. /**
  81982. * Gets or sets the minimal initial rotation in radians.
  81983. */
  81984. minInitialRotation: number;
  81985. /**
  81986. * Gets or sets the maximal initial rotation in radians.
  81987. */
  81988. maxInitialRotation: number;
  81989. /**
  81990. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  81991. */
  81992. minAngularSpeed: number;
  81993. /**
  81994. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  81995. */
  81996. maxAngularSpeed: number;
  81997. /**
  81998. * The texture used to render each particle. (this can be a spritesheet)
  81999. */
  82000. particleTexture: Nullable<Texture>;
  82001. /**
  82002. * The layer mask we are rendering the particles through.
  82003. */
  82004. layerMask: number;
  82005. /**
  82006. * This can help using your own shader to render the particle system.
  82007. * The according effect will be created
  82008. */
  82009. customShader: any;
  82010. /**
  82011. * By default particle system starts as soon as they are created. This prevents the
  82012. * automatic start to happen and let you decide when to start emitting particles.
  82013. */
  82014. preventAutoStart: boolean;
  82015. private _noiseTexture;
  82016. /**
  82017. * Gets or sets a texture used to add random noise to particle positions
  82018. */
  82019. noiseTexture: Nullable<ProceduralTexture>;
  82020. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82021. noiseStrength: Vector3;
  82022. /**
  82023. * Callback triggered when the particle animation is ending.
  82024. */
  82025. onAnimationEnd: Nullable<() => void>;
  82026. /**
  82027. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  82028. */
  82029. blendMode: number;
  82030. /**
  82031. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  82032. * to override the particles.
  82033. */
  82034. forceDepthWrite: boolean;
  82035. /** 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 */
  82036. preWarmCycles: number;
  82037. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  82038. preWarmStepOffset: number;
  82039. /**
  82040. * 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)
  82041. */
  82042. spriteCellChangeSpeed: number;
  82043. /**
  82044. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82045. */
  82046. startSpriteCellID: number;
  82047. /**
  82048. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82049. */
  82050. endSpriteCellID: number;
  82051. /**
  82052. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82053. */
  82054. spriteCellWidth: number;
  82055. /**
  82056. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82057. */
  82058. spriteCellHeight: number;
  82059. /**
  82060. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82061. */
  82062. spriteRandomStartCell: boolean;
  82063. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82064. translationPivot: Vector2;
  82065. /** @hidden */
  82066. protected _isAnimationSheetEnabled: boolean;
  82067. /**
  82068. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82069. */
  82070. beginAnimationOnStart: boolean;
  82071. /**
  82072. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82073. */
  82074. beginAnimationFrom: number;
  82075. /**
  82076. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82077. */
  82078. beginAnimationTo: number;
  82079. /**
  82080. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82081. */
  82082. beginAnimationLoop: boolean;
  82083. /**
  82084. * Gets or sets a world offset applied to all particles
  82085. */
  82086. worldOffset: Vector3;
  82087. /**
  82088. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  82089. */
  82090. isAnimationSheetEnabled: boolean;
  82091. /**
  82092. * Get hosting scene
  82093. * @returns the scene
  82094. */
  82095. getScene(): Scene;
  82096. /**
  82097. * You can use gravity if you want to give an orientation to your particles.
  82098. */
  82099. gravity: Vector3;
  82100. protected _colorGradients: Nullable<Array<ColorGradient>>;
  82101. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  82102. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  82103. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  82104. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  82105. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  82106. protected _dragGradients: Nullable<Array<FactorGradient>>;
  82107. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  82108. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  82109. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  82110. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  82111. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  82112. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  82113. /**
  82114. * Defines the delay in milliseconds before starting the system (0 by default)
  82115. */
  82116. startDelay: number;
  82117. /**
  82118. * Gets the current list of drag gradients.
  82119. * You must use addDragGradient and removeDragGradient to udpate this list
  82120. * @returns the list of drag gradients
  82121. */
  82122. getDragGradients(): Nullable<Array<FactorGradient>>;
  82123. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82124. limitVelocityDamping: number;
  82125. /**
  82126. * Gets the current list of limit velocity gradients.
  82127. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82128. * @returns the list of limit velocity gradients
  82129. */
  82130. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82131. /**
  82132. * Gets the current list of color gradients.
  82133. * You must use addColorGradient and removeColorGradient to udpate this list
  82134. * @returns the list of color gradients
  82135. */
  82136. getColorGradients(): Nullable<Array<ColorGradient>>;
  82137. /**
  82138. * Gets the current list of size gradients.
  82139. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82140. * @returns the list of size gradients
  82141. */
  82142. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82143. /**
  82144. * Gets the current list of color remap gradients.
  82145. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82146. * @returns the list of color remap gradients
  82147. */
  82148. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82149. /**
  82150. * Gets the current list of alpha remap gradients.
  82151. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82152. * @returns the list of alpha remap gradients
  82153. */
  82154. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82155. /**
  82156. * Gets the current list of life time gradients.
  82157. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82158. * @returns the list of life time gradients
  82159. */
  82160. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82161. /**
  82162. * Gets the current list of angular speed gradients.
  82163. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82164. * @returns the list of angular speed gradients
  82165. */
  82166. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82167. /**
  82168. * Gets the current list of velocity gradients.
  82169. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82170. * @returns the list of velocity gradients
  82171. */
  82172. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82173. /**
  82174. * Gets the current list of start size gradients.
  82175. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82176. * @returns the list of start size gradients
  82177. */
  82178. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82179. /**
  82180. * Gets the current list of emit rate gradients.
  82181. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82182. * @returns the list of emit rate gradients
  82183. */
  82184. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82185. /**
  82186. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82187. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82188. */
  82189. direction1: Vector3;
  82190. /**
  82191. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82192. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82193. */
  82194. direction2: Vector3;
  82195. /**
  82196. * 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.
  82197. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82198. */
  82199. minEmitBox: Vector3;
  82200. /**
  82201. * 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.
  82202. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82203. */
  82204. maxEmitBox: Vector3;
  82205. /**
  82206. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82207. */
  82208. color1: Color4;
  82209. /**
  82210. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82211. */
  82212. color2: Color4;
  82213. /**
  82214. * Color the particle will have at the end of its lifetime
  82215. */
  82216. colorDead: Color4;
  82217. /**
  82218. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  82219. */
  82220. textureMask: Color4;
  82221. /**
  82222. * The particle emitter type defines the emitter used by the particle system.
  82223. * It can be for example box, sphere, or cone...
  82224. */
  82225. particleEmitterType: IParticleEmitterType;
  82226. /** @hidden */
  82227. _isSubEmitter: boolean;
  82228. /**
  82229. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82230. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82231. */
  82232. billboardMode: number;
  82233. protected _isBillboardBased: boolean;
  82234. /**
  82235. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82236. */
  82237. isBillboardBased: boolean;
  82238. /**
  82239. * The scene the particle system belongs to.
  82240. */
  82241. protected _scene: Scene;
  82242. /**
  82243. * Local cache of defines for image processing.
  82244. */
  82245. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  82246. /**
  82247. * Default configuration related to image processing available in the standard Material.
  82248. */
  82249. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  82250. /**
  82251. * Gets the image processing configuration used either in this material.
  82252. */
  82253. /**
  82254. * Sets the Default image processing configuration used either in the this material.
  82255. *
  82256. * If sets to null, the scene one is in use.
  82257. */
  82258. imageProcessingConfiguration: ImageProcessingConfiguration;
  82259. /**
  82260. * Attaches a new image processing configuration to the Standard Material.
  82261. * @param configuration
  82262. */
  82263. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  82264. /** @hidden */
  82265. protected _reset(): void;
  82266. /** @hidden */
  82267. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  82268. /**
  82269. * Instantiates a particle system.
  82270. * 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.
  82271. * @param name The name of the particle system
  82272. */
  82273. constructor(name: string);
  82274. /**
  82275. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82276. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82277. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82278. * @returns the emitter
  82279. */
  82280. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82281. /**
  82282. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82283. * @param radius The radius of the hemisphere to emit from
  82284. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82285. * @returns the emitter
  82286. */
  82287. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  82288. /**
  82289. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82290. * @param radius The radius of the sphere to emit from
  82291. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82292. * @returns the emitter
  82293. */
  82294. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  82295. /**
  82296. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82297. * @param radius The radius of the sphere to emit from
  82298. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82299. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82300. * @returns the emitter
  82301. */
  82302. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82303. /**
  82304. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82305. * @param radius The radius of the emission cylinder
  82306. * @param height The height of the emission cylinder
  82307. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82308. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82309. * @returns the emitter
  82310. */
  82311. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82312. /**
  82313. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82314. * @param radius The radius of the cylinder to emit from
  82315. * @param height The height of the emission cylinder
  82316. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82317. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82318. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82319. * @returns the emitter
  82320. */
  82321. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82322. /**
  82323. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82324. * @param radius The radius of the cone to emit from
  82325. * @param angle The base angle of the cone
  82326. * @returns the emitter
  82327. */
  82328. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82329. /**
  82330. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82331. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82332. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82333. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82334. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82335. * @returns the emitter
  82336. */
  82337. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82338. }
  82339. }
  82340. declare module BABYLON {
  82341. /**
  82342. * Type of sub emitter
  82343. */
  82344. export enum SubEmitterType {
  82345. /**
  82346. * Attached to the particle over it's lifetime
  82347. */
  82348. ATTACHED = 0,
  82349. /**
  82350. * Created when the particle dies
  82351. */
  82352. END = 1
  82353. }
  82354. /**
  82355. * Sub emitter class used to emit particles from an existing particle
  82356. */
  82357. export class SubEmitter {
  82358. /**
  82359. * the particle system to be used by the sub emitter
  82360. */
  82361. particleSystem: ParticleSystem;
  82362. /**
  82363. * Type of the submitter (Default: END)
  82364. */
  82365. type: SubEmitterType;
  82366. /**
  82367. * 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)
  82368. * Note: This only is supported when using an emitter of type Mesh
  82369. */
  82370. inheritDirection: boolean;
  82371. /**
  82372. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82373. */
  82374. inheritedVelocityAmount: number;
  82375. /**
  82376. * Creates a sub emitter
  82377. * @param particleSystem the particle system to be used by the sub emitter
  82378. */
  82379. constructor(
  82380. /**
  82381. * the particle system to be used by the sub emitter
  82382. */
  82383. particleSystem: ParticleSystem);
  82384. /**
  82385. * Clones the sub emitter
  82386. * @returns the cloned sub emitter
  82387. */
  82388. clone(): SubEmitter;
  82389. /**
  82390. * Serialize current object to a JSON object
  82391. * @returns the serialized object
  82392. */
  82393. serialize(): any;
  82394. /** @hidden */
  82395. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82396. /**
  82397. * Creates a new SubEmitter from a serialized JSON version
  82398. * @param serializationObject defines the JSON object to read from
  82399. * @param scene defines the hosting scene
  82400. * @param rootUrl defines the rootUrl for data loading
  82401. * @returns a new SubEmitter
  82402. */
  82403. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82404. /** Release associated resources */
  82405. dispose(): void;
  82406. }
  82407. }
  82408. declare module BABYLON {
  82409. /** @hidden */
  82410. export var imageProcessingDeclaration: {
  82411. name: string;
  82412. shader: string;
  82413. };
  82414. }
  82415. declare module BABYLON {
  82416. /** @hidden */
  82417. export var imageProcessingFunctions: {
  82418. name: string;
  82419. shader: string;
  82420. };
  82421. }
  82422. declare module BABYLON {
  82423. /** @hidden */
  82424. export var particlesPixelShader: {
  82425. name: string;
  82426. shader: string;
  82427. };
  82428. }
  82429. declare module BABYLON {
  82430. /** @hidden */
  82431. export var particlesVertexShader: {
  82432. name: string;
  82433. shader: string;
  82434. };
  82435. }
  82436. declare module BABYLON {
  82437. /**
  82438. * This represents a particle system in Babylon.
  82439. * 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.
  82440. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82441. * @example https://doc.babylonjs.com/babylon101/particles
  82442. */
  82443. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82444. /**
  82445. * Billboard mode will only apply to Y axis
  82446. */
  82447. static readonly BILLBOARDMODE_Y: number;
  82448. /**
  82449. * Billboard mode will apply to all axes
  82450. */
  82451. static readonly BILLBOARDMODE_ALL: number;
  82452. /**
  82453. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82454. */
  82455. static readonly BILLBOARDMODE_STRETCHED: number;
  82456. /**
  82457. * This function can be defined to provide custom update for active particles.
  82458. * This function will be called instead of regular update (age, position, color, etc.).
  82459. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82460. */
  82461. updateFunction: (particles: Particle[]) => void;
  82462. private _emitterWorldMatrix;
  82463. /**
  82464. * This function can be defined to specify initial direction for every new particle.
  82465. * It by default use the emitterType defined function
  82466. */
  82467. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82468. /**
  82469. * This function can be defined to specify initial position for every new particle.
  82470. * It by default use the emitterType defined function
  82471. */
  82472. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82473. /**
  82474. * @hidden
  82475. */
  82476. _inheritedVelocityOffset: Vector3;
  82477. /**
  82478. * An event triggered when the system is disposed
  82479. */
  82480. onDisposeObservable: Observable<ParticleSystem>;
  82481. private _onDisposeObserver;
  82482. /**
  82483. * Sets a callback that will be triggered when the system is disposed
  82484. */
  82485. onDispose: () => void;
  82486. private _particles;
  82487. private _epsilon;
  82488. private _capacity;
  82489. private _stockParticles;
  82490. private _newPartsExcess;
  82491. private _vertexData;
  82492. private _vertexBuffer;
  82493. private _vertexBuffers;
  82494. private _spriteBuffer;
  82495. private _indexBuffer;
  82496. private _effect;
  82497. private _customEffect;
  82498. private _cachedDefines;
  82499. private _scaledColorStep;
  82500. private _colorDiff;
  82501. private _scaledDirection;
  82502. private _scaledGravity;
  82503. private _currentRenderId;
  82504. private _alive;
  82505. private _useInstancing;
  82506. private _started;
  82507. private _stopped;
  82508. private _actualFrame;
  82509. private _scaledUpdateSpeed;
  82510. private _vertexBufferSize;
  82511. /** @hidden */
  82512. _currentEmitRateGradient: Nullable<FactorGradient>;
  82513. /** @hidden */
  82514. _currentEmitRate1: number;
  82515. /** @hidden */
  82516. _currentEmitRate2: number;
  82517. /** @hidden */
  82518. _currentStartSizeGradient: Nullable<FactorGradient>;
  82519. /** @hidden */
  82520. _currentStartSize1: number;
  82521. /** @hidden */
  82522. _currentStartSize2: number;
  82523. private readonly _rawTextureWidth;
  82524. private _rampGradientsTexture;
  82525. private _useRampGradients;
  82526. /** Gets or sets a boolean indicating that ramp gradients must be used
  82527. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82528. */
  82529. useRampGradients: boolean;
  82530. /**
  82531. * 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.
  82532. * 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: [])
  82533. */
  82534. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82535. private _subEmitters;
  82536. /**
  82537. * @hidden
  82538. * If the particle systems emitter should be disposed when the particle system is disposed
  82539. */
  82540. _disposeEmitterOnDispose: boolean;
  82541. /**
  82542. * The current active Sub-systems, this property is used by the root particle system only.
  82543. */
  82544. activeSubSystems: Array<ParticleSystem>;
  82545. private _rootParticleSystem;
  82546. /**
  82547. * Gets the current list of active particles
  82548. */
  82549. readonly particles: Particle[];
  82550. /**
  82551. * Returns the string "ParticleSystem"
  82552. * @returns a string containing the class name
  82553. */
  82554. getClassName(): string;
  82555. /**
  82556. * Instantiates a particle system.
  82557. * 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.
  82558. * @param name The name of the particle system
  82559. * @param capacity The max number of particles alive at the same time
  82560. * @param scene The scene the particle system belongs to
  82561. * @param customEffect a custom effect used to change the way particles are rendered by default
  82562. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82563. * @param epsilon Offset used to render the particles
  82564. */
  82565. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82566. private _addFactorGradient;
  82567. private _removeFactorGradient;
  82568. /**
  82569. * Adds a new life time gradient
  82570. * @param gradient defines the gradient to use (between 0 and 1)
  82571. * @param factor defines the life time factor to affect to the specified gradient
  82572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82573. * @returns the current particle system
  82574. */
  82575. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82576. /**
  82577. * Remove a specific life time gradient
  82578. * @param gradient defines the gradient to remove
  82579. * @returns the current particle system
  82580. */
  82581. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82582. /**
  82583. * Adds a new size gradient
  82584. * @param gradient defines the gradient to use (between 0 and 1)
  82585. * @param factor defines the size factor to affect to the specified gradient
  82586. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82587. * @returns the current particle system
  82588. */
  82589. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82590. /**
  82591. * Remove a specific size gradient
  82592. * @param gradient defines the gradient to remove
  82593. * @returns the current particle system
  82594. */
  82595. removeSizeGradient(gradient: number): IParticleSystem;
  82596. /**
  82597. * Adds a new color remap gradient
  82598. * @param gradient defines the gradient to use (between 0 and 1)
  82599. * @param min defines the color remap minimal range
  82600. * @param max defines the color remap maximal range
  82601. * @returns the current particle system
  82602. */
  82603. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82604. /**
  82605. * Remove a specific color remap gradient
  82606. * @param gradient defines the gradient to remove
  82607. * @returns the current particle system
  82608. */
  82609. removeColorRemapGradient(gradient: number): IParticleSystem;
  82610. /**
  82611. * Adds a new alpha remap gradient
  82612. * @param gradient defines the gradient to use (between 0 and 1)
  82613. * @param min defines the alpha remap minimal range
  82614. * @param max defines the alpha remap maximal range
  82615. * @returns the current particle system
  82616. */
  82617. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82618. /**
  82619. * Remove a specific alpha remap gradient
  82620. * @param gradient defines the gradient to remove
  82621. * @returns the current particle system
  82622. */
  82623. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82624. /**
  82625. * Adds a new angular speed gradient
  82626. * @param gradient defines the gradient to use (between 0 and 1)
  82627. * @param factor defines the angular speed to affect to the specified gradient
  82628. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82629. * @returns the current particle system
  82630. */
  82631. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82632. /**
  82633. * Remove a specific angular speed gradient
  82634. * @param gradient defines the gradient to remove
  82635. * @returns the current particle system
  82636. */
  82637. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82638. /**
  82639. * Adds a new velocity gradient
  82640. * @param gradient defines the gradient to use (between 0 and 1)
  82641. * @param factor defines the velocity to affect to the specified gradient
  82642. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82643. * @returns the current particle system
  82644. */
  82645. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82646. /**
  82647. * Remove a specific velocity gradient
  82648. * @param gradient defines the gradient to remove
  82649. * @returns the current particle system
  82650. */
  82651. removeVelocityGradient(gradient: number): IParticleSystem;
  82652. /**
  82653. * Adds a new limit velocity gradient
  82654. * @param gradient defines the gradient to use (between 0 and 1)
  82655. * @param factor defines the limit velocity value to affect to the specified gradient
  82656. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82657. * @returns the current particle system
  82658. */
  82659. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82660. /**
  82661. * Remove a specific limit velocity gradient
  82662. * @param gradient defines the gradient to remove
  82663. * @returns the current particle system
  82664. */
  82665. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82666. /**
  82667. * Adds a new drag gradient
  82668. * @param gradient defines the gradient to use (between 0 and 1)
  82669. * @param factor defines the drag value to affect to the specified gradient
  82670. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82671. * @returns the current particle system
  82672. */
  82673. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82674. /**
  82675. * Remove a specific drag gradient
  82676. * @param gradient defines the gradient to remove
  82677. * @returns the current particle system
  82678. */
  82679. removeDragGradient(gradient: number): IParticleSystem;
  82680. /**
  82681. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82682. * @param gradient defines the gradient to use (between 0 and 1)
  82683. * @param factor defines the emit rate value to affect to the specified gradient
  82684. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82685. * @returns the current particle system
  82686. */
  82687. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82688. /**
  82689. * Remove a specific emit rate gradient
  82690. * @param gradient defines the gradient to remove
  82691. * @returns the current particle system
  82692. */
  82693. removeEmitRateGradient(gradient: number): IParticleSystem;
  82694. /**
  82695. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82696. * @param gradient defines the gradient to use (between 0 and 1)
  82697. * @param factor defines the start size value to affect to the specified gradient
  82698. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82699. * @returns the current particle system
  82700. */
  82701. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82702. /**
  82703. * Remove a specific start size gradient
  82704. * @param gradient defines the gradient to remove
  82705. * @returns the current particle system
  82706. */
  82707. removeStartSizeGradient(gradient: number): IParticleSystem;
  82708. private _createRampGradientTexture;
  82709. /**
  82710. * Gets the current list of ramp gradients.
  82711. * You must use addRampGradient and removeRampGradient to udpate this list
  82712. * @returns the list of ramp gradients
  82713. */
  82714. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82715. /**
  82716. * Adds a new ramp gradient used to remap particle colors
  82717. * @param gradient defines the gradient to use (between 0 and 1)
  82718. * @param color defines the color to affect to the specified gradient
  82719. * @returns the current particle system
  82720. */
  82721. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82722. /**
  82723. * Remove a specific ramp gradient
  82724. * @param gradient defines the gradient to remove
  82725. * @returns the current particle system
  82726. */
  82727. removeRampGradient(gradient: number): ParticleSystem;
  82728. /**
  82729. * Adds a new color gradient
  82730. * @param gradient defines the gradient to use (between 0 and 1)
  82731. * @param color1 defines the color to affect to the specified gradient
  82732. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82733. * @returns this particle system
  82734. */
  82735. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82736. /**
  82737. * Remove a specific color gradient
  82738. * @param gradient defines the gradient to remove
  82739. * @returns this particle system
  82740. */
  82741. removeColorGradient(gradient: number): IParticleSystem;
  82742. private _fetchR;
  82743. protected _reset(): void;
  82744. private _resetEffect;
  82745. private _createVertexBuffers;
  82746. private _createIndexBuffer;
  82747. /**
  82748. * Gets the maximum number of particles active at the same time.
  82749. * @returns The max number of active particles.
  82750. */
  82751. getCapacity(): number;
  82752. /**
  82753. * Gets whether there are still active particles in the system.
  82754. * @returns True if it is alive, otherwise false.
  82755. */
  82756. isAlive(): boolean;
  82757. /**
  82758. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82759. * @returns True if it has been started, otherwise false.
  82760. */
  82761. isStarted(): boolean;
  82762. private _prepareSubEmitterInternalArray;
  82763. /**
  82764. * Starts the particle system and begins to emit
  82765. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  82766. */
  82767. start(delay?: number): void;
  82768. /**
  82769. * Stops the particle system.
  82770. * @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.
  82771. */
  82772. stop(stopSubEmitters?: boolean): void;
  82773. /**
  82774. * Remove all active particles
  82775. */
  82776. reset(): void;
  82777. /**
  82778. * @hidden (for internal use only)
  82779. */
  82780. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  82781. /**
  82782. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  82783. * Its lifetime will start back at 0.
  82784. */
  82785. recycleParticle: (particle: Particle) => void;
  82786. private _stopSubEmitters;
  82787. private _createParticle;
  82788. private _removeFromRoot;
  82789. private _emitFromParticle;
  82790. private _update;
  82791. /** @hidden */
  82792. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  82793. /** @hidden */
  82794. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  82795. /** @hidden */
  82796. private _getEffect;
  82797. /**
  82798. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  82799. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  82800. */
  82801. animate(preWarmOnly?: boolean): void;
  82802. private _appendParticleVertices;
  82803. /**
  82804. * Rebuilds the particle system.
  82805. */
  82806. rebuild(): void;
  82807. /**
  82808. * Is this system ready to be used/rendered
  82809. * @return true if the system is ready
  82810. */
  82811. isReady(): boolean;
  82812. private _render;
  82813. /**
  82814. * Renders the particle system in its current state.
  82815. * @returns the current number of particles
  82816. */
  82817. render(): number;
  82818. /**
  82819. * Disposes the particle system and free the associated resources
  82820. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82821. */
  82822. dispose(disposeTexture?: boolean): void;
  82823. /**
  82824. * Clones the particle system.
  82825. * @param name The name of the cloned object
  82826. * @param newEmitter The new emitter to use
  82827. * @returns the cloned particle system
  82828. */
  82829. clone(name: string, newEmitter: any): ParticleSystem;
  82830. /**
  82831. * Serializes the particle system to a JSON object.
  82832. * @returns the JSON object
  82833. */
  82834. serialize(): any;
  82835. /** @hidden */
  82836. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  82837. /** @hidden */
  82838. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  82839. /**
  82840. * Parses a JSON object to create a particle system.
  82841. * @param parsedParticleSystem The JSON object to parse
  82842. * @param scene The scene to create the particle system in
  82843. * @param rootUrl The root url to use to load external dependencies like texture
  82844. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  82845. * @returns the Parsed particle system
  82846. */
  82847. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  82848. }
  82849. }
  82850. declare module BABYLON {
  82851. /**
  82852. * A particle represents one of the element emitted by a particle system.
  82853. * This is mainly define by its coordinates, direction, velocity and age.
  82854. */
  82855. export class Particle {
  82856. /**
  82857. * The particle system the particle belongs to.
  82858. */
  82859. particleSystem: ParticleSystem;
  82860. private static _Count;
  82861. /**
  82862. * Unique ID of the particle
  82863. */
  82864. id: number;
  82865. /**
  82866. * The world position of the particle in the scene.
  82867. */
  82868. position: Vector3;
  82869. /**
  82870. * The world direction of the particle in the scene.
  82871. */
  82872. direction: Vector3;
  82873. /**
  82874. * The color of the particle.
  82875. */
  82876. color: Color4;
  82877. /**
  82878. * The color change of the particle per step.
  82879. */
  82880. colorStep: Color4;
  82881. /**
  82882. * Defines how long will the life of the particle be.
  82883. */
  82884. lifeTime: number;
  82885. /**
  82886. * The current age of the particle.
  82887. */
  82888. age: number;
  82889. /**
  82890. * The current size of the particle.
  82891. */
  82892. size: number;
  82893. /**
  82894. * The current scale of the particle.
  82895. */
  82896. scale: Vector2;
  82897. /**
  82898. * The current angle of the particle.
  82899. */
  82900. angle: number;
  82901. /**
  82902. * Defines how fast is the angle changing.
  82903. */
  82904. angularSpeed: number;
  82905. /**
  82906. * Defines the cell index used by the particle to be rendered from a sprite.
  82907. */
  82908. cellIndex: number;
  82909. /**
  82910. * The information required to support color remapping
  82911. */
  82912. remapData: Vector4;
  82913. /** @hidden */
  82914. _randomCellOffset?: number;
  82915. /** @hidden */
  82916. _initialDirection: Nullable<Vector3>;
  82917. /** @hidden */
  82918. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  82919. /** @hidden */
  82920. _initialStartSpriteCellID: number;
  82921. /** @hidden */
  82922. _initialEndSpriteCellID: number;
  82923. /** @hidden */
  82924. _currentColorGradient: Nullable<ColorGradient>;
  82925. /** @hidden */
  82926. _currentColor1: Color4;
  82927. /** @hidden */
  82928. _currentColor2: Color4;
  82929. /** @hidden */
  82930. _currentSizeGradient: Nullable<FactorGradient>;
  82931. /** @hidden */
  82932. _currentSize1: number;
  82933. /** @hidden */
  82934. _currentSize2: number;
  82935. /** @hidden */
  82936. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  82937. /** @hidden */
  82938. _currentAngularSpeed1: number;
  82939. /** @hidden */
  82940. _currentAngularSpeed2: number;
  82941. /** @hidden */
  82942. _currentVelocityGradient: Nullable<FactorGradient>;
  82943. /** @hidden */
  82944. _currentVelocity1: number;
  82945. /** @hidden */
  82946. _currentVelocity2: number;
  82947. /** @hidden */
  82948. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  82949. /** @hidden */
  82950. _currentLimitVelocity1: number;
  82951. /** @hidden */
  82952. _currentLimitVelocity2: number;
  82953. /** @hidden */
  82954. _currentDragGradient: Nullable<FactorGradient>;
  82955. /** @hidden */
  82956. _currentDrag1: number;
  82957. /** @hidden */
  82958. _currentDrag2: number;
  82959. /** @hidden */
  82960. _randomNoiseCoordinates1: Vector3;
  82961. /** @hidden */
  82962. _randomNoiseCoordinates2: Vector3;
  82963. /**
  82964. * Creates a new instance Particle
  82965. * @param particleSystem the particle system the particle belongs to
  82966. */
  82967. constructor(
  82968. /**
  82969. * The particle system the particle belongs to.
  82970. */
  82971. particleSystem: ParticleSystem);
  82972. private updateCellInfoFromSystem;
  82973. /**
  82974. * Defines how the sprite cell index is updated for the particle
  82975. */
  82976. updateCellIndex(): void;
  82977. /** @hidden */
  82978. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  82979. /** @hidden */
  82980. _inheritParticleInfoToSubEmitters(): void;
  82981. /** @hidden */
  82982. _reset(): void;
  82983. /**
  82984. * Copy the properties of particle to another one.
  82985. * @param other the particle to copy the information to.
  82986. */
  82987. copyTo(other: Particle): void;
  82988. }
  82989. }
  82990. declare module BABYLON {
  82991. /**
  82992. * Particle emitter represents a volume emitting particles.
  82993. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  82994. */
  82995. export interface IParticleEmitterType {
  82996. /**
  82997. * Called by the particle System when the direction is computed for the created particle.
  82998. * @param worldMatrix is the world matrix of the particle system
  82999. * @param directionToUpdate is the direction vector to update with the result
  83000. * @param particle is the particle we are computed the direction for
  83001. */
  83002. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83003. /**
  83004. * Called by the particle System when the position is computed for the created particle.
  83005. * @param worldMatrix is the world matrix of the particle system
  83006. * @param positionToUpdate is the position vector to update with the result
  83007. * @param particle is the particle we are computed the position for
  83008. */
  83009. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83010. /**
  83011. * Clones the current emitter and returns a copy of it
  83012. * @returns the new emitter
  83013. */
  83014. clone(): IParticleEmitterType;
  83015. /**
  83016. * Called by the GPUParticleSystem to setup the update shader
  83017. * @param effect defines the update shader
  83018. */
  83019. applyToShader(effect: Effect): void;
  83020. /**
  83021. * Returns a string to use to update the GPU particles update shader
  83022. * @returns the effect defines string
  83023. */
  83024. getEffectDefines(): string;
  83025. /**
  83026. * Returns a string representing the class name
  83027. * @returns a string containing the class name
  83028. */
  83029. getClassName(): string;
  83030. /**
  83031. * Serializes the particle system to a JSON object.
  83032. * @returns the JSON object
  83033. */
  83034. serialize(): any;
  83035. /**
  83036. * Parse properties from a JSON object
  83037. * @param serializationObject defines the JSON object
  83038. */
  83039. parse(serializationObject: any): void;
  83040. }
  83041. }
  83042. declare module BABYLON {
  83043. /**
  83044. * Particle emitter emitting particles from the inside of a box.
  83045. * It emits the particles randomly between 2 given directions.
  83046. */
  83047. export class BoxParticleEmitter implements IParticleEmitterType {
  83048. /**
  83049. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83050. */
  83051. direction1: Vector3;
  83052. /**
  83053. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83054. */
  83055. direction2: Vector3;
  83056. /**
  83057. * 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.
  83058. */
  83059. minEmitBox: Vector3;
  83060. /**
  83061. * 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.
  83062. */
  83063. maxEmitBox: Vector3;
  83064. /**
  83065. * Creates a new instance BoxParticleEmitter
  83066. */
  83067. constructor();
  83068. /**
  83069. * Called by the particle System when the direction is computed for the created particle.
  83070. * @param worldMatrix is the world matrix of the particle system
  83071. * @param directionToUpdate is the direction vector to update with the result
  83072. * @param particle is the particle we are computed the direction for
  83073. */
  83074. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83075. /**
  83076. * Called by the particle System when the position is computed for the created particle.
  83077. * @param worldMatrix is the world matrix of the particle system
  83078. * @param positionToUpdate is the position vector to update with the result
  83079. * @param particle is the particle we are computed the position for
  83080. */
  83081. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83082. /**
  83083. * Clones the current emitter and returns a copy of it
  83084. * @returns the new emitter
  83085. */
  83086. clone(): BoxParticleEmitter;
  83087. /**
  83088. * Called by the GPUParticleSystem to setup the update shader
  83089. * @param effect defines the update shader
  83090. */
  83091. applyToShader(effect: Effect): void;
  83092. /**
  83093. * Returns a string to use to update the GPU particles update shader
  83094. * @returns a string containng the defines string
  83095. */
  83096. getEffectDefines(): string;
  83097. /**
  83098. * Returns the string "BoxParticleEmitter"
  83099. * @returns a string containing the class name
  83100. */
  83101. getClassName(): string;
  83102. /**
  83103. * Serializes the particle system to a JSON object.
  83104. * @returns the JSON object
  83105. */
  83106. serialize(): any;
  83107. /**
  83108. * Parse properties from a JSON object
  83109. * @param serializationObject defines the JSON object
  83110. */
  83111. parse(serializationObject: any): void;
  83112. }
  83113. }
  83114. declare module BABYLON {
  83115. /**
  83116. * Particle emitter emitting particles from the inside of a cone.
  83117. * It emits the particles alongside the cone volume from the base to the particle.
  83118. * The emission direction might be randomized.
  83119. */
  83120. export class ConeParticleEmitter implements IParticleEmitterType {
  83121. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83122. directionRandomizer: number;
  83123. private _radius;
  83124. private _angle;
  83125. private _height;
  83126. /**
  83127. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  83128. */
  83129. radiusRange: number;
  83130. /**
  83131. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  83132. */
  83133. heightRange: number;
  83134. /**
  83135. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  83136. */
  83137. emitFromSpawnPointOnly: boolean;
  83138. /**
  83139. * Gets or sets the radius of the emission cone
  83140. */
  83141. radius: number;
  83142. /**
  83143. * Gets or sets the angle of the emission cone
  83144. */
  83145. angle: number;
  83146. private _buildHeight;
  83147. /**
  83148. * Creates a new instance ConeParticleEmitter
  83149. * @param radius the radius of the emission cone (1 by default)
  83150. * @param angle the cone base angle (PI by default)
  83151. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  83152. */
  83153. constructor(radius?: number, angle?: number,
  83154. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83155. directionRandomizer?: number);
  83156. /**
  83157. * Called by the particle System when the direction is computed for the created particle.
  83158. * @param worldMatrix is the world matrix of the particle system
  83159. * @param directionToUpdate is the direction vector to update with the result
  83160. * @param particle is the particle we are computed the direction for
  83161. */
  83162. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83163. /**
  83164. * Called by the particle System when the position is computed for the created particle.
  83165. * @param worldMatrix is the world matrix of the particle system
  83166. * @param positionToUpdate is the position vector to update with the result
  83167. * @param particle is the particle we are computed the position for
  83168. */
  83169. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83170. /**
  83171. * Clones the current emitter and returns a copy of it
  83172. * @returns the new emitter
  83173. */
  83174. clone(): ConeParticleEmitter;
  83175. /**
  83176. * Called by the GPUParticleSystem to setup the update shader
  83177. * @param effect defines the update shader
  83178. */
  83179. applyToShader(effect: Effect): void;
  83180. /**
  83181. * Returns a string to use to update the GPU particles update shader
  83182. * @returns a string containng the defines string
  83183. */
  83184. getEffectDefines(): string;
  83185. /**
  83186. * Returns the string "ConeParticleEmitter"
  83187. * @returns a string containing the class name
  83188. */
  83189. getClassName(): string;
  83190. /**
  83191. * Serializes the particle system to a JSON object.
  83192. * @returns the JSON object
  83193. */
  83194. serialize(): any;
  83195. /**
  83196. * Parse properties from a JSON object
  83197. * @param serializationObject defines the JSON object
  83198. */
  83199. parse(serializationObject: any): void;
  83200. }
  83201. }
  83202. declare module BABYLON {
  83203. /**
  83204. * Particle emitter emitting particles from the inside of a cylinder.
  83205. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  83206. */
  83207. export class CylinderParticleEmitter implements IParticleEmitterType {
  83208. /**
  83209. * The radius of the emission cylinder.
  83210. */
  83211. radius: number;
  83212. /**
  83213. * The height of the emission cylinder.
  83214. */
  83215. height: number;
  83216. /**
  83217. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83218. */
  83219. radiusRange: number;
  83220. /**
  83221. * How much to randomize the particle direction [0-1].
  83222. */
  83223. directionRandomizer: number;
  83224. /**
  83225. * Creates a new instance CylinderParticleEmitter
  83226. * @param radius the radius of the emission cylinder (1 by default)
  83227. * @param height the height of the emission cylinder (1 by default)
  83228. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83229. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83230. */
  83231. constructor(
  83232. /**
  83233. * The radius of the emission cylinder.
  83234. */
  83235. radius?: number,
  83236. /**
  83237. * The height of the emission cylinder.
  83238. */
  83239. height?: number,
  83240. /**
  83241. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83242. */
  83243. radiusRange?: number,
  83244. /**
  83245. * How much to randomize the particle direction [0-1].
  83246. */
  83247. directionRandomizer?: number);
  83248. /**
  83249. * Called by the particle System when the direction is computed for the created particle.
  83250. * @param worldMatrix is the world matrix of the particle system
  83251. * @param directionToUpdate is the direction vector to update with the result
  83252. * @param particle is the particle we are computed the direction for
  83253. */
  83254. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83255. /**
  83256. * Called by the particle System when the position is computed for the created particle.
  83257. * @param worldMatrix is the world matrix of the particle system
  83258. * @param positionToUpdate is the position vector to update with the result
  83259. * @param particle is the particle we are computed the position for
  83260. */
  83261. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83262. /**
  83263. * Clones the current emitter and returns a copy of it
  83264. * @returns the new emitter
  83265. */
  83266. clone(): CylinderParticleEmitter;
  83267. /**
  83268. * Called by the GPUParticleSystem to setup the update shader
  83269. * @param effect defines the update shader
  83270. */
  83271. applyToShader(effect: Effect): void;
  83272. /**
  83273. * Returns a string to use to update the GPU particles update shader
  83274. * @returns a string containng the defines string
  83275. */
  83276. getEffectDefines(): string;
  83277. /**
  83278. * Returns the string "CylinderParticleEmitter"
  83279. * @returns a string containing the class name
  83280. */
  83281. getClassName(): string;
  83282. /**
  83283. * Serializes the particle system to a JSON object.
  83284. * @returns the JSON object
  83285. */
  83286. serialize(): any;
  83287. /**
  83288. * Parse properties from a JSON object
  83289. * @param serializationObject defines the JSON object
  83290. */
  83291. parse(serializationObject: any): void;
  83292. }
  83293. /**
  83294. * Particle emitter emitting particles from the inside of a cylinder.
  83295. * It emits the particles randomly between two vectors.
  83296. */
  83297. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  83298. /**
  83299. * The min limit of the emission direction.
  83300. */
  83301. direction1: Vector3;
  83302. /**
  83303. * The max limit of the emission direction.
  83304. */
  83305. direction2: Vector3;
  83306. /**
  83307. * Creates a new instance CylinderDirectedParticleEmitter
  83308. * @param radius the radius of the emission cylinder (1 by default)
  83309. * @param height the height of the emission cylinder (1 by default)
  83310. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83311. * @param direction1 the min limit of the emission direction (up vector by default)
  83312. * @param direction2 the max limit of the emission direction (up vector by default)
  83313. */
  83314. constructor(radius?: number, height?: number, radiusRange?: number,
  83315. /**
  83316. * The min limit of the emission direction.
  83317. */
  83318. direction1?: Vector3,
  83319. /**
  83320. * The max limit of the emission direction.
  83321. */
  83322. direction2?: Vector3);
  83323. /**
  83324. * Called by the particle System when the direction is computed for the created particle.
  83325. * @param worldMatrix is the world matrix of the particle system
  83326. * @param directionToUpdate is the direction vector to update with the result
  83327. * @param particle is the particle we are computed the direction for
  83328. */
  83329. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83330. /**
  83331. * Clones the current emitter and returns a copy of it
  83332. * @returns the new emitter
  83333. */
  83334. clone(): CylinderDirectedParticleEmitter;
  83335. /**
  83336. * Called by the GPUParticleSystem to setup the update shader
  83337. * @param effect defines the update shader
  83338. */
  83339. applyToShader(effect: Effect): void;
  83340. /**
  83341. * Returns a string to use to update the GPU particles update shader
  83342. * @returns a string containng the defines string
  83343. */
  83344. getEffectDefines(): string;
  83345. /**
  83346. * Returns the string "CylinderDirectedParticleEmitter"
  83347. * @returns a string containing the class name
  83348. */
  83349. getClassName(): string;
  83350. /**
  83351. * Serializes the particle system to a JSON object.
  83352. * @returns the JSON object
  83353. */
  83354. serialize(): any;
  83355. /**
  83356. * Parse properties from a JSON object
  83357. * @param serializationObject defines the JSON object
  83358. */
  83359. parse(serializationObject: any): void;
  83360. }
  83361. }
  83362. declare module BABYLON {
  83363. /**
  83364. * Particle emitter emitting particles from the inside of a hemisphere.
  83365. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83366. */
  83367. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83368. /**
  83369. * The radius of the emission hemisphere.
  83370. */
  83371. radius: number;
  83372. /**
  83373. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83374. */
  83375. radiusRange: number;
  83376. /**
  83377. * How much to randomize the particle direction [0-1].
  83378. */
  83379. directionRandomizer: number;
  83380. /**
  83381. * Creates a new instance HemisphericParticleEmitter
  83382. * @param radius the radius of the emission hemisphere (1 by default)
  83383. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83384. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83385. */
  83386. constructor(
  83387. /**
  83388. * The radius of the emission hemisphere.
  83389. */
  83390. radius?: number,
  83391. /**
  83392. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83393. */
  83394. radiusRange?: number,
  83395. /**
  83396. * How much to randomize the particle direction [0-1].
  83397. */
  83398. directionRandomizer?: number);
  83399. /**
  83400. * Called by the particle System when the direction is computed for the created particle.
  83401. * @param worldMatrix is the world matrix of the particle system
  83402. * @param directionToUpdate is the direction vector to update with the result
  83403. * @param particle is the particle we are computed the direction for
  83404. */
  83405. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83406. /**
  83407. * Called by the particle System when the position is computed for the created particle.
  83408. * @param worldMatrix is the world matrix of the particle system
  83409. * @param positionToUpdate is the position vector to update with the result
  83410. * @param particle is the particle we are computed the position for
  83411. */
  83412. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83413. /**
  83414. * Clones the current emitter and returns a copy of it
  83415. * @returns the new emitter
  83416. */
  83417. clone(): HemisphericParticleEmitter;
  83418. /**
  83419. * Called by the GPUParticleSystem to setup the update shader
  83420. * @param effect defines the update shader
  83421. */
  83422. applyToShader(effect: Effect): void;
  83423. /**
  83424. * Returns a string to use to update the GPU particles update shader
  83425. * @returns a string containng the defines string
  83426. */
  83427. getEffectDefines(): string;
  83428. /**
  83429. * Returns the string "HemisphericParticleEmitter"
  83430. * @returns a string containing the class name
  83431. */
  83432. getClassName(): string;
  83433. /**
  83434. * Serializes the particle system to a JSON object.
  83435. * @returns the JSON object
  83436. */
  83437. serialize(): any;
  83438. /**
  83439. * Parse properties from a JSON object
  83440. * @param serializationObject defines the JSON object
  83441. */
  83442. parse(serializationObject: any): void;
  83443. }
  83444. }
  83445. declare module BABYLON {
  83446. /**
  83447. * Particle emitter emitting particles from a point.
  83448. * It emits the particles randomly between 2 given directions.
  83449. */
  83450. export class PointParticleEmitter implements IParticleEmitterType {
  83451. /**
  83452. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83453. */
  83454. direction1: Vector3;
  83455. /**
  83456. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83457. */
  83458. direction2: Vector3;
  83459. /**
  83460. * Creates a new instance PointParticleEmitter
  83461. */
  83462. constructor();
  83463. /**
  83464. * Called by the particle System when the direction is computed for the created particle.
  83465. * @param worldMatrix is the world matrix of the particle system
  83466. * @param directionToUpdate is the direction vector to update with the result
  83467. * @param particle is the particle we are computed the direction for
  83468. */
  83469. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83470. /**
  83471. * Called by the particle System when the position is computed for the created particle.
  83472. * @param worldMatrix is the world matrix of the particle system
  83473. * @param positionToUpdate is the position vector to update with the result
  83474. * @param particle is the particle we are computed the position for
  83475. */
  83476. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83477. /**
  83478. * Clones the current emitter and returns a copy of it
  83479. * @returns the new emitter
  83480. */
  83481. clone(): PointParticleEmitter;
  83482. /**
  83483. * Called by the GPUParticleSystem to setup the update shader
  83484. * @param effect defines the update shader
  83485. */
  83486. applyToShader(effect: Effect): void;
  83487. /**
  83488. * Returns a string to use to update the GPU particles update shader
  83489. * @returns a string containng the defines string
  83490. */
  83491. getEffectDefines(): string;
  83492. /**
  83493. * Returns the string "PointParticleEmitter"
  83494. * @returns a string containing the class name
  83495. */
  83496. getClassName(): string;
  83497. /**
  83498. * Serializes the particle system to a JSON object.
  83499. * @returns the JSON object
  83500. */
  83501. serialize(): any;
  83502. /**
  83503. * Parse properties from a JSON object
  83504. * @param serializationObject defines the JSON object
  83505. */
  83506. parse(serializationObject: any): void;
  83507. }
  83508. }
  83509. declare module BABYLON {
  83510. /**
  83511. * Particle emitter emitting particles from the inside of a sphere.
  83512. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83513. */
  83514. export class SphereParticleEmitter implements IParticleEmitterType {
  83515. /**
  83516. * The radius of the emission sphere.
  83517. */
  83518. radius: number;
  83519. /**
  83520. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83521. */
  83522. radiusRange: number;
  83523. /**
  83524. * How much to randomize the particle direction [0-1].
  83525. */
  83526. directionRandomizer: number;
  83527. /**
  83528. * Creates a new instance SphereParticleEmitter
  83529. * @param radius the radius of the emission sphere (1 by default)
  83530. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83531. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83532. */
  83533. constructor(
  83534. /**
  83535. * The radius of the emission sphere.
  83536. */
  83537. radius?: number,
  83538. /**
  83539. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83540. */
  83541. radiusRange?: number,
  83542. /**
  83543. * How much to randomize the particle direction [0-1].
  83544. */
  83545. directionRandomizer?: number);
  83546. /**
  83547. * Called by the particle System when the direction is computed for the created particle.
  83548. * @param worldMatrix is the world matrix of the particle system
  83549. * @param directionToUpdate is the direction vector to update with the result
  83550. * @param particle is the particle we are computed the direction for
  83551. */
  83552. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83553. /**
  83554. * Called by the particle System when the position is computed for the created particle.
  83555. * @param worldMatrix is the world matrix of the particle system
  83556. * @param positionToUpdate is the position vector to update with the result
  83557. * @param particle is the particle we are computed the position for
  83558. */
  83559. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83560. /**
  83561. * Clones the current emitter and returns a copy of it
  83562. * @returns the new emitter
  83563. */
  83564. clone(): SphereParticleEmitter;
  83565. /**
  83566. * Called by the GPUParticleSystem to setup the update shader
  83567. * @param effect defines the update shader
  83568. */
  83569. applyToShader(effect: Effect): void;
  83570. /**
  83571. * Returns a string to use to update the GPU particles update shader
  83572. * @returns a string containng the defines string
  83573. */
  83574. getEffectDefines(): string;
  83575. /**
  83576. * Returns the string "SphereParticleEmitter"
  83577. * @returns a string containing the class name
  83578. */
  83579. getClassName(): string;
  83580. /**
  83581. * Serializes the particle system to a JSON object.
  83582. * @returns the JSON object
  83583. */
  83584. serialize(): any;
  83585. /**
  83586. * Parse properties from a JSON object
  83587. * @param serializationObject defines the JSON object
  83588. */
  83589. parse(serializationObject: any): void;
  83590. }
  83591. /**
  83592. * Particle emitter emitting particles from the inside of a sphere.
  83593. * It emits the particles randomly between two vectors.
  83594. */
  83595. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83596. /**
  83597. * The min limit of the emission direction.
  83598. */
  83599. direction1: Vector3;
  83600. /**
  83601. * The max limit of the emission direction.
  83602. */
  83603. direction2: Vector3;
  83604. /**
  83605. * Creates a new instance SphereDirectedParticleEmitter
  83606. * @param radius the radius of the emission sphere (1 by default)
  83607. * @param direction1 the min limit of the emission direction (up vector by default)
  83608. * @param direction2 the max limit of the emission direction (up vector by default)
  83609. */
  83610. constructor(radius?: number,
  83611. /**
  83612. * The min limit of the emission direction.
  83613. */
  83614. direction1?: Vector3,
  83615. /**
  83616. * The max limit of the emission direction.
  83617. */
  83618. direction2?: Vector3);
  83619. /**
  83620. * Called by the particle System when the direction is computed for the created particle.
  83621. * @param worldMatrix is the world matrix of the particle system
  83622. * @param directionToUpdate is the direction vector to update with the result
  83623. * @param particle is the particle we are computed the direction for
  83624. */
  83625. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83626. /**
  83627. * Clones the current emitter and returns a copy of it
  83628. * @returns the new emitter
  83629. */
  83630. clone(): SphereDirectedParticleEmitter;
  83631. /**
  83632. * Called by the GPUParticleSystem to setup the update shader
  83633. * @param effect defines the update shader
  83634. */
  83635. applyToShader(effect: Effect): void;
  83636. /**
  83637. * Returns a string to use to update the GPU particles update shader
  83638. * @returns a string containng the defines string
  83639. */
  83640. getEffectDefines(): string;
  83641. /**
  83642. * Returns the string "SphereDirectedParticleEmitter"
  83643. * @returns a string containing the class name
  83644. */
  83645. getClassName(): string;
  83646. /**
  83647. * Serializes the particle system to a JSON object.
  83648. * @returns the JSON object
  83649. */
  83650. serialize(): any;
  83651. /**
  83652. * Parse properties from a JSON object
  83653. * @param serializationObject defines the JSON object
  83654. */
  83655. parse(serializationObject: any): void;
  83656. }
  83657. }
  83658. declare module BABYLON {
  83659. /**
  83660. * Interface representing a particle system in Babylon.js.
  83661. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83662. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83663. */
  83664. export interface IParticleSystem {
  83665. /**
  83666. * List of animations used by the particle system.
  83667. */
  83668. animations: Animation[];
  83669. /**
  83670. * The id of the Particle system.
  83671. */
  83672. id: string;
  83673. /**
  83674. * The name of the Particle system.
  83675. */
  83676. name: string;
  83677. /**
  83678. * The emitter represents the Mesh or position we are attaching the particle system to.
  83679. */
  83680. emitter: Nullable<AbstractMesh | Vector3>;
  83681. /**
  83682. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83683. */
  83684. isBillboardBased: boolean;
  83685. /**
  83686. * The rendering group used by the Particle system to chose when to render.
  83687. */
  83688. renderingGroupId: number;
  83689. /**
  83690. * The layer mask we are rendering the particles through.
  83691. */
  83692. layerMask: number;
  83693. /**
  83694. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83695. */
  83696. updateSpeed: number;
  83697. /**
  83698. * The amount of time the particle system is running (depends of the overall update speed).
  83699. */
  83700. targetStopDuration: number;
  83701. /**
  83702. * The texture used to render each particle. (this can be a spritesheet)
  83703. */
  83704. particleTexture: Nullable<Texture>;
  83705. /**
  83706. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83707. */
  83708. blendMode: number;
  83709. /**
  83710. * Minimum life time of emitting particles.
  83711. */
  83712. minLifeTime: number;
  83713. /**
  83714. * Maximum life time of emitting particles.
  83715. */
  83716. maxLifeTime: number;
  83717. /**
  83718. * Minimum Size of emitting particles.
  83719. */
  83720. minSize: number;
  83721. /**
  83722. * Maximum Size of emitting particles.
  83723. */
  83724. maxSize: number;
  83725. /**
  83726. * Minimum scale of emitting particles on X axis.
  83727. */
  83728. minScaleX: number;
  83729. /**
  83730. * Maximum scale of emitting particles on X axis.
  83731. */
  83732. maxScaleX: number;
  83733. /**
  83734. * Minimum scale of emitting particles on Y axis.
  83735. */
  83736. minScaleY: number;
  83737. /**
  83738. * Maximum scale of emitting particles on Y axis.
  83739. */
  83740. maxScaleY: number;
  83741. /**
  83742. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83743. */
  83744. color1: Color4;
  83745. /**
  83746. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83747. */
  83748. color2: Color4;
  83749. /**
  83750. * Color the particle will have at the end of its lifetime.
  83751. */
  83752. colorDead: Color4;
  83753. /**
  83754. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  83755. */
  83756. emitRate: number;
  83757. /**
  83758. * You can use gravity if you want to give an orientation to your particles.
  83759. */
  83760. gravity: Vector3;
  83761. /**
  83762. * Minimum power of emitting particles.
  83763. */
  83764. minEmitPower: number;
  83765. /**
  83766. * Maximum power of emitting particles.
  83767. */
  83768. maxEmitPower: number;
  83769. /**
  83770. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83771. */
  83772. minAngularSpeed: number;
  83773. /**
  83774. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83775. */
  83776. maxAngularSpeed: number;
  83777. /**
  83778. * Gets or sets the minimal initial rotation in radians.
  83779. */
  83780. minInitialRotation: number;
  83781. /**
  83782. * Gets or sets the maximal initial rotation in radians.
  83783. */
  83784. maxInitialRotation: number;
  83785. /**
  83786. * The particle emitter type defines the emitter used by the particle system.
  83787. * It can be for example box, sphere, or cone...
  83788. */
  83789. particleEmitterType: Nullable<IParticleEmitterType>;
  83790. /**
  83791. * Defines the delay in milliseconds before starting the system (0 by default)
  83792. */
  83793. startDelay: number;
  83794. /**
  83795. * 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
  83796. */
  83797. preWarmCycles: number;
  83798. /**
  83799. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  83800. */
  83801. preWarmStepOffset: number;
  83802. /**
  83803. * 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)
  83804. */
  83805. spriteCellChangeSpeed: number;
  83806. /**
  83807. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83808. */
  83809. startSpriteCellID: number;
  83810. /**
  83811. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83812. */
  83813. endSpriteCellID: number;
  83814. /**
  83815. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83816. */
  83817. spriteCellWidth: number;
  83818. /**
  83819. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83820. */
  83821. spriteCellHeight: number;
  83822. /**
  83823. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83824. */
  83825. spriteRandomStartCell: boolean;
  83826. /**
  83827. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  83828. */
  83829. isAnimationSheetEnabled: boolean;
  83830. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83831. translationPivot: Vector2;
  83832. /**
  83833. * Gets or sets a texture used to add random noise to particle positions
  83834. */
  83835. noiseTexture: Nullable<BaseTexture>;
  83836. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83837. noiseStrength: Vector3;
  83838. /**
  83839. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83840. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83841. */
  83842. billboardMode: number;
  83843. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83844. limitVelocityDamping: number;
  83845. /**
  83846. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83847. */
  83848. beginAnimationOnStart: boolean;
  83849. /**
  83850. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83851. */
  83852. beginAnimationFrom: number;
  83853. /**
  83854. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83855. */
  83856. beginAnimationTo: number;
  83857. /**
  83858. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83859. */
  83860. beginAnimationLoop: boolean;
  83861. /**
  83862. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83863. */
  83864. disposeOnStop: boolean;
  83865. /**
  83866. * Gets the maximum number of particles active at the same time.
  83867. * @returns The max number of active particles.
  83868. */
  83869. getCapacity(): number;
  83870. /**
  83871. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83872. * @returns True if it has been started, otherwise false.
  83873. */
  83874. isStarted(): boolean;
  83875. /**
  83876. * Animates the particle system for this frame.
  83877. */
  83878. animate(): void;
  83879. /**
  83880. * Renders the particle system in its current state.
  83881. * @returns the current number of particles
  83882. */
  83883. render(): number;
  83884. /**
  83885. * Dispose the particle system and frees its associated resources.
  83886. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83887. */
  83888. dispose(disposeTexture?: boolean): void;
  83889. /**
  83890. * Clones the particle system.
  83891. * @param name The name of the cloned object
  83892. * @param newEmitter The new emitter to use
  83893. * @returns the cloned particle system
  83894. */
  83895. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  83896. /**
  83897. * Serializes the particle system to a JSON object.
  83898. * @returns the JSON object
  83899. */
  83900. serialize(): any;
  83901. /**
  83902. * Rebuild the particle system
  83903. */
  83904. rebuild(): void;
  83905. /**
  83906. * Starts the particle system and begins to emit
  83907. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  83908. */
  83909. start(delay?: number): void;
  83910. /**
  83911. * Stops the particle system.
  83912. */
  83913. stop(): void;
  83914. /**
  83915. * Remove all active particles
  83916. */
  83917. reset(): void;
  83918. /**
  83919. * Is this system ready to be used/rendered
  83920. * @return true if the system is ready
  83921. */
  83922. isReady(): boolean;
  83923. /**
  83924. * Adds a new color gradient
  83925. * @param gradient defines the gradient to use (between 0 and 1)
  83926. * @param color1 defines the color to affect to the specified gradient
  83927. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83928. * @returns the current particle system
  83929. */
  83930. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83931. /**
  83932. * Remove a specific color gradient
  83933. * @param gradient defines the gradient to remove
  83934. * @returns the current particle system
  83935. */
  83936. removeColorGradient(gradient: number): IParticleSystem;
  83937. /**
  83938. * Adds a new size gradient
  83939. * @param gradient defines the gradient to use (between 0 and 1)
  83940. * @param factor defines the size factor to affect to the specified gradient
  83941. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83942. * @returns the current particle system
  83943. */
  83944. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83945. /**
  83946. * Remove a specific size gradient
  83947. * @param gradient defines the gradient to remove
  83948. * @returns the current particle system
  83949. */
  83950. removeSizeGradient(gradient: number): IParticleSystem;
  83951. /**
  83952. * Gets the current list of color gradients.
  83953. * You must use addColorGradient and removeColorGradient to udpate this list
  83954. * @returns the list of color gradients
  83955. */
  83956. getColorGradients(): Nullable<Array<ColorGradient>>;
  83957. /**
  83958. * Gets the current list of size gradients.
  83959. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83960. * @returns the list of size gradients
  83961. */
  83962. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83963. /**
  83964. * Gets the current list of angular speed gradients.
  83965. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83966. * @returns the list of angular speed gradients
  83967. */
  83968. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83969. /**
  83970. * Adds a new angular speed gradient
  83971. * @param gradient defines the gradient to use (between 0 and 1)
  83972. * @param factor defines the angular speed to affect to the specified gradient
  83973. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83974. * @returns the current particle system
  83975. */
  83976. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83977. /**
  83978. * Remove a specific angular speed gradient
  83979. * @param gradient defines the gradient to remove
  83980. * @returns the current particle system
  83981. */
  83982. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83983. /**
  83984. * Gets the current list of velocity gradients.
  83985. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83986. * @returns the list of velocity gradients
  83987. */
  83988. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83989. /**
  83990. * Adds a new velocity gradient
  83991. * @param gradient defines the gradient to use (between 0 and 1)
  83992. * @param factor defines the velocity to affect to the specified gradient
  83993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83994. * @returns the current particle system
  83995. */
  83996. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83997. /**
  83998. * Remove a specific velocity gradient
  83999. * @param gradient defines the gradient to remove
  84000. * @returns the current particle system
  84001. */
  84002. removeVelocityGradient(gradient: number): IParticleSystem;
  84003. /**
  84004. * Gets the current list of limit velocity gradients.
  84005. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84006. * @returns the list of limit velocity gradients
  84007. */
  84008. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84009. /**
  84010. * Adds a new limit velocity gradient
  84011. * @param gradient defines the gradient to use (between 0 and 1)
  84012. * @param factor defines the limit velocity to affect to the specified gradient
  84013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84014. * @returns the current particle system
  84015. */
  84016. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84017. /**
  84018. * Remove a specific limit velocity gradient
  84019. * @param gradient defines the gradient to remove
  84020. * @returns the current particle system
  84021. */
  84022. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84023. /**
  84024. * Adds a new drag gradient
  84025. * @param gradient defines the gradient to use (between 0 and 1)
  84026. * @param factor defines the drag to affect to the specified gradient
  84027. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84028. * @returns the current particle system
  84029. */
  84030. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84031. /**
  84032. * Remove a specific drag gradient
  84033. * @param gradient defines the gradient to remove
  84034. * @returns the current particle system
  84035. */
  84036. removeDragGradient(gradient: number): IParticleSystem;
  84037. /**
  84038. * Gets the current list of drag gradients.
  84039. * You must use addDragGradient and removeDragGradient to udpate this list
  84040. * @returns the list of drag gradients
  84041. */
  84042. getDragGradients(): Nullable<Array<FactorGradient>>;
  84043. /**
  84044. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84045. * @param gradient defines the gradient to use (between 0 and 1)
  84046. * @param factor defines the emit rate to affect to the specified gradient
  84047. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84048. * @returns the current particle system
  84049. */
  84050. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84051. /**
  84052. * Remove a specific emit rate gradient
  84053. * @param gradient defines the gradient to remove
  84054. * @returns the current particle system
  84055. */
  84056. removeEmitRateGradient(gradient: number): IParticleSystem;
  84057. /**
  84058. * Gets the current list of emit rate gradients.
  84059. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84060. * @returns the list of emit rate gradients
  84061. */
  84062. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84063. /**
  84064. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84065. * @param gradient defines the gradient to use (between 0 and 1)
  84066. * @param factor defines the start size to affect to the specified gradient
  84067. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84068. * @returns the current particle system
  84069. */
  84070. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84071. /**
  84072. * Remove a specific start size gradient
  84073. * @param gradient defines the gradient to remove
  84074. * @returns the current particle system
  84075. */
  84076. removeStartSizeGradient(gradient: number): IParticleSystem;
  84077. /**
  84078. * Gets the current list of start size gradients.
  84079. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84080. * @returns the list of start size gradients
  84081. */
  84082. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84083. /**
  84084. * Adds a new life time gradient
  84085. * @param gradient defines the gradient to use (between 0 and 1)
  84086. * @param factor defines the life time factor to affect to the specified gradient
  84087. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84088. * @returns the current particle system
  84089. */
  84090. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84091. /**
  84092. * Remove a specific life time gradient
  84093. * @param gradient defines the gradient to remove
  84094. * @returns the current particle system
  84095. */
  84096. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84097. /**
  84098. * Gets the current list of life time gradients.
  84099. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84100. * @returns the list of life time gradients
  84101. */
  84102. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84103. /**
  84104. * Gets the current list of color gradients.
  84105. * You must use addColorGradient and removeColorGradient to udpate this list
  84106. * @returns the list of color gradients
  84107. */
  84108. getColorGradients(): Nullable<Array<ColorGradient>>;
  84109. /**
  84110. * Adds a new ramp gradient used to remap particle colors
  84111. * @param gradient defines the gradient to use (between 0 and 1)
  84112. * @param color defines the color to affect to the specified gradient
  84113. * @returns the current particle system
  84114. */
  84115. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  84116. /**
  84117. * Gets the current list of ramp gradients.
  84118. * You must use addRampGradient and removeRampGradient to udpate this list
  84119. * @returns the list of ramp gradients
  84120. */
  84121. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84122. /** Gets or sets a boolean indicating that ramp gradients must be used
  84123. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84124. */
  84125. useRampGradients: boolean;
  84126. /**
  84127. * Adds a new color remap gradient
  84128. * @param gradient defines the gradient to use (between 0 and 1)
  84129. * @param min defines the color remap minimal range
  84130. * @param max defines the color remap maximal range
  84131. * @returns the current particle system
  84132. */
  84133. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84134. /**
  84135. * Gets the current list of color remap gradients.
  84136. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84137. * @returns the list of color remap gradients
  84138. */
  84139. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84140. /**
  84141. * Adds a new alpha remap gradient
  84142. * @param gradient defines the gradient to use (between 0 and 1)
  84143. * @param min defines the alpha remap minimal range
  84144. * @param max defines the alpha remap maximal range
  84145. * @returns the current particle system
  84146. */
  84147. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84148. /**
  84149. * Gets the current list of alpha remap gradients.
  84150. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84151. * @returns the list of alpha remap gradients
  84152. */
  84153. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84154. /**
  84155. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84156. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84157. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84158. * @returns the emitter
  84159. */
  84160. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84161. /**
  84162. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84163. * @param radius The radius of the hemisphere to emit from
  84164. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84165. * @returns the emitter
  84166. */
  84167. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  84168. /**
  84169. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84170. * @param radius The radius of the sphere to emit from
  84171. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84172. * @returns the emitter
  84173. */
  84174. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  84175. /**
  84176. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84177. * @param radius The radius of the sphere to emit from
  84178. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84179. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84180. * @returns the emitter
  84181. */
  84182. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84183. /**
  84184. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84185. * @param radius The radius of the emission cylinder
  84186. * @param height The height of the emission cylinder
  84187. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84188. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84189. * @returns the emitter
  84190. */
  84191. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  84192. /**
  84193. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84194. * @param radius The radius of the cylinder to emit from
  84195. * @param height The height of the emission cylinder
  84196. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84197. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84198. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84199. * @returns the emitter
  84200. */
  84201. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84202. /**
  84203. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84204. * @param radius The radius of the cone to emit from
  84205. * @param angle The base angle of the cone
  84206. * @returns the emitter
  84207. */
  84208. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  84209. /**
  84210. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84211. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84212. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84213. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84214. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84215. * @returns the emitter
  84216. */
  84217. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84218. /**
  84219. * Get hosting scene
  84220. * @returns the scene
  84221. */
  84222. getScene(): Scene;
  84223. }
  84224. }
  84225. declare module BABYLON {
  84226. /** @hidden */
  84227. export var linePixelShader: {
  84228. name: string;
  84229. shader: string;
  84230. };
  84231. }
  84232. declare module BABYLON {
  84233. /** @hidden */
  84234. export var lineVertexShader: {
  84235. name: string;
  84236. shader: string;
  84237. };
  84238. }
  84239. declare module BABYLON {
  84240. interface AbstractMesh {
  84241. /**
  84242. * Gets the edgesRenderer associated with the mesh
  84243. */
  84244. edgesRenderer: Nullable<EdgesRenderer>;
  84245. }
  84246. interface LinesMesh {
  84247. /**
  84248. * Enables the edge rendering mode on the mesh.
  84249. * This mode makes the mesh edges visible
  84250. * @param epsilon defines the maximal distance between two angles to detect a face
  84251. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84252. * @returns the currentAbstractMesh
  84253. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84254. */
  84255. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  84256. }
  84257. interface InstancedLinesMesh {
  84258. /**
  84259. * Enables the edge rendering mode on the mesh.
  84260. * This mode makes the mesh edges visible
  84261. * @param epsilon defines the maximal distance between two angles to detect a face
  84262. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84263. * @returns the current InstancedLinesMesh
  84264. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84265. */
  84266. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  84267. }
  84268. /**
  84269. * Defines the minimum contract an Edges renderer should follow.
  84270. */
  84271. export interface IEdgesRenderer extends IDisposable {
  84272. /**
  84273. * Gets or sets a boolean indicating if the edgesRenderer is active
  84274. */
  84275. isEnabled: boolean;
  84276. /**
  84277. * Renders the edges of the attached mesh,
  84278. */
  84279. render(): void;
  84280. /**
  84281. * Checks wether or not the edges renderer is ready to render.
  84282. * @return true if ready, otherwise false.
  84283. */
  84284. isReady(): boolean;
  84285. }
  84286. /**
  84287. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  84288. */
  84289. export class EdgesRenderer implements IEdgesRenderer {
  84290. /**
  84291. * Define the size of the edges with an orthographic camera
  84292. */
  84293. edgesWidthScalerForOrthographic: number;
  84294. /**
  84295. * Define the size of the edges with a perspective camera
  84296. */
  84297. edgesWidthScalerForPerspective: number;
  84298. protected _source: AbstractMesh;
  84299. protected _linesPositions: number[];
  84300. protected _linesNormals: number[];
  84301. protected _linesIndices: number[];
  84302. protected _epsilon: number;
  84303. protected _indicesCount: number;
  84304. protected _lineShader: ShaderMaterial;
  84305. protected _ib: DataBuffer;
  84306. protected _buffers: {
  84307. [key: string]: Nullable<VertexBuffer>;
  84308. };
  84309. protected _checkVerticesInsteadOfIndices: boolean;
  84310. private _meshRebuildObserver;
  84311. private _meshDisposeObserver;
  84312. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  84313. isEnabled: boolean;
  84314. /**
  84315. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  84316. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  84317. * @param source Mesh used to create edges
  84318. * @param epsilon sum of angles in adjacency to check for edge
  84319. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  84320. * @param generateEdgesLines - should generate Lines or only prepare resources.
  84321. */
  84322. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  84323. protected _prepareRessources(): void;
  84324. /** @hidden */
  84325. _rebuild(): void;
  84326. /**
  84327. * Releases the required resources for the edges renderer
  84328. */
  84329. dispose(): void;
  84330. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  84331. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  84332. /**
  84333. * Checks if the pair of p0 and p1 is en edge
  84334. * @param faceIndex
  84335. * @param edge
  84336. * @param faceNormals
  84337. * @param p0
  84338. * @param p1
  84339. * @private
  84340. */
  84341. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  84342. /**
  84343. * push line into the position, normal and index buffer
  84344. * @protected
  84345. */
  84346. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  84347. /**
  84348. * Generates lines edges from adjacencjes
  84349. * @private
  84350. */
  84351. _generateEdgesLines(): void;
  84352. /**
  84353. * Checks wether or not the edges renderer is ready to render.
  84354. * @return true if ready, otherwise false.
  84355. */
  84356. isReady(): boolean;
  84357. /**
  84358. * Renders the edges of the attached mesh,
  84359. */
  84360. render(): void;
  84361. }
  84362. /**
  84363. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  84364. */
  84365. export class LineEdgesRenderer extends EdgesRenderer {
  84366. /**
  84367. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  84368. * @param source LineMesh used to generate edges
  84369. * @param epsilon not important (specified angle for edge detection)
  84370. * @param checkVerticesInsteadOfIndices not important for LineMesh
  84371. */
  84372. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  84373. /**
  84374. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  84375. */
  84376. _generateEdgesLines(): void;
  84377. }
  84378. }
  84379. declare module BABYLON {
  84380. /**
  84381. * This represents the object necessary to create a rendering group.
  84382. * This is exclusively used and created by the rendering manager.
  84383. * To modify the behavior, you use the available helpers in your scene or meshes.
  84384. * @hidden
  84385. */
  84386. export class RenderingGroup {
  84387. index: number;
  84388. private static _zeroVector;
  84389. private _scene;
  84390. private _opaqueSubMeshes;
  84391. private _transparentSubMeshes;
  84392. private _alphaTestSubMeshes;
  84393. private _depthOnlySubMeshes;
  84394. private _particleSystems;
  84395. private _spriteManagers;
  84396. private _opaqueSortCompareFn;
  84397. private _alphaTestSortCompareFn;
  84398. private _transparentSortCompareFn;
  84399. private _renderOpaque;
  84400. private _renderAlphaTest;
  84401. private _renderTransparent;
  84402. /** @hidden */
  84403. _edgesRenderers: SmartArray<IEdgesRenderer>;
  84404. onBeforeTransparentRendering: () => void;
  84405. /**
  84406. * Set the opaque sort comparison function.
  84407. * If null the sub meshes will be render in the order they were created
  84408. */
  84409. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84410. /**
  84411. * Set the alpha test sort comparison function.
  84412. * If null the sub meshes will be render in the order they were created
  84413. */
  84414. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84415. /**
  84416. * Set the transparent sort comparison function.
  84417. * If null the sub meshes will be render in the order they were created
  84418. */
  84419. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84420. /**
  84421. * Creates a new rendering group.
  84422. * @param index The rendering group index
  84423. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  84424. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  84425. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  84426. */
  84427. 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>);
  84428. /**
  84429. * Render all the sub meshes contained in the group.
  84430. * @param customRenderFunction Used to override the default render behaviour of the group.
  84431. * @returns true if rendered some submeshes.
  84432. */
  84433. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  84434. /**
  84435. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  84436. * @param subMeshes The submeshes to render
  84437. */
  84438. private renderOpaqueSorted;
  84439. /**
  84440. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  84441. * @param subMeshes The submeshes to render
  84442. */
  84443. private renderAlphaTestSorted;
  84444. /**
  84445. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  84446. * @param subMeshes The submeshes to render
  84447. */
  84448. private renderTransparentSorted;
  84449. /**
  84450. * Renders the submeshes in a specified order.
  84451. * @param subMeshes The submeshes to sort before render
  84452. * @param sortCompareFn The comparison function use to sort
  84453. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  84454. * @param transparent Specifies to activate blending if true
  84455. */
  84456. private static renderSorted;
  84457. /**
  84458. * Renders the submeshes in the order they were dispatched (no sort applied).
  84459. * @param subMeshes The submeshes to render
  84460. */
  84461. private static renderUnsorted;
  84462. /**
  84463. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84464. * are rendered back to front if in the same alpha index.
  84465. *
  84466. * @param a The first submesh
  84467. * @param b The second submesh
  84468. * @returns The result of the comparison
  84469. */
  84470. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  84471. /**
  84472. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84473. * are rendered back to front.
  84474. *
  84475. * @param a The first submesh
  84476. * @param b The second submesh
  84477. * @returns The result of the comparison
  84478. */
  84479. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  84480. /**
  84481. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84482. * are rendered front to back (prevent overdraw).
  84483. *
  84484. * @param a The first submesh
  84485. * @param b The second submesh
  84486. * @returns The result of the comparison
  84487. */
  84488. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  84489. /**
  84490. * Resets the different lists of submeshes to prepare a new frame.
  84491. */
  84492. prepare(): void;
  84493. dispose(): void;
  84494. /**
  84495. * Inserts the submesh in its correct queue depending on its material.
  84496. * @param subMesh The submesh to dispatch
  84497. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84498. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84499. */
  84500. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84501. dispatchSprites(spriteManager: ISpriteManager): void;
  84502. dispatchParticles(particleSystem: IParticleSystem): void;
  84503. private _renderParticles;
  84504. private _renderSprites;
  84505. }
  84506. }
  84507. declare module BABYLON {
  84508. /**
  84509. * Interface describing the different options available in the rendering manager
  84510. * regarding Auto Clear between groups.
  84511. */
  84512. export interface IRenderingManagerAutoClearSetup {
  84513. /**
  84514. * Defines whether or not autoclear is enable.
  84515. */
  84516. autoClear: boolean;
  84517. /**
  84518. * Defines whether or not to autoclear the depth buffer.
  84519. */
  84520. depth: boolean;
  84521. /**
  84522. * Defines whether or not to autoclear the stencil buffer.
  84523. */
  84524. stencil: boolean;
  84525. }
  84526. /**
  84527. * This class is used by the onRenderingGroupObservable
  84528. */
  84529. export class RenderingGroupInfo {
  84530. /**
  84531. * The Scene that being rendered
  84532. */
  84533. scene: Scene;
  84534. /**
  84535. * The camera currently used for the rendering pass
  84536. */
  84537. camera: Nullable<Camera>;
  84538. /**
  84539. * The ID of the renderingGroup being processed
  84540. */
  84541. renderingGroupId: number;
  84542. }
  84543. /**
  84544. * This is the manager responsible of all the rendering for meshes sprites and particles.
  84545. * It is enable to manage the different groups as well as the different necessary sort functions.
  84546. * This should not be used directly aside of the few static configurations
  84547. */
  84548. export class RenderingManager {
  84549. /**
  84550. * The max id used for rendering groups (not included)
  84551. */
  84552. static MAX_RENDERINGGROUPS: number;
  84553. /**
  84554. * The min id used for rendering groups (included)
  84555. */
  84556. static MIN_RENDERINGGROUPS: number;
  84557. /**
  84558. * Used to globally prevent autoclearing scenes.
  84559. */
  84560. static AUTOCLEAR: boolean;
  84561. /**
  84562. * @hidden
  84563. */
  84564. _useSceneAutoClearSetup: boolean;
  84565. private _scene;
  84566. private _renderingGroups;
  84567. private _depthStencilBufferAlreadyCleaned;
  84568. private _autoClearDepthStencil;
  84569. private _customOpaqueSortCompareFn;
  84570. private _customAlphaTestSortCompareFn;
  84571. private _customTransparentSortCompareFn;
  84572. private _renderingGroupInfo;
  84573. /**
  84574. * Instantiates a new rendering group for a particular scene
  84575. * @param scene Defines the scene the groups belongs to
  84576. */
  84577. constructor(scene: Scene);
  84578. private _clearDepthStencilBuffer;
  84579. /**
  84580. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  84581. * @hidden
  84582. */
  84583. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  84584. /**
  84585. * Resets the different information of the group to prepare a new frame
  84586. * @hidden
  84587. */
  84588. reset(): void;
  84589. /**
  84590. * Dispose and release the group and its associated resources.
  84591. * @hidden
  84592. */
  84593. dispose(): void;
  84594. /**
  84595. * Clear the info related to rendering groups preventing retention points during dispose.
  84596. */
  84597. freeRenderingGroups(): void;
  84598. private _prepareRenderingGroup;
  84599. /**
  84600. * Add a sprite manager to the rendering manager in order to render it this frame.
  84601. * @param spriteManager Define the sprite manager to render
  84602. */
  84603. dispatchSprites(spriteManager: ISpriteManager): void;
  84604. /**
  84605. * Add a particle system to the rendering manager in order to render it this frame.
  84606. * @param particleSystem Define the particle system to render
  84607. */
  84608. dispatchParticles(particleSystem: IParticleSystem): void;
  84609. /**
  84610. * Add a submesh to the manager in order to render it this frame
  84611. * @param subMesh The submesh to dispatch
  84612. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84613. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84614. */
  84615. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84616. /**
  84617. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84618. * This allowed control for front to back rendering or reversly depending of the special needs.
  84619. *
  84620. * @param renderingGroupId The rendering group id corresponding to its index
  84621. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84622. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84623. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84624. */
  84625. 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;
  84626. /**
  84627. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84628. *
  84629. * @param renderingGroupId The rendering group id corresponding to its index
  84630. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84631. * @param depth Automatically clears depth between groups if true and autoClear is true.
  84632. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  84633. */
  84634. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  84635. /**
  84636. * Gets the current auto clear configuration for one rendering group of the rendering
  84637. * manager.
  84638. * @param index the rendering group index to get the information for
  84639. * @returns The auto clear setup for the requested rendering group
  84640. */
  84641. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  84642. }
  84643. }
  84644. declare module BABYLON {
  84645. /**
  84646. * This Helps creating a texture that will be created from a camera in your scene.
  84647. * It is basically a dynamic texture that could be used to create special effects for instance.
  84648. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  84649. */
  84650. export class RenderTargetTexture extends Texture {
  84651. isCube: boolean;
  84652. /**
  84653. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  84654. */
  84655. static readonly REFRESHRATE_RENDER_ONCE: number;
  84656. /**
  84657. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  84658. */
  84659. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  84660. /**
  84661. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  84662. * the central point of your effect and can save a lot of performances.
  84663. */
  84664. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  84665. /**
  84666. * Use this predicate to dynamically define the list of mesh you want to render.
  84667. * If set, the renderList property will be overwritten.
  84668. */
  84669. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  84670. private _renderList;
  84671. /**
  84672. * Use this list to define the list of mesh you want to render.
  84673. */
  84674. renderList: Nullable<Array<AbstractMesh>>;
  84675. private _hookArray;
  84676. /**
  84677. * Define if particles should be rendered in your texture.
  84678. */
  84679. renderParticles: boolean;
  84680. /**
  84681. * Define if sprites should be rendered in your texture.
  84682. */
  84683. renderSprites: boolean;
  84684. /**
  84685. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  84686. */
  84687. coordinatesMode: number;
  84688. /**
  84689. * Define the camera used to render the texture.
  84690. */
  84691. activeCamera: Nullable<Camera>;
  84692. /**
  84693. * Override the render function of the texture with your own one.
  84694. */
  84695. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  84696. /**
  84697. * Define if camera post processes should be use while rendering the texture.
  84698. */
  84699. useCameraPostProcesses: boolean;
  84700. /**
  84701. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  84702. */
  84703. ignoreCameraViewport: boolean;
  84704. private _postProcessManager;
  84705. private _postProcesses;
  84706. private _resizeObserver;
  84707. /**
  84708. * An event triggered when the texture is unbind.
  84709. */
  84710. onBeforeBindObservable: Observable<RenderTargetTexture>;
  84711. /**
  84712. * An event triggered when the texture is unbind.
  84713. */
  84714. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  84715. private _onAfterUnbindObserver;
  84716. /**
  84717. * Set a after unbind callback in the texture.
  84718. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  84719. */
  84720. onAfterUnbind: () => void;
  84721. /**
  84722. * An event triggered before rendering the texture
  84723. */
  84724. onBeforeRenderObservable: Observable<number>;
  84725. private _onBeforeRenderObserver;
  84726. /**
  84727. * Set a before render callback in the texture.
  84728. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  84729. */
  84730. onBeforeRender: (faceIndex: number) => void;
  84731. /**
  84732. * An event triggered after rendering the texture
  84733. */
  84734. onAfterRenderObservable: Observable<number>;
  84735. private _onAfterRenderObserver;
  84736. /**
  84737. * Set a after render callback in the texture.
  84738. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  84739. */
  84740. onAfterRender: (faceIndex: number) => void;
  84741. /**
  84742. * An event triggered after the texture clear
  84743. */
  84744. onClearObservable: Observable<Engine>;
  84745. private _onClearObserver;
  84746. /**
  84747. * Set a clear callback in the texture.
  84748. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  84749. */
  84750. onClear: (Engine: Engine) => void;
  84751. /**
  84752. * Define the clear color of the Render Target if it should be different from the scene.
  84753. */
  84754. clearColor: Color4;
  84755. protected _size: number | {
  84756. width: number;
  84757. height: number;
  84758. };
  84759. protected _initialSizeParameter: number | {
  84760. width: number;
  84761. height: number;
  84762. } | {
  84763. ratio: number;
  84764. };
  84765. protected _sizeRatio: Nullable<number>;
  84766. /** @hidden */
  84767. _generateMipMaps: boolean;
  84768. protected _renderingManager: RenderingManager;
  84769. /** @hidden */
  84770. _waitingRenderList: string[];
  84771. protected _doNotChangeAspectRatio: boolean;
  84772. protected _currentRefreshId: number;
  84773. protected _refreshRate: number;
  84774. protected _textureMatrix: Matrix;
  84775. protected _samples: number;
  84776. protected _renderTargetOptions: RenderTargetCreationOptions;
  84777. /**
  84778. * Gets render target creation options that were used.
  84779. */
  84780. readonly renderTargetOptions: RenderTargetCreationOptions;
  84781. protected _engine: Engine;
  84782. protected _onRatioRescale(): void;
  84783. /**
  84784. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  84785. * It must define where the camera used to render the texture is set
  84786. */
  84787. boundingBoxPosition: Vector3;
  84788. private _boundingBoxSize;
  84789. /**
  84790. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  84791. * When defined, the cubemap will switch to local mode
  84792. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84793. * @example https://www.babylonjs-playground.com/#RNASML
  84794. */
  84795. boundingBoxSize: Vector3;
  84796. /**
  84797. * In case the RTT has been created with a depth texture, get the associated
  84798. * depth texture.
  84799. * Otherwise, return null.
  84800. */
  84801. depthStencilTexture: Nullable<InternalTexture>;
  84802. /**
  84803. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  84804. * or used a shadow, depth texture...
  84805. * @param name The friendly name of the texture
  84806. * @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)
  84807. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  84808. * @param generateMipMaps True if mip maps need to be generated after render.
  84809. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  84810. * @param type The type of the buffer in the RTT (int, half float, float...)
  84811. * @param isCube True if a cube texture needs to be created
  84812. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  84813. * @param generateDepthBuffer True to generate a depth buffer
  84814. * @param generateStencilBuffer True to generate a stencil buffer
  84815. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  84816. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  84817. * @param delayAllocation if the texture allocation should be delayed (default: false)
  84818. */
  84819. constructor(name: string, size: number | {
  84820. width: number;
  84821. height: number;
  84822. } | {
  84823. ratio: number;
  84824. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  84825. /**
  84826. * Creates a depth stencil texture.
  84827. * This is only available in WebGL 2 or with the depth texture extension available.
  84828. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  84829. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  84830. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  84831. */
  84832. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  84833. private _processSizeParameter;
  84834. /**
  84835. * Define the number of samples to use in case of MSAA.
  84836. * It defaults to one meaning no MSAA has been enabled.
  84837. */
  84838. samples: number;
  84839. /**
  84840. * Resets the refresh counter of the texture and start bak from scratch.
  84841. * Could be useful to regenerate the texture if it is setup to render only once.
  84842. */
  84843. resetRefreshCounter(): void;
  84844. /**
  84845. * Define the refresh rate of the texture or the rendering frequency.
  84846. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84847. */
  84848. refreshRate: number;
  84849. /**
  84850. * Adds a post process to the render target rendering passes.
  84851. * @param postProcess define the post process to add
  84852. */
  84853. addPostProcess(postProcess: PostProcess): void;
  84854. /**
  84855. * Clear all the post processes attached to the render target
  84856. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  84857. */
  84858. clearPostProcesses(dispose?: boolean): void;
  84859. /**
  84860. * Remove one of the post process from the list of attached post processes to the texture
  84861. * @param postProcess define the post process to remove from the list
  84862. */
  84863. removePostProcess(postProcess: PostProcess): void;
  84864. /** @hidden */
  84865. _shouldRender(): boolean;
  84866. /**
  84867. * Gets the actual render size of the texture.
  84868. * @returns the width of the render size
  84869. */
  84870. getRenderSize(): number;
  84871. /**
  84872. * Gets the actual render width of the texture.
  84873. * @returns the width of the render size
  84874. */
  84875. getRenderWidth(): number;
  84876. /**
  84877. * Gets the actual render height of the texture.
  84878. * @returns the height of the render size
  84879. */
  84880. getRenderHeight(): number;
  84881. /**
  84882. * Get if the texture can be rescaled or not.
  84883. */
  84884. readonly canRescale: boolean;
  84885. /**
  84886. * Resize the texture using a ratio.
  84887. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  84888. */
  84889. scale(ratio: number): void;
  84890. /**
  84891. * Get the texture reflection matrix used to rotate/transform the reflection.
  84892. * @returns the reflection matrix
  84893. */
  84894. getReflectionTextureMatrix(): Matrix;
  84895. /**
  84896. * Resize the texture to a new desired size.
  84897. * Be carrefull as it will recreate all the data in the new texture.
  84898. * @param size Define the new size. It can be:
  84899. * - a number for squared texture,
  84900. * - an object containing { width: number, height: number }
  84901. * - or an object containing a ratio { ratio: number }
  84902. */
  84903. resize(size: number | {
  84904. width: number;
  84905. height: number;
  84906. } | {
  84907. ratio: number;
  84908. }): void;
  84909. /**
  84910. * Renders all the objects from the render list into the texture.
  84911. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  84912. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  84913. */
  84914. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  84915. private _bestReflectionRenderTargetDimension;
  84916. /**
  84917. * @hidden
  84918. * @param faceIndex face index to bind to if this is a cubetexture
  84919. */
  84920. _bindFrameBuffer(faceIndex?: number): void;
  84921. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84922. private renderToTarget;
  84923. /**
  84924. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84925. * This allowed control for front to back rendering or reversly depending of the special needs.
  84926. *
  84927. * @param renderingGroupId The rendering group id corresponding to its index
  84928. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84929. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84930. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84931. */
  84932. 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;
  84933. /**
  84934. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84935. *
  84936. * @param renderingGroupId The rendering group id corresponding to its index
  84937. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84938. */
  84939. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  84940. /**
  84941. * Clones the texture.
  84942. * @returns the cloned texture
  84943. */
  84944. clone(): RenderTargetTexture;
  84945. /**
  84946. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84947. * @returns The JSON representation of the texture
  84948. */
  84949. serialize(): any;
  84950. /**
  84951. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  84952. */
  84953. disposeFramebufferObjects(): void;
  84954. /**
  84955. * Dispose the texture and release its associated resources.
  84956. */
  84957. dispose(): void;
  84958. /** @hidden */
  84959. _rebuild(): void;
  84960. /**
  84961. * Clear the info related to rendering groups preventing retention point in material dispose.
  84962. */
  84963. freeRenderingGroups(): void;
  84964. /**
  84965. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  84966. * @returns the view count
  84967. */
  84968. getViewCount(): number;
  84969. }
  84970. }
  84971. declare module BABYLON {
  84972. /**
  84973. * Base class for the main features of a material in Babylon.js
  84974. */
  84975. export class Material implements IAnimatable {
  84976. /**
  84977. * Returns the triangle fill mode
  84978. */
  84979. static readonly TriangleFillMode: number;
  84980. /**
  84981. * Returns the wireframe mode
  84982. */
  84983. static readonly WireFrameFillMode: number;
  84984. /**
  84985. * Returns the point fill mode
  84986. */
  84987. static readonly PointFillMode: number;
  84988. /**
  84989. * Returns the point list draw mode
  84990. */
  84991. static readonly PointListDrawMode: number;
  84992. /**
  84993. * Returns the line list draw mode
  84994. */
  84995. static readonly LineListDrawMode: number;
  84996. /**
  84997. * Returns the line loop draw mode
  84998. */
  84999. static readonly LineLoopDrawMode: number;
  85000. /**
  85001. * Returns the line strip draw mode
  85002. */
  85003. static readonly LineStripDrawMode: number;
  85004. /**
  85005. * Returns the triangle strip draw mode
  85006. */
  85007. static readonly TriangleStripDrawMode: number;
  85008. /**
  85009. * Returns the triangle fan draw mode
  85010. */
  85011. static readonly TriangleFanDrawMode: number;
  85012. /**
  85013. * Stores the clock-wise side orientation
  85014. */
  85015. static readonly ClockWiseSideOrientation: number;
  85016. /**
  85017. * Stores the counter clock-wise side orientation
  85018. */
  85019. static readonly CounterClockWiseSideOrientation: number;
  85020. /**
  85021. * The dirty texture flag value
  85022. */
  85023. static readonly TextureDirtyFlag: number;
  85024. /**
  85025. * The dirty light flag value
  85026. */
  85027. static readonly LightDirtyFlag: number;
  85028. /**
  85029. * The dirty fresnel flag value
  85030. */
  85031. static readonly FresnelDirtyFlag: number;
  85032. /**
  85033. * The dirty attribute flag value
  85034. */
  85035. static readonly AttributesDirtyFlag: number;
  85036. /**
  85037. * The dirty misc flag value
  85038. */
  85039. static readonly MiscDirtyFlag: number;
  85040. /**
  85041. * The all dirty flag value
  85042. */
  85043. static readonly AllDirtyFlag: number;
  85044. /**
  85045. * The ID of the material
  85046. */
  85047. id: string;
  85048. /**
  85049. * Gets or sets the unique id of the material
  85050. */
  85051. uniqueId: number;
  85052. /**
  85053. * The name of the material
  85054. */
  85055. name: string;
  85056. /**
  85057. * Gets or sets user defined metadata
  85058. */
  85059. metadata: any;
  85060. /**
  85061. * For internal use only. Please do not use.
  85062. */
  85063. reservedDataStore: any;
  85064. /**
  85065. * Specifies if the ready state should be checked on each call
  85066. */
  85067. checkReadyOnEveryCall: boolean;
  85068. /**
  85069. * Specifies if the ready state should be checked once
  85070. */
  85071. checkReadyOnlyOnce: boolean;
  85072. /**
  85073. * The state of the material
  85074. */
  85075. state: string;
  85076. /**
  85077. * The alpha value of the material
  85078. */
  85079. protected _alpha: number;
  85080. /**
  85081. * List of inspectable custom properties (used by the Inspector)
  85082. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85083. */
  85084. inspectableCustomProperties: IInspectable[];
  85085. /**
  85086. * Sets the alpha value of the material
  85087. */
  85088. /**
  85089. * Gets the alpha value of the material
  85090. */
  85091. alpha: number;
  85092. /**
  85093. * Specifies if back face culling is enabled
  85094. */
  85095. protected _backFaceCulling: boolean;
  85096. /**
  85097. * Sets the back-face culling state
  85098. */
  85099. /**
  85100. * Gets the back-face culling state
  85101. */
  85102. backFaceCulling: boolean;
  85103. /**
  85104. * Stores the value for side orientation
  85105. */
  85106. sideOrientation: number;
  85107. /**
  85108. * Callback triggered when the material is compiled
  85109. */
  85110. onCompiled: Nullable<(effect: Effect) => void>;
  85111. /**
  85112. * Callback triggered when an error occurs
  85113. */
  85114. onError: Nullable<(effect: Effect, errors: string) => void>;
  85115. /**
  85116. * Callback triggered to get the render target textures
  85117. */
  85118. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  85119. /**
  85120. * Gets a boolean indicating that current material needs to register RTT
  85121. */
  85122. readonly hasRenderTargetTextures: boolean;
  85123. /**
  85124. * Specifies if the material should be serialized
  85125. */
  85126. doNotSerialize: boolean;
  85127. /**
  85128. * @hidden
  85129. */
  85130. _storeEffectOnSubMeshes: boolean;
  85131. /**
  85132. * Stores the animations for the material
  85133. */
  85134. animations: Nullable<Array<Animation>>;
  85135. /**
  85136. * An event triggered when the material is disposed
  85137. */
  85138. onDisposeObservable: Observable<Material>;
  85139. /**
  85140. * An observer which watches for dispose events
  85141. */
  85142. private _onDisposeObserver;
  85143. private _onUnBindObservable;
  85144. /**
  85145. * Called during a dispose event
  85146. */
  85147. onDispose: () => void;
  85148. private _onBindObservable;
  85149. /**
  85150. * An event triggered when the material is bound
  85151. */
  85152. readonly onBindObservable: Observable<AbstractMesh>;
  85153. /**
  85154. * An observer which watches for bind events
  85155. */
  85156. private _onBindObserver;
  85157. /**
  85158. * Called during a bind event
  85159. */
  85160. onBind: (Mesh: AbstractMesh) => void;
  85161. /**
  85162. * An event triggered when the material is unbound
  85163. */
  85164. readonly onUnBindObservable: Observable<Material>;
  85165. /**
  85166. * Stores the value of the alpha mode
  85167. */
  85168. private _alphaMode;
  85169. /**
  85170. * Sets the value of the alpha mode.
  85171. *
  85172. * | Value | Type | Description |
  85173. * | --- | --- | --- |
  85174. * | 0 | ALPHA_DISABLE | |
  85175. * | 1 | ALPHA_ADD | |
  85176. * | 2 | ALPHA_COMBINE | |
  85177. * | 3 | ALPHA_SUBTRACT | |
  85178. * | 4 | ALPHA_MULTIPLY | |
  85179. * | 5 | ALPHA_MAXIMIZED | |
  85180. * | 6 | ALPHA_ONEONE | |
  85181. * | 7 | ALPHA_PREMULTIPLIED | |
  85182. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  85183. * | 9 | ALPHA_INTERPOLATE | |
  85184. * | 10 | ALPHA_SCREENMODE | |
  85185. *
  85186. */
  85187. /**
  85188. * Gets the value of the alpha mode
  85189. */
  85190. alphaMode: number;
  85191. /**
  85192. * Stores the state of the need depth pre-pass value
  85193. */
  85194. private _needDepthPrePass;
  85195. /**
  85196. * Sets the need depth pre-pass value
  85197. */
  85198. /**
  85199. * Gets the depth pre-pass value
  85200. */
  85201. needDepthPrePass: boolean;
  85202. /**
  85203. * Specifies if depth writing should be disabled
  85204. */
  85205. disableDepthWrite: boolean;
  85206. /**
  85207. * Specifies if depth writing should be forced
  85208. */
  85209. forceDepthWrite: boolean;
  85210. /**
  85211. * Specifies if there should be a separate pass for culling
  85212. */
  85213. separateCullingPass: boolean;
  85214. /**
  85215. * Stores the state specifing if fog should be enabled
  85216. */
  85217. private _fogEnabled;
  85218. /**
  85219. * Sets the state for enabling fog
  85220. */
  85221. /**
  85222. * Gets the value of the fog enabled state
  85223. */
  85224. fogEnabled: boolean;
  85225. /**
  85226. * Stores the size of points
  85227. */
  85228. pointSize: number;
  85229. /**
  85230. * Stores the z offset value
  85231. */
  85232. zOffset: number;
  85233. /**
  85234. * Gets a value specifying if wireframe mode is enabled
  85235. */
  85236. /**
  85237. * Sets the state of wireframe mode
  85238. */
  85239. wireframe: boolean;
  85240. /**
  85241. * Gets the value specifying if point clouds are enabled
  85242. */
  85243. /**
  85244. * Sets the state of point cloud mode
  85245. */
  85246. pointsCloud: boolean;
  85247. /**
  85248. * Gets the material fill mode
  85249. */
  85250. /**
  85251. * Sets the material fill mode
  85252. */
  85253. fillMode: number;
  85254. /**
  85255. * @hidden
  85256. * Stores the effects for the material
  85257. */
  85258. _effect: Nullable<Effect>;
  85259. /**
  85260. * @hidden
  85261. * Specifies if the material was previously ready
  85262. */
  85263. _wasPreviouslyReady: boolean;
  85264. /**
  85265. * Specifies if uniform buffers should be used
  85266. */
  85267. private _useUBO;
  85268. /**
  85269. * Stores a reference to the scene
  85270. */
  85271. private _scene;
  85272. /**
  85273. * Stores the fill mode state
  85274. */
  85275. private _fillMode;
  85276. /**
  85277. * Specifies if the depth write state should be cached
  85278. */
  85279. private _cachedDepthWriteState;
  85280. /**
  85281. * Stores the uniform buffer
  85282. */
  85283. protected _uniformBuffer: UniformBuffer;
  85284. /** @hidden */
  85285. _indexInSceneMaterialArray: number;
  85286. /** @hidden */
  85287. meshMap: Nullable<{
  85288. [id: string]: AbstractMesh | undefined;
  85289. }>;
  85290. /**
  85291. * Creates a material instance
  85292. * @param name defines the name of the material
  85293. * @param scene defines the scene to reference
  85294. * @param doNotAdd specifies if the material should be added to the scene
  85295. */
  85296. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  85297. /**
  85298. * Returns a string representation of the current material
  85299. * @param fullDetails defines a boolean indicating which levels of logging is desired
  85300. * @returns a string with material information
  85301. */
  85302. toString(fullDetails?: boolean): string;
  85303. /**
  85304. * Gets the class name of the material
  85305. * @returns a string with the class name of the material
  85306. */
  85307. getClassName(): string;
  85308. /**
  85309. * Specifies if updates for the material been locked
  85310. */
  85311. readonly isFrozen: boolean;
  85312. /**
  85313. * Locks updates for the material
  85314. */
  85315. freeze(): void;
  85316. /**
  85317. * Unlocks updates for the material
  85318. */
  85319. unfreeze(): void;
  85320. /**
  85321. * Specifies if the material is ready to be used
  85322. * @param mesh defines the mesh to check
  85323. * @param useInstances specifies if instances should be used
  85324. * @returns a boolean indicating if the material is ready to be used
  85325. */
  85326. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85327. /**
  85328. * Specifies that the submesh is ready to be used
  85329. * @param mesh defines the mesh to check
  85330. * @param subMesh defines which submesh to check
  85331. * @param useInstances specifies that instances should be used
  85332. * @returns a boolean indicating that the submesh is ready or not
  85333. */
  85334. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85335. /**
  85336. * Returns the material effect
  85337. * @returns the effect associated with the material
  85338. */
  85339. getEffect(): Nullable<Effect>;
  85340. /**
  85341. * Returns the current scene
  85342. * @returns a Scene
  85343. */
  85344. getScene(): Scene;
  85345. /**
  85346. * Specifies if the material will require alpha blending
  85347. * @returns a boolean specifying if alpha blending is needed
  85348. */
  85349. needAlphaBlending(): boolean;
  85350. /**
  85351. * Specifies if the mesh will require alpha blending
  85352. * @param mesh defines the mesh to check
  85353. * @returns a boolean specifying if alpha blending is needed for the mesh
  85354. */
  85355. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  85356. /**
  85357. * Specifies if this material should be rendered in alpha test mode
  85358. * @returns a boolean specifying if an alpha test is needed.
  85359. */
  85360. needAlphaTesting(): boolean;
  85361. /**
  85362. * Gets the texture used for the alpha test
  85363. * @returns the texture to use for alpha testing
  85364. */
  85365. getAlphaTestTexture(): Nullable<BaseTexture>;
  85366. /**
  85367. * Marks the material to indicate that it needs to be re-calculated
  85368. */
  85369. markDirty(): void;
  85370. /** @hidden */
  85371. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  85372. /**
  85373. * Binds the material to the mesh
  85374. * @param world defines the world transformation matrix
  85375. * @param mesh defines the mesh to bind the material to
  85376. */
  85377. bind(world: Matrix, mesh?: Mesh): void;
  85378. /**
  85379. * Binds the submesh to the material
  85380. * @param world defines the world transformation matrix
  85381. * @param mesh defines the mesh containing the submesh
  85382. * @param subMesh defines the submesh to bind the material to
  85383. */
  85384. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  85385. /**
  85386. * Binds the world matrix to the material
  85387. * @param world defines the world transformation matrix
  85388. */
  85389. bindOnlyWorldMatrix(world: Matrix): void;
  85390. /**
  85391. * Binds the scene's uniform buffer to the effect.
  85392. * @param effect defines the effect to bind to the scene uniform buffer
  85393. * @param sceneUbo defines the uniform buffer storing scene data
  85394. */
  85395. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  85396. /**
  85397. * Binds the view matrix to the effect
  85398. * @param effect defines the effect to bind the view matrix to
  85399. */
  85400. bindView(effect: Effect): void;
  85401. /**
  85402. * Binds the view projection matrix to the effect
  85403. * @param effect defines the effect to bind the view projection matrix to
  85404. */
  85405. bindViewProjection(effect: Effect): void;
  85406. /**
  85407. * Specifies if material alpha testing should be turned on for the mesh
  85408. * @param mesh defines the mesh to check
  85409. */
  85410. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  85411. /**
  85412. * Processes to execute after binding the material to a mesh
  85413. * @param mesh defines the rendered mesh
  85414. */
  85415. protected _afterBind(mesh?: Mesh): void;
  85416. /**
  85417. * Unbinds the material from the mesh
  85418. */
  85419. unbind(): void;
  85420. /**
  85421. * Gets the active textures from the material
  85422. * @returns an array of textures
  85423. */
  85424. getActiveTextures(): BaseTexture[];
  85425. /**
  85426. * Specifies if the material uses a texture
  85427. * @param texture defines the texture to check against the material
  85428. * @returns a boolean specifying if the material uses the texture
  85429. */
  85430. hasTexture(texture: BaseTexture): boolean;
  85431. /**
  85432. * Makes a duplicate of the material, and gives it a new name
  85433. * @param name defines the new name for the duplicated material
  85434. * @returns the cloned material
  85435. */
  85436. clone(name: string): Nullable<Material>;
  85437. /**
  85438. * Gets the meshes bound to the material
  85439. * @returns an array of meshes bound to the material
  85440. */
  85441. getBindedMeshes(): AbstractMesh[];
  85442. /**
  85443. * Force shader compilation
  85444. * @param mesh defines the mesh associated with this material
  85445. * @param onCompiled defines a function to execute once the material is compiled
  85446. * @param options defines the options to configure the compilation
  85447. */
  85448. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  85449. clipPlane: boolean;
  85450. }>): void;
  85451. /**
  85452. * Force shader compilation
  85453. * @param mesh defines the mesh that will use this material
  85454. * @param options defines additional options for compiling the shaders
  85455. * @returns a promise that resolves when the compilation completes
  85456. */
  85457. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  85458. clipPlane: boolean;
  85459. }>): Promise<void>;
  85460. private static readonly _AllDirtyCallBack;
  85461. private static readonly _ImageProcessingDirtyCallBack;
  85462. private static readonly _TextureDirtyCallBack;
  85463. private static readonly _FresnelDirtyCallBack;
  85464. private static readonly _MiscDirtyCallBack;
  85465. private static readonly _LightsDirtyCallBack;
  85466. private static readonly _AttributeDirtyCallBack;
  85467. private static _FresnelAndMiscDirtyCallBack;
  85468. private static _TextureAndMiscDirtyCallBack;
  85469. private static readonly _DirtyCallbackArray;
  85470. private static readonly _RunDirtyCallBacks;
  85471. /**
  85472. * Marks a define in the material to indicate that it needs to be re-computed
  85473. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  85474. */
  85475. markAsDirty(flag: number): void;
  85476. /**
  85477. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  85478. * @param func defines a function which checks material defines against the submeshes
  85479. */
  85480. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  85481. /**
  85482. * Indicates that we need to re-calculated for all submeshes
  85483. */
  85484. protected _markAllSubMeshesAsAllDirty(): void;
  85485. /**
  85486. * Indicates that image processing needs to be re-calculated for all submeshes
  85487. */
  85488. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  85489. /**
  85490. * Indicates that textures need to be re-calculated for all submeshes
  85491. */
  85492. protected _markAllSubMeshesAsTexturesDirty(): void;
  85493. /**
  85494. * Indicates that fresnel needs to be re-calculated for all submeshes
  85495. */
  85496. protected _markAllSubMeshesAsFresnelDirty(): void;
  85497. /**
  85498. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  85499. */
  85500. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  85501. /**
  85502. * Indicates that lights need to be re-calculated for all submeshes
  85503. */
  85504. protected _markAllSubMeshesAsLightsDirty(): void;
  85505. /**
  85506. * Indicates that attributes need to be re-calculated for all submeshes
  85507. */
  85508. protected _markAllSubMeshesAsAttributesDirty(): void;
  85509. /**
  85510. * Indicates that misc needs to be re-calculated for all submeshes
  85511. */
  85512. protected _markAllSubMeshesAsMiscDirty(): void;
  85513. /**
  85514. * Indicates that textures and misc need to be re-calculated for all submeshes
  85515. */
  85516. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  85517. /**
  85518. * Disposes the material
  85519. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85520. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85521. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85522. */
  85523. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85524. /** @hidden */
  85525. private releaseVertexArrayObject;
  85526. /**
  85527. * Serializes this material
  85528. * @returns the serialized material object
  85529. */
  85530. serialize(): any;
  85531. /**
  85532. * Creates a material from parsed material data
  85533. * @param parsedMaterial defines parsed material data
  85534. * @param scene defines the hosting scene
  85535. * @param rootUrl defines the root URL to use to load textures
  85536. * @returns a new material
  85537. */
  85538. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  85539. }
  85540. }
  85541. declare module BABYLON {
  85542. /**
  85543. * Base class for submeshes
  85544. */
  85545. export class BaseSubMesh {
  85546. /** @hidden */
  85547. _materialDefines: Nullable<MaterialDefines>;
  85548. /** @hidden */
  85549. _materialEffect: Nullable<Effect>;
  85550. /**
  85551. * Gets associated effect
  85552. */
  85553. readonly effect: Nullable<Effect>;
  85554. /**
  85555. * Sets associated effect (effect used to render this submesh)
  85556. * @param effect defines the effect to associate with
  85557. * @param defines defines the set of defines used to compile this effect
  85558. */
  85559. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  85560. }
  85561. /**
  85562. * Defines a subdivision inside a mesh
  85563. */
  85564. export class SubMesh extends BaseSubMesh implements ICullable {
  85565. /** the material index to use */
  85566. materialIndex: number;
  85567. /** vertex index start */
  85568. verticesStart: number;
  85569. /** vertices count */
  85570. verticesCount: number;
  85571. /** index start */
  85572. indexStart: number;
  85573. /** indices count */
  85574. indexCount: number;
  85575. /** @hidden */
  85576. _linesIndexCount: number;
  85577. private _mesh;
  85578. private _renderingMesh;
  85579. private _boundingInfo;
  85580. private _linesIndexBuffer;
  85581. /** @hidden */
  85582. _lastColliderWorldVertices: Nullable<Vector3[]>;
  85583. /** @hidden */
  85584. _trianglePlanes: Plane[];
  85585. /** @hidden */
  85586. _lastColliderTransformMatrix: Nullable<Matrix>;
  85587. /** @hidden */
  85588. _renderId: number;
  85589. /** @hidden */
  85590. _alphaIndex: number;
  85591. /** @hidden */
  85592. _distanceToCamera: number;
  85593. /** @hidden */
  85594. _id: number;
  85595. private _currentMaterial;
  85596. /**
  85597. * Add a new submesh to a mesh
  85598. * @param materialIndex defines the material index to use
  85599. * @param verticesStart defines vertex index start
  85600. * @param verticesCount defines vertices count
  85601. * @param indexStart defines index start
  85602. * @param indexCount defines indices count
  85603. * @param mesh defines the parent mesh
  85604. * @param renderingMesh defines an optional rendering mesh
  85605. * @param createBoundingBox defines if bounding box should be created for this submesh
  85606. * @returns the new submesh
  85607. */
  85608. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  85609. /**
  85610. * Creates a new submesh
  85611. * @param materialIndex defines the material index to use
  85612. * @param verticesStart defines vertex index start
  85613. * @param verticesCount defines vertices count
  85614. * @param indexStart defines index start
  85615. * @param indexCount defines indices count
  85616. * @param mesh defines the parent mesh
  85617. * @param renderingMesh defines an optional rendering mesh
  85618. * @param createBoundingBox defines if bounding box should be created for this submesh
  85619. */
  85620. constructor(
  85621. /** the material index to use */
  85622. materialIndex: number,
  85623. /** vertex index start */
  85624. verticesStart: number,
  85625. /** vertices count */
  85626. verticesCount: number,
  85627. /** index start */
  85628. indexStart: number,
  85629. /** indices count */
  85630. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  85631. /**
  85632. * Returns true if this submesh covers the entire parent mesh
  85633. * @ignorenaming
  85634. */
  85635. readonly IsGlobal: boolean;
  85636. /**
  85637. * Returns the submesh BoudingInfo object
  85638. * @returns current bounding info (or mesh's one if the submesh is global)
  85639. */
  85640. getBoundingInfo(): BoundingInfo;
  85641. /**
  85642. * Sets the submesh BoundingInfo
  85643. * @param boundingInfo defines the new bounding info to use
  85644. * @returns the SubMesh
  85645. */
  85646. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85647. /**
  85648. * Returns the mesh of the current submesh
  85649. * @return the parent mesh
  85650. */
  85651. getMesh(): AbstractMesh;
  85652. /**
  85653. * Returns the rendering mesh of the submesh
  85654. * @returns the rendering mesh (could be different from parent mesh)
  85655. */
  85656. getRenderingMesh(): Mesh;
  85657. /**
  85658. * Returns the submesh material
  85659. * @returns null or the current material
  85660. */
  85661. getMaterial(): Nullable<Material>;
  85662. /**
  85663. * Sets a new updated BoundingInfo object to the submesh
  85664. * @param data defines an optional position array to use to determine the bounding info
  85665. * @returns the SubMesh
  85666. */
  85667. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85668. /** @hidden */
  85669. _checkCollision(collider: Collider): boolean;
  85670. /**
  85671. * Updates the submesh BoundingInfo
  85672. * @param world defines the world matrix to use to update the bounding info
  85673. * @returns the submesh
  85674. */
  85675. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85676. /**
  85677. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85678. * @param frustumPlanes defines the frustum planes
  85679. * @returns true if the submesh is intersecting with the frustum
  85680. */
  85681. isInFrustum(frustumPlanes: Plane[]): boolean;
  85682. /**
  85683. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85684. * @param frustumPlanes defines the frustum planes
  85685. * @returns true if the submesh is inside the frustum
  85686. */
  85687. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85688. /**
  85689. * Renders the submesh
  85690. * @param enableAlphaMode defines if alpha needs to be used
  85691. * @returns the submesh
  85692. */
  85693. render(enableAlphaMode: boolean): SubMesh;
  85694. /**
  85695. * @hidden
  85696. */
  85697. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85698. /**
  85699. * Checks if the submesh intersects with a ray
  85700. * @param ray defines the ray to test
  85701. * @returns true is the passed ray intersects the submesh bounding box
  85702. */
  85703. canIntersects(ray: Ray): boolean;
  85704. /**
  85705. * Intersects current submesh with a ray
  85706. * @param ray defines the ray to test
  85707. * @param positions defines mesh's positions array
  85708. * @param indices defines mesh's indices array
  85709. * @param fastCheck defines if only bounding info should be used
  85710. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85711. * @returns intersection info or null if no intersection
  85712. */
  85713. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85714. /** @hidden */
  85715. private _intersectLines;
  85716. /** @hidden */
  85717. private _intersectUnIndexedLines;
  85718. /** @hidden */
  85719. private _intersectTriangles;
  85720. /** @hidden */
  85721. private _intersectUnIndexedTriangles;
  85722. /** @hidden */
  85723. _rebuild(): void;
  85724. /**
  85725. * Creates a new submesh from the passed mesh
  85726. * @param newMesh defines the new hosting mesh
  85727. * @param newRenderingMesh defines an optional rendering mesh
  85728. * @returns the new submesh
  85729. */
  85730. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85731. /**
  85732. * Release associated resources
  85733. */
  85734. dispose(): void;
  85735. /**
  85736. * Gets the class name
  85737. * @returns the string "SubMesh".
  85738. */
  85739. getClassName(): string;
  85740. /**
  85741. * Creates a new submesh from indices data
  85742. * @param materialIndex the index of the main mesh material
  85743. * @param startIndex the index where to start the copy in the mesh indices array
  85744. * @param indexCount the number of indices to copy then from the startIndex
  85745. * @param mesh the main mesh to create the submesh from
  85746. * @param renderingMesh the optional rendering mesh
  85747. * @returns a new submesh
  85748. */
  85749. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85750. }
  85751. }
  85752. declare module BABYLON {
  85753. /**
  85754. * Class used to store geometry data (vertex buffers + index buffer)
  85755. */
  85756. export class Geometry implements IGetSetVerticesData {
  85757. /**
  85758. * Gets or sets the ID of the geometry
  85759. */
  85760. id: string;
  85761. /**
  85762. * Gets or sets the unique ID of the geometry
  85763. */
  85764. uniqueId: number;
  85765. /**
  85766. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85767. */
  85768. delayLoadState: number;
  85769. /**
  85770. * Gets the file containing the data to load when running in delay load state
  85771. */
  85772. delayLoadingFile: Nullable<string>;
  85773. /**
  85774. * Callback called when the geometry is updated
  85775. */
  85776. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85777. private _scene;
  85778. private _engine;
  85779. private _meshes;
  85780. private _totalVertices;
  85781. /** @hidden */
  85782. _indices: IndicesArray;
  85783. /** @hidden */
  85784. _vertexBuffers: {
  85785. [key: string]: VertexBuffer;
  85786. };
  85787. private _isDisposed;
  85788. private _extend;
  85789. private _boundingBias;
  85790. /** @hidden */
  85791. _delayInfo: Array<string>;
  85792. private _indexBuffer;
  85793. private _indexBufferIsUpdatable;
  85794. /** @hidden */
  85795. _boundingInfo: Nullable<BoundingInfo>;
  85796. /** @hidden */
  85797. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85798. /** @hidden */
  85799. _softwareSkinningFrameId: number;
  85800. private _vertexArrayObjects;
  85801. private _updatable;
  85802. /** @hidden */
  85803. _positions: Nullable<Vector3[]>;
  85804. /**
  85805. * 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
  85806. */
  85807. /**
  85808. * 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
  85809. */
  85810. boundingBias: Vector2;
  85811. /**
  85812. * Static function used to attach a new empty geometry to a mesh
  85813. * @param mesh defines the mesh to attach the geometry to
  85814. * @returns the new Geometry
  85815. */
  85816. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85817. /**
  85818. * Creates a new geometry
  85819. * @param id defines the unique ID
  85820. * @param scene defines the hosting scene
  85821. * @param vertexData defines the VertexData used to get geometry data
  85822. * @param updatable defines if geometry must be updatable (false by default)
  85823. * @param mesh defines the mesh that will be associated with the geometry
  85824. */
  85825. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85826. /**
  85827. * Gets the current extend of the geometry
  85828. */
  85829. readonly extend: {
  85830. minimum: Vector3;
  85831. maximum: Vector3;
  85832. };
  85833. /**
  85834. * Gets the hosting scene
  85835. * @returns the hosting Scene
  85836. */
  85837. getScene(): Scene;
  85838. /**
  85839. * Gets the hosting engine
  85840. * @returns the hosting Engine
  85841. */
  85842. getEngine(): Engine;
  85843. /**
  85844. * Defines if the geometry is ready to use
  85845. * @returns true if the geometry is ready to be used
  85846. */
  85847. isReady(): boolean;
  85848. /**
  85849. * Gets a value indicating that the geometry should not be serialized
  85850. */
  85851. readonly doNotSerialize: boolean;
  85852. /** @hidden */
  85853. _rebuild(): void;
  85854. /**
  85855. * Affects all geometry data in one call
  85856. * @param vertexData defines the geometry data
  85857. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85858. */
  85859. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85860. /**
  85861. * Set specific vertex data
  85862. * @param kind defines the data kind (Position, normal, etc...)
  85863. * @param data defines the vertex data to use
  85864. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85865. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85866. */
  85867. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85868. /**
  85869. * Removes a specific vertex data
  85870. * @param kind defines the data kind (Position, normal, etc...)
  85871. */
  85872. removeVerticesData(kind: string): void;
  85873. /**
  85874. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85875. * @param buffer defines the vertex buffer to use
  85876. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85877. */
  85878. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85879. /**
  85880. * Update a specific vertex buffer
  85881. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85882. * It will do nothing if the buffer is not updatable
  85883. * @param kind defines the data kind (Position, normal, etc...)
  85884. * @param data defines the data to use
  85885. * @param offset defines the offset in the target buffer where to store the data
  85886. * @param useBytes set to true if the offset is in bytes
  85887. */
  85888. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85889. /**
  85890. * Update a specific vertex buffer
  85891. * This function will create a new buffer if the current one is not updatable
  85892. * @param kind defines the data kind (Position, normal, etc...)
  85893. * @param data defines the data to use
  85894. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85895. */
  85896. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85897. private _updateBoundingInfo;
  85898. /** @hidden */
  85899. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85900. /**
  85901. * Gets total number of vertices
  85902. * @returns the total number of vertices
  85903. */
  85904. getTotalVertices(): number;
  85905. /**
  85906. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85907. * @param kind defines the data kind (Position, normal, etc...)
  85908. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85909. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85910. * @returns a float array containing vertex data
  85911. */
  85912. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85913. /**
  85914. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85915. * @param kind defines the data kind (Position, normal, etc...)
  85916. * @returns true if the vertex buffer with the specified kind is updatable
  85917. */
  85918. isVertexBufferUpdatable(kind: string): boolean;
  85919. /**
  85920. * Gets a specific vertex buffer
  85921. * @param kind defines the data kind (Position, normal, etc...)
  85922. * @returns a VertexBuffer
  85923. */
  85924. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85925. /**
  85926. * Returns all vertex buffers
  85927. * @return an object holding all vertex buffers indexed by kind
  85928. */
  85929. getVertexBuffers(): Nullable<{
  85930. [key: string]: VertexBuffer;
  85931. }>;
  85932. /**
  85933. * Gets a boolean indicating if specific vertex buffer is present
  85934. * @param kind defines the data kind (Position, normal, etc...)
  85935. * @returns true if data is present
  85936. */
  85937. isVerticesDataPresent(kind: string): boolean;
  85938. /**
  85939. * Gets a list of all attached data kinds (Position, normal, etc...)
  85940. * @returns a list of string containing all kinds
  85941. */
  85942. getVerticesDataKinds(): string[];
  85943. /**
  85944. * Update index buffer
  85945. * @param indices defines the indices to store in the index buffer
  85946. * @param offset defines the offset in the target buffer where to store the data
  85947. * @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)
  85948. */
  85949. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  85950. /**
  85951. * Creates a new index buffer
  85952. * @param indices defines the indices to store in the index buffer
  85953. * @param totalVertices defines the total number of vertices (could be null)
  85954. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85955. */
  85956. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  85957. /**
  85958. * Return the total number of indices
  85959. * @returns the total number of indices
  85960. */
  85961. getTotalIndices(): number;
  85962. /**
  85963. * Gets the index buffer array
  85964. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85965. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85966. * @returns the index buffer array
  85967. */
  85968. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85969. /**
  85970. * Gets the index buffer
  85971. * @return the index buffer
  85972. */
  85973. getIndexBuffer(): Nullable<DataBuffer>;
  85974. /** @hidden */
  85975. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  85976. /**
  85977. * Release the associated resources for a specific mesh
  85978. * @param mesh defines the source mesh
  85979. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  85980. */
  85981. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  85982. /**
  85983. * Apply current geometry to a given mesh
  85984. * @param mesh defines the mesh to apply geometry to
  85985. */
  85986. applyToMesh(mesh: Mesh): void;
  85987. private _updateExtend;
  85988. private _applyToMesh;
  85989. private notifyUpdate;
  85990. /**
  85991. * Load the geometry if it was flagged as delay loaded
  85992. * @param scene defines the hosting scene
  85993. * @param onLoaded defines a callback called when the geometry is loaded
  85994. */
  85995. load(scene: Scene, onLoaded?: () => void): void;
  85996. private _queueLoad;
  85997. /**
  85998. * Invert the geometry to move from a right handed system to a left handed one.
  85999. */
  86000. toLeftHanded(): void;
  86001. /** @hidden */
  86002. _resetPointsArrayCache(): void;
  86003. /** @hidden */
  86004. _generatePointsArray(): boolean;
  86005. /**
  86006. * Gets a value indicating if the geometry is disposed
  86007. * @returns true if the geometry was disposed
  86008. */
  86009. isDisposed(): boolean;
  86010. private _disposeVertexArrayObjects;
  86011. /**
  86012. * Free all associated resources
  86013. */
  86014. dispose(): void;
  86015. /**
  86016. * Clone the current geometry into a new geometry
  86017. * @param id defines the unique ID of the new geometry
  86018. * @returns a new geometry object
  86019. */
  86020. copy(id: string): Geometry;
  86021. /**
  86022. * Serialize the current geometry info (and not the vertices data) into a JSON object
  86023. * @return a JSON representation of the current geometry data (without the vertices data)
  86024. */
  86025. serialize(): any;
  86026. private toNumberArray;
  86027. /**
  86028. * Serialize all vertices data into a JSON oject
  86029. * @returns a JSON representation of the current geometry data
  86030. */
  86031. serializeVerticeData(): any;
  86032. /**
  86033. * Extracts a clone of a mesh geometry
  86034. * @param mesh defines the source mesh
  86035. * @param id defines the unique ID of the new geometry object
  86036. * @returns the new geometry object
  86037. */
  86038. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  86039. /**
  86040. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  86041. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86042. * Be aware Math.random() could cause collisions, but:
  86043. * "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"
  86044. * @returns a string containing a new GUID
  86045. */
  86046. static RandomId(): string;
  86047. /** @hidden */
  86048. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  86049. private static _CleanMatricesWeights;
  86050. /**
  86051. * Create a new geometry from persisted data (Using .babylon file format)
  86052. * @param parsedVertexData defines the persisted data
  86053. * @param scene defines the hosting scene
  86054. * @param rootUrl defines the root url to use to load assets (like delayed data)
  86055. * @returns the new geometry object
  86056. */
  86057. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  86058. }
  86059. }
  86060. declare module BABYLON {
  86061. /**
  86062. * Define an interface for all classes that will get and set the data on vertices
  86063. */
  86064. export interface IGetSetVerticesData {
  86065. /**
  86066. * Gets a boolean indicating if specific vertex data is present
  86067. * @param kind defines the vertex data kind to use
  86068. * @returns true is data kind is present
  86069. */
  86070. isVerticesDataPresent(kind: string): boolean;
  86071. /**
  86072. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86073. * @param kind defines the data kind (Position, normal, etc...)
  86074. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86075. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86076. * @returns a float array containing vertex data
  86077. */
  86078. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86079. /**
  86080. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86081. * @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.
  86082. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86083. * @returns the indices array or an empty array if the mesh has no geometry
  86084. */
  86085. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86086. /**
  86087. * Set specific vertex data
  86088. * @param kind defines the data kind (Position, normal, etc...)
  86089. * @param data defines the vertex data to use
  86090. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86091. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86092. */
  86093. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  86094. /**
  86095. * Update a specific associated vertex buffer
  86096. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  86097. * - VertexBuffer.PositionKind
  86098. * - VertexBuffer.UVKind
  86099. * - VertexBuffer.UV2Kind
  86100. * - VertexBuffer.UV3Kind
  86101. * - VertexBuffer.UV4Kind
  86102. * - VertexBuffer.UV5Kind
  86103. * - VertexBuffer.UV6Kind
  86104. * - VertexBuffer.ColorKind
  86105. * - VertexBuffer.MatricesIndicesKind
  86106. * - VertexBuffer.MatricesIndicesExtraKind
  86107. * - VertexBuffer.MatricesWeightsKind
  86108. * - VertexBuffer.MatricesWeightsExtraKind
  86109. * @param data defines the data source
  86110. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  86111. * @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)
  86112. */
  86113. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  86114. /**
  86115. * Creates a new index buffer
  86116. * @param indices defines the indices to store in the index buffer
  86117. * @param totalVertices defines the total number of vertices (could be null)
  86118. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86119. */
  86120. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  86121. }
  86122. /**
  86123. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  86124. */
  86125. export class VertexData {
  86126. /**
  86127. * Mesh side orientation : usually the external or front surface
  86128. */
  86129. static readonly FRONTSIDE: number;
  86130. /**
  86131. * Mesh side orientation : usually the internal or back surface
  86132. */
  86133. static readonly BACKSIDE: number;
  86134. /**
  86135. * Mesh side orientation : both internal and external or front and back surfaces
  86136. */
  86137. static readonly DOUBLESIDE: number;
  86138. /**
  86139. * Mesh side orientation : by default, `FRONTSIDE`
  86140. */
  86141. static readonly DEFAULTSIDE: number;
  86142. /**
  86143. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  86144. */
  86145. positions: Nullable<FloatArray>;
  86146. /**
  86147. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  86148. */
  86149. normals: Nullable<FloatArray>;
  86150. /**
  86151. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  86152. */
  86153. tangents: Nullable<FloatArray>;
  86154. /**
  86155. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86156. */
  86157. uvs: Nullable<FloatArray>;
  86158. /**
  86159. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86160. */
  86161. uvs2: Nullable<FloatArray>;
  86162. /**
  86163. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86164. */
  86165. uvs3: Nullable<FloatArray>;
  86166. /**
  86167. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86168. */
  86169. uvs4: Nullable<FloatArray>;
  86170. /**
  86171. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86172. */
  86173. uvs5: Nullable<FloatArray>;
  86174. /**
  86175. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86176. */
  86177. uvs6: Nullable<FloatArray>;
  86178. /**
  86179. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  86180. */
  86181. colors: Nullable<FloatArray>;
  86182. /**
  86183. * 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).
  86184. */
  86185. matricesIndices: Nullable<FloatArray>;
  86186. /**
  86187. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  86188. */
  86189. matricesWeights: Nullable<FloatArray>;
  86190. /**
  86191. * An array extending the number of possible indices
  86192. */
  86193. matricesIndicesExtra: Nullable<FloatArray>;
  86194. /**
  86195. * An array extending the number of possible weights when the number of indices is extended
  86196. */
  86197. matricesWeightsExtra: Nullable<FloatArray>;
  86198. /**
  86199. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  86200. */
  86201. indices: Nullable<IndicesArray>;
  86202. /**
  86203. * Uses the passed data array to set the set the values for the specified kind of data
  86204. * @param data a linear array of floating numbers
  86205. * @param kind the type of data that is being set, eg positions, colors etc
  86206. */
  86207. set(data: FloatArray, kind: string): void;
  86208. /**
  86209. * Associates the vertexData to the passed Mesh.
  86210. * Sets it as updatable or not (default `false`)
  86211. * @param mesh the mesh the vertexData is applied to
  86212. * @param updatable when used and having the value true allows new data to update the vertexData
  86213. * @returns the VertexData
  86214. */
  86215. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  86216. /**
  86217. * Associates the vertexData to the passed Geometry.
  86218. * Sets it as updatable or not (default `false`)
  86219. * @param geometry the geometry the vertexData is applied to
  86220. * @param updatable when used and having the value true allows new data to update the vertexData
  86221. * @returns VertexData
  86222. */
  86223. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  86224. /**
  86225. * Updates the associated mesh
  86226. * @param mesh the mesh to be updated
  86227. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86228. * @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
  86229. * @returns VertexData
  86230. */
  86231. updateMesh(mesh: Mesh): VertexData;
  86232. /**
  86233. * Updates the associated geometry
  86234. * @param geometry the geometry to be updated
  86235. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86236. * @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
  86237. * @returns VertexData.
  86238. */
  86239. updateGeometry(geometry: Geometry): VertexData;
  86240. private _applyTo;
  86241. private _update;
  86242. /**
  86243. * Transforms each position and each normal of the vertexData according to the passed Matrix
  86244. * @param matrix the transforming matrix
  86245. * @returns the VertexData
  86246. */
  86247. transform(matrix: Matrix): VertexData;
  86248. /**
  86249. * Merges the passed VertexData into the current one
  86250. * @param other the VertexData to be merged into the current one
  86251. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  86252. * @returns the modified VertexData
  86253. */
  86254. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  86255. private _mergeElement;
  86256. private _validate;
  86257. /**
  86258. * Serializes the VertexData
  86259. * @returns a serialized object
  86260. */
  86261. serialize(): any;
  86262. /**
  86263. * Extracts the vertexData from a mesh
  86264. * @param mesh the mesh from which to extract the VertexData
  86265. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  86266. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86267. * @returns the object VertexData associated to the passed mesh
  86268. */
  86269. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86270. /**
  86271. * Extracts the vertexData from the geometry
  86272. * @param geometry the geometry from which to extract the VertexData
  86273. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  86274. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86275. * @returns the object VertexData associated to the passed mesh
  86276. */
  86277. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86278. private static _ExtractFrom;
  86279. /**
  86280. * Creates the VertexData for a Ribbon
  86281. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  86282. * * pathArray array of paths, each of which an array of successive Vector3
  86283. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  86284. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  86285. * * 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
  86286. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86287. * * 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)
  86288. * * 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)
  86289. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  86290. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  86291. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  86292. * @returns the VertexData of the ribbon
  86293. */
  86294. static CreateRibbon(options: {
  86295. pathArray: Vector3[][];
  86296. closeArray?: boolean;
  86297. closePath?: boolean;
  86298. offset?: number;
  86299. sideOrientation?: number;
  86300. frontUVs?: Vector4;
  86301. backUVs?: Vector4;
  86302. invertUV?: boolean;
  86303. uvs?: Vector2[];
  86304. colors?: Color4[];
  86305. }): VertexData;
  86306. /**
  86307. * Creates the VertexData for a box
  86308. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86309. * * size sets the width, height and depth of the box to the value of size, optional default 1
  86310. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  86311. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  86312. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  86313. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86314. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86315. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86316. * * 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)
  86317. * * 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)
  86318. * @returns the VertexData of the box
  86319. */
  86320. static CreateBox(options: {
  86321. size?: number;
  86322. width?: number;
  86323. height?: number;
  86324. depth?: number;
  86325. faceUV?: Vector4[];
  86326. faceColors?: Color4[];
  86327. sideOrientation?: number;
  86328. frontUVs?: Vector4;
  86329. backUVs?: Vector4;
  86330. }): VertexData;
  86331. /**
  86332. * Creates the VertexData for a tiled box
  86333. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86334. * * faceTiles sets the pattern, tile size and number of tiles for a face
  86335. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86336. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86337. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86338. * @returns the VertexData of the box
  86339. */
  86340. static CreateTiledBox(options: {
  86341. pattern?: number;
  86342. width?: number;
  86343. height?: number;
  86344. depth?: number;
  86345. tileSize?: number;
  86346. tileWidth?: number;
  86347. tileHeight?: number;
  86348. alignHorizontal?: number;
  86349. alignVertical?: number;
  86350. faceUV?: Vector4[];
  86351. faceColors?: Color4[];
  86352. sideOrientation?: number;
  86353. }): VertexData;
  86354. /**
  86355. * Creates the VertexData for a tiled plane
  86356. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86357. * * pattern a limited pattern arrangement depending on the number
  86358. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  86359. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  86360. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  86361. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86362. * * 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)
  86363. * * 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)
  86364. * @returns the VertexData of the tiled plane
  86365. */
  86366. static CreateTiledPlane(options: {
  86367. pattern?: number;
  86368. tileSize?: number;
  86369. tileWidth?: number;
  86370. tileHeight?: number;
  86371. size?: number;
  86372. width?: number;
  86373. height?: number;
  86374. alignHorizontal?: number;
  86375. alignVertical?: number;
  86376. sideOrientation?: number;
  86377. frontUVs?: Vector4;
  86378. backUVs?: Vector4;
  86379. }): VertexData;
  86380. /**
  86381. * Creates the VertexData for an ellipsoid, defaults to a sphere
  86382. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86383. * * segments sets the number of horizontal strips optional, default 32
  86384. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  86385. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  86386. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  86387. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  86388. * * 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
  86389. * * 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
  86390. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86391. * * 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)
  86392. * * 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)
  86393. * @returns the VertexData of the ellipsoid
  86394. */
  86395. static CreateSphere(options: {
  86396. segments?: number;
  86397. diameter?: number;
  86398. diameterX?: number;
  86399. diameterY?: number;
  86400. diameterZ?: number;
  86401. arc?: number;
  86402. slice?: number;
  86403. sideOrientation?: number;
  86404. frontUVs?: Vector4;
  86405. backUVs?: Vector4;
  86406. }): VertexData;
  86407. /**
  86408. * Creates the VertexData for a cylinder, cone or prism
  86409. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86410. * * height sets the height (y direction) of the cylinder, optional, default 2
  86411. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  86412. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  86413. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  86414. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86415. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  86416. * * 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
  86417. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86418. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86419. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  86420. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  86421. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86422. * * 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)
  86423. * * 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)
  86424. * @returns the VertexData of the cylinder, cone or prism
  86425. */
  86426. static CreateCylinder(options: {
  86427. height?: number;
  86428. diameterTop?: number;
  86429. diameterBottom?: number;
  86430. diameter?: number;
  86431. tessellation?: number;
  86432. subdivisions?: number;
  86433. arc?: number;
  86434. faceColors?: Color4[];
  86435. faceUV?: Vector4[];
  86436. hasRings?: boolean;
  86437. enclose?: boolean;
  86438. sideOrientation?: number;
  86439. frontUVs?: Vector4;
  86440. backUVs?: Vector4;
  86441. }): VertexData;
  86442. /**
  86443. * Creates the VertexData for a torus
  86444. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86445. * * diameter the diameter of the torus, optional default 1
  86446. * * thickness the diameter of the tube forming the torus, optional default 0.5
  86447. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86448. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86449. * * 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)
  86450. * * 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)
  86451. * @returns the VertexData of the torus
  86452. */
  86453. static CreateTorus(options: {
  86454. diameter?: number;
  86455. thickness?: number;
  86456. tessellation?: number;
  86457. sideOrientation?: number;
  86458. frontUVs?: Vector4;
  86459. backUVs?: Vector4;
  86460. }): VertexData;
  86461. /**
  86462. * Creates the VertexData of the LineSystem
  86463. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  86464. * - lines an array of lines, each line being an array of successive Vector3
  86465. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  86466. * @returns the VertexData of the LineSystem
  86467. */
  86468. static CreateLineSystem(options: {
  86469. lines: Vector3[][];
  86470. colors?: Nullable<Color4[][]>;
  86471. }): VertexData;
  86472. /**
  86473. * Create the VertexData for a DashedLines
  86474. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  86475. * - points an array successive Vector3
  86476. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  86477. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  86478. * - dashNb the intended total number of dashes, optional, default 200
  86479. * @returns the VertexData for the DashedLines
  86480. */
  86481. static CreateDashedLines(options: {
  86482. points: Vector3[];
  86483. dashSize?: number;
  86484. gapSize?: number;
  86485. dashNb?: number;
  86486. }): VertexData;
  86487. /**
  86488. * Creates the VertexData for a Ground
  86489. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86490. * - width the width (x direction) of the ground, optional, default 1
  86491. * - height the height (z direction) of the ground, optional, default 1
  86492. * - subdivisions the number of subdivisions per side, optional, default 1
  86493. * @returns the VertexData of the Ground
  86494. */
  86495. static CreateGround(options: {
  86496. width?: number;
  86497. height?: number;
  86498. subdivisions?: number;
  86499. subdivisionsX?: number;
  86500. subdivisionsY?: number;
  86501. }): VertexData;
  86502. /**
  86503. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  86504. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86505. * * xmin the ground minimum X coordinate, optional, default -1
  86506. * * zmin the ground minimum Z coordinate, optional, default -1
  86507. * * xmax the ground maximum X coordinate, optional, default 1
  86508. * * zmax the ground maximum Z coordinate, optional, default 1
  86509. * * 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}
  86510. * * 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}
  86511. * @returns the VertexData of the TiledGround
  86512. */
  86513. static CreateTiledGround(options: {
  86514. xmin: number;
  86515. zmin: number;
  86516. xmax: number;
  86517. zmax: number;
  86518. subdivisions?: {
  86519. w: number;
  86520. h: number;
  86521. };
  86522. precision?: {
  86523. w: number;
  86524. h: number;
  86525. };
  86526. }): VertexData;
  86527. /**
  86528. * Creates the VertexData of the Ground designed from a heightmap
  86529. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  86530. * * width the width (x direction) of the ground
  86531. * * height the height (z direction) of the ground
  86532. * * subdivisions the number of subdivisions per side
  86533. * * minHeight the minimum altitude on the ground, optional, default 0
  86534. * * maxHeight the maximum altitude on the ground, optional default 1
  86535. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  86536. * * buffer the array holding the image color data
  86537. * * bufferWidth the width of image
  86538. * * bufferHeight the height of image
  86539. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  86540. * @returns the VertexData of the Ground designed from a heightmap
  86541. */
  86542. static CreateGroundFromHeightMap(options: {
  86543. width: number;
  86544. height: number;
  86545. subdivisions: number;
  86546. minHeight: number;
  86547. maxHeight: number;
  86548. colorFilter: Color3;
  86549. buffer: Uint8Array;
  86550. bufferWidth: number;
  86551. bufferHeight: number;
  86552. alphaFilter: number;
  86553. }): VertexData;
  86554. /**
  86555. * Creates the VertexData for a Plane
  86556. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  86557. * * size sets the width and height of the plane to the value of size, optional default 1
  86558. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  86559. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  86560. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86561. * * 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)
  86562. * * 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)
  86563. * @returns the VertexData of the box
  86564. */
  86565. static CreatePlane(options: {
  86566. size?: number;
  86567. width?: number;
  86568. height?: number;
  86569. sideOrientation?: number;
  86570. frontUVs?: Vector4;
  86571. backUVs?: Vector4;
  86572. }): VertexData;
  86573. /**
  86574. * Creates the VertexData of the Disc or regular Polygon
  86575. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  86576. * * radius the radius of the disc, optional default 0.5
  86577. * * tessellation the number of polygon sides, optional, default 64
  86578. * * 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
  86579. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86580. * * 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)
  86581. * * 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)
  86582. * @returns the VertexData of the box
  86583. */
  86584. static CreateDisc(options: {
  86585. radius?: number;
  86586. tessellation?: number;
  86587. arc?: number;
  86588. sideOrientation?: number;
  86589. frontUVs?: Vector4;
  86590. backUVs?: Vector4;
  86591. }): VertexData;
  86592. /**
  86593. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  86594. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  86595. * @param polygon a mesh built from polygonTriangulation.build()
  86596. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86597. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86598. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86599. * @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)
  86600. * @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)
  86601. * @returns the VertexData of the Polygon
  86602. */
  86603. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  86604. /**
  86605. * Creates the VertexData of the IcoSphere
  86606. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  86607. * * radius the radius of the IcoSphere, optional default 1
  86608. * * radiusX allows stretching in the x direction, optional, default radius
  86609. * * radiusY allows stretching in the y direction, optional, default radius
  86610. * * radiusZ allows stretching in the z direction, optional, default radius
  86611. * * flat when true creates a flat shaded mesh, optional, default true
  86612. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86613. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86614. * * 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)
  86615. * * 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)
  86616. * @returns the VertexData of the IcoSphere
  86617. */
  86618. static CreateIcoSphere(options: {
  86619. radius?: number;
  86620. radiusX?: number;
  86621. radiusY?: number;
  86622. radiusZ?: number;
  86623. flat?: boolean;
  86624. subdivisions?: number;
  86625. sideOrientation?: number;
  86626. frontUVs?: Vector4;
  86627. backUVs?: Vector4;
  86628. }): VertexData;
  86629. /**
  86630. * Creates the VertexData for a Polyhedron
  86631. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86632. * * type provided types are:
  86633. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86634. * * 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)
  86635. * * size the size of the IcoSphere, optional default 1
  86636. * * sizeX allows stretching in the x direction, optional, default size
  86637. * * sizeY allows stretching in the y direction, optional, default size
  86638. * * sizeZ allows stretching in the z direction, optional, default size
  86639. * * 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
  86640. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86641. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86642. * * flat when true creates a flat shaded mesh, optional, default true
  86643. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86644. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86645. * * 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)
  86646. * * 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)
  86647. * @returns the VertexData of the Polyhedron
  86648. */
  86649. static CreatePolyhedron(options: {
  86650. type?: number;
  86651. size?: number;
  86652. sizeX?: number;
  86653. sizeY?: number;
  86654. sizeZ?: number;
  86655. custom?: any;
  86656. faceUV?: Vector4[];
  86657. faceColors?: Color4[];
  86658. flat?: boolean;
  86659. sideOrientation?: number;
  86660. frontUVs?: Vector4;
  86661. backUVs?: Vector4;
  86662. }): VertexData;
  86663. /**
  86664. * Creates the VertexData for a TorusKnot
  86665. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86666. * * radius the radius of the torus knot, optional, default 2
  86667. * * tube the thickness of the tube, optional, default 0.5
  86668. * * radialSegments the number of sides on each tube segments, optional, default 32
  86669. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86670. * * p the number of windings around the z axis, optional, default 2
  86671. * * q the number of windings around the x axis, optional, default 3
  86672. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86673. * * 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)
  86674. * * 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)
  86675. * @returns the VertexData of the Torus Knot
  86676. */
  86677. static CreateTorusKnot(options: {
  86678. radius?: number;
  86679. tube?: number;
  86680. radialSegments?: number;
  86681. tubularSegments?: number;
  86682. p?: number;
  86683. q?: number;
  86684. sideOrientation?: number;
  86685. frontUVs?: Vector4;
  86686. backUVs?: Vector4;
  86687. }): VertexData;
  86688. /**
  86689. * Compute normals for given positions and indices
  86690. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86691. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86692. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86693. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86694. * * facetNormals : optional array of facet normals (vector3)
  86695. * * facetPositions : optional array of facet positions (vector3)
  86696. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86697. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86698. * * bInfo : optional bounding info, required for facetPartitioning computation
  86699. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86700. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86701. * * useRightHandedSystem: optional boolean to for right handed system computation
  86702. * * depthSort : optional boolean to enable the facet depth sort computation
  86703. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86704. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86705. */
  86706. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86707. facetNormals?: any;
  86708. facetPositions?: any;
  86709. facetPartitioning?: any;
  86710. ratio?: number;
  86711. bInfo?: any;
  86712. bbSize?: Vector3;
  86713. subDiv?: any;
  86714. useRightHandedSystem?: boolean;
  86715. depthSort?: boolean;
  86716. distanceTo?: Vector3;
  86717. depthSortedFacets?: any;
  86718. }): void;
  86719. /** @hidden */
  86720. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86721. /**
  86722. * Applies VertexData created from the imported parameters to the geometry
  86723. * @param parsedVertexData the parsed data from an imported file
  86724. * @param geometry the geometry to apply the VertexData to
  86725. */
  86726. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86727. }
  86728. }
  86729. declare module BABYLON {
  86730. /**
  86731. * Class containing static functions to help procedurally build meshes
  86732. */
  86733. export class DiscBuilder {
  86734. /**
  86735. * Creates a plane polygonal mesh. By default, this is a disc
  86736. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  86737. * * 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
  86738. * * 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
  86739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86740. * * 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
  86741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86742. * @param name defines the name of the mesh
  86743. * @param options defines the options used to create the mesh
  86744. * @param scene defines the hosting scene
  86745. * @returns the plane polygonal mesh
  86746. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  86747. */
  86748. static CreateDisc(name: string, options: {
  86749. radius?: number;
  86750. tessellation?: number;
  86751. arc?: number;
  86752. updatable?: boolean;
  86753. sideOrientation?: number;
  86754. frontUVs?: Vector4;
  86755. backUVs?: Vector4;
  86756. }, scene?: Nullable<Scene>): Mesh;
  86757. }
  86758. }
  86759. declare module BABYLON {
  86760. /**
  86761. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  86762. *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.
  86763. * The SPS is also a particle system. It provides some methods to manage the particles.
  86764. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  86765. *
  86766. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  86767. */
  86768. export class SolidParticleSystem implements IDisposable {
  86769. /**
  86770. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  86771. * Example : var p = SPS.particles[i];
  86772. */
  86773. particles: SolidParticle[];
  86774. /**
  86775. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  86776. */
  86777. nbParticles: number;
  86778. /**
  86779. * If the particles must ever face the camera (default false). Useful for planar particles.
  86780. */
  86781. billboard: boolean;
  86782. /**
  86783. * Recompute normals when adding a shape
  86784. */
  86785. recomputeNormals: boolean;
  86786. /**
  86787. * This a counter ofr your own usage. It's not set by any SPS functions.
  86788. */
  86789. counter: number;
  86790. /**
  86791. * The SPS name. This name is also given to the underlying mesh.
  86792. */
  86793. name: string;
  86794. /**
  86795. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  86796. */
  86797. mesh: Mesh;
  86798. /**
  86799. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  86800. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  86801. */
  86802. vars: any;
  86803. /**
  86804. * This array is populated when the SPS is set as 'pickable'.
  86805. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  86806. * Each element of this array is an object `{idx: int, faceId: int}`.
  86807. * `idx` is the picked particle index in the `SPS.particles` array
  86808. * `faceId` is the picked face index counted within this particle.
  86809. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  86810. */
  86811. pickedParticles: {
  86812. idx: number;
  86813. faceId: number;
  86814. }[];
  86815. /**
  86816. * This array is populated when `enableDepthSort` is set to true.
  86817. * Each element of this array is an instance of the class DepthSortedParticle.
  86818. */
  86819. depthSortedParticles: DepthSortedParticle[];
  86820. /**
  86821. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  86822. * @hidden
  86823. */
  86824. _bSphereOnly: boolean;
  86825. /**
  86826. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  86827. * @hidden
  86828. */
  86829. _bSphereRadiusFactor: number;
  86830. private _scene;
  86831. private _positions;
  86832. private _indices;
  86833. private _normals;
  86834. private _colors;
  86835. private _uvs;
  86836. private _indices32;
  86837. private _positions32;
  86838. private _normals32;
  86839. private _fixedNormal32;
  86840. private _colors32;
  86841. private _uvs32;
  86842. private _index;
  86843. private _updatable;
  86844. private _pickable;
  86845. private _isVisibilityBoxLocked;
  86846. private _alwaysVisible;
  86847. private _depthSort;
  86848. private _shapeCounter;
  86849. private _copy;
  86850. private _color;
  86851. private _computeParticleColor;
  86852. private _computeParticleTexture;
  86853. private _computeParticleRotation;
  86854. private _computeParticleVertex;
  86855. private _computeBoundingBox;
  86856. private _depthSortParticles;
  86857. private _camera;
  86858. private _mustUnrotateFixedNormals;
  86859. private _particlesIntersect;
  86860. private _needs32Bits;
  86861. /**
  86862. * Creates a SPS (Solid Particle System) object.
  86863. * @param name (String) is the SPS name, this will be the underlying mesh name.
  86864. * @param scene (Scene) is the scene in which the SPS is added.
  86865. * @param options defines the options of the sps e.g.
  86866. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  86867. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  86868. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  86869. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  86870. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  86871. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  86872. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  86873. */
  86874. constructor(name: string, scene: Scene, options?: {
  86875. updatable?: boolean;
  86876. isPickable?: boolean;
  86877. enableDepthSort?: boolean;
  86878. particleIntersection?: boolean;
  86879. boundingSphereOnly?: boolean;
  86880. bSphereRadiusFactor?: number;
  86881. });
  86882. /**
  86883. * Builds the SPS underlying mesh. Returns a standard Mesh.
  86884. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  86885. * @returns the created mesh
  86886. */
  86887. buildMesh(): Mesh;
  86888. /**
  86889. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  86890. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  86891. * Thus the particles generated from `digest()` have their property `position` set yet.
  86892. * @param mesh ( Mesh ) is the mesh to be digested
  86893. * @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
  86894. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  86895. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  86896. * @returns the current SPS
  86897. */
  86898. digest(mesh: Mesh, options?: {
  86899. facetNb?: number;
  86900. number?: number;
  86901. delta?: number;
  86902. }): SolidParticleSystem;
  86903. private _unrotateFixedNormals;
  86904. private _resetCopy;
  86905. private _meshBuilder;
  86906. private _posToShape;
  86907. private _uvsToShapeUV;
  86908. private _addParticle;
  86909. /**
  86910. * Adds some particles to the SPS from the model shape. Returns the shape id.
  86911. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  86912. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  86913. * @param nb (positive integer) the number of particles to be created from this model
  86914. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  86915. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  86916. * @returns the number of shapes in the system
  86917. */
  86918. addShape(mesh: Mesh, nb: number, options?: {
  86919. positionFunction?: any;
  86920. vertexFunction?: any;
  86921. }): number;
  86922. private _rebuildParticle;
  86923. /**
  86924. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  86925. * @returns the SPS.
  86926. */
  86927. rebuildMesh(): SolidParticleSystem;
  86928. /**
  86929. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  86930. * This method calls `updateParticle()` for each particle of the SPS.
  86931. * For an animated SPS, it is usually called within the render loop.
  86932. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  86933. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  86934. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  86935. * @returns the SPS.
  86936. */
  86937. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  86938. /**
  86939. * Disposes the SPS.
  86940. */
  86941. dispose(): void;
  86942. /**
  86943. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  86944. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86945. * @returns the SPS.
  86946. */
  86947. refreshVisibleSize(): SolidParticleSystem;
  86948. /**
  86949. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  86950. * @param size the size (float) of the visibility box
  86951. * note : this doesn't lock the SPS mesh bounding box.
  86952. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86953. */
  86954. setVisibilityBox(size: number): void;
  86955. /**
  86956. * Gets whether the SPS as always visible or not
  86957. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86958. */
  86959. /**
  86960. * Sets the SPS as always visible or not
  86961. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86962. */
  86963. isAlwaysVisible: boolean;
  86964. /**
  86965. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86966. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86967. */
  86968. /**
  86969. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86970. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86971. */
  86972. isVisibilityBoxLocked: boolean;
  86973. /**
  86974. * Tells to `setParticles()` to compute the particle rotations or not.
  86975. * Default value : true. The SPS is faster when it's set to false.
  86976. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86977. */
  86978. /**
  86979. * Gets if `setParticles()` computes the particle rotations or not.
  86980. * Default value : true. The SPS is faster when it's set to false.
  86981. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86982. */
  86983. computeParticleRotation: boolean;
  86984. /**
  86985. * Tells to `setParticles()` to compute the particle colors or not.
  86986. * Default value : true. The SPS is faster when it's set to false.
  86987. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86988. */
  86989. /**
  86990. * Gets if `setParticles()` computes the particle colors or not.
  86991. * Default value : true. The SPS is faster when it's set to false.
  86992. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86993. */
  86994. computeParticleColor: boolean;
  86995. /**
  86996. * Gets if `setParticles()` computes the particle textures or not.
  86997. * Default value : true. The SPS is faster when it's set to false.
  86998. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  86999. */
  87000. computeParticleTexture: boolean;
  87001. /**
  87002. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  87003. * Default value : false. The SPS is faster when it's set to false.
  87004. * Note : the particle custom vertex positions aren't stored values.
  87005. */
  87006. /**
  87007. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  87008. * Default value : false. The SPS is faster when it's set to false.
  87009. * Note : the particle custom vertex positions aren't stored values.
  87010. */
  87011. computeParticleVertex: boolean;
  87012. /**
  87013. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  87014. */
  87015. /**
  87016. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  87017. */
  87018. computeBoundingBox: boolean;
  87019. /**
  87020. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  87021. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  87022. * Default : `true`
  87023. */
  87024. /**
  87025. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  87026. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  87027. * Default : `true`
  87028. */
  87029. depthSortParticles: boolean;
  87030. /**
  87031. * This function does nothing. It may be overwritten to set all the particle first values.
  87032. * The SPS doesn't call this function, you may have to call it by your own.
  87033. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  87034. */
  87035. initParticles(): void;
  87036. /**
  87037. * This function does nothing. It may be overwritten to recycle a particle.
  87038. * The SPS doesn't call this function, you may have to call it by your own.
  87039. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  87040. * @param particle The particle to recycle
  87041. * @returns the recycled particle
  87042. */
  87043. recycleParticle(particle: SolidParticle): SolidParticle;
  87044. /**
  87045. * Updates a particle : this function should be overwritten by the user.
  87046. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  87047. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  87048. * @example : just set a particle position or velocity and recycle conditions
  87049. * @param particle The particle to update
  87050. * @returns the updated particle
  87051. */
  87052. updateParticle(particle: SolidParticle): SolidParticle;
  87053. /**
  87054. * Updates a vertex of a particle : it can be overwritten by the user.
  87055. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  87056. * @param particle the current particle
  87057. * @param vertex the current index of the current particle
  87058. * @param pt the index of the current vertex in the particle shape
  87059. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  87060. * @example : just set a vertex particle position
  87061. * @returns the updated vertex
  87062. */
  87063. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  87064. /**
  87065. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  87066. * This does nothing and may be overwritten by the user.
  87067. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87068. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87069. * @param update the boolean update value actually passed to setParticles()
  87070. */
  87071. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  87072. /**
  87073. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  87074. * This will be passed three parameters.
  87075. * This does nothing and may be overwritten by the user.
  87076. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87077. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  87078. * @param update the boolean update value actually passed to setParticles()
  87079. */
  87080. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  87081. }
  87082. }
  87083. declare module BABYLON {
  87084. /**
  87085. * Represents one particle of a solid particle system.
  87086. */
  87087. export class SolidParticle {
  87088. /**
  87089. * particle global index
  87090. */
  87091. idx: number;
  87092. /**
  87093. * The color of the particle
  87094. */
  87095. color: Nullable<Color4>;
  87096. /**
  87097. * The world space position of the particle.
  87098. */
  87099. position: Vector3;
  87100. /**
  87101. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  87102. */
  87103. rotation: Vector3;
  87104. /**
  87105. * The world space rotation quaternion of the particle.
  87106. */
  87107. rotationQuaternion: Nullable<Quaternion>;
  87108. /**
  87109. * The scaling of the particle.
  87110. */
  87111. scaling: Vector3;
  87112. /**
  87113. * The uvs of the particle.
  87114. */
  87115. uvs: Vector4;
  87116. /**
  87117. * The current speed of the particle.
  87118. */
  87119. velocity: Vector3;
  87120. /**
  87121. * The pivot point in the particle local space.
  87122. */
  87123. pivot: Vector3;
  87124. /**
  87125. * Must the particle be translated from its pivot point in its local space ?
  87126. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  87127. * Default : false
  87128. */
  87129. translateFromPivot: boolean;
  87130. /**
  87131. * Is the particle active or not ?
  87132. */
  87133. alive: boolean;
  87134. /**
  87135. * Is the particle visible or not ?
  87136. */
  87137. isVisible: boolean;
  87138. /**
  87139. * Index of this particle in the global "positions" array (Internal use)
  87140. * @hidden
  87141. */
  87142. _pos: number;
  87143. /**
  87144. * @hidden Index of this particle in the global "indices" array (Internal use)
  87145. */
  87146. _ind: number;
  87147. /**
  87148. * @hidden ModelShape of this particle (Internal use)
  87149. */
  87150. _model: ModelShape;
  87151. /**
  87152. * ModelShape id of this particle
  87153. */
  87154. shapeId: number;
  87155. /**
  87156. * Index of the particle in its shape id (Internal use)
  87157. */
  87158. idxInShape: number;
  87159. /**
  87160. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  87161. */
  87162. _modelBoundingInfo: BoundingInfo;
  87163. /**
  87164. * @hidden Particle BoundingInfo object (Internal use)
  87165. */
  87166. _boundingInfo: BoundingInfo;
  87167. /**
  87168. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  87169. */
  87170. _sps: SolidParticleSystem;
  87171. /**
  87172. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  87173. */
  87174. _stillInvisible: boolean;
  87175. /**
  87176. * @hidden Last computed particle rotation matrix
  87177. */
  87178. _rotationMatrix: number[];
  87179. /**
  87180. * Parent particle Id, if any.
  87181. * Default null.
  87182. */
  87183. parentId: Nullable<number>;
  87184. /**
  87185. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  87186. * The possible values are :
  87187. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  87188. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87189. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  87190. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  87191. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87192. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  87193. * */
  87194. cullingStrategy: number;
  87195. /**
  87196. * @hidden Internal global position in the SPS.
  87197. */
  87198. _globalPosition: Vector3;
  87199. /**
  87200. * Creates a Solid Particle object.
  87201. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  87202. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  87203. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  87204. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  87205. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  87206. * @param shapeId (integer) is the model shape identifier in the SPS.
  87207. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  87208. * @param sps defines the sps it is associated to
  87209. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  87210. */
  87211. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  87212. /**
  87213. * Legacy support, changed scale to scaling
  87214. */
  87215. /**
  87216. * Legacy support, changed scale to scaling
  87217. */
  87218. scale: Vector3;
  87219. /**
  87220. * Legacy support, changed quaternion to rotationQuaternion
  87221. */
  87222. /**
  87223. * Legacy support, changed quaternion to rotationQuaternion
  87224. */
  87225. quaternion: Nullable<Quaternion>;
  87226. /**
  87227. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  87228. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  87229. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  87230. * @returns true if it intersects
  87231. */
  87232. intersectsMesh(target: Mesh | SolidParticle): boolean;
  87233. /**
  87234. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  87235. * A particle is in the frustum if its bounding box intersects the frustum
  87236. * @param frustumPlanes defines the frustum to test
  87237. * @returns true if the particle is in the frustum planes
  87238. */
  87239. isInFrustum(frustumPlanes: Plane[]): boolean;
  87240. /**
  87241. * get the rotation matrix of the particle
  87242. * @hidden
  87243. */
  87244. getRotationMatrix(m: Matrix): void;
  87245. }
  87246. /**
  87247. * Represents the shape of the model used by one particle of a solid particle system.
  87248. * SPS internal tool, don't use it manually.
  87249. */
  87250. export class ModelShape {
  87251. /**
  87252. * The shape id
  87253. * @hidden
  87254. */
  87255. shapeID: number;
  87256. /**
  87257. * flat array of model positions (internal use)
  87258. * @hidden
  87259. */
  87260. _shape: Vector3[];
  87261. /**
  87262. * flat array of model UVs (internal use)
  87263. * @hidden
  87264. */
  87265. _shapeUV: number[];
  87266. /**
  87267. * length of the shape in the model indices array (internal use)
  87268. * @hidden
  87269. */
  87270. _indicesLength: number;
  87271. /**
  87272. * Custom position function (internal use)
  87273. * @hidden
  87274. */
  87275. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  87276. /**
  87277. * Custom vertex function (internal use)
  87278. * @hidden
  87279. */
  87280. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  87281. /**
  87282. * 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.
  87283. * SPS internal tool, don't use it manually.
  87284. * @hidden
  87285. */
  87286. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  87287. }
  87288. /**
  87289. * Represents a Depth Sorted Particle in the solid particle system.
  87290. */
  87291. export class DepthSortedParticle {
  87292. /**
  87293. * Index of the particle in the "indices" array
  87294. */
  87295. ind: number;
  87296. /**
  87297. * Length of the particle shape in the "indices" array
  87298. */
  87299. indicesLength: number;
  87300. /**
  87301. * Squared distance from the particle to the camera
  87302. */
  87303. sqDistance: number;
  87304. }
  87305. }
  87306. declare module BABYLON {
  87307. /**
  87308. * @hidden
  87309. */
  87310. export class _MeshCollisionData {
  87311. _checkCollisions: boolean;
  87312. _collisionMask: number;
  87313. _collisionGroup: number;
  87314. _collider: Nullable<Collider>;
  87315. _oldPositionForCollisions: Vector3;
  87316. _diffPositionForCollisions: Vector3;
  87317. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  87318. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  87319. }
  87320. }
  87321. declare module BABYLON {
  87322. /** @hidden */
  87323. class _FacetDataStorage {
  87324. facetPositions: Vector3[];
  87325. facetNormals: Vector3[];
  87326. facetPartitioning: number[][];
  87327. facetNb: number;
  87328. partitioningSubdivisions: number;
  87329. partitioningBBoxRatio: number;
  87330. facetDataEnabled: boolean;
  87331. facetParameters: any;
  87332. bbSize: Vector3;
  87333. subDiv: {
  87334. max: number;
  87335. X: number;
  87336. Y: number;
  87337. Z: number;
  87338. };
  87339. facetDepthSort: boolean;
  87340. facetDepthSortEnabled: boolean;
  87341. depthSortedIndices: IndicesArray;
  87342. depthSortedFacets: {
  87343. ind: number;
  87344. sqDistance: number;
  87345. }[];
  87346. facetDepthSortFunction: (f1: {
  87347. ind: number;
  87348. sqDistance: number;
  87349. }, f2: {
  87350. ind: number;
  87351. sqDistance: number;
  87352. }) => number;
  87353. facetDepthSortFrom: Vector3;
  87354. facetDepthSortOrigin: Vector3;
  87355. invertedMatrix: Matrix;
  87356. }
  87357. /**
  87358. * @hidden
  87359. **/
  87360. class _InternalAbstractMeshDataInfo {
  87361. _hasVertexAlpha: boolean;
  87362. _useVertexColors: boolean;
  87363. _numBoneInfluencers: number;
  87364. _applyFog: boolean;
  87365. _receiveShadows: boolean;
  87366. _facetData: _FacetDataStorage;
  87367. _visibility: number;
  87368. _skeleton: Nullable<Skeleton>;
  87369. _layerMask: number;
  87370. _computeBonesUsingShaders: boolean;
  87371. _isActive: boolean;
  87372. _onlyForInstances: boolean;
  87373. _isActiveIntermediate: boolean;
  87374. _onlyForInstancesIntermediate: boolean;
  87375. }
  87376. /**
  87377. * Class used to store all common mesh properties
  87378. */
  87379. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  87380. /** No occlusion */
  87381. static OCCLUSION_TYPE_NONE: number;
  87382. /** Occlusion set to optimisitic */
  87383. static OCCLUSION_TYPE_OPTIMISTIC: number;
  87384. /** Occlusion set to strict */
  87385. static OCCLUSION_TYPE_STRICT: number;
  87386. /** Use an accurante occlusion algorithm */
  87387. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  87388. /** Use a conservative occlusion algorithm */
  87389. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  87390. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  87391. * Test order :
  87392. * Is the bounding sphere outside the frustum ?
  87393. * If not, are the bounding box vertices outside the frustum ?
  87394. * It not, then the cullable object is in the frustum.
  87395. */
  87396. static readonly CULLINGSTRATEGY_STANDARD: number;
  87397. /** Culling strategy : Bounding Sphere Only.
  87398. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  87399. * It's also less accurate than the standard because some not visible objects can still be selected.
  87400. * Test : is the bounding sphere outside the frustum ?
  87401. * If not, then the cullable object is in the frustum.
  87402. */
  87403. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  87404. /** Culling strategy : Optimistic Inclusion.
  87405. * This in an inclusion test first, then the standard exclusion test.
  87406. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  87407. * 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.
  87408. * Anyway, it's as accurate as the standard strategy.
  87409. * Test :
  87410. * Is the cullable object bounding sphere center in the frustum ?
  87411. * If not, apply the default culling strategy.
  87412. */
  87413. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  87414. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  87415. * This in an inclusion test first, then the bounding sphere only exclusion test.
  87416. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  87417. * 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.
  87418. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  87419. * Test :
  87420. * Is the cullable object bounding sphere center in the frustum ?
  87421. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  87422. */
  87423. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  87424. /**
  87425. * No billboard
  87426. */
  87427. static readonly BILLBOARDMODE_NONE: number;
  87428. /** Billboard on X axis */
  87429. static readonly BILLBOARDMODE_X: number;
  87430. /** Billboard on Y axis */
  87431. static readonly BILLBOARDMODE_Y: number;
  87432. /** Billboard on Z axis */
  87433. static readonly BILLBOARDMODE_Z: number;
  87434. /** Billboard on all axes */
  87435. static readonly BILLBOARDMODE_ALL: number;
  87436. /** @hidden */
  87437. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  87438. /**
  87439. * The culling strategy to use to check whether the mesh must be rendered or not.
  87440. * This value can be changed at any time and will be used on the next render mesh selection.
  87441. * The possible values are :
  87442. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  87443. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87444. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  87445. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  87446. * Please read each static variable documentation to get details about the culling process.
  87447. * */
  87448. cullingStrategy: number;
  87449. /**
  87450. * Gets the number of facets in the mesh
  87451. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87452. */
  87453. readonly facetNb: number;
  87454. /**
  87455. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  87456. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87457. */
  87458. partitioningSubdivisions: number;
  87459. /**
  87460. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  87461. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  87462. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87463. */
  87464. partitioningBBoxRatio: number;
  87465. /**
  87466. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  87467. * Works only for updatable meshes.
  87468. * Doesn't work with multi-materials
  87469. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87470. */
  87471. mustDepthSortFacets: boolean;
  87472. /**
  87473. * The location (Vector3) where the facet depth sort must be computed from.
  87474. * By default, the active camera position.
  87475. * Used only when facet depth sort is enabled
  87476. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87477. */
  87478. facetDepthSortFrom: Vector3;
  87479. /**
  87480. * gets a boolean indicating if facetData is enabled
  87481. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87482. */
  87483. readonly isFacetDataEnabled: boolean;
  87484. /** @hidden */
  87485. _updateNonUniformScalingState(value: boolean): boolean;
  87486. /**
  87487. * An event triggered when this mesh collides with another one
  87488. */
  87489. onCollideObservable: Observable<AbstractMesh>;
  87490. /** Set a function to call when this mesh collides with another one */
  87491. onCollide: () => void;
  87492. /**
  87493. * An event triggered when the collision's position changes
  87494. */
  87495. onCollisionPositionChangeObservable: Observable<Vector3>;
  87496. /** Set a function to call when the collision's position changes */
  87497. onCollisionPositionChange: () => void;
  87498. /**
  87499. * An event triggered when material is changed
  87500. */
  87501. onMaterialChangedObservable: Observable<AbstractMesh>;
  87502. /**
  87503. * Gets or sets the orientation for POV movement & rotation
  87504. */
  87505. definedFacingForward: boolean;
  87506. /** @hidden */
  87507. _occlusionQuery: Nullable<WebGLQuery>;
  87508. /** @hidden */
  87509. _renderingGroup: Nullable<RenderingGroup>;
  87510. /**
  87511. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87512. */
  87513. /**
  87514. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87515. */
  87516. visibility: number;
  87517. /** Gets or sets the alpha index used to sort transparent meshes
  87518. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  87519. */
  87520. alphaIndex: number;
  87521. /**
  87522. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  87523. */
  87524. isVisible: boolean;
  87525. /**
  87526. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  87527. */
  87528. isPickable: boolean;
  87529. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  87530. showSubMeshesBoundingBox: boolean;
  87531. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  87532. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  87533. */
  87534. isBlocker: boolean;
  87535. /**
  87536. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  87537. */
  87538. enablePointerMoveEvents: boolean;
  87539. /**
  87540. * Specifies the rendering group id for this mesh (0 by default)
  87541. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  87542. */
  87543. renderingGroupId: number;
  87544. private _material;
  87545. /** Gets or sets current material */
  87546. material: Nullable<Material>;
  87547. /**
  87548. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  87549. * @see http://doc.babylonjs.com/babylon101/shadows
  87550. */
  87551. receiveShadows: boolean;
  87552. /** Defines color to use when rendering outline */
  87553. outlineColor: Color3;
  87554. /** Define width to use when rendering outline */
  87555. outlineWidth: number;
  87556. /** Defines color to use when rendering overlay */
  87557. overlayColor: Color3;
  87558. /** Defines alpha to use when rendering overlay */
  87559. overlayAlpha: number;
  87560. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  87561. hasVertexAlpha: boolean;
  87562. /** 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) */
  87563. useVertexColors: boolean;
  87564. /**
  87565. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  87566. */
  87567. computeBonesUsingShaders: boolean;
  87568. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  87569. numBoneInfluencers: number;
  87570. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  87571. applyFog: boolean;
  87572. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  87573. useOctreeForRenderingSelection: boolean;
  87574. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  87575. useOctreeForPicking: boolean;
  87576. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  87577. useOctreeForCollisions: boolean;
  87578. /**
  87579. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  87580. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  87581. */
  87582. layerMask: number;
  87583. /**
  87584. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  87585. */
  87586. alwaysSelectAsActiveMesh: boolean;
  87587. /**
  87588. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  87589. */
  87590. doNotSyncBoundingInfo: boolean;
  87591. /**
  87592. * Gets or sets the current action manager
  87593. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87594. */
  87595. actionManager: Nullable<AbstractActionManager>;
  87596. private _meshCollisionData;
  87597. /**
  87598. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  87599. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87600. */
  87601. ellipsoid: Vector3;
  87602. /**
  87603. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  87604. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87605. */
  87606. ellipsoidOffset: Vector3;
  87607. /**
  87608. * Gets or sets a collision mask used to mask collisions (default is -1).
  87609. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87610. */
  87611. collisionMask: number;
  87612. /**
  87613. * Gets or sets the current collision group mask (-1 by default).
  87614. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87615. */
  87616. collisionGroup: number;
  87617. /**
  87618. * Defines edge width used when edgesRenderer is enabled
  87619. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87620. */
  87621. edgesWidth: number;
  87622. /**
  87623. * Defines edge color used when edgesRenderer is enabled
  87624. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87625. */
  87626. edgesColor: Color4;
  87627. /** @hidden */
  87628. _edgesRenderer: Nullable<IEdgesRenderer>;
  87629. /** @hidden */
  87630. _masterMesh: Nullable<AbstractMesh>;
  87631. /** @hidden */
  87632. _boundingInfo: Nullable<BoundingInfo>;
  87633. /** @hidden */
  87634. _renderId: number;
  87635. /**
  87636. * Gets or sets the list of subMeshes
  87637. * @see http://doc.babylonjs.com/how_to/multi_materials
  87638. */
  87639. subMeshes: SubMesh[];
  87640. /** @hidden */
  87641. _intersectionsInProgress: AbstractMesh[];
  87642. /** @hidden */
  87643. _unIndexed: boolean;
  87644. /** @hidden */
  87645. _lightSources: Light[];
  87646. /** Gets the list of lights affecting that mesh */
  87647. readonly lightSources: Light[];
  87648. /** @hidden */
  87649. readonly _positions: Nullable<Vector3[]>;
  87650. /** @hidden */
  87651. _waitingData: {
  87652. lods: Nullable<any>;
  87653. actions: Nullable<any>;
  87654. freezeWorldMatrix: Nullable<boolean>;
  87655. };
  87656. /** @hidden */
  87657. _bonesTransformMatrices: Nullable<Float32Array>;
  87658. /** @hidden */
  87659. _transformMatrixTexture: Nullable<RawTexture>;
  87660. /**
  87661. * Gets or sets a skeleton to apply skining transformations
  87662. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87663. */
  87664. skeleton: Nullable<Skeleton>;
  87665. /**
  87666. * An event triggered when the mesh is rebuilt.
  87667. */
  87668. onRebuildObservable: Observable<AbstractMesh>;
  87669. /**
  87670. * Creates a new AbstractMesh
  87671. * @param name defines the name of the mesh
  87672. * @param scene defines the hosting scene
  87673. */
  87674. constructor(name: string, scene?: Nullable<Scene>);
  87675. /**
  87676. * Returns the string "AbstractMesh"
  87677. * @returns "AbstractMesh"
  87678. */
  87679. getClassName(): string;
  87680. /**
  87681. * Gets a string representation of the current mesh
  87682. * @param fullDetails defines a boolean indicating if full details must be included
  87683. * @returns a string representation of the current mesh
  87684. */
  87685. toString(fullDetails?: boolean): string;
  87686. /**
  87687. * @hidden
  87688. */
  87689. protected _getEffectiveParent(): Nullable<Node>;
  87690. /** @hidden */
  87691. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  87692. /** @hidden */
  87693. _rebuild(): void;
  87694. /** @hidden */
  87695. _resyncLightSources(): void;
  87696. /** @hidden */
  87697. _resyncLighSource(light: Light): void;
  87698. /** @hidden */
  87699. _unBindEffect(): void;
  87700. /** @hidden */
  87701. _removeLightSource(light: Light): void;
  87702. private _markSubMeshesAsDirty;
  87703. /** @hidden */
  87704. _markSubMeshesAsLightDirty(): void;
  87705. /** @hidden */
  87706. _markSubMeshesAsAttributesDirty(): void;
  87707. /** @hidden */
  87708. _markSubMeshesAsMiscDirty(): void;
  87709. /**
  87710. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  87711. */
  87712. scaling: Vector3;
  87713. /**
  87714. * Returns true if the mesh is blocked. Implemented by child classes
  87715. */
  87716. readonly isBlocked: boolean;
  87717. /**
  87718. * Returns the mesh itself by default. Implemented by child classes
  87719. * @param camera defines the camera to use to pick the right LOD level
  87720. * @returns the currentAbstractMesh
  87721. */
  87722. getLOD(camera: Camera): Nullable<AbstractMesh>;
  87723. /**
  87724. * Returns 0 by default. Implemented by child classes
  87725. * @returns an integer
  87726. */
  87727. getTotalVertices(): number;
  87728. /**
  87729. * Returns a positive integer : the total number of indices in this mesh geometry.
  87730. * @returns the numner of indices or zero if the mesh has no geometry.
  87731. */
  87732. getTotalIndices(): number;
  87733. /**
  87734. * Returns null by default. Implemented by child classes
  87735. * @returns null
  87736. */
  87737. getIndices(): Nullable<IndicesArray>;
  87738. /**
  87739. * Returns the array of the requested vertex data kind. Implemented by child classes
  87740. * @param kind defines the vertex data kind to use
  87741. * @returns null
  87742. */
  87743. getVerticesData(kind: string): Nullable<FloatArray>;
  87744. /**
  87745. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87746. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87747. * Note that a new underlying VertexBuffer object is created each call.
  87748. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87749. * @param kind defines vertex data kind:
  87750. * * VertexBuffer.PositionKind
  87751. * * VertexBuffer.UVKind
  87752. * * VertexBuffer.UV2Kind
  87753. * * VertexBuffer.UV3Kind
  87754. * * VertexBuffer.UV4Kind
  87755. * * VertexBuffer.UV5Kind
  87756. * * VertexBuffer.UV6Kind
  87757. * * VertexBuffer.ColorKind
  87758. * * VertexBuffer.MatricesIndicesKind
  87759. * * VertexBuffer.MatricesIndicesExtraKind
  87760. * * VertexBuffer.MatricesWeightsKind
  87761. * * VertexBuffer.MatricesWeightsExtraKind
  87762. * @param data defines the data source
  87763. * @param updatable defines if the data must be flagged as updatable (or static)
  87764. * @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
  87765. * @returns the current mesh
  87766. */
  87767. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87768. /**
  87769. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87770. * If the mesh has no geometry, it is simply returned as it is.
  87771. * @param kind defines vertex data kind:
  87772. * * VertexBuffer.PositionKind
  87773. * * VertexBuffer.UVKind
  87774. * * VertexBuffer.UV2Kind
  87775. * * VertexBuffer.UV3Kind
  87776. * * VertexBuffer.UV4Kind
  87777. * * VertexBuffer.UV5Kind
  87778. * * VertexBuffer.UV6Kind
  87779. * * VertexBuffer.ColorKind
  87780. * * VertexBuffer.MatricesIndicesKind
  87781. * * VertexBuffer.MatricesIndicesExtraKind
  87782. * * VertexBuffer.MatricesWeightsKind
  87783. * * VertexBuffer.MatricesWeightsExtraKind
  87784. * @param data defines the data source
  87785. * @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
  87786. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  87787. * @returns the current mesh
  87788. */
  87789. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  87790. /**
  87791. * Sets the mesh indices,
  87792. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87793. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  87794. * @param totalVertices Defines the total number of vertices
  87795. * @returns the current mesh
  87796. */
  87797. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  87798. /**
  87799. * Gets a boolean indicating if specific vertex data is present
  87800. * @param kind defines the vertex data kind to use
  87801. * @returns true is data kind is present
  87802. */
  87803. isVerticesDataPresent(kind: string): boolean;
  87804. /**
  87805. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  87806. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  87807. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  87808. * @returns a BoundingInfo
  87809. */
  87810. getBoundingInfo(): BoundingInfo;
  87811. /**
  87812. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87813. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87814. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87815. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87816. * @returns the current mesh
  87817. */
  87818. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  87819. /**
  87820. * Overwrite the current bounding info
  87821. * @param boundingInfo defines the new bounding info
  87822. * @returns the current mesh
  87823. */
  87824. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  87825. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  87826. readonly useBones: boolean;
  87827. /** @hidden */
  87828. _preActivate(): void;
  87829. /** @hidden */
  87830. _preActivateForIntermediateRendering(renderId: number): void;
  87831. /** @hidden */
  87832. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87833. /** @hidden */
  87834. _postActivate(): void;
  87835. /** @hidden */
  87836. _freeze(): void;
  87837. /** @hidden */
  87838. _unFreeze(): void;
  87839. /**
  87840. * Gets the current world matrix
  87841. * @returns a Matrix
  87842. */
  87843. getWorldMatrix(): Matrix;
  87844. /** @hidden */
  87845. _getWorldMatrixDeterminant(): number;
  87846. /**
  87847. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  87848. */
  87849. readonly isAnInstance: boolean;
  87850. /**
  87851. * Perform relative position change from the point of view of behind the front of the mesh.
  87852. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87853. * Supports definition of mesh facing forward or backward
  87854. * @param amountRight defines the distance on the right axis
  87855. * @param amountUp defines the distance on the up axis
  87856. * @param amountForward defines the distance on the forward axis
  87857. * @returns the current mesh
  87858. */
  87859. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  87860. /**
  87861. * Calculate relative position change from the point of view of behind the front of the mesh.
  87862. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87863. * Supports definition of mesh facing forward or backward
  87864. * @param amountRight defines the distance on the right axis
  87865. * @param amountUp defines the distance on the up axis
  87866. * @param amountForward defines the distance on the forward axis
  87867. * @returns the new displacement vector
  87868. */
  87869. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  87870. /**
  87871. * Perform relative rotation change from the point of view of behind the front of the mesh.
  87872. * Supports definition of mesh facing forward or backward
  87873. * @param flipBack defines the flip
  87874. * @param twirlClockwise defines the twirl
  87875. * @param tiltRight defines the tilt
  87876. * @returns the current mesh
  87877. */
  87878. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  87879. /**
  87880. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  87881. * Supports definition of mesh facing forward or backward.
  87882. * @param flipBack defines the flip
  87883. * @param twirlClockwise defines the twirl
  87884. * @param tiltRight defines the tilt
  87885. * @returns the new rotation vector
  87886. */
  87887. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  87888. /**
  87889. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87890. * This means the mesh underlying bounding box and sphere are recomputed.
  87891. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87892. * @returns the current mesh
  87893. */
  87894. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  87895. /** @hidden */
  87896. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  87897. /** @hidden */
  87898. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  87899. /** @hidden */
  87900. _updateBoundingInfo(): AbstractMesh;
  87901. /** @hidden */
  87902. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  87903. /** @hidden */
  87904. protected _afterComputeWorldMatrix(): void;
  87905. /** @hidden */
  87906. readonly _effectiveMesh: AbstractMesh;
  87907. /**
  87908. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87909. * A mesh is in the frustum if its bounding box intersects the frustum
  87910. * @param frustumPlanes defines the frustum to test
  87911. * @returns true if the mesh is in the frustum planes
  87912. */
  87913. isInFrustum(frustumPlanes: Plane[]): boolean;
  87914. /**
  87915. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  87916. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  87917. * @param frustumPlanes defines the frustum to test
  87918. * @returns true if the mesh is completely in the frustum planes
  87919. */
  87920. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87921. /**
  87922. * True if the mesh intersects another mesh or a SolidParticle object
  87923. * @param mesh defines a target mesh or SolidParticle to test
  87924. * @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)
  87925. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  87926. * @returns true if there is an intersection
  87927. */
  87928. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  87929. /**
  87930. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  87931. * @param point defines the point to test
  87932. * @returns true if there is an intersection
  87933. */
  87934. intersectsPoint(point: Vector3): boolean;
  87935. /**
  87936. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  87937. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87938. */
  87939. checkCollisions: boolean;
  87940. /**
  87941. * Gets Collider object used to compute collisions (not physics)
  87942. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87943. */
  87944. readonly collider: Nullable<Collider>;
  87945. /**
  87946. * Move the mesh using collision engine
  87947. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87948. * @param displacement defines the requested displacement vector
  87949. * @returns the current mesh
  87950. */
  87951. moveWithCollisions(displacement: Vector3): AbstractMesh;
  87952. private _onCollisionPositionChange;
  87953. /** @hidden */
  87954. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  87955. /** @hidden */
  87956. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  87957. /** @hidden */
  87958. _checkCollision(collider: Collider): AbstractMesh;
  87959. /** @hidden */
  87960. _generatePointsArray(): boolean;
  87961. /**
  87962. * Checks if the passed Ray intersects with the mesh
  87963. * @param ray defines the ray to use
  87964. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  87965. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87966. * @returns the picking info
  87967. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87968. */
  87969. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  87970. /**
  87971. * Clones the current mesh
  87972. * @param name defines the mesh name
  87973. * @param newParent defines the new mesh parent
  87974. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  87975. * @returns the new mesh
  87976. */
  87977. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87978. /**
  87979. * Disposes all the submeshes of the current meshnp
  87980. * @returns the current mesh
  87981. */
  87982. releaseSubMeshes(): AbstractMesh;
  87983. /**
  87984. * Releases resources associated with this abstract mesh.
  87985. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87986. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87987. */
  87988. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87989. /**
  87990. * Adds the passed mesh as a child to the current mesh
  87991. * @param mesh defines the child mesh
  87992. * @returns the current mesh
  87993. */
  87994. addChild(mesh: AbstractMesh): AbstractMesh;
  87995. /**
  87996. * Removes the passed mesh from the current mesh children list
  87997. * @param mesh defines the child mesh
  87998. * @returns the current mesh
  87999. */
  88000. removeChild(mesh: AbstractMesh): AbstractMesh;
  88001. /** @hidden */
  88002. private _initFacetData;
  88003. /**
  88004. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  88005. * This method can be called within the render loop.
  88006. * 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
  88007. * @returns the current mesh
  88008. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88009. */
  88010. updateFacetData(): AbstractMesh;
  88011. /**
  88012. * Returns the facetLocalNormals array.
  88013. * The normals are expressed in the mesh local spac
  88014. * @returns an array of Vector3
  88015. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88016. */
  88017. getFacetLocalNormals(): Vector3[];
  88018. /**
  88019. * Returns the facetLocalPositions array.
  88020. * The facet positions are expressed in the mesh local space
  88021. * @returns an array of Vector3
  88022. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88023. */
  88024. getFacetLocalPositions(): Vector3[];
  88025. /**
  88026. * Returns the facetLocalPartioning array
  88027. * @returns an array of array of numbers
  88028. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88029. */
  88030. getFacetLocalPartitioning(): number[][];
  88031. /**
  88032. * Returns the i-th facet position in the world system.
  88033. * This method allocates a new Vector3 per call
  88034. * @param i defines the facet index
  88035. * @returns a new Vector3
  88036. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88037. */
  88038. getFacetPosition(i: number): Vector3;
  88039. /**
  88040. * Sets the reference Vector3 with the i-th facet position in the world system
  88041. * @param i defines the facet index
  88042. * @param ref defines the target vector
  88043. * @returns the current mesh
  88044. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88045. */
  88046. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  88047. /**
  88048. * Returns the i-th facet normal in the world system.
  88049. * This method allocates a new Vector3 per call
  88050. * @param i defines the facet index
  88051. * @returns a new Vector3
  88052. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88053. */
  88054. getFacetNormal(i: number): Vector3;
  88055. /**
  88056. * Sets the reference Vector3 with the i-th facet normal in the world system
  88057. * @param i defines the facet index
  88058. * @param ref defines the target vector
  88059. * @returns the current mesh
  88060. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88061. */
  88062. getFacetNormalToRef(i: number, ref: Vector3): this;
  88063. /**
  88064. * 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)
  88065. * @param x defines x coordinate
  88066. * @param y defines y coordinate
  88067. * @param z defines z coordinate
  88068. * @returns the array of facet indexes
  88069. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88070. */
  88071. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  88072. /**
  88073. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  88074. * @param projected sets as the (x,y,z) world projection on the facet
  88075. * @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
  88076. * @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
  88077. * @param x defines x coordinate
  88078. * @param y defines y coordinate
  88079. * @param z defines z coordinate
  88080. * @returns the face index if found (or null instead)
  88081. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88082. */
  88083. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  88084. /**
  88085. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  88086. * @param projected sets as the (x,y,z) local projection on the facet
  88087. * @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
  88088. * @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
  88089. * @param x defines x coordinate
  88090. * @param y defines y coordinate
  88091. * @param z defines z coordinate
  88092. * @returns the face index if found (or null instead)
  88093. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88094. */
  88095. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  88096. /**
  88097. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  88098. * @returns the parameters
  88099. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88100. */
  88101. getFacetDataParameters(): any;
  88102. /**
  88103. * Disables the feature FacetData and frees the related memory
  88104. * @returns the current mesh
  88105. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  88106. */
  88107. disableFacetData(): AbstractMesh;
  88108. /**
  88109. * Updates the AbstractMesh indices array
  88110. * @param indices defines the data source
  88111. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  88112. * @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)
  88113. * @returns the current mesh
  88114. */
  88115. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  88116. /**
  88117. * Creates new normals data for the mesh
  88118. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  88119. * @returns the current mesh
  88120. */
  88121. createNormals(updatable: boolean): AbstractMesh;
  88122. /**
  88123. * Align the mesh with a normal
  88124. * @param normal defines the normal to use
  88125. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  88126. * @returns the current mesh
  88127. */
  88128. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  88129. /** @hidden */
  88130. _checkOcclusionQuery(): boolean;
  88131. /**
  88132. * Disables the mesh edge rendering mode
  88133. * @returns the currentAbstractMesh
  88134. */
  88135. disableEdgesRendering(): AbstractMesh;
  88136. /**
  88137. * Enables the edge rendering mode on the mesh.
  88138. * This mode makes the mesh edges visible
  88139. * @param epsilon defines the maximal distance between two angles to detect a face
  88140. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88141. * @returns the currentAbstractMesh
  88142. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88143. */
  88144. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88145. }
  88146. }
  88147. declare module BABYLON {
  88148. /**
  88149. * Interface used to define ActionEvent
  88150. */
  88151. export interface IActionEvent {
  88152. /** The mesh or sprite that triggered the action */
  88153. source: any;
  88154. /** The X mouse cursor position at the time of the event */
  88155. pointerX: number;
  88156. /** The Y mouse cursor position at the time of the event */
  88157. pointerY: number;
  88158. /** The mesh that is currently pointed at (can be null) */
  88159. meshUnderPointer: Nullable<AbstractMesh>;
  88160. /** the original (browser) event that triggered the ActionEvent */
  88161. sourceEvent?: any;
  88162. /** additional data for the event */
  88163. additionalData?: any;
  88164. }
  88165. /**
  88166. * ActionEvent is the event being sent when an action is triggered.
  88167. */
  88168. export class ActionEvent implements IActionEvent {
  88169. /** The mesh or sprite that triggered the action */
  88170. source: any;
  88171. /** The X mouse cursor position at the time of the event */
  88172. pointerX: number;
  88173. /** The Y mouse cursor position at the time of the event */
  88174. pointerY: number;
  88175. /** The mesh that is currently pointed at (can be null) */
  88176. meshUnderPointer: Nullable<AbstractMesh>;
  88177. /** the original (browser) event that triggered the ActionEvent */
  88178. sourceEvent?: any;
  88179. /** additional data for the event */
  88180. additionalData?: any;
  88181. /**
  88182. * Creates a new ActionEvent
  88183. * @param source The mesh or sprite that triggered the action
  88184. * @param pointerX The X mouse cursor position at the time of the event
  88185. * @param pointerY The Y mouse cursor position at the time of the event
  88186. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  88187. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  88188. * @param additionalData additional data for the event
  88189. */
  88190. constructor(
  88191. /** The mesh or sprite that triggered the action */
  88192. source: any,
  88193. /** The X mouse cursor position at the time of the event */
  88194. pointerX: number,
  88195. /** The Y mouse cursor position at the time of the event */
  88196. pointerY: number,
  88197. /** The mesh that is currently pointed at (can be null) */
  88198. meshUnderPointer: Nullable<AbstractMesh>,
  88199. /** the original (browser) event that triggered the ActionEvent */
  88200. sourceEvent?: any,
  88201. /** additional data for the event */
  88202. additionalData?: any);
  88203. /**
  88204. * Helper function to auto-create an ActionEvent from a source mesh.
  88205. * @param source The source mesh that triggered the event
  88206. * @param evt The original (browser) event
  88207. * @param additionalData additional data for the event
  88208. * @returns the new ActionEvent
  88209. */
  88210. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  88211. /**
  88212. * Helper function to auto-create an ActionEvent from a source sprite
  88213. * @param source The source sprite that triggered the event
  88214. * @param scene Scene associated with the sprite
  88215. * @param evt The original (browser) event
  88216. * @param additionalData additional data for the event
  88217. * @returns the new ActionEvent
  88218. */
  88219. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  88220. /**
  88221. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  88222. * @param scene the scene where the event occurred
  88223. * @param evt The original (browser) event
  88224. * @returns the new ActionEvent
  88225. */
  88226. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  88227. /**
  88228. * Helper function to auto-create an ActionEvent from a primitive
  88229. * @param prim defines the target primitive
  88230. * @param pointerPos defines the pointer position
  88231. * @param evt The original (browser) event
  88232. * @param additionalData additional data for the event
  88233. * @returns the new ActionEvent
  88234. */
  88235. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  88236. }
  88237. }
  88238. declare module BABYLON {
  88239. /**
  88240. * Abstract class used to decouple action Manager from scene and meshes.
  88241. * Do not instantiate.
  88242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  88243. */
  88244. export abstract class AbstractActionManager implements IDisposable {
  88245. /** Gets the list of active triggers */
  88246. static Triggers: {
  88247. [key: string]: number;
  88248. };
  88249. /** Gets the cursor to use when hovering items */
  88250. hoverCursor: string;
  88251. /** Gets the list of actions */
  88252. actions: IAction[];
  88253. /**
  88254. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  88255. */
  88256. isRecursive: boolean;
  88257. /**
  88258. * Releases all associated resources
  88259. */
  88260. abstract dispose(): void;
  88261. /**
  88262. * Does this action manager has pointer triggers
  88263. */
  88264. abstract readonly hasPointerTriggers: boolean;
  88265. /**
  88266. * Does this action manager has pick triggers
  88267. */
  88268. abstract readonly hasPickTriggers: boolean;
  88269. /**
  88270. * Process a specific trigger
  88271. * @param trigger defines the trigger to process
  88272. * @param evt defines the event details to be processed
  88273. */
  88274. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  88275. /**
  88276. * Does this action manager handles actions of any of the given triggers
  88277. * @param triggers defines the triggers to be tested
  88278. * @return a boolean indicating whether one (or more) of the triggers is handled
  88279. */
  88280. abstract hasSpecificTriggers(triggers: number[]): boolean;
  88281. /**
  88282. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  88283. * speed.
  88284. * @param triggerA defines the trigger to be tested
  88285. * @param triggerB defines the trigger to be tested
  88286. * @return a boolean indicating whether one (or more) of the triggers is handled
  88287. */
  88288. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  88289. /**
  88290. * Does this action manager handles actions of a given trigger
  88291. * @param trigger defines the trigger to be tested
  88292. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  88293. * @return whether the trigger is handled
  88294. */
  88295. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  88296. /**
  88297. * Serialize this manager to a JSON object
  88298. * @param name defines the property name to store this manager
  88299. * @returns a JSON representation of this manager
  88300. */
  88301. abstract serialize(name: string): any;
  88302. /**
  88303. * Registers an action to this action manager
  88304. * @param action defines the action to be registered
  88305. * @return the action amended (prepared) after registration
  88306. */
  88307. abstract registerAction(action: IAction): Nullable<IAction>;
  88308. /**
  88309. * Unregisters an action to this action manager
  88310. * @param action defines the action to be unregistered
  88311. * @return a boolean indicating whether the action has been unregistered
  88312. */
  88313. abstract unregisterAction(action: IAction): Boolean;
  88314. /**
  88315. * Does exist one action manager with at least one trigger
  88316. **/
  88317. static readonly HasTriggers: boolean;
  88318. /**
  88319. * Does exist one action manager with at least one pick trigger
  88320. **/
  88321. static readonly HasPickTriggers: boolean;
  88322. /**
  88323. * Does exist one action manager that handles actions of a given trigger
  88324. * @param trigger defines the trigger to be tested
  88325. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  88326. **/
  88327. static HasSpecificTrigger(trigger: number): boolean;
  88328. }
  88329. }
  88330. declare module BABYLON {
  88331. /**
  88332. * Defines how a node can be built from a string name.
  88333. */
  88334. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  88335. /**
  88336. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  88337. */
  88338. export class Node implements IBehaviorAware<Node> {
  88339. /** @hidden */
  88340. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  88341. private static _NodeConstructors;
  88342. /**
  88343. * Add a new node constructor
  88344. * @param type defines the type name of the node to construct
  88345. * @param constructorFunc defines the constructor function
  88346. */
  88347. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  88348. /**
  88349. * Returns a node constructor based on type name
  88350. * @param type defines the type name
  88351. * @param name defines the new node name
  88352. * @param scene defines the hosting scene
  88353. * @param options defines optional options to transmit to constructors
  88354. * @returns the new constructor or null
  88355. */
  88356. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  88357. /**
  88358. * Gets or sets the name of the node
  88359. */
  88360. name: string;
  88361. /**
  88362. * Gets or sets the id of the node
  88363. */
  88364. id: string;
  88365. /**
  88366. * Gets or sets the unique id of the node
  88367. */
  88368. uniqueId: number;
  88369. /**
  88370. * Gets or sets a string used to store user defined state for the node
  88371. */
  88372. state: string;
  88373. /**
  88374. * Gets or sets an object used to store user defined information for the node
  88375. */
  88376. metadata: any;
  88377. /**
  88378. * For internal use only. Please do not use.
  88379. */
  88380. reservedDataStore: any;
  88381. /**
  88382. * List of inspectable custom properties (used by the Inspector)
  88383. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88384. */
  88385. inspectableCustomProperties: IInspectable[];
  88386. /**
  88387. * Gets or sets a boolean used to define if the node must be serialized
  88388. */
  88389. doNotSerialize: boolean;
  88390. /** @hidden */
  88391. _isDisposed: boolean;
  88392. /**
  88393. * Gets a list of Animations associated with the node
  88394. */
  88395. animations: Animation[];
  88396. protected _ranges: {
  88397. [name: string]: Nullable<AnimationRange>;
  88398. };
  88399. /**
  88400. * Callback raised when the node is ready to be used
  88401. */
  88402. onReady: Nullable<(node: Node) => void>;
  88403. private _isEnabled;
  88404. private _isParentEnabled;
  88405. private _isReady;
  88406. /** @hidden */
  88407. _currentRenderId: number;
  88408. private _parentUpdateId;
  88409. /** @hidden */
  88410. _childUpdateId: number;
  88411. /** @hidden */
  88412. _waitingParentId: Nullable<string>;
  88413. /** @hidden */
  88414. _scene: Scene;
  88415. /** @hidden */
  88416. _cache: any;
  88417. private _parentNode;
  88418. private _children;
  88419. /** @hidden */
  88420. _worldMatrix: Matrix;
  88421. /** @hidden */
  88422. _worldMatrixDeterminant: number;
  88423. /** @hidden */
  88424. _worldMatrixDeterminantIsDirty: boolean;
  88425. /** @hidden */
  88426. private _sceneRootNodesIndex;
  88427. /**
  88428. * Gets a boolean indicating if the node has been disposed
  88429. * @returns true if the node was disposed
  88430. */
  88431. isDisposed(): boolean;
  88432. /**
  88433. * Gets or sets the parent of the node (without keeping the current position in the scene)
  88434. * @see https://doc.babylonjs.com/how_to/parenting
  88435. */
  88436. parent: Nullable<Node>;
  88437. private addToSceneRootNodes;
  88438. private removeFromSceneRootNodes;
  88439. private _animationPropertiesOverride;
  88440. /**
  88441. * Gets or sets the animation properties override
  88442. */
  88443. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88444. /**
  88445. * Gets a string idenfifying the name of the class
  88446. * @returns "Node" string
  88447. */
  88448. getClassName(): string;
  88449. /** @hidden */
  88450. readonly _isNode: boolean;
  88451. /**
  88452. * An event triggered when the mesh is disposed
  88453. */
  88454. onDisposeObservable: Observable<Node>;
  88455. private _onDisposeObserver;
  88456. /**
  88457. * Sets a callback that will be raised when the node will be disposed
  88458. */
  88459. onDispose: () => void;
  88460. /**
  88461. * Creates a new Node
  88462. * @param name the name and id to be given to this node
  88463. * @param scene the scene this node will be added to
  88464. * @param addToRootNodes the node will be added to scene.rootNodes
  88465. */
  88466. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  88467. /**
  88468. * Gets the scene of the node
  88469. * @returns a scene
  88470. */
  88471. getScene(): Scene;
  88472. /**
  88473. * Gets the engine of the node
  88474. * @returns a Engine
  88475. */
  88476. getEngine(): Engine;
  88477. private _behaviors;
  88478. /**
  88479. * Attach a behavior to the node
  88480. * @see http://doc.babylonjs.com/features/behaviour
  88481. * @param behavior defines the behavior to attach
  88482. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  88483. * @returns the current Node
  88484. */
  88485. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  88486. /**
  88487. * Remove an attached behavior
  88488. * @see http://doc.babylonjs.com/features/behaviour
  88489. * @param behavior defines the behavior to attach
  88490. * @returns the current Node
  88491. */
  88492. removeBehavior(behavior: Behavior<Node>): Node;
  88493. /**
  88494. * Gets the list of attached behaviors
  88495. * @see http://doc.babylonjs.com/features/behaviour
  88496. */
  88497. readonly behaviors: Behavior<Node>[];
  88498. /**
  88499. * Gets an attached behavior by name
  88500. * @param name defines the name of the behavior to look for
  88501. * @see http://doc.babylonjs.com/features/behaviour
  88502. * @returns null if behavior was not found else the requested behavior
  88503. */
  88504. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  88505. /**
  88506. * Returns the latest update of the World matrix
  88507. * @returns a Matrix
  88508. */
  88509. getWorldMatrix(): Matrix;
  88510. /** @hidden */
  88511. _getWorldMatrixDeterminant(): number;
  88512. /**
  88513. * Returns directly the latest state of the mesh World matrix.
  88514. * A Matrix is returned.
  88515. */
  88516. readonly worldMatrixFromCache: Matrix;
  88517. /** @hidden */
  88518. _initCache(): void;
  88519. /** @hidden */
  88520. updateCache(force?: boolean): void;
  88521. /** @hidden */
  88522. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  88523. /** @hidden */
  88524. _updateCache(ignoreParentClass?: boolean): void;
  88525. /** @hidden */
  88526. _isSynchronized(): boolean;
  88527. /** @hidden */
  88528. _markSyncedWithParent(): void;
  88529. /** @hidden */
  88530. isSynchronizedWithParent(): boolean;
  88531. /** @hidden */
  88532. isSynchronized(): boolean;
  88533. /**
  88534. * Is this node ready to be used/rendered
  88535. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88536. * @return true if the node is ready
  88537. */
  88538. isReady(completeCheck?: boolean): boolean;
  88539. /**
  88540. * Is this node enabled?
  88541. * 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
  88542. * @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
  88543. * @return whether this node (and its parent) is enabled
  88544. */
  88545. isEnabled(checkAncestors?: boolean): boolean;
  88546. /** @hidden */
  88547. protected _syncParentEnabledState(): void;
  88548. /**
  88549. * Set the enabled state of this node
  88550. * @param value defines the new enabled state
  88551. */
  88552. setEnabled(value: boolean): void;
  88553. /**
  88554. * Is this node a descendant of the given node?
  88555. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  88556. * @param ancestor defines the parent node to inspect
  88557. * @returns a boolean indicating if this node is a descendant of the given node
  88558. */
  88559. isDescendantOf(ancestor: Node): boolean;
  88560. /** @hidden */
  88561. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  88562. /**
  88563. * Will return all nodes that have this node as ascendant
  88564. * @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
  88565. * @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
  88566. * @return all children nodes of all types
  88567. */
  88568. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  88569. /**
  88570. * Get all child-meshes of this node
  88571. * @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)
  88572. * @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
  88573. * @returns an array of AbstractMesh
  88574. */
  88575. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  88576. /**
  88577. * Get all direct children of this node
  88578. * @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
  88579. * @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)
  88580. * @returns an array of Node
  88581. */
  88582. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  88583. /** @hidden */
  88584. _setReady(state: boolean): void;
  88585. /**
  88586. * Get an animation by name
  88587. * @param name defines the name of the animation to look for
  88588. * @returns null if not found else the requested animation
  88589. */
  88590. getAnimationByName(name: string): Nullable<Animation>;
  88591. /**
  88592. * Creates an animation range for this node
  88593. * @param name defines the name of the range
  88594. * @param from defines the starting key
  88595. * @param to defines the end key
  88596. */
  88597. createAnimationRange(name: string, from: number, to: number): void;
  88598. /**
  88599. * Delete a specific animation range
  88600. * @param name defines the name of the range to delete
  88601. * @param deleteFrames defines if animation frames from the range must be deleted as well
  88602. */
  88603. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88604. /**
  88605. * Get an animation range by name
  88606. * @param name defines the name of the animation range to look for
  88607. * @returns null if not found else the requested animation range
  88608. */
  88609. getAnimationRange(name: string): Nullable<AnimationRange>;
  88610. /**
  88611. * Gets the list of all animation ranges defined on this node
  88612. * @returns an array
  88613. */
  88614. getAnimationRanges(): Nullable<AnimationRange>[];
  88615. /**
  88616. * Will start the animation sequence
  88617. * @param name defines the range frames for animation sequence
  88618. * @param loop defines if the animation should loop (false by default)
  88619. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  88620. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  88621. * @returns the object created for this animation. If range does not exist, it will return null
  88622. */
  88623. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88624. /**
  88625. * Serialize animation ranges into a JSON compatible object
  88626. * @returns serialization object
  88627. */
  88628. serializeAnimationRanges(): any;
  88629. /**
  88630. * Computes the world matrix of the node
  88631. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88632. * @returns the world matrix
  88633. */
  88634. computeWorldMatrix(force?: boolean): Matrix;
  88635. /**
  88636. * Releases resources associated with this node.
  88637. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88638. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88639. */
  88640. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88641. /**
  88642. * Parse animation range data from a serialization object and store them into a given node
  88643. * @param node defines where to store the animation ranges
  88644. * @param parsedNode defines the serialization object to read data from
  88645. * @param scene defines the hosting scene
  88646. */
  88647. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  88648. /**
  88649. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  88650. * @param includeDescendants Include bounding info from descendants as well (true by default)
  88651. * @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
  88652. * @returns the new bounding vectors
  88653. */
  88654. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  88655. min: Vector3;
  88656. max: Vector3;
  88657. };
  88658. }
  88659. }
  88660. declare module BABYLON {
  88661. /**
  88662. * @hidden
  88663. */
  88664. export class _IAnimationState {
  88665. key: number;
  88666. repeatCount: number;
  88667. workValue?: any;
  88668. loopMode?: number;
  88669. offsetValue?: any;
  88670. highLimitValue?: any;
  88671. }
  88672. /**
  88673. * Class used to store any kind of animation
  88674. */
  88675. export class Animation {
  88676. /**Name of the animation */
  88677. name: string;
  88678. /**Property to animate */
  88679. targetProperty: string;
  88680. /**The frames per second of the animation */
  88681. framePerSecond: number;
  88682. /**The data type of the animation */
  88683. dataType: number;
  88684. /**The loop mode of the animation */
  88685. loopMode?: number | undefined;
  88686. /**Specifies if blending should be enabled */
  88687. enableBlending?: boolean | undefined;
  88688. /**
  88689. * Use matrix interpolation instead of using direct key value when animating matrices
  88690. */
  88691. static AllowMatricesInterpolation: boolean;
  88692. /**
  88693. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  88694. */
  88695. static AllowMatrixDecomposeForInterpolation: boolean;
  88696. /**
  88697. * Stores the key frames of the animation
  88698. */
  88699. private _keys;
  88700. /**
  88701. * Stores the easing function of the animation
  88702. */
  88703. private _easingFunction;
  88704. /**
  88705. * @hidden Internal use only
  88706. */
  88707. _runtimeAnimations: RuntimeAnimation[];
  88708. /**
  88709. * The set of event that will be linked to this animation
  88710. */
  88711. private _events;
  88712. /**
  88713. * Stores an array of target property paths
  88714. */
  88715. targetPropertyPath: string[];
  88716. /**
  88717. * Stores the blending speed of the animation
  88718. */
  88719. blendingSpeed: number;
  88720. /**
  88721. * Stores the animation ranges for the animation
  88722. */
  88723. private _ranges;
  88724. /**
  88725. * @hidden Internal use
  88726. */
  88727. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  88728. /**
  88729. * Sets up an animation
  88730. * @param property The property to animate
  88731. * @param animationType The animation type to apply
  88732. * @param framePerSecond The frames per second of the animation
  88733. * @param easingFunction The easing function used in the animation
  88734. * @returns The created animation
  88735. */
  88736. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  88737. /**
  88738. * Create and start an animation on a node
  88739. * @param name defines the name of the global animation that will be run on all nodes
  88740. * @param node defines the root node where the animation will take place
  88741. * @param targetProperty defines property to animate
  88742. * @param framePerSecond defines the number of frame per second yo use
  88743. * @param totalFrame defines the number of frames in total
  88744. * @param from defines the initial value
  88745. * @param to defines the final value
  88746. * @param loopMode defines which loop mode you want to use (off by default)
  88747. * @param easingFunction defines the easing function to use (linear by default)
  88748. * @param onAnimationEnd defines the callback to call when animation end
  88749. * @returns the animatable created for this animation
  88750. */
  88751. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88752. /**
  88753. * Create and start an animation on a node and its descendants
  88754. * @param name defines the name of the global animation that will be run on all nodes
  88755. * @param node defines the root node where the animation will take place
  88756. * @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
  88757. * @param targetProperty defines property to animate
  88758. * @param framePerSecond defines the number of frame per second to use
  88759. * @param totalFrame defines the number of frames in total
  88760. * @param from defines the initial value
  88761. * @param to defines the final value
  88762. * @param loopMode defines which loop mode you want to use (off by default)
  88763. * @param easingFunction defines the easing function to use (linear by default)
  88764. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88765. * @returns the list of animatables created for all nodes
  88766. * @example https://www.babylonjs-playground.com/#MH0VLI
  88767. */
  88768. 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[]>;
  88769. /**
  88770. * Creates a new animation, merges it with the existing animations and starts it
  88771. * @param name Name of the animation
  88772. * @param node Node which contains the scene that begins the animations
  88773. * @param targetProperty Specifies which property to animate
  88774. * @param framePerSecond The frames per second of the animation
  88775. * @param totalFrame The total number of frames
  88776. * @param from The frame at the beginning of the animation
  88777. * @param to The frame at the end of the animation
  88778. * @param loopMode Specifies the loop mode of the animation
  88779. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  88780. * @param onAnimationEnd Callback to run once the animation is complete
  88781. * @returns Nullable animation
  88782. */
  88783. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88784. /**
  88785. * Transition property of an host to the target Value
  88786. * @param property The property to transition
  88787. * @param targetValue The target Value of the property
  88788. * @param host The object where the property to animate belongs
  88789. * @param scene Scene used to run the animation
  88790. * @param frameRate Framerate (in frame/s) to use
  88791. * @param transition The transition type we want to use
  88792. * @param duration The duration of the animation, in milliseconds
  88793. * @param onAnimationEnd Callback trigger at the end of the animation
  88794. * @returns Nullable animation
  88795. */
  88796. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  88797. /**
  88798. * Return the array of runtime animations currently using this animation
  88799. */
  88800. readonly runtimeAnimations: RuntimeAnimation[];
  88801. /**
  88802. * Specifies if any of the runtime animations are currently running
  88803. */
  88804. readonly hasRunningRuntimeAnimations: boolean;
  88805. /**
  88806. * Initializes the animation
  88807. * @param name Name of the animation
  88808. * @param targetProperty Property to animate
  88809. * @param framePerSecond The frames per second of the animation
  88810. * @param dataType The data type of the animation
  88811. * @param loopMode The loop mode of the animation
  88812. * @param enableBlending Specifies if blending should be enabled
  88813. */
  88814. constructor(
  88815. /**Name of the animation */
  88816. name: string,
  88817. /**Property to animate */
  88818. targetProperty: string,
  88819. /**The frames per second of the animation */
  88820. framePerSecond: number,
  88821. /**The data type of the animation */
  88822. dataType: number,
  88823. /**The loop mode of the animation */
  88824. loopMode?: number | undefined,
  88825. /**Specifies if blending should be enabled */
  88826. enableBlending?: boolean | undefined);
  88827. /**
  88828. * Converts the animation to a string
  88829. * @param fullDetails support for multiple levels of logging within scene loading
  88830. * @returns String form of the animation
  88831. */
  88832. toString(fullDetails?: boolean): string;
  88833. /**
  88834. * Add an event to this animation
  88835. * @param event Event to add
  88836. */
  88837. addEvent(event: AnimationEvent): void;
  88838. /**
  88839. * Remove all events found at the given frame
  88840. * @param frame The frame to remove events from
  88841. */
  88842. removeEvents(frame: number): void;
  88843. /**
  88844. * Retrieves all the events from the animation
  88845. * @returns Events from the animation
  88846. */
  88847. getEvents(): AnimationEvent[];
  88848. /**
  88849. * Creates an animation range
  88850. * @param name Name of the animation range
  88851. * @param from Starting frame of the animation range
  88852. * @param to Ending frame of the animation
  88853. */
  88854. createRange(name: string, from: number, to: number): void;
  88855. /**
  88856. * Deletes an animation range by name
  88857. * @param name Name of the animation range to delete
  88858. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  88859. */
  88860. deleteRange(name: string, deleteFrames?: boolean): void;
  88861. /**
  88862. * Gets the animation range by name, or null if not defined
  88863. * @param name Name of the animation range
  88864. * @returns Nullable animation range
  88865. */
  88866. getRange(name: string): Nullable<AnimationRange>;
  88867. /**
  88868. * Gets the key frames from the animation
  88869. * @returns The key frames of the animation
  88870. */
  88871. getKeys(): Array<IAnimationKey>;
  88872. /**
  88873. * Gets the highest frame rate of the animation
  88874. * @returns Highest frame rate of the animation
  88875. */
  88876. getHighestFrame(): number;
  88877. /**
  88878. * Gets the easing function of the animation
  88879. * @returns Easing function of the animation
  88880. */
  88881. getEasingFunction(): IEasingFunction;
  88882. /**
  88883. * Sets the easing function of the animation
  88884. * @param easingFunction A custom mathematical formula for animation
  88885. */
  88886. setEasingFunction(easingFunction: EasingFunction): void;
  88887. /**
  88888. * Interpolates a scalar linearly
  88889. * @param startValue Start value of the animation curve
  88890. * @param endValue End value of the animation curve
  88891. * @param gradient Scalar amount to interpolate
  88892. * @returns Interpolated scalar value
  88893. */
  88894. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  88895. /**
  88896. * Interpolates a scalar cubically
  88897. * @param startValue Start value of the animation curve
  88898. * @param outTangent End tangent of the animation
  88899. * @param endValue End value of the animation curve
  88900. * @param inTangent Start tangent of the animation curve
  88901. * @param gradient Scalar amount to interpolate
  88902. * @returns Interpolated scalar value
  88903. */
  88904. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  88905. /**
  88906. * Interpolates a quaternion using a spherical linear interpolation
  88907. * @param startValue Start value of the animation curve
  88908. * @param endValue End value of the animation curve
  88909. * @param gradient Scalar amount to interpolate
  88910. * @returns Interpolated quaternion value
  88911. */
  88912. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  88913. /**
  88914. * Interpolates a quaternion cubically
  88915. * @param startValue Start value of the animation curve
  88916. * @param outTangent End tangent of the animation curve
  88917. * @param endValue End value of the animation curve
  88918. * @param inTangent Start tangent of the animation curve
  88919. * @param gradient Scalar amount to interpolate
  88920. * @returns Interpolated quaternion value
  88921. */
  88922. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  88923. /**
  88924. * Interpolates a Vector3 linearl
  88925. * @param startValue Start value of the animation curve
  88926. * @param endValue End value of the animation curve
  88927. * @param gradient Scalar amount to interpolate
  88928. * @returns Interpolated scalar value
  88929. */
  88930. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  88931. /**
  88932. * Interpolates a Vector3 cubically
  88933. * @param startValue Start value of the animation curve
  88934. * @param outTangent End tangent of the animation
  88935. * @param endValue End value of the animation curve
  88936. * @param inTangent Start tangent of the animation curve
  88937. * @param gradient Scalar amount to interpolate
  88938. * @returns InterpolatedVector3 value
  88939. */
  88940. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  88941. /**
  88942. * Interpolates a Vector2 linearly
  88943. * @param startValue Start value of the animation curve
  88944. * @param endValue End value of the animation curve
  88945. * @param gradient Scalar amount to interpolate
  88946. * @returns Interpolated Vector2 value
  88947. */
  88948. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  88949. /**
  88950. * Interpolates a Vector2 cubically
  88951. * @param startValue Start value of the animation curve
  88952. * @param outTangent End tangent of the animation
  88953. * @param endValue End value of the animation curve
  88954. * @param inTangent Start tangent of the animation curve
  88955. * @param gradient Scalar amount to interpolate
  88956. * @returns Interpolated Vector2 value
  88957. */
  88958. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  88959. /**
  88960. * Interpolates a size linearly
  88961. * @param startValue Start value of the animation curve
  88962. * @param endValue End value of the animation curve
  88963. * @param gradient Scalar amount to interpolate
  88964. * @returns Interpolated Size value
  88965. */
  88966. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  88967. /**
  88968. * Interpolates a Color3 linearly
  88969. * @param startValue Start value of the animation curve
  88970. * @param endValue End value of the animation curve
  88971. * @param gradient Scalar amount to interpolate
  88972. * @returns Interpolated Color3 value
  88973. */
  88974. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  88975. /**
  88976. * @hidden Internal use only
  88977. */
  88978. _getKeyValue(value: any): any;
  88979. /**
  88980. * @hidden Internal use only
  88981. */
  88982. _interpolate(currentFrame: number, state: _IAnimationState): any;
  88983. /**
  88984. * Defines the function to use to interpolate matrices
  88985. * @param startValue defines the start matrix
  88986. * @param endValue defines the end matrix
  88987. * @param gradient defines the gradient between both matrices
  88988. * @param result defines an optional target matrix where to store the interpolation
  88989. * @returns the interpolated matrix
  88990. */
  88991. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  88992. /**
  88993. * Makes a copy of the animation
  88994. * @returns Cloned animation
  88995. */
  88996. clone(): Animation;
  88997. /**
  88998. * Sets the key frames of the animation
  88999. * @param values The animation key frames to set
  89000. */
  89001. setKeys(values: Array<IAnimationKey>): void;
  89002. /**
  89003. * Serializes the animation to an object
  89004. * @returns Serialized object
  89005. */
  89006. serialize(): any;
  89007. /**
  89008. * Float animation type
  89009. */
  89010. private static _ANIMATIONTYPE_FLOAT;
  89011. /**
  89012. * Vector3 animation type
  89013. */
  89014. private static _ANIMATIONTYPE_VECTOR3;
  89015. /**
  89016. * Quaternion animation type
  89017. */
  89018. private static _ANIMATIONTYPE_QUATERNION;
  89019. /**
  89020. * Matrix animation type
  89021. */
  89022. private static _ANIMATIONTYPE_MATRIX;
  89023. /**
  89024. * Color3 animation type
  89025. */
  89026. private static _ANIMATIONTYPE_COLOR3;
  89027. /**
  89028. * Vector2 animation type
  89029. */
  89030. private static _ANIMATIONTYPE_VECTOR2;
  89031. /**
  89032. * Size animation type
  89033. */
  89034. private static _ANIMATIONTYPE_SIZE;
  89035. /**
  89036. * Relative Loop Mode
  89037. */
  89038. private static _ANIMATIONLOOPMODE_RELATIVE;
  89039. /**
  89040. * Cycle Loop Mode
  89041. */
  89042. private static _ANIMATIONLOOPMODE_CYCLE;
  89043. /**
  89044. * Constant Loop Mode
  89045. */
  89046. private static _ANIMATIONLOOPMODE_CONSTANT;
  89047. /**
  89048. * Get the float animation type
  89049. */
  89050. static readonly ANIMATIONTYPE_FLOAT: number;
  89051. /**
  89052. * Get the Vector3 animation type
  89053. */
  89054. static readonly ANIMATIONTYPE_VECTOR3: number;
  89055. /**
  89056. * Get the Vector2 animation type
  89057. */
  89058. static readonly ANIMATIONTYPE_VECTOR2: number;
  89059. /**
  89060. * Get the Size animation type
  89061. */
  89062. static readonly ANIMATIONTYPE_SIZE: number;
  89063. /**
  89064. * Get the Quaternion animation type
  89065. */
  89066. static readonly ANIMATIONTYPE_QUATERNION: number;
  89067. /**
  89068. * Get the Matrix animation type
  89069. */
  89070. static readonly ANIMATIONTYPE_MATRIX: number;
  89071. /**
  89072. * Get the Color3 animation type
  89073. */
  89074. static readonly ANIMATIONTYPE_COLOR3: number;
  89075. /**
  89076. * Get the Relative Loop Mode
  89077. */
  89078. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  89079. /**
  89080. * Get the Cycle Loop Mode
  89081. */
  89082. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  89083. /**
  89084. * Get the Constant Loop Mode
  89085. */
  89086. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  89087. /** @hidden */
  89088. static _UniversalLerp(left: any, right: any, amount: number): any;
  89089. /**
  89090. * Parses an animation object and creates an animation
  89091. * @param parsedAnimation Parsed animation object
  89092. * @returns Animation object
  89093. */
  89094. static Parse(parsedAnimation: any): Animation;
  89095. /**
  89096. * Appends the serialized animations from the source animations
  89097. * @param source Source containing the animations
  89098. * @param destination Target to store the animations
  89099. */
  89100. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  89101. }
  89102. }
  89103. declare module BABYLON {
  89104. /**
  89105. * Base class of all the textures in babylon.
  89106. * It groups all the common properties the materials, post process, lights... might need
  89107. * in order to make a correct use of the texture.
  89108. */
  89109. export class BaseTexture implements IAnimatable {
  89110. /**
  89111. * Default anisotropic filtering level for the application.
  89112. * It is set to 4 as a good tradeoff between perf and quality.
  89113. */
  89114. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  89115. /**
  89116. * Gets or sets the unique id of the texture
  89117. */
  89118. uniqueId: number;
  89119. /**
  89120. * Define the name of the texture.
  89121. */
  89122. name: string;
  89123. /**
  89124. * Gets or sets an object used to store user defined information.
  89125. */
  89126. metadata: any;
  89127. /**
  89128. * For internal use only. Please do not use.
  89129. */
  89130. reservedDataStore: any;
  89131. private _hasAlpha;
  89132. /**
  89133. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  89134. */
  89135. hasAlpha: boolean;
  89136. /**
  89137. * Defines if the alpha value should be determined via the rgb values.
  89138. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  89139. */
  89140. getAlphaFromRGB: boolean;
  89141. /**
  89142. * Intensity or strength of the texture.
  89143. * It is commonly used by materials to fine tune the intensity of the texture
  89144. */
  89145. level: number;
  89146. /**
  89147. * Define the UV chanel to use starting from 0 and defaulting to 0.
  89148. * This is part of the texture as textures usually maps to one uv set.
  89149. */
  89150. coordinatesIndex: number;
  89151. private _coordinatesMode;
  89152. /**
  89153. * How a texture is mapped.
  89154. *
  89155. * | Value | Type | Description |
  89156. * | ----- | ----------------------------------- | ----------- |
  89157. * | 0 | EXPLICIT_MODE | |
  89158. * | 1 | SPHERICAL_MODE | |
  89159. * | 2 | PLANAR_MODE | |
  89160. * | 3 | CUBIC_MODE | |
  89161. * | 4 | PROJECTION_MODE | |
  89162. * | 5 | SKYBOX_MODE | |
  89163. * | 6 | INVCUBIC_MODE | |
  89164. * | 7 | EQUIRECTANGULAR_MODE | |
  89165. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  89166. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  89167. */
  89168. coordinatesMode: number;
  89169. /**
  89170. * | Value | Type | Description |
  89171. * | ----- | ------------------ | ----------- |
  89172. * | 0 | CLAMP_ADDRESSMODE | |
  89173. * | 1 | WRAP_ADDRESSMODE | |
  89174. * | 2 | MIRROR_ADDRESSMODE | |
  89175. */
  89176. wrapU: number;
  89177. /**
  89178. * | Value | Type | Description |
  89179. * | ----- | ------------------ | ----------- |
  89180. * | 0 | CLAMP_ADDRESSMODE | |
  89181. * | 1 | WRAP_ADDRESSMODE | |
  89182. * | 2 | MIRROR_ADDRESSMODE | |
  89183. */
  89184. wrapV: number;
  89185. /**
  89186. * | Value | Type | Description |
  89187. * | ----- | ------------------ | ----------- |
  89188. * | 0 | CLAMP_ADDRESSMODE | |
  89189. * | 1 | WRAP_ADDRESSMODE | |
  89190. * | 2 | MIRROR_ADDRESSMODE | |
  89191. */
  89192. wrapR: number;
  89193. /**
  89194. * With compliant hardware and browser (supporting anisotropic filtering)
  89195. * this defines the level of anisotropic filtering in the texture.
  89196. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  89197. */
  89198. anisotropicFilteringLevel: number;
  89199. /**
  89200. * Define if the texture is a cube texture or if false a 2d texture.
  89201. */
  89202. isCube: boolean;
  89203. /**
  89204. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  89205. */
  89206. is3D: boolean;
  89207. /**
  89208. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  89209. * HDR texture are usually stored in linear space.
  89210. * This only impacts the PBR and Background materials
  89211. */
  89212. gammaSpace: boolean;
  89213. /**
  89214. * Gets whether or not the texture contains RGBD data.
  89215. */
  89216. readonly isRGBD: boolean;
  89217. /**
  89218. * Is Z inverted in the texture (useful in a cube texture).
  89219. */
  89220. invertZ: boolean;
  89221. /**
  89222. * Are mip maps generated for this texture or not.
  89223. */
  89224. readonly noMipmap: boolean;
  89225. /**
  89226. * @hidden
  89227. */
  89228. lodLevelInAlpha: boolean;
  89229. /**
  89230. * With prefiltered texture, defined the offset used during the prefiltering steps.
  89231. */
  89232. lodGenerationOffset: number;
  89233. /**
  89234. * With prefiltered texture, defined the scale used during the prefiltering steps.
  89235. */
  89236. lodGenerationScale: number;
  89237. /**
  89238. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  89239. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  89240. * average roughness values.
  89241. */
  89242. linearSpecularLOD: boolean;
  89243. /**
  89244. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  89245. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  89246. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  89247. */
  89248. irradianceTexture: Nullable<BaseTexture>;
  89249. /**
  89250. * Define if the texture is a render target.
  89251. */
  89252. isRenderTarget: boolean;
  89253. /**
  89254. * Define the unique id of the texture in the scene.
  89255. */
  89256. readonly uid: string;
  89257. /**
  89258. * Return a string representation of the texture.
  89259. * @returns the texture as a string
  89260. */
  89261. toString(): string;
  89262. /**
  89263. * Get the class name of the texture.
  89264. * @returns "BaseTexture"
  89265. */
  89266. getClassName(): string;
  89267. /**
  89268. * Define the list of animation attached to the texture.
  89269. */
  89270. animations: Animation[];
  89271. /**
  89272. * An event triggered when the texture is disposed.
  89273. */
  89274. onDisposeObservable: Observable<BaseTexture>;
  89275. private _onDisposeObserver;
  89276. /**
  89277. * Callback triggered when the texture has been disposed.
  89278. * Kept for back compatibility, you can use the onDisposeObservable instead.
  89279. */
  89280. onDispose: () => void;
  89281. /**
  89282. * Define the current state of the loading sequence when in delayed load mode.
  89283. */
  89284. delayLoadState: number;
  89285. private _scene;
  89286. /** @hidden */
  89287. _texture: Nullable<InternalTexture>;
  89288. private _uid;
  89289. /**
  89290. * Define if the texture is preventinga material to render or not.
  89291. * If not and the texture is not ready, the engine will use a default black texture instead.
  89292. */
  89293. readonly isBlocking: boolean;
  89294. /**
  89295. * Instantiates a new BaseTexture.
  89296. * Base class of all the textures in babylon.
  89297. * It groups all the common properties the materials, post process, lights... might need
  89298. * in order to make a correct use of the texture.
  89299. * @param scene Define the scene the texture blongs to
  89300. */
  89301. constructor(scene: Nullable<Scene>);
  89302. /**
  89303. * Get the scene the texture belongs to.
  89304. * @returns the scene or null if undefined
  89305. */
  89306. getScene(): Nullable<Scene>;
  89307. /**
  89308. * Get the texture transform matrix used to offset tile the texture for istance.
  89309. * @returns the transformation matrix
  89310. */
  89311. getTextureMatrix(): Matrix;
  89312. /**
  89313. * Get the texture reflection matrix used to rotate/transform the reflection.
  89314. * @returns the reflection matrix
  89315. */
  89316. getReflectionTextureMatrix(): Matrix;
  89317. /**
  89318. * Get the underlying lower level texture from Babylon.
  89319. * @returns the insternal texture
  89320. */
  89321. getInternalTexture(): Nullable<InternalTexture>;
  89322. /**
  89323. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  89324. * @returns true if ready or not blocking
  89325. */
  89326. isReadyOrNotBlocking(): boolean;
  89327. /**
  89328. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  89329. * @returns true if fully ready
  89330. */
  89331. isReady(): boolean;
  89332. private _cachedSize;
  89333. /**
  89334. * Get the size of the texture.
  89335. * @returns the texture size.
  89336. */
  89337. getSize(): ISize;
  89338. /**
  89339. * Get the base size of the texture.
  89340. * It can be different from the size if the texture has been resized for POT for instance
  89341. * @returns the base size
  89342. */
  89343. getBaseSize(): ISize;
  89344. /**
  89345. * Update the sampling mode of the texture.
  89346. * Default is Trilinear mode.
  89347. *
  89348. * | Value | Type | Description |
  89349. * | ----- | ------------------ | ----------- |
  89350. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  89351. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  89352. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  89353. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  89354. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  89355. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  89356. * | 7 | NEAREST_LINEAR | |
  89357. * | 8 | NEAREST_NEAREST | |
  89358. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  89359. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  89360. * | 11 | LINEAR_LINEAR | |
  89361. * | 12 | LINEAR_NEAREST | |
  89362. *
  89363. * > _mag_: magnification filter (close to the viewer)
  89364. * > _min_: minification filter (far from the viewer)
  89365. * > _mip_: filter used between mip map levels
  89366. *@param samplingMode Define the new sampling mode of the texture
  89367. */
  89368. updateSamplingMode(samplingMode: number): void;
  89369. /**
  89370. * Scales the texture if is `canRescale()`
  89371. * @param ratio the resize factor we want to use to rescale
  89372. */
  89373. scale(ratio: number): void;
  89374. /**
  89375. * Get if the texture can rescale.
  89376. */
  89377. readonly canRescale: boolean;
  89378. /** @hidden */
  89379. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  89380. /** @hidden */
  89381. _rebuild(): void;
  89382. /**
  89383. * Triggers the load sequence in delayed load mode.
  89384. */
  89385. delayLoad(): void;
  89386. /**
  89387. * Clones the texture.
  89388. * @returns the cloned texture
  89389. */
  89390. clone(): Nullable<BaseTexture>;
  89391. /**
  89392. * Get the texture underlying type (INT, FLOAT...)
  89393. */
  89394. readonly textureType: number;
  89395. /**
  89396. * Get the texture underlying format (RGB, RGBA...)
  89397. */
  89398. readonly textureFormat: number;
  89399. /**
  89400. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  89401. * This will returns an RGBA array buffer containing either in values (0-255) or
  89402. * float values (0-1) depending of the underlying buffer type.
  89403. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  89404. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  89405. * @param buffer defines a user defined buffer to fill with data (can be null)
  89406. * @returns The Array buffer containing the pixels data.
  89407. */
  89408. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  89409. /**
  89410. * Release and destroy the underlying lower level texture aka internalTexture.
  89411. */
  89412. releaseInternalTexture(): void;
  89413. /**
  89414. * Get the polynomial representation of the texture data.
  89415. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  89416. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  89417. */
  89418. sphericalPolynomial: Nullable<SphericalPolynomial>;
  89419. /** @hidden */
  89420. readonly _lodTextureHigh: Nullable<BaseTexture>;
  89421. /** @hidden */
  89422. readonly _lodTextureMid: Nullable<BaseTexture>;
  89423. /** @hidden */
  89424. readonly _lodTextureLow: Nullable<BaseTexture>;
  89425. /**
  89426. * Dispose the texture and release its associated resources.
  89427. */
  89428. dispose(): void;
  89429. /**
  89430. * Serialize the texture into a JSON representation that can be parsed later on.
  89431. * @returns the JSON representation of the texture
  89432. */
  89433. serialize(): any;
  89434. /**
  89435. * Helper function to be called back once a list of texture contains only ready textures.
  89436. * @param textures Define the list of textures to wait for
  89437. * @param callback Define the callback triggered once the entire list will be ready
  89438. */
  89439. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  89440. }
  89441. }
  89442. declare module BABYLON {
  89443. /**
  89444. * Uniform buffer objects.
  89445. *
  89446. * Handles blocks of uniform on the GPU.
  89447. *
  89448. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89449. *
  89450. * For more information, please refer to :
  89451. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89452. */
  89453. export class UniformBuffer {
  89454. private _engine;
  89455. private _buffer;
  89456. private _data;
  89457. private _bufferData;
  89458. private _dynamic?;
  89459. private _uniformLocations;
  89460. private _uniformSizes;
  89461. private _uniformLocationPointer;
  89462. private _needSync;
  89463. private _noUBO;
  89464. private _currentEffect;
  89465. private static _MAX_UNIFORM_SIZE;
  89466. private static _tempBuffer;
  89467. /**
  89468. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  89469. * This is dynamic to allow compat with webgl 1 and 2.
  89470. * You will need to pass the name of the uniform as well as the value.
  89471. */
  89472. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  89473. /**
  89474. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  89475. * This is dynamic to allow compat with webgl 1 and 2.
  89476. * You will need to pass the name of the uniform as well as the value.
  89477. */
  89478. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  89479. /**
  89480. * Lambda to Update a single float in a uniform buffer.
  89481. * This is dynamic to allow compat with webgl 1 and 2.
  89482. * You will need to pass the name of the uniform as well as the value.
  89483. */
  89484. updateFloat: (name: string, x: number) => void;
  89485. /**
  89486. * Lambda to Update a vec2 of float in a uniform buffer.
  89487. * This is dynamic to allow compat with webgl 1 and 2.
  89488. * You will need to pass the name of the uniform as well as the value.
  89489. */
  89490. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  89491. /**
  89492. * Lambda to Update a vec3 of float in a uniform buffer.
  89493. * This is dynamic to allow compat with webgl 1 and 2.
  89494. * You will need to pass the name of the uniform as well as the value.
  89495. */
  89496. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  89497. /**
  89498. * Lambda to Update a vec4 of float in a uniform buffer.
  89499. * This is dynamic to allow compat with webgl 1 and 2.
  89500. * You will need to pass the name of the uniform as well as the value.
  89501. */
  89502. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  89503. /**
  89504. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  89505. * This is dynamic to allow compat with webgl 1 and 2.
  89506. * You will need to pass the name of the uniform as well as the value.
  89507. */
  89508. updateMatrix: (name: string, mat: Matrix) => void;
  89509. /**
  89510. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  89511. * This is dynamic to allow compat with webgl 1 and 2.
  89512. * You will need to pass the name of the uniform as well as the value.
  89513. */
  89514. updateVector3: (name: string, vector: Vector3) => void;
  89515. /**
  89516. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  89517. * This is dynamic to allow compat with webgl 1 and 2.
  89518. * You will need to pass the name of the uniform as well as the value.
  89519. */
  89520. updateVector4: (name: string, vector: Vector4) => void;
  89521. /**
  89522. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  89523. * This is dynamic to allow compat with webgl 1 and 2.
  89524. * You will need to pass the name of the uniform as well as the value.
  89525. */
  89526. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  89527. /**
  89528. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  89529. * This is dynamic to allow compat with webgl 1 and 2.
  89530. * You will need to pass the name of the uniform as well as the value.
  89531. */
  89532. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  89533. /**
  89534. * Instantiates a new Uniform buffer objects.
  89535. *
  89536. * Handles blocks of uniform on the GPU.
  89537. *
  89538. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89539. *
  89540. * For more information, please refer to :
  89541. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89542. * @param engine Define the engine the buffer is associated with
  89543. * @param data Define the data contained in the buffer
  89544. * @param dynamic Define if the buffer is updatable
  89545. */
  89546. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  89547. /**
  89548. * Indicates if the buffer is using the WebGL2 UBO implementation,
  89549. * or just falling back on setUniformXXX calls.
  89550. */
  89551. readonly useUbo: boolean;
  89552. /**
  89553. * Indicates if the WebGL underlying uniform buffer is in sync
  89554. * with the javascript cache data.
  89555. */
  89556. readonly isSync: boolean;
  89557. /**
  89558. * Indicates if the WebGL underlying uniform buffer is dynamic.
  89559. * Also, a dynamic UniformBuffer will disable cache verification and always
  89560. * update the underlying WebGL uniform buffer to the GPU.
  89561. * @returns if Dynamic, otherwise false
  89562. */
  89563. isDynamic(): boolean;
  89564. /**
  89565. * The data cache on JS side.
  89566. * @returns the underlying data as a float array
  89567. */
  89568. getData(): Float32Array;
  89569. /**
  89570. * The underlying WebGL Uniform buffer.
  89571. * @returns the webgl buffer
  89572. */
  89573. getBuffer(): Nullable<DataBuffer>;
  89574. /**
  89575. * std140 layout specifies how to align data within an UBO structure.
  89576. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  89577. * for specs.
  89578. */
  89579. private _fillAlignment;
  89580. /**
  89581. * Adds an uniform in the buffer.
  89582. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  89583. * for the layout to be correct !
  89584. * @param name Name of the uniform, as used in the uniform block in the shader.
  89585. * @param size Data size, or data directly.
  89586. */
  89587. addUniform(name: string, size: number | number[]): void;
  89588. /**
  89589. * Adds a Matrix 4x4 to the uniform buffer.
  89590. * @param name Name of the uniform, as used in the uniform block in the shader.
  89591. * @param mat A 4x4 matrix.
  89592. */
  89593. addMatrix(name: string, mat: Matrix): void;
  89594. /**
  89595. * Adds a vec2 to the uniform buffer.
  89596. * @param name Name of the uniform, as used in the uniform block in the shader.
  89597. * @param x Define the x component value of the vec2
  89598. * @param y Define the y component value of the vec2
  89599. */
  89600. addFloat2(name: string, x: number, y: number): void;
  89601. /**
  89602. * Adds a vec3 to the uniform buffer.
  89603. * @param name Name of the uniform, as used in the uniform block in the shader.
  89604. * @param x Define the x component value of the vec3
  89605. * @param y Define the y component value of the vec3
  89606. * @param z Define the z component value of the vec3
  89607. */
  89608. addFloat3(name: string, x: number, y: number, z: number): void;
  89609. /**
  89610. * Adds a vec3 to the uniform buffer.
  89611. * @param name Name of the uniform, as used in the uniform block in the shader.
  89612. * @param color Define the vec3 from a Color
  89613. */
  89614. addColor3(name: string, color: Color3): void;
  89615. /**
  89616. * Adds a vec4 to the uniform buffer.
  89617. * @param name Name of the uniform, as used in the uniform block in the shader.
  89618. * @param color Define the rgb components from a Color
  89619. * @param alpha Define the a component of the vec4
  89620. */
  89621. addColor4(name: string, color: Color3, alpha: number): void;
  89622. /**
  89623. * Adds a vec3 to the uniform buffer.
  89624. * @param name Name of the uniform, as used in the uniform block in the shader.
  89625. * @param vector Define the vec3 components from a Vector
  89626. */
  89627. addVector3(name: string, vector: Vector3): void;
  89628. /**
  89629. * Adds a Matrix 3x3 to the uniform buffer.
  89630. * @param name Name of the uniform, as used in the uniform block in the shader.
  89631. */
  89632. addMatrix3x3(name: string): void;
  89633. /**
  89634. * Adds a Matrix 2x2 to the uniform buffer.
  89635. * @param name Name of the uniform, as used in the uniform block in the shader.
  89636. */
  89637. addMatrix2x2(name: string): void;
  89638. /**
  89639. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  89640. */
  89641. create(): void;
  89642. /** @hidden */
  89643. _rebuild(): void;
  89644. /**
  89645. * Updates the WebGL Uniform Buffer on the GPU.
  89646. * If the `dynamic` flag is set to true, no cache comparison is done.
  89647. * Otherwise, the buffer will be updated only if the cache differs.
  89648. */
  89649. update(): void;
  89650. /**
  89651. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  89652. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89653. * @param data Define the flattened data
  89654. * @param size Define the size of the data.
  89655. */
  89656. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  89657. private _updateMatrix3x3ForUniform;
  89658. private _updateMatrix3x3ForEffect;
  89659. private _updateMatrix2x2ForEffect;
  89660. private _updateMatrix2x2ForUniform;
  89661. private _updateFloatForEffect;
  89662. private _updateFloatForUniform;
  89663. private _updateFloat2ForEffect;
  89664. private _updateFloat2ForUniform;
  89665. private _updateFloat3ForEffect;
  89666. private _updateFloat3ForUniform;
  89667. private _updateFloat4ForEffect;
  89668. private _updateFloat4ForUniform;
  89669. private _updateMatrixForEffect;
  89670. private _updateMatrixForUniform;
  89671. private _updateVector3ForEffect;
  89672. private _updateVector3ForUniform;
  89673. private _updateVector4ForEffect;
  89674. private _updateVector4ForUniform;
  89675. private _updateColor3ForEffect;
  89676. private _updateColor3ForUniform;
  89677. private _updateColor4ForEffect;
  89678. private _updateColor4ForUniform;
  89679. /**
  89680. * Sets a sampler uniform on the effect.
  89681. * @param name Define the name of the sampler.
  89682. * @param texture Define the texture to set in the sampler
  89683. */
  89684. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  89685. /**
  89686. * Directly updates the value of the uniform in the cache AND on the GPU.
  89687. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89688. * @param data Define the flattened data
  89689. */
  89690. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  89691. /**
  89692. * Binds this uniform buffer to an effect.
  89693. * @param effect Define the effect to bind the buffer to
  89694. * @param name Name of the uniform block in the shader.
  89695. */
  89696. bindToEffect(effect: Effect, name: string): void;
  89697. /**
  89698. * Disposes the uniform buffer.
  89699. */
  89700. dispose(): void;
  89701. }
  89702. }
  89703. declare module BABYLON {
  89704. /**
  89705. * Class used to work with sound analyzer using fast fourier transform (FFT)
  89706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89707. */
  89708. export class Analyser {
  89709. /**
  89710. * Gets or sets the smoothing
  89711. * @ignorenaming
  89712. */
  89713. SMOOTHING: number;
  89714. /**
  89715. * Gets or sets the FFT table size
  89716. * @ignorenaming
  89717. */
  89718. FFT_SIZE: number;
  89719. /**
  89720. * Gets or sets the bar graph amplitude
  89721. * @ignorenaming
  89722. */
  89723. BARGRAPHAMPLITUDE: number;
  89724. /**
  89725. * Gets or sets the position of the debug canvas
  89726. * @ignorenaming
  89727. */
  89728. DEBUGCANVASPOS: {
  89729. x: number;
  89730. y: number;
  89731. };
  89732. /**
  89733. * Gets or sets the debug canvas size
  89734. * @ignorenaming
  89735. */
  89736. DEBUGCANVASSIZE: {
  89737. width: number;
  89738. height: number;
  89739. };
  89740. private _byteFreqs;
  89741. private _byteTime;
  89742. private _floatFreqs;
  89743. private _webAudioAnalyser;
  89744. private _debugCanvas;
  89745. private _debugCanvasContext;
  89746. private _scene;
  89747. private _registerFunc;
  89748. private _audioEngine;
  89749. /**
  89750. * Creates a new analyser
  89751. * @param scene defines hosting scene
  89752. */
  89753. constructor(scene: Scene);
  89754. /**
  89755. * Get the number of data values you will have to play with for the visualization
  89756. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  89757. * @returns a number
  89758. */
  89759. getFrequencyBinCount(): number;
  89760. /**
  89761. * Gets the current frequency data as a byte array
  89762. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89763. * @returns a Uint8Array
  89764. */
  89765. getByteFrequencyData(): Uint8Array;
  89766. /**
  89767. * Gets the current waveform as a byte array
  89768. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  89769. * @returns a Uint8Array
  89770. */
  89771. getByteTimeDomainData(): Uint8Array;
  89772. /**
  89773. * Gets the current frequency data as a float array
  89774. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89775. * @returns a Float32Array
  89776. */
  89777. getFloatFrequencyData(): Float32Array;
  89778. /**
  89779. * Renders the debug canvas
  89780. */
  89781. drawDebugCanvas(): void;
  89782. /**
  89783. * Stops rendering the debug canvas and removes it
  89784. */
  89785. stopDebugCanvas(): void;
  89786. /**
  89787. * Connects two audio nodes
  89788. * @param inputAudioNode defines first node to connect
  89789. * @param outputAudioNode defines second node to connect
  89790. */
  89791. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  89792. /**
  89793. * Releases all associated resources
  89794. */
  89795. dispose(): void;
  89796. }
  89797. }
  89798. declare module BABYLON {
  89799. /**
  89800. * This represents an audio engine and it is responsible
  89801. * to play, synchronize and analyse sounds throughout the application.
  89802. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89803. */
  89804. export interface IAudioEngine extends IDisposable {
  89805. /**
  89806. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89807. */
  89808. readonly canUseWebAudio: boolean;
  89809. /**
  89810. * Gets the current AudioContext if available.
  89811. */
  89812. readonly audioContext: Nullable<AudioContext>;
  89813. /**
  89814. * The master gain node defines the global audio volume of your audio engine.
  89815. */
  89816. readonly masterGain: GainNode;
  89817. /**
  89818. * Gets whether or not mp3 are supported by your browser.
  89819. */
  89820. readonly isMP3supported: boolean;
  89821. /**
  89822. * Gets whether or not ogg are supported by your browser.
  89823. */
  89824. readonly isOGGsupported: boolean;
  89825. /**
  89826. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89827. * @ignoreNaming
  89828. */
  89829. WarnedWebAudioUnsupported: boolean;
  89830. /**
  89831. * Defines if the audio engine relies on a custom unlocked button.
  89832. * In this case, the embedded button will not be displayed.
  89833. */
  89834. useCustomUnlockedButton: boolean;
  89835. /**
  89836. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  89837. */
  89838. readonly unlocked: boolean;
  89839. /**
  89840. * Event raised when audio has been unlocked on the browser.
  89841. */
  89842. onAudioUnlockedObservable: Observable<AudioEngine>;
  89843. /**
  89844. * Event raised when audio has been locked on the browser.
  89845. */
  89846. onAudioLockedObservable: Observable<AudioEngine>;
  89847. /**
  89848. * Flags the audio engine in Locked state.
  89849. * This happens due to new browser policies preventing audio to autoplay.
  89850. */
  89851. lock(): void;
  89852. /**
  89853. * Unlocks the audio engine once a user action has been done on the dom.
  89854. * This is helpful to resume play once browser policies have been satisfied.
  89855. */
  89856. unlock(): void;
  89857. }
  89858. /**
  89859. * This represents the default audio engine used in babylon.
  89860. * It is responsible to play, synchronize and analyse sounds throughout the application.
  89861. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89862. */
  89863. export class AudioEngine implements IAudioEngine {
  89864. private _audioContext;
  89865. private _audioContextInitialized;
  89866. private _muteButton;
  89867. private _hostElement;
  89868. /**
  89869. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89870. */
  89871. canUseWebAudio: boolean;
  89872. /**
  89873. * The master gain node defines the global audio volume of your audio engine.
  89874. */
  89875. masterGain: GainNode;
  89876. /**
  89877. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89878. * @ignoreNaming
  89879. */
  89880. WarnedWebAudioUnsupported: boolean;
  89881. /**
  89882. * Gets whether or not mp3 are supported by your browser.
  89883. */
  89884. isMP3supported: boolean;
  89885. /**
  89886. * Gets whether or not ogg are supported by your browser.
  89887. */
  89888. isOGGsupported: boolean;
  89889. /**
  89890. * Gets whether audio has been unlocked on the device.
  89891. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  89892. * a user interaction has happened.
  89893. */
  89894. unlocked: boolean;
  89895. /**
  89896. * Defines if the audio engine relies on a custom unlocked button.
  89897. * In this case, the embedded button will not be displayed.
  89898. */
  89899. useCustomUnlockedButton: boolean;
  89900. /**
  89901. * Event raised when audio has been unlocked on the browser.
  89902. */
  89903. onAudioUnlockedObservable: Observable<AudioEngine>;
  89904. /**
  89905. * Event raised when audio has been locked on the browser.
  89906. */
  89907. onAudioLockedObservable: Observable<AudioEngine>;
  89908. /**
  89909. * Gets the current AudioContext if available.
  89910. */
  89911. readonly audioContext: Nullable<AudioContext>;
  89912. private _connectedAnalyser;
  89913. /**
  89914. * Instantiates a new audio engine.
  89915. *
  89916. * There should be only one per page as some browsers restrict the number
  89917. * of audio contexts you can create.
  89918. * @param hostElement defines the host element where to display the mute icon if necessary
  89919. */
  89920. constructor(hostElement?: Nullable<HTMLElement>);
  89921. /**
  89922. * Flags the audio engine in Locked state.
  89923. * This happens due to new browser policies preventing audio to autoplay.
  89924. */
  89925. lock(): void;
  89926. /**
  89927. * Unlocks the audio engine once a user action has been done on the dom.
  89928. * This is helpful to resume play once browser policies have been satisfied.
  89929. */
  89930. unlock(): void;
  89931. private _resumeAudioContext;
  89932. private _initializeAudioContext;
  89933. private _tryToRun;
  89934. private _triggerRunningState;
  89935. private _triggerSuspendedState;
  89936. private _displayMuteButton;
  89937. private _moveButtonToTopLeft;
  89938. private _onResize;
  89939. private _hideMuteButton;
  89940. /**
  89941. * Destroy and release the resources associated with the audio ccontext.
  89942. */
  89943. dispose(): void;
  89944. /**
  89945. * Gets the global volume sets on the master gain.
  89946. * @returns the global volume if set or -1 otherwise
  89947. */
  89948. getGlobalVolume(): number;
  89949. /**
  89950. * Sets the global volume of your experience (sets on the master gain).
  89951. * @param newVolume Defines the new global volume of the application
  89952. */
  89953. setGlobalVolume(newVolume: number): void;
  89954. /**
  89955. * Connect the audio engine to an audio analyser allowing some amazing
  89956. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  89957. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  89958. * @param analyser The analyser to connect to the engine
  89959. */
  89960. connectToAnalyser(analyser: Analyser): void;
  89961. }
  89962. }
  89963. declare module BABYLON {
  89964. /**
  89965. * Interface used to present a loading screen while loading a scene
  89966. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89967. */
  89968. export interface ILoadingScreen {
  89969. /**
  89970. * Function called to display the loading screen
  89971. */
  89972. displayLoadingUI: () => void;
  89973. /**
  89974. * Function called to hide the loading screen
  89975. */
  89976. hideLoadingUI: () => void;
  89977. /**
  89978. * Gets or sets the color to use for the background
  89979. */
  89980. loadingUIBackgroundColor: string;
  89981. /**
  89982. * Gets or sets the text to display while loading
  89983. */
  89984. loadingUIText: string;
  89985. }
  89986. /**
  89987. * Class used for the default loading screen
  89988. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89989. */
  89990. export class DefaultLoadingScreen implements ILoadingScreen {
  89991. private _renderingCanvas;
  89992. private _loadingText;
  89993. private _loadingDivBackgroundColor;
  89994. private _loadingDiv;
  89995. private _loadingTextDiv;
  89996. /** Gets or sets the logo url to use for the default loading screen */
  89997. static DefaultLogoUrl: string;
  89998. /** Gets or sets the spinner url to use for the default loading screen */
  89999. static DefaultSpinnerUrl: string;
  90000. /**
  90001. * Creates a new default loading screen
  90002. * @param _renderingCanvas defines the canvas used to render the scene
  90003. * @param _loadingText defines the default text to display
  90004. * @param _loadingDivBackgroundColor defines the default background color
  90005. */
  90006. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  90007. /**
  90008. * Function called to display the loading screen
  90009. */
  90010. displayLoadingUI(): void;
  90011. /**
  90012. * Function called to hide the loading screen
  90013. */
  90014. hideLoadingUI(): void;
  90015. /**
  90016. * Gets or sets the text to display while loading
  90017. */
  90018. loadingUIText: string;
  90019. /**
  90020. * Gets or sets the color to use for the background
  90021. */
  90022. loadingUIBackgroundColor: string;
  90023. private _resizeLoadingUI;
  90024. }
  90025. }
  90026. declare module BABYLON {
  90027. /** @hidden */
  90028. export class WebGLPipelineContext implements IPipelineContext {
  90029. engine: Engine;
  90030. program: Nullable<WebGLProgram>;
  90031. context?: WebGLRenderingContext;
  90032. vertexShader?: WebGLShader;
  90033. fragmentShader?: WebGLShader;
  90034. isParallelCompiled: boolean;
  90035. onCompiled?: () => void;
  90036. transformFeedback?: WebGLTransformFeedback | null;
  90037. readonly isAsync: boolean;
  90038. readonly isReady: boolean;
  90039. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  90040. }
  90041. }
  90042. declare module BABYLON {
  90043. /** @hidden */
  90044. export class WebGLDataBuffer extends DataBuffer {
  90045. private _buffer;
  90046. constructor(resource: WebGLBuffer);
  90047. readonly underlyingResource: any;
  90048. }
  90049. }
  90050. declare module BABYLON {
  90051. /** @hidden */
  90052. export class WebGL2ShaderProcessor implements IShaderProcessor {
  90053. attributeProcessor(attribute: string): string;
  90054. varyingProcessor(varying: string, isFragment: boolean): string;
  90055. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  90056. }
  90057. }
  90058. declare module BABYLON {
  90059. /**
  90060. * Settings for finer control over video usage
  90061. */
  90062. export interface VideoTextureSettings {
  90063. /**
  90064. * Applies `autoplay` to video, if specified
  90065. */
  90066. autoPlay?: boolean;
  90067. /**
  90068. * Applies `loop` to video, if specified
  90069. */
  90070. loop?: boolean;
  90071. /**
  90072. * Automatically updates internal texture from video at every frame in the render loop
  90073. */
  90074. autoUpdateTexture: boolean;
  90075. /**
  90076. * Image src displayed during the video loading or until the user interacts with the video.
  90077. */
  90078. poster?: string;
  90079. }
  90080. /**
  90081. * If you want to display a video in your scene, this is the special texture for that.
  90082. * This special texture works similar to other textures, with the exception of a few parameters.
  90083. * @see https://doc.babylonjs.com/how_to/video_texture
  90084. */
  90085. export class VideoTexture extends Texture {
  90086. /**
  90087. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  90088. */
  90089. readonly autoUpdateTexture: boolean;
  90090. /**
  90091. * The video instance used by the texture internally
  90092. */
  90093. readonly video: HTMLVideoElement;
  90094. private _onUserActionRequestedObservable;
  90095. /**
  90096. * Event triggerd when a dom action is required by the user to play the video.
  90097. * This happens due to recent changes in browser policies preventing video to auto start.
  90098. */
  90099. readonly onUserActionRequestedObservable: Observable<Texture>;
  90100. private _generateMipMaps;
  90101. private _engine;
  90102. private _stillImageCaptured;
  90103. private _displayingPosterTexture;
  90104. private _settings;
  90105. private _createInternalTextureOnEvent;
  90106. /**
  90107. * Creates a video texture.
  90108. * If you want to display a video in your scene, this is the special texture for that.
  90109. * This special texture works similar to other textures, with the exception of a few parameters.
  90110. * @see https://doc.babylonjs.com/how_to/video_texture
  90111. * @param name optional name, will detect from video source, if not defined
  90112. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  90113. * @param scene is obviously the current scene.
  90114. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  90115. * @param invertY is false by default but can be used to invert video on Y axis
  90116. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  90117. * @param settings allows finer control over video usage
  90118. */
  90119. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  90120. private _getName;
  90121. private _getVideo;
  90122. private _createInternalTexture;
  90123. private reset;
  90124. /**
  90125. * @hidden Internal method to initiate `update`.
  90126. */
  90127. _rebuild(): void;
  90128. /**
  90129. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  90130. */
  90131. update(): void;
  90132. /**
  90133. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  90134. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  90135. */
  90136. updateTexture(isVisible: boolean): void;
  90137. protected _updateInternalTexture: () => void;
  90138. /**
  90139. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  90140. * @param url New url.
  90141. */
  90142. updateURL(url: string): void;
  90143. /**
  90144. * Dispose the texture and release its associated resources.
  90145. */
  90146. dispose(): void;
  90147. /**
  90148. * Creates a video texture straight from a stream.
  90149. * @param scene Define the scene the texture should be created in
  90150. * @param stream Define the stream the texture should be created from
  90151. * @returns The created video texture as a promise
  90152. */
  90153. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  90154. /**
  90155. * Creates a video texture straight from your WebCam video feed.
  90156. * @param scene Define the scene the texture should be created in
  90157. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  90158. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  90159. * @returns The created video texture as a promise
  90160. */
  90161. static CreateFromWebCamAsync(scene: Scene, constraints: {
  90162. minWidth: number;
  90163. maxWidth: number;
  90164. minHeight: number;
  90165. maxHeight: number;
  90166. deviceId: string;
  90167. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  90168. /**
  90169. * Creates a video texture straight from your WebCam video feed.
  90170. * @param scene Define the scene the texture should be created in
  90171. * @param onReady Define a callback to triggered once the texture will be ready
  90172. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  90173. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  90174. */
  90175. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  90176. minWidth: number;
  90177. maxWidth: number;
  90178. minHeight: number;
  90179. maxHeight: number;
  90180. deviceId: string;
  90181. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  90182. }
  90183. }
  90184. declare module BABYLON {
  90185. /**
  90186. * Interface for attribute information associated with buffer instanciation
  90187. */
  90188. export class InstancingAttributeInfo {
  90189. /**
  90190. * Index/offset of the attribute in the vertex shader
  90191. */
  90192. index: number;
  90193. /**
  90194. * size of the attribute, 1, 2, 3 or 4
  90195. */
  90196. attributeSize: number;
  90197. /**
  90198. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  90199. * default is FLOAT
  90200. */
  90201. attribyteType: number;
  90202. /**
  90203. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  90204. */
  90205. normalized: boolean;
  90206. /**
  90207. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  90208. */
  90209. offset: number;
  90210. /**
  90211. * Name of the GLSL attribute, for debugging purpose only
  90212. */
  90213. attributeName: string;
  90214. }
  90215. /**
  90216. * Define options used to create a depth texture
  90217. */
  90218. export class DepthTextureCreationOptions {
  90219. /** Specifies whether or not a stencil should be allocated in the texture */
  90220. generateStencil?: boolean;
  90221. /** Specifies whether or not bilinear filtering is enable on the texture */
  90222. bilinearFiltering?: boolean;
  90223. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  90224. comparisonFunction?: number;
  90225. /** Specifies if the created texture is a cube texture */
  90226. isCube?: boolean;
  90227. }
  90228. /**
  90229. * Class used to describe the capabilities of the engine relatively to the current browser
  90230. */
  90231. export class EngineCapabilities {
  90232. /** Maximum textures units per fragment shader */
  90233. maxTexturesImageUnits: number;
  90234. /** Maximum texture units per vertex shader */
  90235. maxVertexTextureImageUnits: number;
  90236. /** Maximum textures units in the entire pipeline */
  90237. maxCombinedTexturesImageUnits: number;
  90238. /** Maximum texture size */
  90239. maxTextureSize: number;
  90240. /** Maximum cube texture size */
  90241. maxCubemapTextureSize: number;
  90242. /** Maximum render texture size */
  90243. maxRenderTextureSize: number;
  90244. /** Maximum number of vertex attributes */
  90245. maxVertexAttribs: number;
  90246. /** Maximum number of varyings */
  90247. maxVaryingVectors: number;
  90248. /** Maximum number of uniforms per vertex shader */
  90249. maxVertexUniformVectors: number;
  90250. /** Maximum number of uniforms per fragment shader */
  90251. maxFragmentUniformVectors: number;
  90252. /** Defines if standard derivates (dx/dy) are supported */
  90253. standardDerivatives: boolean;
  90254. /** Defines if s3tc texture compression is supported */
  90255. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  90256. /** Defines if pvrtc texture compression is supported */
  90257. pvrtc: any;
  90258. /** Defines if etc1 texture compression is supported */
  90259. etc1: any;
  90260. /** Defines if etc2 texture compression is supported */
  90261. etc2: any;
  90262. /** Defines if astc texture compression is supported */
  90263. astc: any;
  90264. /** Defines if float textures are supported */
  90265. textureFloat: boolean;
  90266. /** Defines if vertex array objects are supported */
  90267. vertexArrayObject: boolean;
  90268. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  90269. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  90270. /** Gets the maximum level of anisotropy supported */
  90271. maxAnisotropy: number;
  90272. /** Defines if instancing is supported */
  90273. instancedArrays: boolean;
  90274. /** Defines if 32 bits indices are supported */
  90275. uintIndices: boolean;
  90276. /** Defines if high precision shaders are supported */
  90277. highPrecisionShaderSupported: boolean;
  90278. /** Defines if depth reading in the fragment shader is supported */
  90279. fragmentDepthSupported: boolean;
  90280. /** Defines if float texture linear filtering is supported*/
  90281. textureFloatLinearFiltering: boolean;
  90282. /** Defines if rendering to float textures is supported */
  90283. textureFloatRender: boolean;
  90284. /** Defines if half float textures are supported*/
  90285. textureHalfFloat: boolean;
  90286. /** Defines if half float texture linear filtering is supported*/
  90287. textureHalfFloatLinearFiltering: boolean;
  90288. /** Defines if rendering to half float textures is supported */
  90289. textureHalfFloatRender: boolean;
  90290. /** Defines if textureLOD shader command is supported */
  90291. textureLOD: boolean;
  90292. /** Defines if draw buffers extension is supported */
  90293. drawBuffersExtension: boolean;
  90294. /** Defines if depth textures are supported */
  90295. depthTextureExtension: boolean;
  90296. /** Defines if float color buffer are supported */
  90297. colorBufferFloat: boolean;
  90298. /** Gets disjoint timer query extension (null if not supported) */
  90299. timerQuery: EXT_disjoint_timer_query;
  90300. /** Defines if timestamp can be used with timer query */
  90301. canUseTimestampForTimerQuery: boolean;
  90302. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  90303. multiview: any;
  90304. /** Function used to let the system compiles shaders in background */
  90305. parallelShaderCompile: {
  90306. COMPLETION_STATUS_KHR: number;
  90307. };
  90308. }
  90309. /** Interface defining initialization parameters for Engine class */
  90310. export interface EngineOptions extends WebGLContextAttributes {
  90311. /**
  90312. * Defines if the engine should no exceed a specified device ratio
  90313. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  90314. */
  90315. limitDeviceRatio?: number;
  90316. /**
  90317. * Defines if webvr should be enabled automatically
  90318. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90319. */
  90320. autoEnableWebVR?: boolean;
  90321. /**
  90322. * Defines if webgl2 should be turned off even if supported
  90323. * @see http://doc.babylonjs.com/features/webgl2
  90324. */
  90325. disableWebGL2Support?: boolean;
  90326. /**
  90327. * Defines if webaudio should be initialized as well
  90328. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90329. */
  90330. audioEngine?: boolean;
  90331. /**
  90332. * Defines if animations should run using a deterministic lock step
  90333. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90334. */
  90335. deterministicLockstep?: boolean;
  90336. /** Defines the maximum steps to use with deterministic lock step mode */
  90337. lockstepMaxSteps?: number;
  90338. /**
  90339. * Defines that engine should ignore context lost events
  90340. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  90341. */
  90342. doNotHandleContextLost?: boolean;
  90343. /**
  90344. * Defines that engine should ignore modifying touch action attribute and style
  90345. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  90346. */
  90347. doNotHandleTouchAction?: boolean;
  90348. /**
  90349. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  90350. */
  90351. useHighPrecisionFloats?: boolean;
  90352. }
  90353. /**
  90354. * Defines the interface used by display changed events
  90355. */
  90356. export interface IDisplayChangedEventArgs {
  90357. /** Gets the vrDisplay object (if any) */
  90358. vrDisplay: Nullable<any>;
  90359. /** Gets a boolean indicating if webVR is supported */
  90360. vrSupported: boolean;
  90361. }
  90362. /**
  90363. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  90364. */
  90365. export class Engine {
  90366. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  90367. static ExceptionList: ({
  90368. key: string;
  90369. capture: string;
  90370. captureConstraint: number;
  90371. targets: string[];
  90372. } | {
  90373. key: string;
  90374. capture: null;
  90375. captureConstraint: null;
  90376. targets: string[];
  90377. })[];
  90378. /** Gets the list of created engines */
  90379. static readonly Instances: Engine[];
  90380. /**
  90381. * Gets the latest created engine
  90382. */
  90383. static readonly LastCreatedEngine: Nullable<Engine>;
  90384. /**
  90385. * Gets the latest created scene
  90386. */
  90387. static readonly LastCreatedScene: Nullable<Scene>;
  90388. /**
  90389. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  90390. * @param flag defines which part of the materials must be marked as dirty
  90391. * @param predicate defines a predicate used to filter which materials should be affected
  90392. */
  90393. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90394. /** @hidden */
  90395. static _TextureLoaders: IInternalTextureLoader[];
  90396. /** Defines that alpha blending is disabled */
  90397. static readonly ALPHA_DISABLE: number;
  90398. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  90399. static readonly ALPHA_ADD: number;
  90400. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  90401. static readonly ALPHA_COMBINE: number;
  90402. /** Defines that alpha blending to DEST - SRC * DEST */
  90403. static readonly ALPHA_SUBTRACT: number;
  90404. /** Defines that alpha blending to SRC * DEST */
  90405. static readonly ALPHA_MULTIPLY: number;
  90406. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  90407. static readonly ALPHA_MAXIMIZED: number;
  90408. /** Defines that alpha blending to SRC + DEST */
  90409. static readonly ALPHA_ONEONE: number;
  90410. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  90411. static readonly ALPHA_PREMULTIPLIED: number;
  90412. /**
  90413. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  90414. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  90415. */
  90416. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  90417. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  90418. static readonly ALPHA_INTERPOLATE: number;
  90419. /**
  90420. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  90421. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  90422. */
  90423. static readonly ALPHA_SCREENMODE: number;
  90424. /** Defines that the ressource is not delayed*/
  90425. static readonly DELAYLOADSTATE_NONE: number;
  90426. /** Defines that the ressource was successfully delay loaded */
  90427. static readonly DELAYLOADSTATE_LOADED: number;
  90428. /** Defines that the ressource is currently delay loading */
  90429. static readonly DELAYLOADSTATE_LOADING: number;
  90430. /** Defines that the ressource is delayed and has not started loading */
  90431. static readonly DELAYLOADSTATE_NOTLOADED: number;
  90432. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  90433. static readonly NEVER: number;
  90434. /** 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 */
  90435. static readonly ALWAYS: number;
  90436. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  90437. static readonly LESS: number;
  90438. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  90439. static readonly EQUAL: number;
  90440. /** 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 */
  90441. static readonly LEQUAL: number;
  90442. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  90443. static readonly GREATER: number;
  90444. /** 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 */
  90445. static readonly GEQUAL: number;
  90446. /** 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 */
  90447. static readonly NOTEQUAL: number;
  90448. /** Passed to stencilOperation to specify that stencil value must be kept */
  90449. static readonly KEEP: number;
  90450. /** Passed to stencilOperation to specify that stencil value must be replaced */
  90451. static readonly REPLACE: number;
  90452. /** Passed to stencilOperation to specify that stencil value must be incremented */
  90453. static readonly INCR: number;
  90454. /** Passed to stencilOperation to specify that stencil value must be decremented */
  90455. static readonly DECR: number;
  90456. /** Passed to stencilOperation to specify that stencil value must be inverted */
  90457. static readonly INVERT: number;
  90458. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  90459. static readonly INCR_WRAP: number;
  90460. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  90461. static readonly DECR_WRAP: number;
  90462. /** Texture is not repeating outside of 0..1 UVs */
  90463. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  90464. /** Texture is repeating outside of 0..1 UVs */
  90465. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  90466. /** Texture is repeating and mirrored */
  90467. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  90468. /** ALPHA */
  90469. static readonly TEXTUREFORMAT_ALPHA: number;
  90470. /** LUMINANCE */
  90471. static readonly TEXTUREFORMAT_LUMINANCE: number;
  90472. /** LUMINANCE_ALPHA */
  90473. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  90474. /** RGB */
  90475. static readonly TEXTUREFORMAT_RGB: number;
  90476. /** RGBA */
  90477. static readonly TEXTUREFORMAT_RGBA: number;
  90478. /** RED */
  90479. static readonly TEXTUREFORMAT_RED: number;
  90480. /** RED (2nd reference) */
  90481. static readonly TEXTUREFORMAT_R: number;
  90482. /** RG */
  90483. static readonly TEXTUREFORMAT_RG: number;
  90484. /** RED_INTEGER */
  90485. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  90486. /** RED_INTEGER (2nd reference) */
  90487. static readonly TEXTUREFORMAT_R_INTEGER: number;
  90488. /** RG_INTEGER */
  90489. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  90490. /** RGB_INTEGER */
  90491. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  90492. /** RGBA_INTEGER */
  90493. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  90494. /** UNSIGNED_BYTE */
  90495. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  90496. /** UNSIGNED_BYTE (2nd reference) */
  90497. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  90498. /** FLOAT */
  90499. static readonly TEXTURETYPE_FLOAT: number;
  90500. /** HALF_FLOAT */
  90501. static readonly TEXTURETYPE_HALF_FLOAT: number;
  90502. /** BYTE */
  90503. static readonly TEXTURETYPE_BYTE: number;
  90504. /** SHORT */
  90505. static readonly TEXTURETYPE_SHORT: number;
  90506. /** UNSIGNED_SHORT */
  90507. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  90508. /** INT */
  90509. static readonly TEXTURETYPE_INT: number;
  90510. /** UNSIGNED_INT */
  90511. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  90512. /** UNSIGNED_SHORT_4_4_4_4 */
  90513. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  90514. /** UNSIGNED_SHORT_5_5_5_1 */
  90515. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  90516. /** UNSIGNED_SHORT_5_6_5 */
  90517. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  90518. /** UNSIGNED_INT_2_10_10_10_REV */
  90519. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  90520. /** UNSIGNED_INT_24_8 */
  90521. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  90522. /** UNSIGNED_INT_10F_11F_11F_REV */
  90523. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  90524. /** UNSIGNED_INT_5_9_9_9_REV */
  90525. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  90526. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  90527. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  90528. /** nearest is mag = nearest and min = nearest and mip = linear */
  90529. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  90530. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90531. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  90532. /** Trilinear is mag = linear and min = linear and mip = linear */
  90533. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  90534. /** nearest is mag = nearest and min = nearest and mip = linear */
  90535. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  90536. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90537. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  90538. /** Trilinear is mag = linear and min = linear and mip = linear */
  90539. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  90540. /** mag = nearest and min = nearest and mip = nearest */
  90541. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  90542. /** mag = nearest and min = linear and mip = nearest */
  90543. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  90544. /** mag = nearest and min = linear and mip = linear */
  90545. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  90546. /** mag = nearest and min = linear and mip = none */
  90547. static readonly TEXTURE_NEAREST_LINEAR: number;
  90548. /** mag = nearest and min = nearest and mip = none */
  90549. static readonly TEXTURE_NEAREST_NEAREST: number;
  90550. /** mag = linear and min = nearest and mip = nearest */
  90551. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  90552. /** mag = linear and min = nearest and mip = linear */
  90553. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  90554. /** mag = linear and min = linear and mip = none */
  90555. static readonly TEXTURE_LINEAR_LINEAR: number;
  90556. /** mag = linear and min = nearest and mip = none */
  90557. static readonly TEXTURE_LINEAR_NEAREST: number;
  90558. /** Explicit coordinates mode */
  90559. static readonly TEXTURE_EXPLICIT_MODE: number;
  90560. /** Spherical coordinates mode */
  90561. static readonly TEXTURE_SPHERICAL_MODE: number;
  90562. /** Planar coordinates mode */
  90563. static readonly TEXTURE_PLANAR_MODE: number;
  90564. /** Cubic coordinates mode */
  90565. static readonly TEXTURE_CUBIC_MODE: number;
  90566. /** Projection coordinates mode */
  90567. static readonly TEXTURE_PROJECTION_MODE: number;
  90568. /** Skybox coordinates mode */
  90569. static readonly TEXTURE_SKYBOX_MODE: number;
  90570. /** Inverse Cubic coordinates mode */
  90571. static readonly TEXTURE_INVCUBIC_MODE: number;
  90572. /** Equirectangular coordinates mode */
  90573. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  90574. /** Equirectangular Fixed coordinates mode */
  90575. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  90576. /** Equirectangular Fixed Mirrored coordinates mode */
  90577. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  90578. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  90579. static readonly SCALEMODE_FLOOR: number;
  90580. /** Defines that texture rescaling will look for the nearest power of 2 size */
  90581. static readonly SCALEMODE_NEAREST: number;
  90582. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  90583. static readonly SCALEMODE_CEILING: number;
  90584. /**
  90585. * Returns the current npm package of the sdk
  90586. */
  90587. static readonly NpmPackage: string;
  90588. /**
  90589. * Returns the current version of the framework
  90590. */
  90591. static readonly Version: string;
  90592. /**
  90593. * Returns a string describing the current engine
  90594. */
  90595. readonly description: string;
  90596. /**
  90597. * Gets or sets the epsilon value used by collision engine
  90598. */
  90599. static CollisionsEpsilon: number;
  90600. /**
  90601. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  90602. */
  90603. static ShadersRepository: string;
  90604. /**
  90605. * Method called to create the default loading screen.
  90606. * This can be overriden in your own app.
  90607. * @param canvas The rendering canvas element
  90608. * @returns The loading screen
  90609. */
  90610. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  90611. /**
  90612. * Method called to create the default rescale post process on each engine.
  90613. */
  90614. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  90615. /** @hidden */
  90616. _shaderProcessor: IShaderProcessor;
  90617. /**
  90618. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  90619. */
  90620. forcePOTTextures: boolean;
  90621. /**
  90622. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  90623. */
  90624. isFullscreen: boolean;
  90625. /**
  90626. * Gets a boolean indicating if the pointer is currently locked
  90627. */
  90628. isPointerLock: boolean;
  90629. /**
  90630. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  90631. */
  90632. cullBackFaces: boolean;
  90633. /**
  90634. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  90635. */
  90636. renderEvenInBackground: boolean;
  90637. /**
  90638. * Gets or sets a boolean indicating that cache can be kept between frames
  90639. */
  90640. preventCacheWipeBetweenFrames: boolean;
  90641. /**
  90642. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  90643. **/
  90644. enableOfflineSupport: boolean;
  90645. /**
  90646. * 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)
  90647. **/
  90648. disableManifestCheck: boolean;
  90649. /**
  90650. * Gets the list of created scenes
  90651. */
  90652. scenes: Scene[];
  90653. /**
  90654. * Event raised when a new scene is created
  90655. */
  90656. onNewSceneAddedObservable: Observable<Scene>;
  90657. /**
  90658. * Gets the list of created postprocesses
  90659. */
  90660. postProcesses: PostProcess[];
  90661. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  90662. validateShaderPrograms: boolean;
  90663. /**
  90664. * Observable event triggered each time the rendering canvas is resized
  90665. */
  90666. onResizeObservable: Observable<Engine>;
  90667. /**
  90668. * Observable event triggered each time the canvas loses focus
  90669. */
  90670. onCanvasBlurObservable: Observable<Engine>;
  90671. /**
  90672. * Observable event triggered each time the canvas gains focus
  90673. */
  90674. onCanvasFocusObservable: Observable<Engine>;
  90675. /**
  90676. * Observable event triggered each time the canvas receives pointerout event
  90677. */
  90678. onCanvasPointerOutObservable: Observable<PointerEvent>;
  90679. /**
  90680. * Observable event triggered before each texture is initialized
  90681. */
  90682. onBeforeTextureInitObservable: Observable<Texture>;
  90683. /**
  90684. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  90685. */
  90686. disableUniformBuffers: boolean;
  90687. /** @hidden */
  90688. _uniformBuffers: UniformBuffer[];
  90689. /**
  90690. * Gets a boolean indicating that the engine supports uniform buffers
  90691. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90692. */
  90693. readonly supportsUniformBuffers: boolean;
  90694. /**
  90695. * Observable raised when the engine begins a new frame
  90696. */
  90697. onBeginFrameObservable: Observable<Engine>;
  90698. /**
  90699. * If set, will be used to request the next animation frame for the render loop
  90700. */
  90701. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  90702. /**
  90703. * Observable raised when the engine ends the current frame
  90704. */
  90705. onEndFrameObservable: Observable<Engine>;
  90706. /**
  90707. * Observable raised when the engine is about to compile a shader
  90708. */
  90709. onBeforeShaderCompilationObservable: Observable<Engine>;
  90710. /**
  90711. * Observable raised when the engine has jsut compiled a shader
  90712. */
  90713. onAfterShaderCompilationObservable: Observable<Engine>;
  90714. /** @hidden */
  90715. _gl: WebGLRenderingContext;
  90716. private _renderingCanvas;
  90717. private _windowIsBackground;
  90718. private _webGLVersion;
  90719. protected _highPrecisionShadersAllowed: boolean;
  90720. /** @hidden */
  90721. readonly _shouldUseHighPrecisionShader: boolean;
  90722. /**
  90723. * Gets a boolean indicating that only power of 2 textures are supported
  90724. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  90725. */
  90726. readonly needPOTTextures: boolean;
  90727. /** @hidden */
  90728. _badOS: boolean;
  90729. /** @hidden */
  90730. _badDesktopOS: boolean;
  90731. /**
  90732. * Gets the audio engine
  90733. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90734. * @ignorenaming
  90735. */
  90736. static audioEngine: IAudioEngine;
  90737. /**
  90738. * Default AudioEngine factory responsible of creating the Audio Engine.
  90739. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  90740. */
  90741. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  90742. /**
  90743. * Default offline support factory responsible of creating a tool used to store data locally.
  90744. * By default, this will create a Database object if the workload has been embedded.
  90745. */
  90746. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  90747. private _onFocus;
  90748. private _onBlur;
  90749. private _onCanvasPointerOut;
  90750. private _onCanvasBlur;
  90751. private _onCanvasFocus;
  90752. private _onFullscreenChange;
  90753. private _onPointerLockChange;
  90754. private _hardwareScalingLevel;
  90755. /** @hidden */
  90756. _caps: EngineCapabilities;
  90757. private _pointerLockRequested;
  90758. private _isStencilEnable;
  90759. private _colorWrite;
  90760. private _loadingScreen;
  90761. /** @hidden */
  90762. _drawCalls: PerfCounter;
  90763. private _glVersion;
  90764. private _glRenderer;
  90765. private _glVendor;
  90766. private _videoTextureSupported;
  90767. private _renderingQueueLaunched;
  90768. private _activeRenderLoops;
  90769. private _deterministicLockstep;
  90770. private _lockstepMaxSteps;
  90771. /**
  90772. * Observable signaled when a context lost event is raised
  90773. */
  90774. onContextLostObservable: Observable<Engine>;
  90775. /**
  90776. * Observable signaled when a context restored event is raised
  90777. */
  90778. onContextRestoredObservable: Observable<Engine>;
  90779. private _onContextLost;
  90780. private _onContextRestored;
  90781. private _contextWasLost;
  90782. /** @hidden */
  90783. _doNotHandleContextLost: boolean;
  90784. /**
  90785. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  90786. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  90787. */
  90788. doNotHandleContextLost: boolean;
  90789. private _performanceMonitor;
  90790. private _fps;
  90791. private _deltaTime;
  90792. /**
  90793. * Turn this value on if you want to pause FPS computation when in background
  90794. */
  90795. disablePerformanceMonitorInBackground: boolean;
  90796. /**
  90797. * Gets the performance monitor attached to this engine
  90798. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  90799. */
  90800. readonly performanceMonitor: PerformanceMonitor;
  90801. /**
  90802. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  90803. */
  90804. disableVertexArrayObjects: boolean;
  90805. /** @hidden */
  90806. protected _depthCullingState: _DepthCullingState;
  90807. /** @hidden */
  90808. protected _stencilState: _StencilState;
  90809. /** @hidden */
  90810. protected _alphaState: _AlphaState;
  90811. /** @hidden */
  90812. protected _alphaMode: number;
  90813. /** @hidden */
  90814. _internalTexturesCache: InternalTexture[];
  90815. /** @hidden */
  90816. protected _activeChannel: number;
  90817. private _currentTextureChannel;
  90818. /** @hidden */
  90819. protected _boundTexturesCache: {
  90820. [key: string]: Nullable<InternalTexture>;
  90821. };
  90822. /** @hidden */
  90823. protected _currentEffect: Nullable<Effect>;
  90824. /** @hidden */
  90825. protected _currentProgram: Nullable<WebGLProgram>;
  90826. private _compiledEffects;
  90827. private _vertexAttribArraysEnabled;
  90828. /** @hidden */
  90829. protected _cachedViewport: Nullable<Viewport>;
  90830. private _cachedVertexArrayObject;
  90831. /** @hidden */
  90832. protected _cachedVertexBuffers: any;
  90833. /** @hidden */
  90834. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  90835. /** @hidden */
  90836. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  90837. /** @hidden */
  90838. _currentRenderTarget: Nullable<InternalTexture>;
  90839. private _uintIndicesCurrentlySet;
  90840. private _currentBoundBuffer;
  90841. /** @hidden */
  90842. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  90843. private _currentBufferPointers;
  90844. private _currentInstanceLocations;
  90845. private _currentInstanceBuffers;
  90846. private _textureUnits;
  90847. /** @hidden */
  90848. _workingCanvas: Nullable<HTMLCanvasElement>;
  90849. /** @hidden */
  90850. _workingContext: Nullable<CanvasRenderingContext2D>;
  90851. private _rescalePostProcess;
  90852. private _dummyFramebuffer;
  90853. private _externalData;
  90854. /** @hidden */
  90855. _bindedRenderFunction: any;
  90856. private _vaoRecordInProgress;
  90857. private _mustWipeVertexAttributes;
  90858. private _emptyTexture;
  90859. private _emptyCubeTexture;
  90860. private _emptyTexture3D;
  90861. /** @hidden */
  90862. _frameHandler: number;
  90863. private _nextFreeTextureSlots;
  90864. private _maxSimultaneousTextures;
  90865. private _activeRequests;
  90866. private _texturesSupported;
  90867. /** @hidden */
  90868. _textureFormatInUse: Nullable<string>;
  90869. /**
  90870. * Gets the list of texture formats supported
  90871. */
  90872. readonly texturesSupported: Array<string>;
  90873. /**
  90874. * Gets the list of texture formats in use
  90875. */
  90876. readonly textureFormatInUse: Nullable<string>;
  90877. /**
  90878. * Gets the current viewport
  90879. */
  90880. readonly currentViewport: Nullable<Viewport>;
  90881. /**
  90882. * Gets the default empty texture
  90883. */
  90884. readonly emptyTexture: InternalTexture;
  90885. /**
  90886. * Gets the default empty 3D texture
  90887. */
  90888. readonly emptyTexture3D: InternalTexture;
  90889. /**
  90890. * Gets the default empty cube texture
  90891. */
  90892. readonly emptyCubeTexture: InternalTexture;
  90893. /**
  90894. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  90895. */
  90896. readonly premultipliedAlpha: boolean;
  90897. /**
  90898. * Creates a new engine
  90899. * @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
  90900. * @param antialias defines enable antialiasing (default: false)
  90901. * @param options defines further options to be sent to the getContext() function
  90902. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  90903. */
  90904. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  90905. /**
  90906. * Initializes a webVR display and starts listening to display change events
  90907. * The onVRDisplayChangedObservable will be notified upon these changes
  90908. * @returns The onVRDisplayChangedObservable
  90909. */
  90910. initWebVR(): Observable<IDisplayChangedEventArgs>;
  90911. /** @hidden */
  90912. _prepareVRComponent(): void;
  90913. /** @hidden */
  90914. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  90915. /** @hidden */
  90916. _submitVRFrame(): void;
  90917. /**
  90918. * Call this function to leave webVR mode
  90919. * Will do nothing if webVR is not supported or if there is no webVR device
  90920. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90921. */
  90922. disableVR(): void;
  90923. /**
  90924. * Gets a boolean indicating that the system is in VR mode and is presenting
  90925. * @returns true if VR mode is engaged
  90926. */
  90927. isVRPresenting(): boolean;
  90928. /** @hidden */
  90929. _requestVRFrame(): void;
  90930. private _disableTouchAction;
  90931. private _rebuildInternalTextures;
  90932. private _rebuildEffects;
  90933. /**
  90934. * Gets a boolean indicating if all created effects are ready
  90935. * @returns true if all effects are ready
  90936. */
  90937. areAllEffectsReady(): boolean;
  90938. private _rebuildBuffers;
  90939. private _initGLContext;
  90940. /**
  90941. * Gets version of the current webGL context
  90942. */
  90943. readonly webGLVersion: number;
  90944. /**
  90945. * Gets a string idenfifying the name of the class
  90946. * @returns "Engine" string
  90947. */
  90948. getClassName(): string;
  90949. /**
  90950. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  90951. */
  90952. readonly isStencilEnable: boolean;
  90953. /** @hidden */
  90954. _prepareWorkingCanvas(): void;
  90955. /**
  90956. * Reset the texture cache to empty state
  90957. */
  90958. resetTextureCache(): void;
  90959. /**
  90960. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  90961. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90962. * @returns true if engine is in deterministic lock step mode
  90963. */
  90964. isDeterministicLockStep(): boolean;
  90965. /**
  90966. * Gets the max steps when engine is running in deterministic lock step
  90967. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90968. * @returns the max steps
  90969. */
  90970. getLockstepMaxSteps(): number;
  90971. /**
  90972. * Gets an object containing information about the current webGL context
  90973. * @returns an object containing the vender, the renderer and the version of the current webGL context
  90974. */
  90975. getGlInfo(): {
  90976. vendor: string;
  90977. renderer: string;
  90978. version: string;
  90979. };
  90980. /**
  90981. * Gets current aspect ratio
  90982. * @param camera defines the camera to use to get the aspect ratio
  90983. * @param useScreen defines if screen size must be used (or the current render target if any)
  90984. * @returns a number defining the aspect ratio
  90985. */
  90986. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  90987. /**
  90988. * Gets current screen aspect ratio
  90989. * @returns a number defining the aspect ratio
  90990. */
  90991. getScreenAspectRatio(): number;
  90992. /**
  90993. * Gets the current render width
  90994. * @param useScreen defines if screen size must be used (or the current render target if any)
  90995. * @returns a number defining the current render width
  90996. */
  90997. getRenderWidth(useScreen?: boolean): number;
  90998. /**
  90999. * Gets the current render height
  91000. * @param useScreen defines if screen size must be used (or the current render target if any)
  91001. * @returns a number defining the current render height
  91002. */
  91003. getRenderHeight(useScreen?: boolean): number;
  91004. /**
  91005. * Gets the HTML canvas attached with the current webGL context
  91006. * @returns a HTML canvas
  91007. */
  91008. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  91009. /**
  91010. * Gets the client rect of the HTML canvas attached with the current webGL context
  91011. * @returns a client rectanglee
  91012. */
  91013. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  91014. /**
  91015. * Defines the hardware scaling level.
  91016. * By default the hardware scaling level is computed from the window device ratio.
  91017. * 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.
  91018. * @param level defines the level to use
  91019. */
  91020. setHardwareScalingLevel(level: number): void;
  91021. /**
  91022. * Gets the current hardware scaling level.
  91023. * By default the hardware scaling level is computed from the window device ratio.
  91024. * 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.
  91025. * @returns a number indicating the current hardware scaling level
  91026. */
  91027. getHardwareScalingLevel(): number;
  91028. /**
  91029. * Gets the list of loaded textures
  91030. * @returns an array containing all loaded textures
  91031. */
  91032. getLoadedTexturesCache(): InternalTexture[];
  91033. /**
  91034. * Gets the object containing all engine capabilities
  91035. * @returns the EngineCapabilities object
  91036. */
  91037. getCaps(): EngineCapabilities;
  91038. /**
  91039. * Gets the current depth function
  91040. * @returns a number defining the depth function
  91041. */
  91042. getDepthFunction(): Nullable<number>;
  91043. /**
  91044. * Sets the current depth function
  91045. * @param depthFunc defines the function to use
  91046. */
  91047. setDepthFunction(depthFunc: number): void;
  91048. /**
  91049. * Sets the current depth function to GREATER
  91050. */
  91051. setDepthFunctionToGreater(): void;
  91052. /**
  91053. * Sets the current depth function to GEQUAL
  91054. */
  91055. setDepthFunctionToGreaterOrEqual(): void;
  91056. /**
  91057. * Sets the current depth function to LESS
  91058. */
  91059. setDepthFunctionToLess(): void;
  91060. private _cachedStencilBuffer;
  91061. private _cachedStencilFunction;
  91062. private _cachedStencilMask;
  91063. private _cachedStencilOperationPass;
  91064. private _cachedStencilOperationFail;
  91065. private _cachedStencilOperationDepthFail;
  91066. private _cachedStencilReference;
  91067. /**
  91068. * Caches the the state of the stencil buffer
  91069. */
  91070. cacheStencilState(): void;
  91071. /**
  91072. * Restores the state of the stencil buffer
  91073. */
  91074. restoreStencilState(): void;
  91075. /**
  91076. * Sets the current depth function to LEQUAL
  91077. */
  91078. setDepthFunctionToLessOrEqual(): void;
  91079. /**
  91080. * Gets a boolean indicating if stencil buffer is enabled
  91081. * @returns the current stencil buffer state
  91082. */
  91083. getStencilBuffer(): boolean;
  91084. /**
  91085. * Enable or disable the stencil buffer
  91086. * @param enable defines if the stencil buffer must be enabled or disabled
  91087. */
  91088. setStencilBuffer(enable: boolean): void;
  91089. /**
  91090. * Gets the current stencil mask
  91091. * @returns a number defining the new stencil mask to use
  91092. */
  91093. getStencilMask(): number;
  91094. /**
  91095. * Sets the current stencil mask
  91096. * @param mask defines the new stencil mask to use
  91097. */
  91098. setStencilMask(mask: number): void;
  91099. /**
  91100. * Gets the current stencil function
  91101. * @returns a number defining the stencil function to use
  91102. */
  91103. getStencilFunction(): number;
  91104. /**
  91105. * Gets the current stencil reference value
  91106. * @returns a number defining the stencil reference value to use
  91107. */
  91108. getStencilFunctionReference(): number;
  91109. /**
  91110. * Gets the current stencil mask
  91111. * @returns a number defining the stencil mask to use
  91112. */
  91113. getStencilFunctionMask(): number;
  91114. /**
  91115. * Sets the current stencil function
  91116. * @param stencilFunc defines the new stencil function to use
  91117. */
  91118. setStencilFunction(stencilFunc: number): void;
  91119. /**
  91120. * Sets the current stencil reference
  91121. * @param reference defines the new stencil reference to use
  91122. */
  91123. setStencilFunctionReference(reference: number): void;
  91124. /**
  91125. * Sets the current stencil mask
  91126. * @param mask defines the new stencil mask to use
  91127. */
  91128. setStencilFunctionMask(mask: number): void;
  91129. /**
  91130. * Gets the current stencil operation when stencil fails
  91131. * @returns a number defining stencil operation to use when stencil fails
  91132. */
  91133. getStencilOperationFail(): number;
  91134. /**
  91135. * Gets the current stencil operation when depth fails
  91136. * @returns a number defining stencil operation to use when depth fails
  91137. */
  91138. getStencilOperationDepthFail(): number;
  91139. /**
  91140. * Gets the current stencil operation when stencil passes
  91141. * @returns a number defining stencil operation to use when stencil passes
  91142. */
  91143. getStencilOperationPass(): number;
  91144. /**
  91145. * Sets the stencil operation to use when stencil fails
  91146. * @param operation defines the stencil operation to use when stencil fails
  91147. */
  91148. setStencilOperationFail(operation: number): void;
  91149. /**
  91150. * Sets the stencil operation to use when depth fails
  91151. * @param operation defines the stencil operation to use when depth fails
  91152. */
  91153. setStencilOperationDepthFail(operation: number): void;
  91154. /**
  91155. * Sets the stencil operation to use when stencil passes
  91156. * @param operation defines the stencil operation to use when stencil passes
  91157. */
  91158. setStencilOperationPass(operation: number): void;
  91159. /**
  91160. * Sets a boolean indicating if the dithering state is enabled or disabled
  91161. * @param value defines the dithering state
  91162. */
  91163. setDitheringState(value: boolean): void;
  91164. /**
  91165. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  91166. * @param value defines the rasterizer state
  91167. */
  91168. setRasterizerState(value: boolean): void;
  91169. /**
  91170. * stop executing a render loop function and remove it from the execution array
  91171. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  91172. */
  91173. stopRenderLoop(renderFunction?: () => void): void;
  91174. /** @hidden */
  91175. _renderLoop(): void;
  91176. /**
  91177. * Register and execute a render loop. The engine can have more than one render function
  91178. * @param renderFunction defines the function to continuously execute
  91179. */
  91180. runRenderLoop(renderFunction: () => void): void;
  91181. /**
  91182. * Toggle full screen mode
  91183. * @param requestPointerLock defines if a pointer lock should be requested from the user
  91184. */
  91185. switchFullscreen(requestPointerLock: boolean): void;
  91186. /**
  91187. * Enters full screen mode
  91188. * @param requestPointerLock defines if a pointer lock should be requested from the user
  91189. */
  91190. enterFullscreen(requestPointerLock: boolean): void;
  91191. /**
  91192. * Exits full screen mode
  91193. */
  91194. exitFullscreen(): void;
  91195. /**
  91196. * Enters Pointerlock mode
  91197. */
  91198. enterPointerlock(): void;
  91199. /**
  91200. * Exits Pointerlock mode
  91201. */
  91202. exitPointerlock(): void;
  91203. /**
  91204. * Clear the current render buffer or the current render target (if any is set up)
  91205. * @param color defines the color to use
  91206. * @param backBuffer defines if the back buffer must be cleared
  91207. * @param depth defines if the depth buffer must be cleared
  91208. * @param stencil defines if the stencil buffer must be cleared
  91209. */
  91210. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  91211. /**
  91212. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  91213. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  91214. * @param y defines the y-coordinate of the corner of the clear rectangle
  91215. * @param width defines the width of the clear rectangle
  91216. * @param height defines the height of the clear rectangle
  91217. * @param clearColor defines the clear color
  91218. */
  91219. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  91220. /**
  91221. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  91222. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  91223. * @param y defines the y-coordinate of the corner of the clear rectangle
  91224. * @param width defines the width of the clear rectangle
  91225. * @param height defines the height of the clear rectangle
  91226. */
  91227. enableScissor(x: number, y: number, width: number, height: number): void;
  91228. /**
  91229. * Disable previously set scissor test rectangle
  91230. */
  91231. disableScissor(): void;
  91232. private _viewportCached;
  91233. /** @hidden */
  91234. _viewport(x: number, y: number, width: number, height: number): void;
  91235. /**
  91236. * Set the WebGL's viewport
  91237. * @param viewport defines the viewport element to be used
  91238. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  91239. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  91240. */
  91241. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  91242. /**
  91243. * Directly set the WebGL Viewport
  91244. * @param x defines the x coordinate of the viewport (in screen space)
  91245. * @param y defines the y coordinate of the viewport (in screen space)
  91246. * @param width defines the width of the viewport (in screen space)
  91247. * @param height defines the height of the viewport (in screen space)
  91248. * @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
  91249. */
  91250. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  91251. /**
  91252. * Begin a new frame
  91253. */
  91254. beginFrame(): void;
  91255. /**
  91256. * Enf the current frame
  91257. */
  91258. endFrame(): void;
  91259. /**
  91260. * Resize the view according to the canvas' size
  91261. */
  91262. resize(): void;
  91263. /**
  91264. * Force a specific size of the canvas
  91265. * @param width defines the new canvas' width
  91266. * @param height defines the new canvas' height
  91267. */
  91268. setSize(width: number, height: number): void;
  91269. /**
  91270. * Binds the frame buffer to the specified texture.
  91271. * @param texture The texture to render to or null for the default canvas
  91272. * @param faceIndex The face of the texture to render to in case of cube texture
  91273. * @param requiredWidth The width of the target to render to
  91274. * @param requiredHeight The height of the target to render to
  91275. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  91276. * @param depthStencilTexture The depth stencil texture to use to render
  91277. * @param lodLevel defines le lod level to bind to the frame buffer
  91278. */
  91279. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  91280. /** @hidden */
  91281. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  91282. /**
  91283. * Unbind the current render target texture from the webGL context
  91284. * @param texture defines the render target texture to unbind
  91285. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  91286. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  91287. */
  91288. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  91289. /**
  91290. * Force the mipmap generation for the given render target texture
  91291. * @param texture defines the render target texture to use
  91292. */
  91293. generateMipMapsForCubemap(texture: InternalTexture): void;
  91294. /**
  91295. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  91296. */
  91297. flushFramebuffer(): void;
  91298. /**
  91299. * Unbind the current render target and bind the default framebuffer
  91300. */
  91301. restoreDefaultFramebuffer(): void;
  91302. /**
  91303. * Create an uniform buffer
  91304. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91305. * @param elements defines the content of the uniform buffer
  91306. * @returns the webGL uniform buffer
  91307. */
  91308. createUniformBuffer(elements: FloatArray): DataBuffer;
  91309. /**
  91310. * Create a dynamic uniform buffer
  91311. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91312. * @param elements defines the content of the uniform buffer
  91313. * @returns the webGL uniform buffer
  91314. */
  91315. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  91316. /**
  91317. * Update an existing uniform buffer
  91318. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91319. * @param uniformBuffer defines the target uniform buffer
  91320. * @param elements defines the content to update
  91321. * @param offset defines the offset in the uniform buffer where update should start
  91322. * @param count defines the size of the data to update
  91323. */
  91324. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  91325. private _resetVertexBufferBinding;
  91326. /**
  91327. * Creates a vertex buffer
  91328. * @param data the data for the vertex buffer
  91329. * @returns the new WebGL static buffer
  91330. */
  91331. createVertexBuffer(data: DataArray): DataBuffer;
  91332. /**
  91333. * Creates a dynamic vertex buffer
  91334. * @param data the data for the dynamic vertex buffer
  91335. * @returns the new WebGL dynamic buffer
  91336. */
  91337. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  91338. /**
  91339. * Update a dynamic index buffer
  91340. * @param indexBuffer defines the target index buffer
  91341. * @param indices defines the data to update
  91342. * @param offset defines the offset in the target index buffer where update should start
  91343. */
  91344. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91345. /**
  91346. * Updates a dynamic vertex buffer.
  91347. * @param vertexBuffer the vertex buffer to update
  91348. * @param data the data used to update the vertex buffer
  91349. * @param byteOffset the byte offset of the data
  91350. * @param byteLength the byte length of the data
  91351. */
  91352. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91353. private _resetIndexBufferBinding;
  91354. /**
  91355. * Creates a new index buffer
  91356. * @param indices defines the content of the index buffer
  91357. * @param updatable defines if the index buffer must be updatable
  91358. * @returns a new webGL buffer
  91359. */
  91360. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  91361. /**
  91362. * Bind a webGL buffer to the webGL context
  91363. * @param buffer defines the buffer to bind
  91364. */
  91365. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  91366. /**
  91367. * Bind an uniform buffer to the current webGL context
  91368. * @param buffer defines the buffer to bind
  91369. */
  91370. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  91371. /**
  91372. * Bind a buffer to the current webGL context at a given location
  91373. * @param buffer defines the buffer to bind
  91374. * @param location defines the index where to bind the buffer
  91375. */
  91376. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  91377. /**
  91378. * Bind a specific block at a given index in a specific shader program
  91379. * @param pipelineContext defines the pipeline context to use
  91380. * @param blockName defines the block name
  91381. * @param index defines the index where to bind the block
  91382. */
  91383. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  91384. private bindIndexBuffer;
  91385. private bindBuffer;
  91386. /**
  91387. * update the bound buffer with the given data
  91388. * @param data defines the data to update
  91389. */
  91390. updateArrayBuffer(data: Float32Array): void;
  91391. private _vertexAttribPointer;
  91392. private _bindIndexBufferWithCache;
  91393. private _bindVertexBuffersAttributes;
  91394. /**
  91395. * Records a vertex array object
  91396. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91397. * @param vertexBuffers defines the list of vertex buffers to store
  91398. * @param indexBuffer defines the index buffer to store
  91399. * @param effect defines the effect to store
  91400. * @returns the new vertex array object
  91401. */
  91402. recordVertexArrayObject(vertexBuffers: {
  91403. [key: string]: VertexBuffer;
  91404. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  91405. /**
  91406. * Bind a specific vertex array object
  91407. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91408. * @param vertexArrayObject defines the vertex array object to bind
  91409. * @param indexBuffer defines the index buffer to bind
  91410. */
  91411. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  91412. /**
  91413. * Bind webGl buffers directly to the webGL context
  91414. * @param vertexBuffer defines the vertex buffer to bind
  91415. * @param indexBuffer defines the index buffer to bind
  91416. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  91417. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  91418. * @param effect defines the effect associated with the vertex buffer
  91419. */
  91420. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  91421. private _unbindVertexArrayObject;
  91422. /**
  91423. * Bind a list of vertex buffers to the webGL context
  91424. * @param vertexBuffers defines the list of vertex buffers to bind
  91425. * @param indexBuffer defines the index buffer to bind
  91426. * @param effect defines the effect associated with the vertex buffers
  91427. */
  91428. bindBuffers(vertexBuffers: {
  91429. [key: string]: Nullable<VertexBuffer>;
  91430. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  91431. /**
  91432. * Unbind all instance attributes
  91433. */
  91434. unbindInstanceAttributes(): void;
  91435. /**
  91436. * Release and free the memory of a vertex array object
  91437. * @param vao defines the vertex array object to delete
  91438. */
  91439. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  91440. /** @hidden */
  91441. _releaseBuffer(buffer: DataBuffer): boolean;
  91442. /**
  91443. * Creates a webGL buffer to use with instanciation
  91444. * @param capacity defines the size of the buffer
  91445. * @returns the webGL buffer
  91446. */
  91447. createInstancesBuffer(capacity: number): DataBuffer;
  91448. /**
  91449. * Delete a webGL buffer used with instanciation
  91450. * @param buffer defines the webGL buffer to delete
  91451. */
  91452. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  91453. /**
  91454. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  91455. * @param instancesBuffer defines the webGL buffer to update and bind
  91456. * @param data defines the data to store in the buffer
  91457. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  91458. */
  91459. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  91460. /**
  91461. * Apply all cached states (depth, culling, stencil and alpha)
  91462. */
  91463. applyStates(): void;
  91464. /**
  91465. * Send a draw order
  91466. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91467. * @param indexStart defines the starting index
  91468. * @param indexCount defines the number of index to draw
  91469. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91470. */
  91471. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  91472. /**
  91473. * Draw a list of points
  91474. * @param verticesStart defines the index of first vertex to draw
  91475. * @param verticesCount defines the count of vertices to draw
  91476. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91477. */
  91478. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91479. /**
  91480. * Draw a list of unindexed primitives
  91481. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91482. * @param verticesStart defines the index of first vertex to draw
  91483. * @param verticesCount defines the count of vertices to draw
  91484. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91485. */
  91486. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91487. /**
  91488. * Draw a list of indexed primitives
  91489. * @param fillMode defines the primitive to use
  91490. * @param indexStart defines the starting index
  91491. * @param indexCount defines the number of index to draw
  91492. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91493. */
  91494. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  91495. /**
  91496. * Draw a list of unindexed primitives
  91497. * @param fillMode defines the primitive to use
  91498. * @param verticesStart defines the index of first vertex to draw
  91499. * @param verticesCount defines the count of vertices to draw
  91500. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91501. */
  91502. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91503. private _drawMode;
  91504. /** @hidden */
  91505. _releaseEffect(effect: Effect): void;
  91506. /** @hidden */
  91507. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  91508. /**
  91509. * Create a new effect (used to store vertex/fragment shaders)
  91510. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  91511. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  91512. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  91513. * @param samplers defines an array of string used to represent textures
  91514. * @param defines defines the string containing the defines to use to compile the shaders
  91515. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  91516. * @param onCompiled defines a function to call when the effect creation is successful
  91517. * @param onError defines a function to call when the effect creation has failed
  91518. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  91519. * @returns the new Effect
  91520. */
  91521. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  91522. private _compileShader;
  91523. private _compileRawShader;
  91524. /**
  91525. * Directly creates a webGL program
  91526. * @param pipelineContext defines the pipeline context to attach to
  91527. * @param vertexCode defines the vertex shader code to use
  91528. * @param fragmentCode defines the fragment shader code to use
  91529. * @param context defines the webGL context to use (if not set, the current one will be used)
  91530. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91531. * @returns the new webGL program
  91532. */
  91533. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91534. /**
  91535. * Creates a webGL program
  91536. * @param pipelineContext defines the pipeline context to attach to
  91537. * @param vertexCode defines the vertex shader code to use
  91538. * @param fragmentCode defines the fragment shader code to use
  91539. * @param defines defines the string containing the defines to use to compile the shaders
  91540. * @param context defines the webGL context to use (if not set, the current one will be used)
  91541. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91542. * @returns the new webGL program
  91543. */
  91544. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91545. /**
  91546. * Creates a new pipeline context
  91547. * @returns the new pipeline
  91548. */
  91549. createPipelineContext(): WebGLPipelineContext;
  91550. private _createShaderProgram;
  91551. private _finalizePipelineContext;
  91552. /** @hidden */
  91553. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  91554. /** @hidden */
  91555. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  91556. /** @hidden */
  91557. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  91558. /**
  91559. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  91560. * @param pipelineContext defines the pipeline context to use
  91561. * @param uniformsNames defines the list of uniform names
  91562. * @returns an array of webGL uniform locations
  91563. */
  91564. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  91565. /**
  91566. * Gets the lsit of active attributes for a given webGL program
  91567. * @param pipelineContext defines the pipeline context to use
  91568. * @param attributesNames defines the list of attribute names to get
  91569. * @returns an array of indices indicating the offset of each attribute
  91570. */
  91571. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  91572. /**
  91573. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  91574. * @param effect defines the effect to activate
  91575. */
  91576. enableEffect(effect: Nullable<Effect>): void;
  91577. /**
  91578. * Set the value of an uniform to an array of int32
  91579. * @param uniform defines the webGL uniform location where to store the value
  91580. * @param array defines the array of int32 to store
  91581. */
  91582. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91583. /**
  91584. * Set the value of an uniform to an array of int32 (stored as vec2)
  91585. * @param uniform defines the webGL uniform location where to store the value
  91586. * @param array defines the array of int32 to store
  91587. */
  91588. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91589. /**
  91590. * Set the value of an uniform to an array of int32 (stored as vec3)
  91591. * @param uniform defines the webGL uniform location where to store the value
  91592. * @param array defines the array of int32 to store
  91593. */
  91594. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91595. /**
  91596. * Set the value of an uniform to an array of int32 (stored as vec4)
  91597. * @param uniform defines the webGL uniform location where to store the value
  91598. * @param array defines the array of int32 to store
  91599. */
  91600. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91601. /**
  91602. * Set the value of an uniform to an array of float32
  91603. * @param uniform defines the webGL uniform location where to store the value
  91604. * @param array defines the array of float32 to store
  91605. */
  91606. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91607. /**
  91608. * Set the value of an uniform to an array of float32 (stored as vec2)
  91609. * @param uniform defines the webGL uniform location where to store the value
  91610. * @param array defines the array of float32 to store
  91611. */
  91612. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91613. /**
  91614. * Set the value of an uniform to an array of float32 (stored as vec3)
  91615. * @param uniform defines the webGL uniform location where to store the value
  91616. * @param array defines the array of float32 to store
  91617. */
  91618. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91619. /**
  91620. * Set the value of an uniform to an array of float32 (stored as vec4)
  91621. * @param uniform defines the webGL uniform location where to store the value
  91622. * @param array defines the array of float32 to store
  91623. */
  91624. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91625. /**
  91626. * Set the value of an uniform to an array of number
  91627. * @param uniform defines the webGL uniform location where to store the value
  91628. * @param array defines the array of number to store
  91629. */
  91630. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91631. /**
  91632. * Set the value of an uniform to an array of number (stored as vec2)
  91633. * @param uniform defines the webGL uniform location where to store the value
  91634. * @param array defines the array of number to store
  91635. */
  91636. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91637. /**
  91638. * Set the value of an uniform to an array of number (stored as vec3)
  91639. * @param uniform defines the webGL uniform location where to store the value
  91640. * @param array defines the array of number to store
  91641. */
  91642. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91643. /**
  91644. * Set the value of an uniform to an array of number (stored as vec4)
  91645. * @param uniform defines the webGL uniform location where to store the value
  91646. * @param array defines the array of number to store
  91647. */
  91648. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91649. /**
  91650. * Set the value of an uniform to an array of float32 (stored as matrices)
  91651. * @param uniform defines the webGL uniform location where to store the value
  91652. * @param matrices defines the array of float32 to store
  91653. */
  91654. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  91655. /**
  91656. * Set the value of an uniform to a matrix
  91657. * @param uniform defines the webGL uniform location where to store the value
  91658. * @param matrix defines the matrix to store
  91659. */
  91660. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  91661. /**
  91662. * Set the value of an uniform to a matrix (3x3)
  91663. * @param uniform defines the webGL uniform location where to store the value
  91664. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  91665. */
  91666. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91667. /**
  91668. * Set the value of an uniform to a matrix (2x2)
  91669. * @param uniform defines the webGL uniform location where to store the value
  91670. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  91671. */
  91672. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91673. /**
  91674. * Set the value of an uniform to a number (int)
  91675. * @param uniform defines the webGL uniform location where to store the value
  91676. * @param value defines the int number to store
  91677. */
  91678. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91679. /**
  91680. * Set the value of an uniform to a number (float)
  91681. * @param uniform defines the webGL uniform location where to store the value
  91682. * @param value defines the float number to store
  91683. */
  91684. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91685. /**
  91686. * Set the value of an uniform to a vec2
  91687. * @param uniform defines the webGL uniform location where to store the value
  91688. * @param x defines the 1st component of the value
  91689. * @param y defines the 2nd component of the value
  91690. */
  91691. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  91692. /**
  91693. * Set the value of an uniform to a vec3
  91694. * @param uniform defines the webGL uniform location where to store the value
  91695. * @param x defines the 1st component of the value
  91696. * @param y defines the 2nd component of the value
  91697. * @param z defines the 3rd component of the value
  91698. */
  91699. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  91700. /**
  91701. * Set the value of an uniform to a boolean
  91702. * @param uniform defines the webGL uniform location where to store the value
  91703. * @param bool defines the boolean to store
  91704. */
  91705. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  91706. /**
  91707. * Set the value of an uniform to a vec4
  91708. * @param uniform defines the webGL uniform location where to store the value
  91709. * @param x defines the 1st component of the value
  91710. * @param y defines the 2nd component of the value
  91711. * @param z defines the 3rd component of the value
  91712. * @param w defines the 4th component of the value
  91713. */
  91714. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  91715. /**
  91716. * Set the value of an uniform to a Color3
  91717. * @param uniform defines the webGL uniform location where to store the value
  91718. * @param color3 defines the color to store
  91719. */
  91720. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  91721. /**
  91722. * Set the value of an uniform to a Color3 and an alpha value
  91723. * @param uniform defines the webGL uniform location where to store the value
  91724. * @param color3 defines the color to store
  91725. * @param alpha defines the alpha component to store
  91726. */
  91727. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  91728. /**
  91729. * Sets a Color4 on a uniform variable
  91730. * @param uniform defines the uniform location
  91731. * @param color4 defines the value to be set
  91732. */
  91733. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  91734. /**
  91735. * Set various states to the webGL context
  91736. * @param culling defines backface culling state
  91737. * @param zOffset defines the value to apply to zOffset (0 by default)
  91738. * @param force defines if states must be applied even if cache is up to date
  91739. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  91740. */
  91741. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  91742. /**
  91743. * Set the z offset to apply to current rendering
  91744. * @param value defines the offset to apply
  91745. */
  91746. setZOffset(value: number): void;
  91747. /**
  91748. * Gets the current value of the zOffset
  91749. * @returns the current zOffset state
  91750. */
  91751. getZOffset(): number;
  91752. /**
  91753. * Enable or disable depth buffering
  91754. * @param enable defines the state to set
  91755. */
  91756. setDepthBuffer(enable: boolean): void;
  91757. /**
  91758. * Gets a boolean indicating if depth writing is enabled
  91759. * @returns the current depth writing state
  91760. */
  91761. getDepthWrite(): boolean;
  91762. /**
  91763. * Enable or disable depth writing
  91764. * @param enable defines the state to set
  91765. */
  91766. setDepthWrite(enable: boolean): void;
  91767. /**
  91768. * Enable or disable color writing
  91769. * @param enable defines the state to set
  91770. */
  91771. setColorWrite(enable: boolean): void;
  91772. /**
  91773. * Gets a boolean indicating if color writing is enabled
  91774. * @returns the current color writing state
  91775. */
  91776. getColorWrite(): boolean;
  91777. /**
  91778. * Sets alpha constants used by some alpha blending modes
  91779. * @param r defines the red component
  91780. * @param g defines the green component
  91781. * @param b defines the blue component
  91782. * @param a defines the alpha component
  91783. */
  91784. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  91785. /**
  91786. * Sets the current alpha mode
  91787. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  91788. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  91789. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91790. */
  91791. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  91792. /**
  91793. * Gets the current alpha mode
  91794. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91795. * @returns the current alpha mode
  91796. */
  91797. getAlphaMode(): number;
  91798. /**
  91799. * Clears the list of texture accessible through engine.
  91800. * This can help preventing texture load conflict due to name collision.
  91801. */
  91802. clearInternalTexturesCache(): void;
  91803. /**
  91804. * Force the entire cache to be cleared
  91805. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  91806. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  91807. */
  91808. wipeCaches(bruteForce?: boolean): void;
  91809. /**
  91810. * Set the compressed texture format to use, based on the formats you have, and the formats
  91811. * supported by the hardware / browser.
  91812. *
  91813. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  91814. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  91815. * to API arguments needed to compressed textures. This puts the burden on the container
  91816. * generator to house the arcane code for determining these for current & future formats.
  91817. *
  91818. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  91819. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  91820. *
  91821. * Note: The result of this call is not taken into account when a texture is base64.
  91822. *
  91823. * @param formatsAvailable defines the list of those format families you have created
  91824. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  91825. *
  91826. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  91827. * @returns The extension selected.
  91828. */
  91829. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  91830. /** @hidden */
  91831. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  91832. min: number;
  91833. mag: number;
  91834. };
  91835. /** @hidden */
  91836. _createTexture(): WebGLTexture;
  91837. /**
  91838. * Usually called from Texture.ts.
  91839. * Passed information to create a WebGLTexture
  91840. * @param urlArg defines a value which contains one of the following:
  91841. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  91842. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  91843. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  91844. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  91845. * @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)
  91846. * @param scene needed for loading to the correct scene
  91847. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  91848. * @param onLoad optional callback to be called upon successful completion
  91849. * @param onError optional callback to be called upon failure
  91850. * @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
  91851. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  91852. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  91853. * @param forcedExtension defines the extension to use to pick the right loader
  91854. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  91855. * @returns a InternalTexture for assignment back into BABYLON.Texture
  91856. */
  91857. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  91858. /**
  91859. * @hidden
  91860. * Rescales a texture
  91861. * @param source input texutre
  91862. * @param destination destination texture
  91863. * @param scene scene to use to render the resize
  91864. * @param internalFormat format to use when resizing
  91865. * @param onComplete callback to be called when resize has completed
  91866. */
  91867. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  91868. private _unpackFlipYCached;
  91869. /**
  91870. * In case you are sharing the context with other applications, it might
  91871. * be interested to not cache the unpack flip y state to ensure a consistent
  91872. * value would be set.
  91873. */
  91874. enableUnpackFlipYCached: boolean;
  91875. /** @hidden */
  91876. _unpackFlipY(value: boolean): void;
  91877. /** @hidden */
  91878. _getUnpackAlignement(): number;
  91879. /**
  91880. * Creates a dynamic texture
  91881. * @param width defines the width of the texture
  91882. * @param height defines the height of the texture
  91883. * @param generateMipMaps defines if the engine should generate the mip levels
  91884. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91885. * @returns the dynamic texture inside an InternalTexture
  91886. */
  91887. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  91888. /**
  91889. * Update the sampling mode of a given texture
  91890. * @param samplingMode defines the required sampling mode
  91891. * @param texture defines the texture to update
  91892. */
  91893. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  91894. /**
  91895. * Update the content of a dynamic texture
  91896. * @param texture defines the texture to update
  91897. * @param canvas defines the canvas containing the source
  91898. * @param invertY defines if data must be stored with Y axis inverted
  91899. * @param premulAlpha defines if alpha is stored as premultiplied
  91900. * @param format defines the format of the data
  91901. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  91902. */
  91903. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  91904. /**
  91905. * Update a video texture
  91906. * @param texture defines the texture to update
  91907. * @param video defines the video element to use
  91908. * @param invertY defines if data must be stored with Y axis inverted
  91909. */
  91910. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  91911. /**
  91912. * Updates a depth texture Comparison Mode and Function.
  91913. * If the comparison Function is equal to 0, the mode will be set to none.
  91914. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  91915. * @param texture The texture to set the comparison function for
  91916. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  91917. */
  91918. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  91919. /** @hidden */
  91920. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  91921. width: number;
  91922. height: number;
  91923. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  91924. /**
  91925. * Creates a depth stencil texture.
  91926. * This is only available in WebGL 2 or with the depth texture extension available.
  91927. * @param size The size of face edge in the texture.
  91928. * @param options The options defining the texture.
  91929. * @returns The texture
  91930. */
  91931. createDepthStencilTexture(size: number | {
  91932. width: number;
  91933. height: number;
  91934. }, options: DepthTextureCreationOptions): InternalTexture;
  91935. /**
  91936. * Creates a depth stencil texture.
  91937. * This is only available in WebGL 2 or with the depth texture extension available.
  91938. * @param size The size of face edge in the texture.
  91939. * @param options The options defining the texture.
  91940. * @returns The texture
  91941. */
  91942. private _createDepthStencilTexture;
  91943. /**
  91944. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  91945. * @param renderTarget The render target to set the frame buffer for
  91946. */
  91947. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  91948. /**
  91949. * Creates a new render target texture
  91950. * @param size defines the size of the texture
  91951. * @param options defines the options used to create the texture
  91952. * @returns a new render target texture stored in an InternalTexture
  91953. */
  91954. createRenderTargetTexture(size: number | {
  91955. width: number;
  91956. height: number;
  91957. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  91958. /** @hidden */
  91959. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  91960. /**
  91961. * Updates the sample count of a render target texture
  91962. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  91963. * @param texture defines the texture to update
  91964. * @param samples defines the sample count to set
  91965. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  91966. */
  91967. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  91968. /** @hidden */
  91969. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91970. /** @hidden */
  91971. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  91972. /** @hidden */
  91973. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91974. /** @hidden */
  91975. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  91976. /**
  91977. * @hidden
  91978. */
  91979. _setCubeMapTextureParams(loadMipmap: boolean): void;
  91980. private _prepareWebGLTextureContinuation;
  91981. private _prepareWebGLTexture;
  91982. /** @hidden */
  91983. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  91984. /** @hidden */
  91985. _releaseFramebufferObjects(texture: InternalTexture): void;
  91986. /** @hidden */
  91987. _releaseTexture(texture: InternalTexture): void;
  91988. private setProgram;
  91989. private _boundUniforms;
  91990. /**
  91991. * Binds an effect to the webGL context
  91992. * @param effect defines the effect to bind
  91993. */
  91994. bindSamplers(effect: Effect): void;
  91995. private _activateCurrentTexture;
  91996. /** @hidden */
  91997. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  91998. /** @hidden */
  91999. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  92000. /**
  92001. * Sets a texture to the webGL context from a postprocess
  92002. * @param channel defines the channel to use
  92003. * @param postProcess defines the source postprocess
  92004. */
  92005. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  92006. /**
  92007. * Binds the output of the passed in post process to the texture channel specified
  92008. * @param channel The channel the texture should be bound to
  92009. * @param postProcess The post process which's output should be bound
  92010. */
  92011. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  92012. /**
  92013. * Unbind all textures from the webGL context
  92014. */
  92015. unbindAllTextures(): void;
  92016. /**
  92017. * Sets a texture to the according uniform.
  92018. * @param channel The texture channel
  92019. * @param uniform The uniform to set
  92020. * @param texture The texture to apply
  92021. */
  92022. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  92023. /**
  92024. * Sets a depth stencil texture from a render target to the according uniform.
  92025. * @param channel The texture channel
  92026. * @param uniform The uniform to set
  92027. * @param texture The render target texture containing the depth stencil texture to apply
  92028. */
  92029. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  92030. private _bindSamplerUniformToChannel;
  92031. private _getTextureWrapMode;
  92032. private _setTexture;
  92033. /**
  92034. * Sets an array of texture to the webGL context
  92035. * @param channel defines the channel where the texture array must be set
  92036. * @param uniform defines the associated uniform location
  92037. * @param textures defines the array of textures to bind
  92038. */
  92039. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  92040. /** @hidden */
  92041. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  92042. private _setTextureParameterFloat;
  92043. private _setTextureParameterInteger;
  92044. /**
  92045. * Reads pixels from the current frame buffer. Please note that this function can be slow
  92046. * @param x defines the x coordinate of the rectangle where pixels must be read
  92047. * @param y defines the y coordinate of the rectangle where pixels must be read
  92048. * @param width defines the width of the rectangle where pixels must be read
  92049. * @param height defines the height of the rectangle where pixels must be read
  92050. * @returns a Uint8Array containing RGBA colors
  92051. */
  92052. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  92053. /**
  92054. * Add an externaly attached data from its key.
  92055. * This method call will fail and return false, if such key already exists.
  92056. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  92057. * @param key the unique key that identifies the data
  92058. * @param data the data object to associate to the key for this Engine instance
  92059. * @return true if no such key were already present and the data was added successfully, false otherwise
  92060. */
  92061. addExternalData<T>(key: string, data: T): boolean;
  92062. /**
  92063. * Get an externaly attached data from its key
  92064. * @param key the unique key that identifies the data
  92065. * @return the associated data, if present (can be null), or undefined if not present
  92066. */
  92067. getExternalData<T>(key: string): T;
  92068. /**
  92069. * Get an externaly attached data from its key, create it using a factory if it's not already present
  92070. * @param key the unique key that identifies the data
  92071. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  92072. * @return the associated data, can be null if the factory returned null.
  92073. */
  92074. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  92075. /**
  92076. * Remove an externaly attached data from the Engine instance
  92077. * @param key the unique key that identifies the data
  92078. * @return true if the data was successfully removed, false if it doesn't exist
  92079. */
  92080. removeExternalData(key: string): boolean;
  92081. /**
  92082. * Unbind all vertex attributes from the webGL context
  92083. */
  92084. unbindAllAttributes(): void;
  92085. /**
  92086. * 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
  92087. */
  92088. releaseEffects(): void;
  92089. /**
  92090. * Dispose and release all associated resources
  92091. */
  92092. dispose(): void;
  92093. /**
  92094. * Display the loading screen
  92095. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92096. */
  92097. displayLoadingUI(): void;
  92098. /**
  92099. * Hide the loading screen
  92100. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92101. */
  92102. hideLoadingUI(): void;
  92103. /**
  92104. * Gets the current loading screen object
  92105. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92106. */
  92107. /**
  92108. * Sets the current loading screen object
  92109. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92110. */
  92111. loadingScreen: ILoadingScreen;
  92112. /**
  92113. * Sets the current loading screen text
  92114. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92115. */
  92116. loadingUIText: string;
  92117. /**
  92118. * Sets the current loading screen background color
  92119. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92120. */
  92121. loadingUIBackgroundColor: string;
  92122. /**
  92123. * Attach a new callback raised when context lost event is fired
  92124. * @param callback defines the callback to call
  92125. */
  92126. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  92127. /**
  92128. * Attach a new callback raised when context restored event is fired
  92129. * @param callback defines the callback to call
  92130. */
  92131. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  92132. /**
  92133. * Gets the source code of the vertex shader associated with a specific webGL program
  92134. * @param program defines the program to use
  92135. * @returns a string containing the source code of the vertex shader associated with the program
  92136. */
  92137. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  92138. /**
  92139. * Gets the source code of the fragment shader associated with a specific webGL program
  92140. * @param program defines the program to use
  92141. * @returns a string containing the source code of the fragment shader associated with the program
  92142. */
  92143. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  92144. /**
  92145. * Get the current error code of the webGL context
  92146. * @returns the error code
  92147. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  92148. */
  92149. getError(): number;
  92150. /**
  92151. * Gets the current framerate
  92152. * @returns a number representing the framerate
  92153. */
  92154. getFps(): number;
  92155. /**
  92156. * Gets the time spent between current and previous frame
  92157. * @returns a number representing the delta time in ms
  92158. */
  92159. getDeltaTime(): number;
  92160. private _measureFps;
  92161. /** @hidden */
  92162. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  92163. private _canRenderToFloatFramebuffer;
  92164. private _canRenderToHalfFloatFramebuffer;
  92165. private _canRenderToFramebuffer;
  92166. /** @hidden */
  92167. _getWebGLTextureType(type: number): number;
  92168. /** @hidden */
  92169. _getInternalFormat(format: number): number;
  92170. /** @hidden */
  92171. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  92172. /** @hidden */
  92173. _getRGBAMultiSampleBufferFormat(type: number): number;
  92174. /** @hidden */
  92175. _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;
  92176. /** @hidden */
  92177. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  92178. /**
  92179. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  92180. * @returns true if the engine can be created
  92181. * @ignorenaming
  92182. */
  92183. static isSupported(): boolean;
  92184. }
  92185. }
  92186. declare module BABYLON {
  92187. /**
  92188. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  92189. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  92190. */
  92191. export class EffectFallbacks {
  92192. private _defines;
  92193. private _currentRank;
  92194. private _maxRank;
  92195. private _mesh;
  92196. /**
  92197. * Removes the fallback from the bound mesh.
  92198. */
  92199. unBindMesh(): void;
  92200. /**
  92201. * Adds a fallback on the specified property.
  92202. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92203. * @param define The name of the define in the shader
  92204. */
  92205. addFallback(rank: number, define: string): void;
  92206. /**
  92207. * Sets the mesh to use CPU skinning when needing to fallback.
  92208. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92209. * @param mesh The mesh to use the fallbacks.
  92210. */
  92211. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  92212. /**
  92213. * Checks to see if more fallbacks are still availible.
  92214. */
  92215. readonly isMoreFallbacks: boolean;
  92216. /**
  92217. * Removes the defines that should be removed when falling back.
  92218. * @param currentDefines defines the current define statements for the shader.
  92219. * @param effect defines the current effect we try to compile
  92220. * @returns The resulting defines with defines of the current rank removed.
  92221. */
  92222. reduce(currentDefines: string, effect: Effect): string;
  92223. }
  92224. /**
  92225. * Options to be used when creating an effect.
  92226. */
  92227. export class EffectCreationOptions {
  92228. /**
  92229. * Atrributes that will be used in the shader.
  92230. */
  92231. attributes: string[];
  92232. /**
  92233. * Uniform varible names that will be set in the shader.
  92234. */
  92235. uniformsNames: string[];
  92236. /**
  92237. * Uniform buffer varible names that will be set in the shader.
  92238. */
  92239. uniformBuffersNames: string[];
  92240. /**
  92241. * Sampler texture variable names that will be set in the shader.
  92242. */
  92243. samplers: string[];
  92244. /**
  92245. * Define statements that will be set in the shader.
  92246. */
  92247. defines: any;
  92248. /**
  92249. * Possible fallbacks for this effect to improve performance when needed.
  92250. */
  92251. fallbacks: Nullable<EffectFallbacks>;
  92252. /**
  92253. * Callback that will be called when the shader is compiled.
  92254. */
  92255. onCompiled: Nullable<(effect: Effect) => void>;
  92256. /**
  92257. * Callback that will be called if an error occurs during shader compilation.
  92258. */
  92259. onError: Nullable<(effect: Effect, errors: string) => void>;
  92260. /**
  92261. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92262. */
  92263. indexParameters: any;
  92264. /**
  92265. * Max number of lights that can be used in the shader.
  92266. */
  92267. maxSimultaneousLights: number;
  92268. /**
  92269. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  92270. */
  92271. transformFeedbackVaryings: Nullable<string[]>;
  92272. }
  92273. /**
  92274. * Effect containing vertex and fragment shader that can be executed on an object.
  92275. */
  92276. export class Effect implements IDisposable {
  92277. /**
  92278. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  92279. */
  92280. static ShadersRepository: string;
  92281. /**
  92282. * Name of the effect.
  92283. */
  92284. name: any;
  92285. /**
  92286. * String container all the define statements that should be set on the shader.
  92287. */
  92288. defines: string;
  92289. /**
  92290. * Callback that will be called when the shader is compiled.
  92291. */
  92292. onCompiled: Nullable<(effect: Effect) => void>;
  92293. /**
  92294. * Callback that will be called if an error occurs during shader compilation.
  92295. */
  92296. onError: Nullable<(effect: Effect, errors: string) => void>;
  92297. /**
  92298. * Callback that will be called when effect is bound.
  92299. */
  92300. onBind: Nullable<(effect: Effect) => void>;
  92301. /**
  92302. * Unique ID of the effect.
  92303. */
  92304. uniqueId: number;
  92305. /**
  92306. * Observable that will be called when the shader is compiled.
  92307. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  92308. */
  92309. onCompileObservable: Observable<Effect>;
  92310. /**
  92311. * Observable that will be called if an error occurs during shader compilation.
  92312. */
  92313. onErrorObservable: Observable<Effect>;
  92314. /** @hidden */
  92315. _onBindObservable: Nullable<Observable<Effect>>;
  92316. /**
  92317. * Observable that will be called when effect is bound.
  92318. */
  92319. readonly onBindObservable: Observable<Effect>;
  92320. /** @hidden */
  92321. _bonesComputationForcedToCPU: boolean;
  92322. private static _uniqueIdSeed;
  92323. private _engine;
  92324. private _uniformBuffersNames;
  92325. private _uniformsNames;
  92326. private _samplerList;
  92327. private _samplers;
  92328. private _isReady;
  92329. private _compilationError;
  92330. private _attributesNames;
  92331. private _attributes;
  92332. private _uniforms;
  92333. /**
  92334. * Key for the effect.
  92335. * @hidden
  92336. */
  92337. _key: string;
  92338. private _indexParameters;
  92339. private _fallbacks;
  92340. private _vertexSourceCode;
  92341. private _fragmentSourceCode;
  92342. private _vertexSourceCodeOverride;
  92343. private _fragmentSourceCodeOverride;
  92344. private _transformFeedbackVaryings;
  92345. /**
  92346. * Compiled shader to webGL program.
  92347. * @hidden
  92348. */
  92349. _pipelineContext: Nullable<IPipelineContext>;
  92350. private _valueCache;
  92351. private static _baseCache;
  92352. /**
  92353. * Instantiates an effect.
  92354. * An effect can be used to create/manage/execute vertex and fragment shaders.
  92355. * @param baseName Name of the effect.
  92356. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  92357. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  92358. * @param samplers List of sampler variables that will be passed to the shader.
  92359. * @param engine Engine to be used to render the effect
  92360. * @param defines Define statements to be added to the shader.
  92361. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  92362. * @param onCompiled Callback that will be called when the shader is compiled.
  92363. * @param onError Callback that will be called if an error occurs during shader compilation.
  92364. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92365. */
  92366. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  92367. private _useFinalCode;
  92368. /**
  92369. * Unique key for this effect
  92370. */
  92371. readonly key: string;
  92372. /**
  92373. * If the effect has been compiled and prepared.
  92374. * @returns if the effect is compiled and prepared.
  92375. */
  92376. isReady(): boolean;
  92377. /**
  92378. * The engine the effect was initialized with.
  92379. * @returns the engine.
  92380. */
  92381. getEngine(): Engine;
  92382. /**
  92383. * The pipeline context for this effect
  92384. * @returns the associated pipeline context
  92385. */
  92386. getPipelineContext(): Nullable<IPipelineContext>;
  92387. /**
  92388. * The set of names of attribute variables for the shader.
  92389. * @returns An array of attribute names.
  92390. */
  92391. getAttributesNames(): string[];
  92392. /**
  92393. * Returns the attribute at the given index.
  92394. * @param index The index of the attribute.
  92395. * @returns The location of the attribute.
  92396. */
  92397. getAttributeLocation(index: number): number;
  92398. /**
  92399. * Returns the attribute based on the name of the variable.
  92400. * @param name of the attribute to look up.
  92401. * @returns the attribute location.
  92402. */
  92403. getAttributeLocationByName(name: string): number;
  92404. /**
  92405. * The number of attributes.
  92406. * @returns the numnber of attributes.
  92407. */
  92408. getAttributesCount(): number;
  92409. /**
  92410. * Gets the index of a uniform variable.
  92411. * @param uniformName of the uniform to look up.
  92412. * @returns the index.
  92413. */
  92414. getUniformIndex(uniformName: string): number;
  92415. /**
  92416. * Returns the attribute based on the name of the variable.
  92417. * @param uniformName of the uniform to look up.
  92418. * @returns the location of the uniform.
  92419. */
  92420. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92421. /**
  92422. * Returns an array of sampler variable names
  92423. * @returns The array of sampler variable neames.
  92424. */
  92425. getSamplers(): string[];
  92426. /**
  92427. * The error from the last compilation.
  92428. * @returns the error string.
  92429. */
  92430. getCompilationError(): string;
  92431. /**
  92432. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92433. * @param func The callback to be used.
  92434. */
  92435. executeWhenCompiled(func: (effect: Effect) => void): void;
  92436. private _checkIsReady;
  92437. /** @hidden */
  92438. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92439. /** @hidden */
  92440. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92441. /** @hidden */
  92442. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92443. /**
  92444. * Recompiles the webGL program
  92445. * @param vertexSourceCode The source code for the vertex shader.
  92446. * @param fragmentSourceCode The source code for the fragment shader.
  92447. * @param onCompiled Callback called when completed.
  92448. * @param onError Callback called on error.
  92449. * @hidden
  92450. */
  92451. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92452. /**
  92453. * Prepares the effect
  92454. * @hidden
  92455. */
  92456. _prepareEffect(): void;
  92457. /**
  92458. * Checks if the effect is supported. (Must be called after compilation)
  92459. */
  92460. readonly isSupported: boolean;
  92461. /**
  92462. * Binds a texture to the engine to be used as output of the shader.
  92463. * @param channel Name of the output variable.
  92464. * @param texture Texture to bind.
  92465. * @hidden
  92466. */
  92467. _bindTexture(channel: string, texture: InternalTexture): void;
  92468. /**
  92469. * Sets a texture on the engine to be used in the shader.
  92470. * @param channel Name of the sampler variable.
  92471. * @param texture Texture to set.
  92472. */
  92473. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92474. /**
  92475. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92476. * @param channel Name of the sampler variable.
  92477. * @param texture Texture to set.
  92478. */
  92479. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92480. /**
  92481. * Sets an array of textures on the engine to be used in the shader.
  92482. * @param channel Name of the variable.
  92483. * @param textures Textures to set.
  92484. */
  92485. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92486. /**
  92487. * 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)
  92488. * @param channel Name of the sampler variable.
  92489. * @param postProcess Post process to get the input texture from.
  92490. */
  92491. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92492. /**
  92493. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92494. * 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)
  92495. * @param channel Name of the sampler variable.
  92496. * @param postProcess Post process to get the output texture from.
  92497. */
  92498. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92499. /** @hidden */
  92500. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  92501. /** @hidden */
  92502. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92503. /** @hidden */
  92504. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92505. /** @hidden */
  92506. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92507. /**
  92508. * Binds a buffer to a uniform.
  92509. * @param buffer Buffer to bind.
  92510. * @param name Name of the uniform variable to bind to.
  92511. */
  92512. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92513. /**
  92514. * Binds block to a uniform.
  92515. * @param blockName Name of the block to bind.
  92516. * @param index Index to bind.
  92517. */
  92518. bindUniformBlock(blockName: string, index: number): void;
  92519. /**
  92520. * Sets an interger value on a uniform variable.
  92521. * @param uniformName Name of the variable.
  92522. * @param value Value to be set.
  92523. * @returns this effect.
  92524. */
  92525. setInt(uniformName: string, value: number): Effect;
  92526. /**
  92527. * Sets an int array on a uniform variable.
  92528. * @param uniformName Name of the variable.
  92529. * @param array array to be set.
  92530. * @returns this effect.
  92531. */
  92532. setIntArray(uniformName: string, array: Int32Array): Effect;
  92533. /**
  92534. * 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)
  92535. * @param uniformName Name of the variable.
  92536. * @param array array to be set.
  92537. * @returns this effect.
  92538. */
  92539. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92540. /**
  92541. * 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)
  92542. * @param uniformName Name of the variable.
  92543. * @param array array to be set.
  92544. * @returns this effect.
  92545. */
  92546. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92547. /**
  92548. * 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)
  92549. * @param uniformName Name of the variable.
  92550. * @param array array to be set.
  92551. * @returns this effect.
  92552. */
  92553. setIntArray4(uniformName: string, array: Int32Array): Effect;
  92554. /**
  92555. * Sets an float array on a uniform variable.
  92556. * @param uniformName Name of the variable.
  92557. * @param array array to be set.
  92558. * @returns this effect.
  92559. */
  92560. setFloatArray(uniformName: string, array: Float32Array): Effect;
  92561. /**
  92562. * 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)
  92563. * @param uniformName Name of the variable.
  92564. * @param array array to be set.
  92565. * @returns this effect.
  92566. */
  92567. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  92568. /**
  92569. * 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)
  92570. * @param uniformName Name of the variable.
  92571. * @param array array to be set.
  92572. * @returns this effect.
  92573. */
  92574. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  92575. /**
  92576. * 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)
  92577. * @param uniformName Name of the variable.
  92578. * @param array array to be set.
  92579. * @returns this effect.
  92580. */
  92581. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  92582. /**
  92583. * Sets an array on a uniform variable.
  92584. * @param uniformName Name of the variable.
  92585. * @param array array to be set.
  92586. * @returns this effect.
  92587. */
  92588. setArray(uniformName: string, array: number[]): Effect;
  92589. /**
  92590. * 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)
  92591. * @param uniformName Name of the variable.
  92592. * @param array array to be set.
  92593. * @returns this effect.
  92594. */
  92595. setArray2(uniformName: string, array: number[]): Effect;
  92596. /**
  92597. * 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)
  92598. * @param uniformName Name of the variable.
  92599. * @param array array to be set.
  92600. * @returns this effect.
  92601. */
  92602. setArray3(uniformName: string, array: number[]): Effect;
  92603. /**
  92604. * 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)
  92605. * @param uniformName Name of the variable.
  92606. * @param array array to be set.
  92607. * @returns this effect.
  92608. */
  92609. setArray4(uniformName: string, array: number[]): Effect;
  92610. /**
  92611. * Sets matrices on a uniform variable.
  92612. * @param uniformName Name of the variable.
  92613. * @param matrices matrices to be set.
  92614. * @returns this effect.
  92615. */
  92616. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92617. /**
  92618. * Sets matrix on a uniform variable.
  92619. * @param uniformName Name of the variable.
  92620. * @param matrix matrix to be set.
  92621. * @returns this effect.
  92622. */
  92623. setMatrix(uniformName: string, matrix: Matrix): Effect;
  92624. /**
  92625. * 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)
  92626. * @param uniformName Name of the variable.
  92627. * @param matrix matrix to be set.
  92628. * @returns this effect.
  92629. */
  92630. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92631. /**
  92632. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92633. * @param uniformName Name of the variable.
  92634. * @param matrix matrix to be set.
  92635. * @returns this effect.
  92636. */
  92637. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92638. /**
  92639. * Sets a float on a uniform variable.
  92640. * @param uniformName Name of the variable.
  92641. * @param value value to be set.
  92642. * @returns this effect.
  92643. */
  92644. setFloat(uniformName: string, value: number): Effect;
  92645. /**
  92646. * Sets a boolean on a uniform variable.
  92647. * @param uniformName Name of the variable.
  92648. * @param bool value to be set.
  92649. * @returns this effect.
  92650. */
  92651. setBool(uniformName: string, bool: boolean): Effect;
  92652. /**
  92653. * Sets a Vector2 on a uniform variable.
  92654. * @param uniformName Name of the variable.
  92655. * @param vector2 vector2 to be set.
  92656. * @returns this effect.
  92657. */
  92658. setVector2(uniformName: string, vector2: Vector2): Effect;
  92659. /**
  92660. * Sets a float2 on a uniform variable.
  92661. * @param uniformName Name of the variable.
  92662. * @param x First float in float2.
  92663. * @param y Second float in float2.
  92664. * @returns this effect.
  92665. */
  92666. setFloat2(uniformName: string, x: number, y: number): Effect;
  92667. /**
  92668. * Sets a Vector3 on a uniform variable.
  92669. * @param uniformName Name of the variable.
  92670. * @param vector3 Value to be set.
  92671. * @returns this effect.
  92672. */
  92673. setVector3(uniformName: string, vector3: Vector3): Effect;
  92674. /**
  92675. * Sets a float3 on a uniform variable.
  92676. * @param uniformName Name of the variable.
  92677. * @param x First float in float3.
  92678. * @param y Second float in float3.
  92679. * @param z Third float in float3.
  92680. * @returns this effect.
  92681. */
  92682. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92683. /**
  92684. * Sets a Vector4 on a uniform variable.
  92685. * @param uniformName Name of the variable.
  92686. * @param vector4 Value to be set.
  92687. * @returns this effect.
  92688. */
  92689. setVector4(uniformName: string, vector4: Vector4): Effect;
  92690. /**
  92691. * Sets a float4 on a uniform variable.
  92692. * @param uniformName Name of the variable.
  92693. * @param x First float in float4.
  92694. * @param y Second float in float4.
  92695. * @param z Third float in float4.
  92696. * @param w Fourth float in float4.
  92697. * @returns this effect.
  92698. */
  92699. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92700. /**
  92701. * Sets a Color3 on a uniform variable.
  92702. * @param uniformName Name of the variable.
  92703. * @param color3 Value to be set.
  92704. * @returns this effect.
  92705. */
  92706. setColor3(uniformName: string, color3: Color3): Effect;
  92707. /**
  92708. * Sets a Color4 on a uniform variable.
  92709. * @param uniformName Name of the variable.
  92710. * @param color3 Value to be set.
  92711. * @param alpha Alpha value to be set.
  92712. * @returns this effect.
  92713. */
  92714. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  92715. /**
  92716. * Sets a Color4 on a uniform variable
  92717. * @param uniformName defines the name of the variable
  92718. * @param color4 defines the value to be set
  92719. * @returns this effect.
  92720. */
  92721. setDirectColor4(uniformName: string, color4: Color4): Effect;
  92722. /** Release all associated resources */
  92723. dispose(): void;
  92724. /**
  92725. * This function will add a new shader to the shader store
  92726. * @param name the name of the shader
  92727. * @param pixelShader optional pixel shader content
  92728. * @param vertexShader optional vertex shader content
  92729. */
  92730. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92731. /**
  92732. * Store of each shader (The can be looked up using effect.key)
  92733. */
  92734. static ShadersStore: {
  92735. [key: string]: string;
  92736. };
  92737. /**
  92738. * Store of each included file for a shader (The can be looked up using effect.key)
  92739. */
  92740. static IncludesShadersStore: {
  92741. [key: string]: string;
  92742. };
  92743. /**
  92744. * Resets the cache of effects.
  92745. */
  92746. static ResetCache(): void;
  92747. }
  92748. }
  92749. declare module BABYLON {
  92750. /**
  92751. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  92752. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  92753. * 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;
  92754. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  92755. */
  92756. export class ColorCurves {
  92757. private _dirty;
  92758. private _tempColor;
  92759. private _globalCurve;
  92760. private _highlightsCurve;
  92761. private _midtonesCurve;
  92762. private _shadowsCurve;
  92763. private _positiveCurve;
  92764. private _negativeCurve;
  92765. private _globalHue;
  92766. private _globalDensity;
  92767. private _globalSaturation;
  92768. private _globalExposure;
  92769. /**
  92770. * Gets the global Hue value.
  92771. * 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).
  92772. */
  92773. /**
  92774. * Sets the global Hue value.
  92775. * 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).
  92776. */
  92777. globalHue: number;
  92778. /**
  92779. * Gets the global Density value.
  92780. * 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.
  92781. * Values less than zero provide a filter of opposite hue.
  92782. */
  92783. /**
  92784. * Sets the global Density value.
  92785. * 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.
  92786. * Values less than zero provide a filter of opposite hue.
  92787. */
  92788. globalDensity: number;
  92789. /**
  92790. * Gets the global Saturation value.
  92791. * 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.
  92792. */
  92793. /**
  92794. * Sets the global Saturation value.
  92795. * 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.
  92796. */
  92797. globalSaturation: number;
  92798. /**
  92799. * Gets the global Exposure value.
  92800. * 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.
  92801. */
  92802. /**
  92803. * Sets the global Exposure value.
  92804. * 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.
  92805. */
  92806. globalExposure: number;
  92807. private _highlightsHue;
  92808. private _highlightsDensity;
  92809. private _highlightsSaturation;
  92810. private _highlightsExposure;
  92811. /**
  92812. * Gets the highlights Hue value.
  92813. * 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).
  92814. */
  92815. /**
  92816. * Sets the highlights Hue value.
  92817. * 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).
  92818. */
  92819. highlightsHue: number;
  92820. /**
  92821. * Gets the highlights Density value.
  92822. * 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.
  92823. * Values less than zero provide a filter of opposite hue.
  92824. */
  92825. /**
  92826. * Sets the highlights Density value.
  92827. * 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.
  92828. * Values less than zero provide a filter of opposite hue.
  92829. */
  92830. highlightsDensity: number;
  92831. /**
  92832. * Gets the highlights Saturation value.
  92833. * 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.
  92834. */
  92835. /**
  92836. * Sets the highlights Saturation value.
  92837. * 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.
  92838. */
  92839. highlightsSaturation: number;
  92840. /**
  92841. * Gets the highlights Exposure value.
  92842. * 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.
  92843. */
  92844. /**
  92845. * Sets the highlights Exposure value.
  92846. * 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.
  92847. */
  92848. highlightsExposure: number;
  92849. private _midtonesHue;
  92850. private _midtonesDensity;
  92851. private _midtonesSaturation;
  92852. private _midtonesExposure;
  92853. /**
  92854. * Gets the midtones Hue value.
  92855. * 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).
  92856. */
  92857. /**
  92858. * Sets the midtones Hue value.
  92859. * 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).
  92860. */
  92861. midtonesHue: number;
  92862. /**
  92863. * Gets the midtones Density value.
  92864. * 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.
  92865. * Values less than zero provide a filter of opposite hue.
  92866. */
  92867. /**
  92868. * Sets the midtones Density value.
  92869. * 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.
  92870. * Values less than zero provide a filter of opposite hue.
  92871. */
  92872. midtonesDensity: number;
  92873. /**
  92874. * Gets the midtones Saturation value.
  92875. * 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.
  92876. */
  92877. /**
  92878. * Sets the midtones Saturation value.
  92879. * 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.
  92880. */
  92881. midtonesSaturation: number;
  92882. /**
  92883. * Gets the midtones Exposure value.
  92884. * 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.
  92885. */
  92886. /**
  92887. * Sets the midtones Exposure value.
  92888. * 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.
  92889. */
  92890. midtonesExposure: number;
  92891. private _shadowsHue;
  92892. private _shadowsDensity;
  92893. private _shadowsSaturation;
  92894. private _shadowsExposure;
  92895. /**
  92896. * Gets the shadows Hue value.
  92897. * 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).
  92898. */
  92899. /**
  92900. * Sets the shadows Hue value.
  92901. * 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).
  92902. */
  92903. shadowsHue: number;
  92904. /**
  92905. * Gets the shadows Density value.
  92906. * 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.
  92907. * Values less than zero provide a filter of opposite hue.
  92908. */
  92909. /**
  92910. * Sets the shadows Density value.
  92911. * 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.
  92912. * Values less than zero provide a filter of opposite hue.
  92913. */
  92914. shadowsDensity: number;
  92915. /**
  92916. * Gets the shadows Saturation value.
  92917. * 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.
  92918. */
  92919. /**
  92920. * Sets the shadows Saturation value.
  92921. * 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.
  92922. */
  92923. shadowsSaturation: number;
  92924. /**
  92925. * Gets the shadows Exposure value.
  92926. * 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.
  92927. */
  92928. /**
  92929. * Sets the shadows Exposure value.
  92930. * 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.
  92931. */
  92932. shadowsExposure: number;
  92933. /**
  92934. * Returns the class name
  92935. * @returns The class name
  92936. */
  92937. getClassName(): string;
  92938. /**
  92939. * Binds the color curves to the shader.
  92940. * @param colorCurves The color curve to bind
  92941. * @param effect The effect to bind to
  92942. * @param positiveUniform The positive uniform shader parameter
  92943. * @param neutralUniform The neutral uniform shader parameter
  92944. * @param negativeUniform The negative uniform shader parameter
  92945. */
  92946. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  92947. /**
  92948. * Prepare the list of uniforms associated with the ColorCurves effects.
  92949. * @param uniformsList The list of uniforms used in the effect
  92950. */
  92951. static PrepareUniforms(uniformsList: string[]): void;
  92952. /**
  92953. * Returns color grading data based on a hue, density, saturation and exposure value.
  92954. * @param filterHue The hue of the color filter.
  92955. * @param filterDensity The density of the color filter.
  92956. * @param saturation The saturation.
  92957. * @param exposure The exposure.
  92958. * @param result The result data container.
  92959. */
  92960. private getColorGradingDataToRef;
  92961. /**
  92962. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  92963. * @param value The input slider value in range [-100,100].
  92964. * @returns Adjusted value.
  92965. */
  92966. private static applyColorGradingSliderNonlinear;
  92967. /**
  92968. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  92969. * @param hue The hue (H) input.
  92970. * @param saturation The saturation (S) input.
  92971. * @param brightness The brightness (B) input.
  92972. * @result An RGBA color represented as Vector4.
  92973. */
  92974. private static fromHSBToRef;
  92975. /**
  92976. * Returns a value clamped between min and max
  92977. * @param value The value to clamp
  92978. * @param min The minimum of value
  92979. * @param max The maximum of value
  92980. * @returns The clamped value.
  92981. */
  92982. private static clamp;
  92983. /**
  92984. * Clones the current color curve instance.
  92985. * @return The cloned curves
  92986. */
  92987. clone(): ColorCurves;
  92988. /**
  92989. * Serializes the current color curve instance to a json representation.
  92990. * @return a JSON representation
  92991. */
  92992. serialize(): any;
  92993. /**
  92994. * Parses the color curve from a json representation.
  92995. * @param source the JSON source to parse
  92996. * @return The parsed curves
  92997. */
  92998. static Parse(source: any): ColorCurves;
  92999. }
  93000. }
  93001. declare module BABYLON {
  93002. /**
  93003. * Interface to follow in your material defines to integrate easily the
  93004. * Image proccessing functions.
  93005. * @hidden
  93006. */
  93007. export interface IImageProcessingConfigurationDefines {
  93008. IMAGEPROCESSING: boolean;
  93009. VIGNETTE: boolean;
  93010. VIGNETTEBLENDMODEMULTIPLY: boolean;
  93011. VIGNETTEBLENDMODEOPAQUE: boolean;
  93012. TONEMAPPING: boolean;
  93013. TONEMAPPING_ACES: boolean;
  93014. CONTRAST: boolean;
  93015. EXPOSURE: boolean;
  93016. COLORCURVES: boolean;
  93017. COLORGRADING: boolean;
  93018. COLORGRADING3D: boolean;
  93019. SAMPLER3DGREENDEPTH: boolean;
  93020. SAMPLER3DBGRMAP: boolean;
  93021. IMAGEPROCESSINGPOSTPROCESS: boolean;
  93022. }
  93023. /**
  93024. * @hidden
  93025. */
  93026. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  93027. IMAGEPROCESSING: boolean;
  93028. VIGNETTE: boolean;
  93029. VIGNETTEBLENDMODEMULTIPLY: boolean;
  93030. VIGNETTEBLENDMODEOPAQUE: boolean;
  93031. TONEMAPPING: boolean;
  93032. TONEMAPPING_ACES: boolean;
  93033. CONTRAST: boolean;
  93034. COLORCURVES: boolean;
  93035. COLORGRADING: boolean;
  93036. COLORGRADING3D: boolean;
  93037. SAMPLER3DGREENDEPTH: boolean;
  93038. SAMPLER3DBGRMAP: boolean;
  93039. IMAGEPROCESSINGPOSTPROCESS: boolean;
  93040. EXPOSURE: boolean;
  93041. constructor();
  93042. }
  93043. /**
  93044. * This groups together the common properties used for image processing either in direct forward pass
  93045. * or through post processing effect depending on the use of the image processing pipeline in your scene
  93046. * or not.
  93047. */
  93048. export class ImageProcessingConfiguration {
  93049. /**
  93050. * Default tone mapping applied in BabylonJS.
  93051. */
  93052. static readonly TONEMAPPING_STANDARD: number;
  93053. /**
  93054. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  93055. * to other engines rendering to increase portability.
  93056. */
  93057. static readonly TONEMAPPING_ACES: number;
  93058. /**
  93059. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  93060. */
  93061. colorCurves: Nullable<ColorCurves>;
  93062. private _colorCurvesEnabled;
  93063. /**
  93064. * Gets wether the color curves effect is enabled.
  93065. */
  93066. /**
  93067. * Sets wether the color curves effect is enabled.
  93068. */
  93069. colorCurvesEnabled: boolean;
  93070. private _colorGradingTexture;
  93071. /**
  93072. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  93073. */
  93074. /**
  93075. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  93076. */
  93077. colorGradingTexture: Nullable<BaseTexture>;
  93078. private _colorGradingEnabled;
  93079. /**
  93080. * Gets wether the color grading effect is enabled.
  93081. */
  93082. /**
  93083. * Sets wether the color grading effect is enabled.
  93084. */
  93085. colorGradingEnabled: boolean;
  93086. private _colorGradingWithGreenDepth;
  93087. /**
  93088. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  93089. */
  93090. /**
  93091. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  93092. */
  93093. colorGradingWithGreenDepth: boolean;
  93094. private _colorGradingBGR;
  93095. /**
  93096. * Gets wether the color grading texture contains BGR values.
  93097. */
  93098. /**
  93099. * Sets wether the color grading texture contains BGR values.
  93100. */
  93101. colorGradingBGR: boolean;
  93102. /** @hidden */
  93103. _exposure: number;
  93104. /**
  93105. * Gets the Exposure used in the effect.
  93106. */
  93107. /**
  93108. * Sets the Exposure used in the effect.
  93109. */
  93110. exposure: number;
  93111. private _toneMappingEnabled;
  93112. /**
  93113. * Gets wether the tone mapping effect is enabled.
  93114. */
  93115. /**
  93116. * Sets wether the tone mapping effect is enabled.
  93117. */
  93118. toneMappingEnabled: boolean;
  93119. private _toneMappingType;
  93120. /**
  93121. * Gets the type of tone mapping effect.
  93122. */
  93123. /**
  93124. * Sets the type of tone mapping effect used in BabylonJS.
  93125. */
  93126. toneMappingType: number;
  93127. protected _contrast: number;
  93128. /**
  93129. * Gets the contrast used in the effect.
  93130. */
  93131. /**
  93132. * Sets the contrast used in the effect.
  93133. */
  93134. contrast: number;
  93135. /**
  93136. * Vignette stretch size.
  93137. */
  93138. vignetteStretch: number;
  93139. /**
  93140. * Vignette centre X Offset.
  93141. */
  93142. vignetteCentreX: number;
  93143. /**
  93144. * Vignette centre Y Offset.
  93145. */
  93146. vignetteCentreY: number;
  93147. /**
  93148. * Vignette weight or intensity of the vignette effect.
  93149. */
  93150. vignetteWeight: number;
  93151. /**
  93152. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  93153. * if vignetteEnabled is set to true.
  93154. */
  93155. vignetteColor: Color4;
  93156. /**
  93157. * Camera field of view used by the Vignette effect.
  93158. */
  93159. vignetteCameraFov: number;
  93160. private _vignetteBlendMode;
  93161. /**
  93162. * Gets the vignette blend mode allowing different kind of effect.
  93163. */
  93164. /**
  93165. * Sets the vignette blend mode allowing different kind of effect.
  93166. */
  93167. vignetteBlendMode: number;
  93168. private _vignetteEnabled;
  93169. /**
  93170. * Gets wether the vignette effect is enabled.
  93171. */
  93172. /**
  93173. * Sets wether the vignette effect is enabled.
  93174. */
  93175. vignetteEnabled: boolean;
  93176. private _applyByPostProcess;
  93177. /**
  93178. * Gets wether the image processing is applied through a post process or not.
  93179. */
  93180. /**
  93181. * Sets wether the image processing is applied through a post process or not.
  93182. */
  93183. applyByPostProcess: boolean;
  93184. private _isEnabled;
  93185. /**
  93186. * Gets wether the image processing is enabled or not.
  93187. */
  93188. /**
  93189. * Sets wether the image processing is enabled or not.
  93190. */
  93191. isEnabled: boolean;
  93192. /**
  93193. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  93194. */
  93195. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  93196. /**
  93197. * Method called each time the image processing information changes requires to recompile the effect.
  93198. */
  93199. protected _updateParameters(): void;
  93200. /**
  93201. * Gets the current class name.
  93202. * @return "ImageProcessingConfiguration"
  93203. */
  93204. getClassName(): string;
  93205. /**
  93206. * Prepare the list of uniforms associated with the Image Processing effects.
  93207. * @param uniforms The list of uniforms used in the effect
  93208. * @param defines the list of defines currently in use
  93209. */
  93210. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  93211. /**
  93212. * Prepare the list of samplers associated with the Image Processing effects.
  93213. * @param samplersList The list of uniforms used in the effect
  93214. * @param defines the list of defines currently in use
  93215. */
  93216. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  93217. /**
  93218. * Prepare the list of defines associated to the shader.
  93219. * @param defines the list of defines to complete
  93220. * @param forPostProcess Define if we are currently in post process mode or not
  93221. */
  93222. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  93223. /**
  93224. * Returns true if all the image processing information are ready.
  93225. * @returns True if ready, otherwise, false
  93226. */
  93227. isReady(): boolean;
  93228. /**
  93229. * Binds the image processing to the shader.
  93230. * @param effect The effect to bind to
  93231. * @param aspectRatio Define the current aspect ratio of the effect
  93232. */
  93233. bind(effect: Effect, aspectRatio?: number): void;
  93234. /**
  93235. * Clones the current image processing instance.
  93236. * @return The cloned image processing
  93237. */
  93238. clone(): ImageProcessingConfiguration;
  93239. /**
  93240. * Serializes the current image processing instance to a json representation.
  93241. * @return a JSON representation
  93242. */
  93243. serialize(): any;
  93244. /**
  93245. * Parses the image processing from a json representation.
  93246. * @param source the JSON source to parse
  93247. * @return The parsed image processing
  93248. */
  93249. static Parse(source: any): ImageProcessingConfiguration;
  93250. private static _VIGNETTEMODE_MULTIPLY;
  93251. private static _VIGNETTEMODE_OPAQUE;
  93252. /**
  93253. * Used to apply the vignette as a mix with the pixel color.
  93254. */
  93255. static readonly VIGNETTEMODE_MULTIPLY: number;
  93256. /**
  93257. * Used to apply the vignette as a replacement of the pixel color.
  93258. */
  93259. static readonly VIGNETTEMODE_OPAQUE: number;
  93260. }
  93261. }
  93262. declare module BABYLON {
  93263. /**
  93264. * This represents all the required information to add a fresnel effect on a material:
  93265. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93266. */
  93267. export class FresnelParameters {
  93268. private _isEnabled;
  93269. /**
  93270. * Define if the fresnel effect is enable or not.
  93271. */
  93272. isEnabled: boolean;
  93273. /**
  93274. * Define the color used on edges (grazing angle)
  93275. */
  93276. leftColor: Color3;
  93277. /**
  93278. * Define the color used on center
  93279. */
  93280. rightColor: Color3;
  93281. /**
  93282. * Define bias applied to computed fresnel term
  93283. */
  93284. bias: number;
  93285. /**
  93286. * Defined the power exponent applied to fresnel term
  93287. */
  93288. power: number;
  93289. /**
  93290. * Clones the current fresnel and its valuues
  93291. * @returns a clone fresnel configuration
  93292. */
  93293. clone(): FresnelParameters;
  93294. /**
  93295. * Serializes the current fresnel parameters to a JSON representation.
  93296. * @return the JSON serialization
  93297. */
  93298. serialize(): any;
  93299. /**
  93300. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  93301. * @param parsedFresnelParameters Define the JSON representation
  93302. * @returns the parsed parameters
  93303. */
  93304. static Parse(parsedFresnelParameters: any): FresnelParameters;
  93305. }
  93306. }
  93307. declare module BABYLON {
  93308. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  93309. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93310. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93311. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93312. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93313. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93314. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93315. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93316. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93317. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93318. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93319. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93320. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93321. /**
  93322. * Decorator used to define property that can be serialized as reference to a camera
  93323. * @param sourceName defines the name of the property to decorate
  93324. */
  93325. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93326. /**
  93327. * Class used to help serialization objects
  93328. */
  93329. export class SerializationHelper {
  93330. /** @hidden */
  93331. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  93332. /** @hidden */
  93333. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  93334. /** @hidden */
  93335. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  93336. /** @hidden */
  93337. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  93338. /**
  93339. * Appends the serialized animations from the source animations
  93340. * @param source Source containing the animations
  93341. * @param destination Target to store the animations
  93342. */
  93343. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93344. /**
  93345. * Static function used to serialized a specific entity
  93346. * @param entity defines the entity to serialize
  93347. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93348. * @returns a JSON compatible object representing the serialization of the entity
  93349. */
  93350. static Serialize<T>(entity: T, serializationObject?: any): any;
  93351. /**
  93352. * Creates a new entity from a serialization data object
  93353. * @param creationFunction defines a function used to instanciated the new entity
  93354. * @param source defines the source serialization data
  93355. * @param scene defines the hosting scene
  93356. * @param rootUrl defines the root url for resources
  93357. * @returns a new entity
  93358. */
  93359. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93360. /**
  93361. * Clones an object
  93362. * @param creationFunction defines the function used to instanciate the new object
  93363. * @param source defines the source object
  93364. * @returns the cloned object
  93365. */
  93366. static Clone<T>(creationFunction: () => T, source: T): T;
  93367. /**
  93368. * Instanciates a new object based on a source one (some data will be shared between both object)
  93369. * @param creationFunction defines the function used to instanciate the new object
  93370. * @param source defines the source object
  93371. * @returns the new object
  93372. */
  93373. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93374. }
  93375. }
  93376. declare module BABYLON {
  93377. /**
  93378. * This is the base class of all the camera used in the application.
  93379. * @see http://doc.babylonjs.com/features/cameras
  93380. */
  93381. export class Camera extends Node {
  93382. /** @hidden */
  93383. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93384. /**
  93385. * This is the default projection mode used by the cameras.
  93386. * It helps recreating a feeling of perspective and better appreciate depth.
  93387. * This is the best way to simulate real life cameras.
  93388. */
  93389. static readonly PERSPECTIVE_CAMERA: number;
  93390. /**
  93391. * This helps creating camera with an orthographic mode.
  93392. * 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.
  93393. */
  93394. static readonly ORTHOGRAPHIC_CAMERA: number;
  93395. /**
  93396. * This is the default FOV mode for perspective cameras.
  93397. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93398. */
  93399. static readonly FOVMODE_VERTICAL_FIXED: number;
  93400. /**
  93401. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93402. */
  93403. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93404. /**
  93405. * This specifies ther is no need for a camera rig.
  93406. * Basically only one eye is rendered corresponding to the camera.
  93407. */
  93408. static readonly RIG_MODE_NONE: number;
  93409. /**
  93410. * Simulates a camera Rig with one blue eye and one red eye.
  93411. * This can be use with 3d blue and red glasses.
  93412. */
  93413. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93414. /**
  93415. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93416. */
  93417. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93418. /**
  93419. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93420. */
  93421. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93422. /**
  93423. * Defines that both eyes of the camera will be rendered over under each other.
  93424. */
  93425. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93426. /**
  93427. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93428. */
  93429. static readonly RIG_MODE_VR: number;
  93430. /**
  93431. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93432. */
  93433. static readonly RIG_MODE_WEBVR: number;
  93434. /**
  93435. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93436. */
  93437. static readonly RIG_MODE_CUSTOM: number;
  93438. /**
  93439. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93440. */
  93441. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93442. /**
  93443. * Define the input manager associated with the camera.
  93444. */
  93445. inputs: CameraInputsManager<Camera>;
  93446. /** @hidden */
  93447. _position: Vector3;
  93448. /**
  93449. * Define the current local position of the camera in the scene
  93450. */
  93451. position: Vector3;
  93452. /**
  93453. * The vector the camera should consider as up.
  93454. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93455. */
  93456. upVector: Vector3;
  93457. /**
  93458. * Define the current limit on the left side for an orthographic camera
  93459. * In scene unit
  93460. */
  93461. orthoLeft: Nullable<number>;
  93462. /**
  93463. * Define the current limit on the right side for an orthographic camera
  93464. * In scene unit
  93465. */
  93466. orthoRight: Nullable<number>;
  93467. /**
  93468. * Define the current limit on the bottom side for an orthographic camera
  93469. * In scene unit
  93470. */
  93471. orthoBottom: Nullable<number>;
  93472. /**
  93473. * Define the current limit on the top side for an orthographic camera
  93474. * In scene unit
  93475. */
  93476. orthoTop: Nullable<number>;
  93477. /**
  93478. * Field Of View is set in Radians. (default is 0.8)
  93479. */
  93480. fov: number;
  93481. /**
  93482. * Define the minimum distance the camera can see from.
  93483. * This is important to note that the depth buffer are not infinite and the closer it starts
  93484. * the more your scene might encounter depth fighting issue.
  93485. */
  93486. minZ: number;
  93487. /**
  93488. * Define the maximum distance the camera can see to.
  93489. * This is important to note that the depth buffer are not infinite and the further it end
  93490. * the more your scene might encounter depth fighting issue.
  93491. */
  93492. maxZ: number;
  93493. /**
  93494. * Define the default inertia of the camera.
  93495. * This helps giving a smooth feeling to the camera movement.
  93496. */
  93497. inertia: number;
  93498. /**
  93499. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  93500. */
  93501. mode: number;
  93502. /**
  93503. * Define wether the camera is intermediate.
  93504. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93505. */
  93506. isIntermediate: boolean;
  93507. /**
  93508. * Define the viewport of the camera.
  93509. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93510. */
  93511. viewport: Viewport;
  93512. /**
  93513. * Restricts the camera to viewing objects with the same layerMask.
  93514. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93515. */
  93516. layerMask: number;
  93517. /**
  93518. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93519. */
  93520. fovMode: number;
  93521. /**
  93522. * Rig mode of the camera.
  93523. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93524. * This is normally controlled byt the camera themselves as internal use.
  93525. */
  93526. cameraRigMode: number;
  93527. /**
  93528. * Defines the distance between both "eyes" in case of a RIG
  93529. */
  93530. interaxialDistance: number;
  93531. /**
  93532. * Defines if stereoscopic rendering is done side by side or over under.
  93533. */
  93534. isStereoscopicSideBySide: boolean;
  93535. /**
  93536. * 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
  93537. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93538. * else in the scene.
  93539. */
  93540. customRenderTargets: RenderTargetTexture[];
  93541. /**
  93542. * When set, the camera will render to this render target instead of the default canvas
  93543. */
  93544. outputRenderTarget: Nullable<RenderTargetTexture>;
  93545. /**
  93546. * Observable triggered when the camera view matrix has changed.
  93547. */
  93548. onViewMatrixChangedObservable: Observable<Camera>;
  93549. /**
  93550. * Observable triggered when the camera Projection matrix has changed.
  93551. */
  93552. onProjectionMatrixChangedObservable: Observable<Camera>;
  93553. /**
  93554. * Observable triggered when the inputs have been processed.
  93555. */
  93556. onAfterCheckInputsObservable: Observable<Camera>;
  93557. /**
  93558. * Observable triggered when reset has been called and applied to the camera.
  93559. */
  93560. onRestoreStateObservable: Observable<Camera>;
  93561. /** @hidden */
  93562. _cameraRigParams: any;
  93563. /** @hidden */
  93564. _rigCameras: Camera[];
  93565. /** @hidden */
  93566. _rigPostProcess: Nullable<PostProcess>;
  93567. protected _webvrViewMatrix: Matrix;
  93568. /** @hidden */
  93569. _skipRendering: boolean;
  93570. /** @hidden */
  93571. _projectionMatrix: Matrix;
  93572. /** @hidden */
  93573. _postProcesses: Nullable<PostProcess>[];
  93574. /** @hidden */
  93575. _activeMeshes: SmartArray<AbstractMesh>;
  93576. protected _globalPosition: Vector3;
  93577. /** @hidden */
  93578. _computedViewMatrix: Matrix;
  93579. private _doNotComputeProjectionMatrix;
  93580. private _transformMatrix;
  93581. private _frustumPlanes;
  93582. private _refreshFrustumPlanes;
  93583. private _storedFov;
  93584. private _stateStored;
  93585. /**
  93586. * Instantiates a new camera object.
  93587. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93588. * @see http://doc.babylonjs.com/features/cameras
  93589. * @param name Defines the name of the camera in the scene
  93590. * @param position Defines the position of the camera
  93591. * @param scene Defines the scene the camera belongs too
  93592. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93593. */
  93594. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93595. /**
  93596. * Store current camera state (fov, position, etc..)
  93597. * @returns the camera
  93598. */
  93599. storeState(): Camera;
  93600. /**
  93601. * Restores the camera state values if it has been stored. You must call storeState() first
  93602. */
  93603. protected _restoreStateValues(): boolean;
  93604. /**
  93605. * Restored camera state. You must call storeState() first.
  93606. * @returns true if restored and false otherwise
  93607. */
  93608. restoreState(): boolean;
  93609. /**
  93610. * Gets the class name of the camera.
  93611. * @returns the class name
  93612. */
  93613. getClassName(): string;
  93614. /** @hidden */
  93615. readonly _isCamera: boolean;
  93616. /**
  93617. * Gets a string representation of the camera useful for debug purpose.
  93618. * @param fullDetails Defines that a more verboe level of logging is required
  93619. * @returns the string representation
  93620. */
  93621. toString(fullDetails?: boolean): string;
  93622. /**
  93623. * Gets the current world space position of the camera.
  93624. */
  93625. readonly globalPosition: Vector3;
  93626. /**
  93627. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93628. * @returns the active meshe list
  93629. */
  93630. getActiveMeshes(): SmartArray<AbstractMesh>;
  93631. /**
  93632. * Check wether a mesh is part of the current active mesh list of the camera
  93633. * @param mesh Defines the mesh to check
  93634. * @returns true if active, false otherwise
  93635. */
  93636. isActiveMesh(mesh: Mesh): boolean;
  93637. /**
  93638. * Is this camera ready to be used/rendered
  93639. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93640. * @return true if the camera is ready
  93641. */
  93642. isReady(completeCheck?: boolean): boolean;
  93643. /** @hidden */
  93644. _initCache(): void;
  93645. /** @hidden */
  93646. _updateCache(ignoreParentClass?: boolean): void;
  93647. /** @hidden */
  93648. _isSynchronized(): boolean;
  93649. /** @hidden */
  93650. _isSynchronizedViewMatrix(): boolean;
  93651. /** @hidden */
  93652. _isSynchronizedProjectionMatrix(): boolean;
  93653. /**
  93654. * Attach the input controls to a specific dom element to get the input from.
  93655. * @param element Defines the element the controls should be listened from
  93656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93657. */
  93658. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93659. /**
  93660. * Detach the current controls from the specified dom element.
  93661. * @param element Defines the element to stop listening the inputs from
  93662. */
  93663. detachControl(element: HTMLElement): void;
  93664. /**
  93665. * Update the camera state according to the different inputs gathered during the frame.
  93666. */
  93667. update(): void;
  93668. /** @hidden */
  93669. _checkInputs(): void;
  93670. /** @hidden */
  93671. readonly rigCameras: Camera[];
  93672. /**
  93673. * Gets the post process used by the rig cameras
  93674. */
  93675. readonly rigPostProcess: Nullable<PostProcess>;
  93676. /**
  93677. * Internal, gets the first post proces.
  93678. * @returns the first post process to be run on this camera.
  93679. */
  93680. _getFirstPostProcess(): Nullable<PostProcess>;
  93681. private _cascadePostProcessesToRigCams;
  93682. /**
  93683. * Attach a post process to the camera.
  93684. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93685. * @param postProcess The post process to attach to the camera
  93686. * @param insertAt The position of the post process in case several of them are in use in the scene
  93687. * @returns the position the post process has been inserted at
  93688. */
  93689. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93690. /**
  93691. * Detach a post process to the camera.
  93692. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93693. * @param postProcess The post process to detach from the camera
  93694. */
  93695. detachPostProcess(postProcess: PostProcess): void;
  93696. /**
  93697. * Gets the current world matrix of the camera
  93698. */
  93699. getWorldMatrix(): Matrix;
  93700. /** @hidden */
  93701. _getViewMatrix(): Matrix;
  93702. /**
  93703. * Gets the current view matrix of the camera.
  93704. * @param force forces the camera to recompute the matrix without looking at the cached state
  93705. * @returns the view matrix
  93706. */
  93707. getViewMatrix(force?: boolean): Matrix;
  93708. /**
  93709. * Freeze the projection matrix.
  93710. * It will prevent the cache check of the camera projection compute and can speed up perf
  93711. * if no parameter of the camera are meant to change
  93712. * @param projection Defines manually a projection if necessary
  93713. */
  93714. freezeProjectionMatrix(projection?: Matrix): void;
  93715. /**
  93716. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93717. */
  93718. unfreezeProjectionMatrix(): void;
  93719. /**
  93720. * Gets the current projection matrix of the camera.
  93721. * @param force forces the camera to recompute the matrix without looking at the cached state
  93722. * @returns the projection matrix
  93723. */
  93724. getProjectionMatrix(force?: boolean): Matrix;
  93725. /**
  93726. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93727. * @returns a Matrix
  93728. */
  93729. getTransformationMatrix(): Matrix;
  93730. private _updateFrustumPlanes;
  93731. /**
  93732. * Checks if a cullable object (mesh...) is in the camera frustum
  93733. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93734. * @param target The object to check
  93735. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93736. * @returns true if the object is in frustum otherwise false
  93737. */
  93738. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93739. /**
  93740. * Checks if a cullable object (mesh...) is in the camera frustum
  93741. * Unlike isInFrustum this cheks the full bounding box
  93742. * @param target The object to check
  93743. * @returns true if the object is in frustum otherwise false
  93744. */
  93745. isCompletelyInFrustum(target: ICullable): boolean;
  93746. /**
  93747. * Gets a ray in the forward direction from the camera.
  93748. * @param length Defines the length of the ray to create
  93749. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93750. * @param origin Defines the start point of the ray which defaults to the camera position
  93751. * @returns the forward ray
  93752. */
  93753. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93754. /**
  93755. * Releases resources associated with this node.
  93756. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93757. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93758. */
  93759. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93760. /** @hidden */
  93761. _isLeftCamera: boolean;
  93762. /**
  93763. * Gets the left camera of a rig setup in case of Rigged Camera
  93764. */
  93765. readonly isLeftCamera: boolean;
  93766. /** @hidden */
  93767. _isRightCamera: boolean;
  93768. /**
  93769. * Gets the right camera of a rig setup in case of Rigged Camera
  93770. */
  93771. readonly isRightCamera: boolean;
  93772. /**
  93773. * Gets the left camera of a rig setup in case of Rigged Camera
  93774. */
  93775. readonly leftCamera: Nullable<FreeCamera>;
  93776. /**
  93777. * Gets the right camera of a rig setup in case of Rigged Camera
  93778. */
  93779. readonly rightCamera: Nullable<FreeCamera>;
  93780. /**
  93781. * Gets the left camera target of a rig setup in case of Rigged Camera
  93782. * @returns the target position
  93783. */
  93784. getLeftTarget(): Nullable<Vector3>;
  93785. /**
  93786. * Gets the right camera target of a rig setup in case of Rigged Camera
  93787. * @returns the target position
  93788. */
  93789. getRightTarget(): Nullable<Vector3>;
  93790. /**
  93791. * @hidden
  93792. */
  93793. setCameraRigMode(mode: number, rigParams: any): void;
  93794. /** @hidden */
  93795. static _setStereoscopicRigMode(camera: Camera): void;
  93796. /** @hidden */
  93797. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93798. /** @hidden */
  93799. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93800. /** @hidden */
  93801. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93802. /** @hidden */
  93803. _getVRProjectionMatrix(): Matrix;
  93804. protected _updateCameraRotationMatrix(): void;
  93805. protected _updateWebVRCameraRotationMatrix(): void;
  93806. /**
  93807. * This function MUST be overwritten by the different WebVR cameras available.
  93808. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93809. * @hidden
  93810. */
  93811. _getWebVRProjectionMatrix(): Matrix;
  93812. /**
  93813. * This function MUST be overwritten by the different WebVR cameras available.
  93814. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93815. * @hidden
  93816. */
  93817. _getWebVRViewMatrix(): Matrix;
  93818. /** @hidden */
  93819. setCameraRigParameter(name: string, value: any): void;
  93820. /**
  93821. * needs to be overridden by children so sub has required properties to be copied
  93822. * @hidden
  93823. */
  93824. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93825. /**
  93826. * May need to be overridden by children
  93827. * @hidden
  93828. */
  93829. _updateRigCameras(): void;
  93830. /** @hidden */
  93831. _setupInputs(): void;
  93832. /**
  93833. * Serialiaze the camera setup to a json represention
  93834. * @returns the JSON representation
  93835. */
  93836. serialize(): any;
  93837. /**
  93838. * Clones the current camera.
  93839. * @param name The cloned camera name
  93840. * @returns the cloned camera
  93841. */
  93842. clone(name: string): Camera;
  93843. /**
  93844. * Gets the direction of the camera relative to a given local axis.
  93845. * @param localAxis Defines the reference axis to provide a relative direction.
  93846. * @return the direction
  93847. */
  93848. getDirection(localAxis: Vector3): Vector3;
  93849. /**
  93850. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93851. * @param localAxis Defines the reference axis to provide a relative direction.
  93852. * @param result Defines the vector to store the result in
  93853. */
  93854. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93855. /**
  93856. * Gets a camera constructor for a given camera type
  93857. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93858. * @param name The name of the camera the result will be able to instantiate
  93859. * @param scene The scene the result will construct the camera in
  93860. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93861. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93862. * @returns a factory method to construc the camera
  93863. */
  93864. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93865. /**
  93866. * Compute the world matrix of the camera.
  93867. * @returns the camera workd matrix
  93868. */
  93869. computeWorldMatrix(): Matrix;
  93870. /**
  93871. * Parse a JSON and creates the camera from the parsed information
  93872. * @param parsedCamera The JSON to parse
  93873. * @param scene The scene to instantiate the camera in
  93874. * @returns the newly constructed camera
  93875. */
  93876. static Parse(parsedCamera: any, scene: Scene): Camera;
  93877. }
  93878. }
  93879. declare module BABYLON {
  93880. /**
  93881. * Interface for any object that can request an animation frame
  93882. */
  93883. export interface ICustomAnimationFrameRequester {
  93884. /**
  93885. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93886. */
  93887. renderFunction?: Function;
  93888. /**
  93889. * Called to request the next frame to render to
  93890. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93891. */
  93892. requestAnimationFrame: Function;
  93893. /**
  93894. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93895. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93896. */
  93897. requestID?: number;
  93898. }
  93899. /**
  93900. * Interface containing an array of animations
  93901. */
  93902. export interface IAnimatable {
  93903. /**
  93904. * Array of animations
  93905. */
  93906. animations: Nullable<Array<Animation>>;
  93907. }
  93908. /** Interface used by value gradients (color, factor, ...) */
  93909. export interface IValueGradient {
  93910. /**
  93911. * Gets or sets the gradient value (between 0 and 1)
  93912. */
  93913. gradient: number;
  93914. }
  93915. /** Class used to store color4 gradient */
  93916. export class ColorGradient implements IValueGradient {
  93917. /**
  93918. * Gets or sets the gradient value (between 0 and 1)
  93919. */
  93920. gradient: number;
  93921. /**
  93922. * Gets or sets first associated color
  93923. */
  93924. color1: Color4;
  93925. /**
  93926. * Gets or sets second associated color
  93927. */
  93928. color2?: Color4;
  93929. /**
  93930. * Will get a color picked randomly between color1 and color2.
  93931. * If color2 is undefined then color1 will be used
  93932. * @param result defines the target Color4 to store the result in
  93933. */
  93934. getColorToRef(result: Color4): void;
  93935. }
  93936. /** Class used to store color 3 gradient */
  93937. export class Color3Gradient implements IValueGradient {
  93938. /**
  93939. * Gets or sets the gradient value (between 0 and 1)
  93940. */
  93941. gradient: number;
  93942. /**
  93943. * Gets or sets the associated color
  93944. */
  93945. color: Color3;
  93946. }
  93947. /** Class used to store factor gradient */
  93948. export class FactorGradient implements IValueGradient {
  93949. /**
  93950. * Gets or sets the gradient value (between 0 and 1)
  93951. */
  93952. gradient: number;
  93953. /**
  93954. * Gets or sets first associated factor
  93955. */
  93956. factor1: number;
  93957. /**
  93958. * Gets or sets second associated factor
  93959. */
  93960. factor2?: number;
  93961. /**
  93962. * Will get a number picked randomly between factor1 and factor2.
  93963. * If factor2 is undefined then factor1 will be used
  93964. * @returns the picked number
  93965. */
  93966. getFactor(): number;
  93967. }
  93968. /**
  93969. * @ignore
  93970. * Application error to support additional information when loading a file
  93971. */
  93972. export class LoadFileError extends Error {
  93973. /** defines the optional web request */
  93974. request?: WebRequest | undefined;
  93975. private static _setPrototypeOf;
  93976. /**
  93977. * Creates a new LoadFileError
  93978. * @param message defines the message of the error
  93979. * @param request defines the optional web request
  93980. */
  93981. constructor(message: string,
  93982. /** defines the optional web request */
  93983. request?: WebRequest | undefined);
  93984. }
  93985. /**
  93986. * Class used to define a retry strategy when error happens while loading assets
  93987. */
  93988. export class RetryStrategy {
  93989. /**
  93990. * Function used to defines an exponential back off strategy
  93991. * @param maxRetries defines the maximum number of retries (3 by default)
  93992. * @param baseInterval defines the interval between retries
  93993. * @returns the strategy function to use
  93994. */
  93995. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  93996. }
  93997. /**
  93998. * File request interface
  93999. */
  94000. export interface IFileRequest {
  94001. /**
  94002. * Raised when the request is complete (success or error).
  94003. */
  94004. onCompleteObservable: Observable<IFileRequest>;
  94005. /**
  94006. * Aborts the request for a file.
  94007. */
  94008. abort: () => void;
  94009. }
  94010. /**
  94011. * Class containing a set of static utilities functions
  94012. */
  94013. export class Tools {
  94014. /**
  94015. * Gets or sets the base URL to use to load assets
  94016. */
  94017. static BaseUrl: string;
  94018. /**
  94019. * Enable/Disable Custom HTTP Request Headers globally.
  94020. * default = false
  94021. * @see CustomRequestHeaders
  94022. */
  94023. static UseCustomRequestHeaders: boolean;
  94024. /**
  94025. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  94026. * i.e. when loading files, where the server/service expects an Authorization header
  94027. */
  94028. static CustomRequestHeaders: {
  94029. [key: string]: string;
  94030. };
  94031. /**
  94032. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  94033. */
  94034. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  94035. /**
  94036. * Default behaviour for cors in the application.
  94037. * It can be a string if the expected behavior is identical in the entire app.
  94038. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  94039. */
  94040. static CorsBehavior: string | ((url: string | string[]) => string);
  94041. /**
  94042. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  94043. * @ignorenaming
  94044. */
  94045. static UseFallbackTexture: boolean;
  94046. /**
  94047. * Use this object to register external classes like custom textures or material
  94048. * to allow the laoders to instantiate them
  94049. */
  94050. static RegisteredExternalClasses: {
  94051. [key: string]: Object;
  94052. };
  94053. /**
  94054. * Texture content used if a texture cannot loaded
  94055. * @ignorenaming
  94056. */
  94057. static fallbackTexture: string;
  94058. /**
  94059. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  94060. * @param u defines the coordinate on X axis
  94061. * @param v defines the coordinate on Y axis
  94062. * @param width defines the width of the source data
  94063. * @param height defines the height of the source data
  94064. * @param pixels defines the source byte array
  94065. * @param color defines the output color
  94066. */
  94067. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  94068. /**
  94069. * Interpolates between a and b via alpha
  94070. * @param a The lower value (returned when alpha = 0)
  94071. * @param b The upper value (returned when alpha = 1)
  94072. * @param alpha The interpolation-factor
  94073. * @return The mixed value
  94074. */
  94075. static Mix(a: number, b: number, alpha: number): number;
  94076. /**
  94077. * Tries to instantiate a new object from a given class name
  94078. * @param className defines the class name to instantiate
  94079. * @returns the new object or null if the system was not able to do the instantiation
  94080. */
  94081. static Instantiate(className: string): any;
  94082. /**
  94083. * Provides a slice function that will work even on IE
  94084. * @param data defines the array to slice
  94085. * @param start defines the start of the data (optional)
  94086. * @param end defines the end of the data (optional)
  94087. * @returns the new sliced array
  94088. */
  94089. static Slice<T>(data: T, start?: number, end?: number): T;
  94090. /**
  94091. * Polyfill for setImmediate
  94092. * @param action defines the action to execute after the current execution block
  94093. */
  94094. static SetImmediate(action: () => void): void;
  94095. /**
  94096. * Function indicating if a number is an exponent of 2
  94097. * @param value defines the value to test
  94098. * @returns true if the value is an exponent of 2
  94099. */
  94100. static IsExponentOfTwo(value: number): boolean;
  94101. private static _tmpFloatArray;
  94102. /**
  94103. * Returns the nearest 32-bit single precision float representation of a Number
  94104. * @param value A Number. If the parameter is of a different type, it will get converted
  94105. * to a number or to NaN if it cannot be converted
  94106. * @returns number
  94107. */
  94108. static FloatRound(value: number): number;
  94109. /**
  94110. * Find the next highest power of two.
  94111. * @param x Number to start search from.
  94112. * @return Next highest power of two.
  94113. */
  94114. static CeilingPOT(x: number): number;
  94115. /**
  94116. * Find the next lowest power of two.
  94117. * @param x Number to start search from.
  94118. * @return Next lowest power of two.
  94119. */
  94120. static FloorPOT(x: number): number;
  94121. /**
  94122. * Find the nearest power of two.
  94123. * @param x Number to start search from.
  94124. * @return Next nearest power of two.
  94125. */
  94126. static NearestPOT(x: number): number;
  94127. /**
  94128. * Get the closest exponent of two
  94129. * @param value defines the value to approximate
  94130. * @param max defines the maximum value to return
  94131. * @param mode defines how to define the closest value
  94132. * @returns closest exponent of two of the given value
  94133. */
  94134. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  94135. /**
  94136. * Extracts the filename from a path
  94137. * @param path defines the path to use
  94138. * @returns the filename
  94139. */
  94140. static GetFilename(path: string): string;
  94141. /**
  94142. * Extracts the "folder" part of a path (everything before the filename).
  94143. * @param uri The URI to extract the info from
  94144. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  94145. * @returns The "folder" part of the path
  94146. */
  94147. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  94148. /**
  94149. * Extracts text content from a DOM element hierarchy
  94150. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  94151. */
  94152. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  94153. /**
  94154. * Convert an angle in radians to degrees
  94155. * @param angle defines the angle to convert
  94156. * @returns the angle in degrees
  94157. */
  94158. static ToDegrees(angle: number): number;
  94159. /**
  94160. * Convert an angle in degrees to radians
  94161. * @param angle defines the angle to convert
  94162. * @returns the angle in radians
  94163. */
  94164. static ToRadians(angle: number): number;
  94165. /**
  94166. * Encode a buffer to a base64 string
  94167. * @param buffer defines the buffer to encode
  94168. * @returns the encoded string
  94169. */
  94170. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  94171. /**
  94172. * Extracts minimum and maximum values from a list of indexed positions
  94173. * @param positions defines the positions to use
  94174. * @param indices defines the indices to the positions
  94175. * @param indexStart defines the start index
  94176. * @param indexCount defines the end index
  94177. * @param bias defines bias value to add to the result
  94178. * @return minimum and maximum values
  94179. */
  94180. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  94181. minimum: Vector3;
  94182. maximum: Vector3;
  94183. };
  94184. /**
  94185. * Extracts minimum and maximum values from a list of positions
  94186. * @param positions defines the positions to use
  94187. * @param start defines the start index in the positions array
  94188. * @param count defines the number of positions to handle
  94189. * @param bias defines bias value to add to the result
  94190. * @param stride defines the stride size to use (distance between two positions in the positions array)
  94191. * @return minimum and maximum values
  94192. */
  94193. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  94194. minimum: Vector3;
  94195. maximum: Vector3;
  94196. };
  94197. /**
  94198. * Returns an array if obj is not an array
  94199. * @param obj defines the object to evaluate as an array
  94200. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  94201. * @returns either obj directly if obj is an array or a new array containing obj
  94202. */
  94203. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  94204. /**
  94205. * Gets the pointer prefix to use
  94206. * @returns "pointer" if touch is enabled. Else returns "mouse"
  94207. */
  94208. static GetPointerPrefix(): string;
  94209. /**
  94210. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  94211. * @param func - the function to be called
  94212. * @param requester - the object that will request the next frame. Falls back to window.
  94213. * @returns frame number
  94214. */
  94215. static QueueNewFrame(func: () => void, requester?: any): number;
  94216. /**
  94217. * Ask the browser to promote the current element to fullscreen rendering mode
  94218. * @param element defines the DOM element to promote
  94219. */
  94220. static RequestFullscreen(element: HTMLElement): void;
  94221. /**
  94222. * Asks the browser to exit fullscreen mode
  94223. */
  94224. static ExitFullscreen(): void;
  94225. /**
  94226. * Ask the browser to promote the current element to pointerlock mode
  94227. * @param element defines the DOM element to promote
  94228. */
  94229. static RequestPointerlock(element: HTMLElement): void;
  94230. /**
  94231. * Asks the browser to exit pointerlock mode
  94232. */
  94233. static ExitPointerlock(): void;
  94234. /**
  94235. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  94236. * @param url define the url we are trying
  94237. * @param element define the dom element where to configure the cors policy
  94238. */
  94239. static SetCorsBehavior(url: string | string[], element: {
  94240. crossOrigin: string | null;
  94241. }): void;
  94242. /**
  94243. * Removes unwanted characters from an url
  94244. * @param url defines the url to clean
  94245. * @returns the cleaned url
  94246. */
  94247. static CleanUrl(url: string): string;
  94248. /**
  94249. * Gets or sets a function used to pre-process url before using them to load assets
  94250. */
  94251. static PreprocessUrl: (url: string) => string;
  94252. /**
  94253. * Loads an image as an HTMLImageElement.
  94254. * @param input url string, ArrayBuffer, or Blob to load
  94255. * @param onLoad callback called when the image successfully loads
  94256. * @param onError callback called when the image fails to load
  94257. * @param offlineProvider offline provider for caching
  94258. * @returns the HTMLImageElement of the loaded image
  94259. */
  94260. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  94261. /**
  94262. * Loads a file
  94263. * @param url url string, ArrayBuffer, or Blob to load
  94264. * @param onSuccess callback called when the file successfully loads
  94265. * @param onProgress callback called while file is loading (if the server supports this mode)
  94266. * @param offlineProvider defines the offline provider for caching
  94267. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  94268. * @param onError callback called when the file fails to load
  94269. * @returns a file request object
  94270. */
  94271. 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;
  94272. /**
  94273. * Loads a file from a url
  94274. * @param url the file url to load
  94275. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  94276. */
  94277. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  94278. /**
  94279. * Load a script (identified by an url). When the url returns, the
  94280. * content of this file is added into a new script element, attached to the DOM (body element)
  94281. * @param scriptUrl defines the url of the script to laod
  94282. * @param onSuccess defines the callback called when the script is loaded
  94283. * @param onError defines the callback to call if an error occurs
  94284. * @param scriptId defines the id of the script element
  94285. */
  94286. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  94287. /**
  94288. * Load an asynchronous script (identified by an url). When the url returns, the
  94289. * content of this file is added into a new script element, attached to the DOM (body element)
  94290. * @param scriptUrl defines the url of the script to laod
  94291. * @param scriptId defines the id of the script element
  94292. * @returns a promise request object
  94293. */
  94294. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  94295. /**
  94296. * Loads a file from a blob
  94297. * @param fileToLoad defines the blob to use
  94298. * @param callback defines the callback to call when data is loaded
  94299. * @param progressCallback defines the callback to call during loading process
  94300. * @returns a file request object
  94301. */
  94302. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  94303. /**
  94304. * Loads a file
  94305. * @param fileToLoad defines the file to load
  94306. * @param callback defines the callback to call when data is loaded
  94307. * @param progressCallBack defines the callback to call during loading process
  94308. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  94309. * @returns a file request object
  94310. */
  94311. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  94312. /**
  94313. * Creates a data url from a given string content
  94314. * @param content defines the content to convert
  94315. * @returns the new data url link
  94316. */
  94317. static FileAsURL(content: string): string;
  94318. /**
  94319. * Format the given number to a specific decimal format
  94320. * @param value defines the number to format
  94321. * @param decimals defines the number of decimals to use
  94322. * @returns the formatted string
  94323. */
  94324. static Format(value: number, decimals?: number): string;
  94325. /**
  94326. * Checks if a given vector is inside a specific range
  94327. * @param v defines the vector to test
  94328. * @param min defines the minimum range
  94329. * @param max defines the maximum range
  94330. */
  94331. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  94332. /**
  94333. * Tries to copy an object by duplicating every property
  94334. * @param source defines the source object
  94335. * @param destination defines the target object
  94336. * @param doNotCopyList defines a list of properties to avoid
  94337. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  94338. */
  94339. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  94340. /**
  94341. * Gets a boolean indicating if the given object has no own property
  94342. * @param obj defines the object to test
  94343. * @returns true if object has no own property
  94344. */
  94345. static IsEmpty(obj: any): boolean;
  94346. /**
  94347. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  94348. * @param str Source string
  94349. * @param suffix Suffix to search for in the source string
  94350. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94351. */
  94352. static EndsWith(str: string, suffix: string): boolean;
  94353. /**
  94354. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  94355. * @param str Source string
  94356. * @param suffix Suffix to search for in the source string
  94357. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94358. */
  94359. static StartsWith(str: string, suffix: string): boolean;
  94360. /**
  94361. * Function used to register events at window level
  94362. * @param events defines the events to register
  94363. */
  94364. static RegisterTopRootEvents(events: {
  94365. name: string;
  94366. handler: Nullable<(e: FocusEvent) => any>;
  94367. }[]): void;
  94368. /**
  94369. * Function used to unregister events from window level
  94370. * @param events defines the events to unregister
  94371. */
  94372. static UnregisterTopRootEvents(events: {
  94373. name: string;
  94374. handler: Nullable<(e: FocusEvent) => any>;
  94375. }[]): void;
  94376. /**
  94377. * @ignore
  94378. */
  94379. static _ScreenshotCanvas: HTMLCanvasElement;
  94380. /**
  94381. * Dumps the current bound framebuffer
  94382. * @param width defines the rendering width
  94383. * @param height defines the rendering height
  94384. * @param engine defines the hosting engine
  94385. * @param successCallback defines the callback triggered once the data are available
  94386. * @param mimeType defines the mime type of the result
  94387. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  94388. */
  94389. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94390. /**
  94391. * Converts the canvas data to blob.
  94392. * This acts as a polyfill for browsers not supporting the to blob function.
  94393. * @param canvas Defines the canvas to extract the data from
  94394. * @param successCallback Defines the callback triggered once the data are available
  94395. * @param mimeType Defines the mime type of the result
  94396. */
  94397. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  94398. /**
  94399. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  94400. * @param successCallback defines the callback triggered once the data are available
  94401. * @param mimeType defines the mime type of the result
  94402. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  94403. */
  94404. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94405. /**
  94406. * Downloads a blob in the browser
  94407. * @param blob defines the blob to download
  94408. * @param fileName defines the name of the downloaded file
  94409. */
  94410. static Download(blob: Blob, fileName: string): void;
  94411. /**
  94412. * Captures a screenshot of the current rendering
  94413. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94414. * @param engine defines the rendering engine
  94415. * @param camera defines the source camera
  94416. * @param size This parameter can be set to a single number or to an object with the
  94417. * following (optional) properties: precision, width, height. If a single number is passed,
  94418. * it will be used for both width and height. If an object is passed, the screenshot size
  94419. * will be derived from the parameters. The precision property is a multiplier allowing
  94420. * rendering at a higher or lower resolution
  94421. * @param successCallback defines the callback receives a single parameter which contains the
  94422. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94423. * src parameter of an <img> to display it
  94424. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  94425. * Check your browser for supported MIME types
  94426. */
  94427. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  94428. /**
  94429. * Generates an image screenshot from the specified camera.
  94430. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94431. * @param engine The engine to use for rendering
  94432. * @param camera The camera to use for rendering
  94433. * @param size This parameter can be set to a single number or to an object with the
  94434. * following (optional) properties: precision, width, height. If a single number is passed,
  94435. * it will be used for both width and height. If an object is passed, the screenshot size
  94436. * will be derived from the parameters. The precision property is a multiplier allowing
  94437. * rendering at a higher or lower resolution
  94438. * @param successCallback The callback receives a single parameter which contains the
  94439. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94440. * src parameter of an <img> to display it
  94441. * @param mimeType The MIME type of the screenshot image (default: image/png).
  94442. * Check your browser for supported MIME types
  94443. * @param samples Texture samples (default: 1)
  94444. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  94445. * @param fileName A name for for the downloaded file.
  94446. */
  94447. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  94448. /**
  94449. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94450. * Be aware Math.random() could cause collisions, but:
  94451. * "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"
  94452. * @returns a pseudo random id
  94453. */
  94454. static RandomId(): string;
  94455. /**
  94456. * Test if the given uri is a base64 string
  94457. * @param uri The uri to test
  94458. * @return True if the uri is a base64 string or false otherwise
  94459. */
  94460. static IsBase64(uri: string): boolean;
  94461. /**
  94462. * Decode the given base64 uri.
  94463. * @param uri The uri to decode
  94464. * @return The decoded base64 data.
  94465. */
  94466. static DecodeBase64(uri: string): ArrayBuffer;
  94467. /**
  94468. * Gets the absolute url.
  94469. * @param url the input url
  94470. * @return the absolute url
  94471. */
  94472. static GetAbsoluteUrl(url: string): string;
  94473. /**
  94474. * No log
  94475. */
  94476. static readonly NoneLogLevel: number;
  94477. /**
  94478. * Only message logs
  94479. */
  94480. static readonly MessageLogLevel: number;
  94481. /**
  94482. * Only warning logs
  94483. */
  94484. static readonly WarningLogLevel: number;
  94485. /**
  94486. * Only error logs
  94487. */
  94488. static readonly ErrorLogLevel: number;
  94489. /**
  94490. * All logs
  94491. */
  94492. static readonly AllLogLevel: number;
  94493. /**
  94494. * Gets a value indicating the number of loading errors
  94495. * @ignorenaming
  94496. */
  94497. static readonly errorsCount: number;
  94498. /**
  94499. * Callback called when a new log is added
  94500. */
  94501. static OnNewCacheEntry: (entry: string) => void;
  94502. /**
  94503. * Log a message to the console
  94504. * @param message defines the message to log
  94505. */
  94506. static Log(message: string): void;
  94507. /**
  94508. * Write a warning message to the console
  94509. * @param message defines the message to log
  94510. */
  94511. static Warn(message: string): void;
  94512. /**
  94513. * Write an error message to the console
  94514. * @param message defines the message to log
  94515. */
  94516. static Error(message: string): void;
  94517. /**
  94518. * Gets current log cache (list of logs)
  94519. */
  94520. static readonly LogCache: string;
  94521. /**
  94522. * Clears the log cache
  94523. */
  94524. static ClearLogCache(): void;
  94525. /**
  94526. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  94527. */
  94528. static LogLevels: number;
  94529. /**
  94530. * Checks if the loaded document was accessed via `file:`-Protocol.
  94531. * @returns boolean
  94532. */
  94533. static IsFileURL(): boolean;
  94534. /**
  94535. * Checks if the window object exists
  94536. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  94537. */
  94538. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  94539. /**
  94540. * No performance log
  94541. */
  94542. static readonly PerformanceNoneLogLevel: number;
  94543. /**
  94544. * Use user marks to log performance
  94545. */
  94546. static readonly PerformanceUserMarkLogLevel: number;
  94547. /**
  94548. * Log performance to the console
  94549. */
  94550. static readonly PerformanceConsoleLogLevel: number;
  94551. private static _performance;
  94552. /**
  94553. * Sets the current performance log level
  94554. */
  94555. static PerformanceLogLevel: number;
  94556. private static _StartPerformanceCounterDisabled;
  94557. private static _EndPerformanceCounterDisabled;
  94558. private static _StartUserMark;
  94559. private static _EndUserMark;
  94560. private static _StartPerformanceConsole;
  94561. private static _EndPerformanceConsole;
  94562. /**
  94563. * Starts a performance counter
  94564. */
  94565. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94566. /**
  94567. * Ends a specific performance coutner
  94568. */
  94569. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94570. /**
  94571. * Gets either window.performance.now() if supported or Date.now() else
  94572. */
  94573. static readonly Now: number;
  94574. /**
  94575. * This method will return the name of the class used to create the instance of the given object.
  94576. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  94577. * @param object the object to get the class name from
  94578. * @param isType defines if the object is actually a type
  94579. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  94580. */
  94581. static GetClassName(object: any, isType?: boolean): string;
  94582. /**
  94583. * Gets the first element of an array satisfying a given predicate
  94584. * @param array defines the array to browse
  94585. * @param predicate defines the predicate to use
  94586. * @returns null if not found or the element
  94587. */
  94588. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  94589. /**
  94590. * This method will return the name of the full name of the class, including its owning module (if any).
  94591. * 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).
  94592. * @param object the object to get the class name from
  94593. * @param isType defines if the object is actually a type
  94594. * @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.
  94595. * @ignorenaming
  94596. */
  94597. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  94598. /**
  94599. * Returns a promise that resolves after the given amount of time.
  94600. * @param delay Number of milliseconds to delay
  94601. * @returns Promise that resolves after the given amount of time
  94602. */
  94603. static DelayAsync(delay: number): Promise<void>;
  94604. /**
  94605. * Gets the current gradient from an array of IValueGradient
  94606. * @param ratio defines the current ratio to get
  94607. * @param gradients defines the array of IValueGradient
  94608. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  94609. */
  94610. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  94611. }
  94612. /**
  94613. * This class is used to track a performance counter which is number based.
  94614. * The user has access to many properties which give statistics of different nature.
  94615. *
  94616. * The implementer can track two kinds of Performance Counter: time and count.
  94617. * 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.
  94618. * 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.
  94619. */
  94620. export class PerfCounter {
  94621. /**
  94622. * Gets or sets a global boolean to turn on and off all the counters
  94623. */
  94624. static Enabled: boolean;
  94625. /**
  94626. * Returns the smallest value ever
  94627. */
  94628. readonly min: number;
  94629. /**
  94630. * Returns the biggest value ever
  94631. */
  94632. readonly max: number;
  94633. /**
  94634. * Returns the average value since the performance counter is running
  94635. */
  94636. readonly average: number;
  94637. /**
  94638. * Returns the average value of the last second the counter was monitored
  94639. */
  94640. readonly lastSecAverage: number;
  94641. /**
  94642. * Returns the current value
  94643. */
  94644. readonly current: number;
  94645. /**
  94646. * Gets the accumulated total
  94647. */
  94648. readonly total: number;
  94649. /**
  94650. * Gets the total value count
  94651. */
  94652. readonly count: number;
  94653. /**
  94654. * Creates a new counter
  94655. */
  94656. constructor();
  94657. /**
  94658. * Call this method to start monitoring a new frame.
  94659. * 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.
  94660. */
  94661. fetchNewFrame(): void;
  94662. /**
  94663. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94664. * @param newCount the count value to add to the monitored count
  94665. * @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.
  94666. */
  94667. addCount(newCount: number, fetchResult: boolean): void;
  94668. /**
  94669. * Start monitoring this performance counter
  94670. */
  94671. beginMonitoring(): void;
  94672. /**
  94673. * Compute the time lapsed since the previous beginMonitoring() call.
  94674. * @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
  94675. */
  94676. endMonitoring(newFrame?: boolean): void;
  94677. private _fetchResult;
  94678. private _startMonitoringTime;
  94679. private _min;
  94680. private _max;
  94681. private _average;
  94682. private _current;
  94683. private _totalValueCount;
  94684. private _totalAccumulated;
  94685. private _lastSecAverage;
  94686. private _lastSecAccumulated;
  94687. private _lastSecTime;
  94688. private _lastSecValueCount;
  94689. }
  94690. /**
  94691. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  94692. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  94693. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  94694. * @param name The name of the class, case should be preserved
  94695. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  94696. */
  94697. export function className(name: string, module?: string): (target: Object) => void;
  94698. /**
  94699. * An implementation of a loop for asynchronous functions.
  94700. */
  94701. export class AsyncLoop {
  94702. /**
  94703. * Defines the number of iterations for the loop
  94704. */
  94705. iterations: number;
  94706. /**
  94707. * Defines the current index of the loop.
  94708. */
  94709. index: number;
  94710. private _done;
  94711. private _fn;
  94712. private _successCallback;
  94713. /**
  94714. * Constructor.
  94715. * @param iterations the number of iterations.
  94716. * @param func the function to run each iteration
  94717. * @param successCallback the callback that will be called upon succesful execution
  94718. * @param offset starting offset.
  94719. */
  94720. constructor(
  94721. /**
  94722. * Defines the number of iterations for the loop
  94723. */
  94724. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  94725. /**
  94726. * Execute the next iteration. Must be called after the last iteration was finished.
  94727. */
  94728. executeNext(): void;
  94729. /**
  94730. * Break the loop and run the success callback.
  94731. */
  94732. breakLoop(): void;
  94733. /**
  94734. * Create and run an async loop.
  94735. * @param iterations the number of iterations.
  94736. * @param fn the function to run each iteration
  94737. * @param successCallback the callback that will be called upon succesful execution
  94738. * @param offset starting offset.
  94739. * @returns the created async loop object
  94740. */
  94741. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  94742. /**
  94743. * A for-loop that will run a given number of iterations synchronous and the rest async.
  94744. * @param iterations total number of iterations
  94745. * @param syncedIterations number of synchronous iterations in each async iteration.
  94746. * @param fn the function to call each iteration.
  94747. * @param callback a success call back that will be called when iterating stops.
  94748. * @param breakFunction a break condition (optional)
  94749. * @param timeout timeout settings for the setTimeout function. default - 0.
  94750. * @returns the created async loop object
  94751. */
  94752. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  94753. }
  94754. }
  94755. declare module BABYLON {
  94756. /** @hidden */
  94757. export interface ICollisionCoordinator {
  94758. createCollider(): Collider;
  94759. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94760. init(scene: Scene): void;
  94761. }
  94762. /** @hidden */
  94763. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  94764. private _scene;
  94765. private _scaledPosition;
  94766. private _scaledVelocity;
  94767. private _finalPosition;
  94768. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94769. createCollider(): Collider;
  94770. init(scene: Scene): void;
  94771. private _collideWithWorld;
  94772. }
  94773. }
  94774. declare module BABYLON {
  94775. /**
  94776. * Class used to manage all inputs for the scene.
  94777. */
  94778. export class InputManager {
  94779. /** The distance in pixel that you have to move to prevent some events */
  94780. static DragMovementThreshold: number;
  94781. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  94782. static LongPressDelay: number;
  94783. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  94784. static DoubleClickDelay: number;
  94785. /** If you need to check double click without raising a single click at first click, enable this flag */
  94786. static ExclusiveDoubleClickMode: boolean;
  94787. private _wheelEventName;
  94788. private _onPointerMove;
  94789. private _onPointerDown;
  94790. private _onPointerUp;
  94791. private _initClickEvent;
  94792. private _initActionManager;
  94793. private _delayedSimpleClick;
  94794. private _delayedSimpleClickTimeout;
  94795. private _previousDelayedSimpleClickTimeout;
  94796. private _meshPickProceed;
  94797. private _previousButtonPressed;
  94798. private _currentPickResult;
  94799. private _previousPickResult;
  94800. private _totalPointersPressed;
  94801. private _doubleClickOccured;
  94802. private _pointerOverMesh;
  94803. private _pickedDownMesh;
  94804. private _pickedUpMesh;
  94805. private _pointerX;
  94806. private _pointerY;
  94807. private _unTranslatedPointerX;
  94808. private _unTranslatedPointerY;
  94809. private _startingPointerPosition;
  94810. private _previousStartingPointerPosition;
  94811. private _startingPointerTime;
  94812. private _previousStartingPointerTime;
  94813. private _pointerCaptures;
  94814. private _onKeyDown;
  94815. private _onKeyUp;
  94816. private _onCanvasFocusObserver;
  94817. private _onCanvasBlurObserver;
  94818. private _scene;
  94819. /**
  94820. * Creates a new InputManager
  94821. * @param scene defines the hosting scene
  94822. */
  94823. constructor(scene: Scene);
  94824. /**
  94825. * Gets the mesh that is currently under the pointer
  94826. */
  94827. readonly meshUnderPointer: Nullable<AbstractMesh>;
  94828. /**
  94829. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  94830. */
  94831. readonly unTranslatedPointer: Vector2;
  94832. /**
  94833. * Gets or sets the current on-screen X position of the pointer
  94834. */
  94835. pointerX: number;
  94836. /**
  94837. * Gets or sets the current on-screen Y position of the pointer
  94838. */
  94839. pointerY: number;
  94840. private _updatePointerPosition;
  94841. private _processPointerMove;
  94842. private _setRayOnPointerInfo;
  94843. private _checkPrePointerObservable;
  94844. /**
  94845. * Use this method to simulate a pointer move on a mesh
  94846. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94847. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94848. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94849. */
  94850. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94851. /**
  94852. * Use this method to simulate a pointer down on a mesh
  94853. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94854. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94855. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94856. */
  94857. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94858. private _processPointerDown;
  94859. /** @hidden */
  94860. _isPointerSwiping(): boolean;
  94861. /**
  94862. * Use this method to simulate a pointer up on a mesh
  94863. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94864. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94865. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94866. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  94867. */
  94868. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  94869. private _processPointerUp;
  94870. /**
  94871. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  94872. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  94873. * @returns true if the pointer was captured
  94874. */
  94875. isPointerCaptured(pointerId?: number): boolean;
  94876. /**
  94877. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  94878. * @param attachUp defines if you want to attach events to pointerup
  94879. * @param attachDown defines if you want to attach events to pointerdown
  94880. * @param attachMove defines if you want to attach events to pointermove
  94881. */
  94882. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  94883. /**
  94884. * Detaches all event handlers
  94885. */
  94886. detachControl(): void;
  94887. /**
  94888. * Force the value of meshUnderPointer
  94889. * @param mesh defines the mesh to use
  94890. */
  94891. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  94892. /**
  94893. * Gets the mesh under the pointer
  94894. * @returns a Mesh or null if no mesh is under the pointer
  94895. */
  94896. getPointerOverMesh(): Nullable<AbstractMesh>;
  94897. }
  94898. }
  94899. declare module BABYLON {
  94900. /**
  94901. * This class defines the direct association between an animation and a target
  94902. */
  94903. export class TargetedAnimation {
  94904. /**
  94905. * Animation to perform
  94906. */
  94907. animation: Animation;
  94908. /**
  94909. * Target to animate
  94910. */
  94911. target: any;
  94912. /**
  94913. * Serialize the object
  94914. * @returns the JSON object representing the current entity
  94915. */
  94916. serialize(): any;
  94917. }
  94918. /**
  94919. * Use this class to create coordinated animations on multiple targets
  94920. */
  94921. export class AnimationGroup implements IDisposable {
  94922. /** The name of the animation group */
  94923. name: string;
  94924. private _scene;
  94925. private _targetedAnimations;
  94926. private _animatables;
  94927. private _from;
  94928. private _to;
  94929. private _isStarted;
  94930. private _isPaused;
  94931. private _speedRatio;
  94932. private _loopAnimation;
  94933. /**
  94934. * Gets or sets the unique id of the node
  94935. */
  94936. uniqueId: number;
  94937. /**
  94938. * This observable will notify when one animation have ended
  94939. */
  94940. onAnimationEndObservable: Observable<TargetedAnimation>;
  94941. /**
  94942. * Observer raised when one animation loops
  94943. */
  94944. onAnimationLoopObservable: Observable<TargetedAnimation>;
  94945. /**
  94946. * This observable will notify when all animations have ended.
  94947. */
  94948. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  94949. /**
  94950. * This observable will notify when all animations have paused.
  94951. */
  94952. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  94953. /**
  94954. * This observable will notify when all animations are playing.
  94955. */
  94956. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  94957. /**
  94958. * Gets the first frame
  94959. */
  94960. readonly from: number;
  94961. /**
  94962. * Gets the last frame
  94963. */
  94964. readonly to: number;
  94965. /**
  94966. * Define if the animations are started
  94967. */
  94968. readonly isStarted: boolean;
  94969. /**
  94970. * Gets a value indicating that the current group is playing
  94971. */
  94972. readonly isPlaying: boolean;
  94973. /**
  94974. * Gets or sets the speed ratio to use for all animations
  94975. */
  94976. /**
  94977. * Gets or sets the speed ratio to use for all animations
  94978. */
  94979. speedRatio: number;
  94980. /**
  94981. * Gets or sets if all animations should loop or not
  94982. */
  94983. loopAnimation: boolean;
  94984. /**
  94985. * Gets the targeted animations for this animation group
  94986. */
  94987. readonly targetedAnimations: Array<TargetedAnimation>;
  94988. /**
  94989. * returning the list of animatables controlled by this animation group.
  94990. */
  94991. readonly animatables: Array<Animatable>;
  94992. /**
  94993. * Instantiates a new Animation Group.
  94994. * This helps managing several animations at once.
  94995. * @see http://doc.babylonjs.com/how_to/group
  94996. * @param name Defines the name of the group
  94997. * @param scene Defines the scene the group belongs to
  94998. */
  94999. constructor(
  95000. /** The name of the animation group */
  95001. name: string, scene?: Nullable<Scene>);
  95002. /**
  95003. * Add an animation (with its target) in the group
  95004. * @param animation defines the animation we want to add
  95005. * @param target defines the target of the animation
  95006. * @returns the TargetedAnimation object
  95007. */
  95008. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  95009. /**
  95010. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  95011. * It can add constant keys at begin or end
  95012. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  95013. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  95014. * @returns the animation group
  95015. */
  95016. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  95017. /**
  95018. * Start all animations on given targets
  95019. * @param loop defines if animations must loop
  95020. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  95021. * @param from defines the from key (optional)
  95022. * @param to defines the to key (optional)
  95023. * @returns the current animation group
  95024. */
  95025. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  95026. /**
  95027. * Pause all animations
  95028. * @returns the animation group
  95029. */
  95030. pause(): AnimationGroup;
  95031. /**
  95032. * Play all animations to initial state
  95033. * This function will start() the animations if they were not started or will restart() them if they were paused
  95034. * @param loop defines if animations must loop
  95035. * @returns the animation group
  95036. */
  95037. play(loop?: boolean): AnimationGroup;
  95038. /**
  95039. * Reset all animations to initial state
  95040. * @returns the animation group
  95041. */
  95042. reset(): AnimationGroup;
  95043. /**
  95044. * Restart animations from key 0
  95045. * @returns the animation group
  95046. */
  95047. restart(): AnimationGroup;
  95048. /**
  95049. * Stop all animations
  95050. * @returns the animation group
  95051. */
  95052. stop(): AnimationGroup;
  95053. /**
  95054. * Set animation weight for all animatables
  95055. * @param weight defines the weight to use
  95056. * @return the animationGroup
  95057. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  95058. */
  95059. setWeightForAllAnimatables(weight: number): AnimationGroup;
  95060. /**
  95061. * Synchronize and normalize all animatables with a source animatable
  95062. * @param root defines the root animatable to synchronize with
  95063. * @return the animationGroup
  95064. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  95065. */
  95066. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  95067. /**
  95068. * Goes to a specific frame in this animation group
  95069. * @param frame the frame number to go to
  95070. * @return the animationGroup
  95071. */
  95072. goToFrame(frame: number): AnimationGroup;
  95073. /**
  95074. * Dispose all associated resources
  95075. */
  95076. dispose(): void;
  95077. private _checkAnimationGroupEnded;
  95078. /**
  95079. * Clone the current animation group and returns a copy
  95080. * @param newName defines the name of the new group
  95081. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  95082. * @returns the new aniamtion group
  95083. */
  95084. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  95085. /**
  95086. * Serializes the animationGroup to an object
  95087. * @returns Serialized object
  95088. */
  95089. serialize(): any;
  95090. /**
  95091. * Returns a new AnimationGroup object parsed from the source provided.
  95092. * @param parsedAnimationGroup defines the source
  95093. * @param scene defines the scene that will receive the animationGroup
  95094. * @returns a new AnimationGroup
  95095. */
  95096. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  95097. /**
  95098. * Returns the string "AnimationGroup"
  95099. * @returns "AnimationGroup"
  95100. */
  95101. getClassName(): string;
  95102. /**
  95103. * Creates a detailled string about the object
  95104. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  95105. * @returns a string representing the object
  95106. */
  95107. toString(fullDetails?: boolean): string;
  95108. }
  95109. }
  95110. declare module BABYLON {
  95111. /**
  95112. * Define an interface for all classes that will hold resources
  95113. */
  95114. export interface IDisposable {
  95115. /**
  95116. * Releases all held resources
  95117. */
  95118. dispose(): void;
  95119. }
  95120. /** Interface defining initialization parameters for Scene class */
  95121. export interface SceneOptions {
  95122. /**
  95123. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  95124. * It will improve performance when the number of geometries becomes important.
  95125. */
  95126. useGeometryUniqueIdsMap?: boolean;
  95127. /**
  95128. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  95129. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  95130. */
  95131. useMaterialMeshMap?: boolean;
  95132. /**
  95133. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  95134. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  95135. */
  95136. useClonedMeshhMap?: boolean;
  95137. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  95138. virtual?: boolean;
  95139. }
  95140. /**
  95141. * Represents a scene to be rendered by the engine.
  95142. * @see http://doc.babylonjs.com/features/scene
  95143. */
  95144. export class Scene extends AbstractScene implements IAnimatable {
  95145. private static _uniqueIdCounter;
  95146. /** The fog is deactivated */
  95147. static readonly FOGMODE_NONE: number;
  95148. /** The fog density is following an exponential function */
  95149. static readonly FOGMODE_EXP: number;
  95150. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  95151. static readonly FOGMODE_EXP2: number;
  95152. /** The fog density is following a linear function. */
  95153. static readonly FOGMODE_LINEAR: number;
  95154. /**
  95155. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  95156. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95157. */
  95158. static MinDeltaTime: number;
  95159. /**
  95160. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  95161. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95162. */
  95163. static MaxDeltaTime: number;
  95164. /**
  95165. * Factory used to create the default material.
  95166. * @param name The name of the material to create
  95167. * @param scene The scene to create the material for
  95168. * @returns The default material
  95169. */
  95170. static DefaultMaterialFactory(scene: Scene): Material;
  95171. /**
  95172. * Factory used to create the a collision coordinator.
  95173. * @returns The collision coordinator
  95174. */
  95175. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  95176. /** @hidden */
  95177. _inputManager: InputManager;
  95178. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  95179. cameraToUseForPointers: Nullable<Camera>;
  95180. /** @hidden */
  95181. readonly _isScene: boolean;
  95182. /**
  95183. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  95184. */
  95185. autoClear: boolean;
  95186. /**
  95187. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  95188. */
  95189. autoClearDepthAndStencil: boolean;
  95190. /**
  95191. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  95192. */
  95193. clearColor: Color4;
  95194. /**
  95195. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  95196. */
  95197. ambientColor: Color3;
  95198. /**
  95199. * This is use to store the default BRDF lookup for PBR materials in your scene.
  95200. * It should only be one of the following (if not the default embedded one):
  95201. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  95202. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  95203. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  95204. * The material properties need to be setup according to the type of texture in use.
  95205. */
  95206. environmentBRDFTexture: BaseTexture;
  95207. /** @hidden */
  95208. protected _environmentTexture: Nullable<BaseTexture>;
  95209. /**
  95210. * Texture used in all pbr material as the reflection texture.
  95211. * As in the majority of the scene they are the same (exception for multi room and so on),
  95212. * this is easier to reference from here than from all the materials.
  95213. */
  95214. /**
  95215. * Texture used in all pbr material as the reflection texture.
  95216. * As in the majority of the scene they are the same (exception for multi room and so on),
  95217. * this is easier to set here than in all the materials.
  95218. */
  95219. environmentTexture: Nullable<BaseTexture>;
  95220. /** @hidden */
  95221. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95222. /**
  95223. * Default image processing configuration used either in the rendering
  95224. * Forward main pass or through the imageProcessingPostProcess if present.
  95225. * As in the majority of the scene they are the same (exception for multi camera),
  95226. * this is easier to reference from here than from all the materials and post process.
  95227. *
  95228. * No setter as we it is a shared configuration, you can set the values instead.
  95229. */
  95230. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  95231. private _forceWireframe;
  95232. /**
  95233. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  95234. */
  95235. forceWireframe: boolean;
  95236. private _forcePointsCloud;
  95237. /**
  95238. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  95239. */
  95240. forcePointsCloud: boolean;
  95241. /**
  95242. * Gets or sets the active clipplane 1
  95243. */
  95244. clipPlane: Nullable<Plane>;
  95245. /**
  95246. * Gets or sets the active clipplane 2
  95247. */
  95248. clipPlane2: Nullable<Plane>;
  95249. /**
  95250. * Gets or sets the active clipplane 3
  95251. */
  95252. clipPlane3: Nullable<Plane>;
  95253. /**
  95254. * Gets or sets the active clipplane 4
  95255. */
  95256. clipPlane4: Nullable<Plane>;
  95257. /**
  95258. * Gets or sets a boolean indicating if animations are enabled
  95259. */
  95260. animationsEnabled: boolean;
  95261. private _animationPropertiesOverride;
  95262. /**
  95263. * Gets or sets the animation properties override
  95264. */
  95265. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  95266. /**
  95267. * Gets or sets a boolean indicating if a constant deltatime has to be used
  95268. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  95269. */
  95270. useConstantAnimationDeltaTime: boolean;
  95271. /**
  95272. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  95273. * Please note that it requires to run a ray cast through the scene on every frame
  95274. */
  95275. constantlyUpdateMeshUnderPointer: boolean;
  95276. /**
  95277. * Defines the HTML cursor to use when hovering over interactive elements
  95278. */
  95279. hoverCursor: string;
  95280. /**
  95281. * Defines the HTML default cursor to use (empty by default)
  95282. */
  95283. defaultCursor: string;
  95284. /**
  95285. * This is used to call preventDefault() on pointer down
  95286. * in order to block unwanted artifacts like system double clicks
  95287. */
  95288. preventDefaultOnPointerDown: boolean;
  95289. /**
  95290. * This is used to call preventDefault() on pointer up
  95291. * in order to block unwanted artifacts like system double clicks
  95292. */
  95293. preventDefaultOnPointerUp: boolean;
  95294. /**
  95295. * Gets or sets user defined metadata
  95296. */
  95297. metadata: any;
  95298. /**
  95299. * For internal use only. Please do not use.
  95300. */
  95301. reservedDataStore: any;
  95302. /**
  95303. * Gets the name of the plugin used to load this scene (null by default)
  95304. */
  95305. loadingPluginName: string;
  95306. /**
  95307. * Use this array to add regular expressions used to disable offline support for specific urls
  95308. */
  95309. disableOfflineSupportExceptionRules: RegExp[];
  95310. /**
  95311. * An event triggered when the scene is disposed.
  95312. */
  95313. onDisposeObservable: Observable<Scene>;
  95314. private _onDisposeObserver;
  95315. /** Sets a function to be executed when this scene is disposed. */
  95316. onDispose: () => void;
  95317. /**
  95318. * An event triggered before rendering the scene (right after animations and physics)
  95319. */
  95320. onBeforeRenderObservable: Observable<Scene>;
  95321. private _onBeforeRenderObserver;
  95322. /** Sets a function to be executed before rendering this scene */
  95323. beforeRender: Nullable<() => void>;
  95324. /**
  95325. * An event triggered after rendering the scene
  95326. */
  95327. onAfterRenderObservable: Observable<Scene>;
  95328. /**
  95329. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  95330. */
  95331. onAfterRenderCameraObservable: Observable<Camera>;
  95332. private _onAfterRenderObserver;
  95333. /** Sets a function to be executed after rendering this scene */
  95334. afterRender: Nullable<() => void>;
  95335. /**
  95336. * An event triggered before animating the scene
  95337. */
  95338. onBeforeAnimationsObservable: Observable<Scene>;
  95339. /**
  95340. * An event triggered after animations processing
  95341. */
  95342. onAfterAnimationsObservable: Observable<Scene>;
  95343. /**
  95344. * An event triggered before draw calls are ready to be sent
  95345. */
  95346. onBeforeDrawPhaseObservable: Observable<Scene>;
  95347. /**
  95348. * An event triggered after draw calls have been sent
  95349. */
  95350. onAfterDrawPhaseObservable: Observable<Scene>;
  95351. /**
  95352. * An event triggered when the scene is ready
  95353. */
  95354. onReadyObservable: Observable<Scene>;
  95355. /**
  95356. * An event triggered before rendering a camera
  95357. */
  95358. onBeforeCameraRenderObservable: Observable<Camera>;
  95359. private _onBeforeCameraRenderObserver;
  95360. /** Sets a function to be executed before rendering a camera*/
  95361. beforeCameraRender: () => void;
  95362. /**
  95363. * An event triggered after rendering a camera
  95364. */
  95365. onAfterCameraRenderObservable: Observable<Camera>;
  95366. private _onAfterCameraRenderObserver;
  95367. /** Sets a function to be executed after rendering a camera*/
  95368. afterCameraRender: () => void;
  95369. /**
  95370. * An event triggered when active meshes evaluation is about to start
  95371. */
  95372. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  95373. /**
  95374. * An event triggered when active meshes evaluation is done
  95375. */
  95376. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  95377. /**
  95378. * An event triggered when particles rendering is about to start
  95379. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95380. */
  95381. onBeforeParticlesRenderingObservable: Observable<Scene>;
  95382. /**
  95383. * An event triggered when particles rendering is done
  95384. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95385. */
  95386. onAfterParticlesRenderingObservable: Observable<Scene>;
  95387. /**
  95388. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  95389. */
  95390. onDataLoadedObservable: Observable<Scene>;
  95391. /**
  95392. * An event triggered when a camera is created
  95393. */
  95394. onNewCameraAddedObservable: Observable<Camera>;
  95395. /**
  95396. * An event triggered when a camera is removed
  95397. */
  95398. onCameraRemovedObservable: Observable<Camera>;
  95399. /**
  95400. * An event triggered when a light is created
  95401. */
  95402. onNewLightAddedObservable: Observable<Light>;
  95403. /**
  95404. * An event triggered when a light is removed
  95405. */
  95406. onLightRemovedObservable: Observable<Light>;
  95407. /**
  95408. * An event triggered when a geometry is created
  95409. */
  95410. onNewGeometryAddedObservable: Observable<Geometry>;
  95411. /**
  95412. * An event triggered when a geometry is removed
  95413. */
  95414. onGeometryRemovedObservable: Observable<Geometry>;
  95415. /**
  95416. * An event triggered when a transform node is created
  95417. */
  95418. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  95419. /**
  95420. * An event triggered when a transform node is removed
  95421. */
  95422. onTransformNodeRemovedObservable: Observable<TransformNode>;
  95423. /**
  95424. * An event triggered when a mesh is created
  95425. */
  95426. onNewMeshAddedObservable: Observable<AbstractMesh>;
  95427. /**
  95428. * An event triggered when a mesh is removed
  95429. */
  95430. onMeshRemovedObservable: Observable<AbstractMesh>;
  95431. /**
  95432. * An event triggered when a skeleton is created
  95433. */
  95434. onNewSkeletonAddedObservable: Observable<Skeleton>;
  95435. /**
  95436. * An event triggered when a skeleton is removed
  95437. */
  95438. onSkeletonRemovedObservable: Observable<Skeleton>;
  95439. /**
  95440. * An event triggered when a material is created
  95441. */
  95442. onNewMaterialAddedObservable: Observable<Material>;
  95443. /**
  95444. * An event triggered when a material is removed
  95445. */
  95446. onMaterialRemovedObservable: Observable<Material>;
  95447. /**
  95448. * An event triggered when a texture is created
  95449. */
  95450. onNewTextureAddedObservable: Observable<BaseTexture>;
  95451. /**
  95452. * An event triggered when a texture is removed
  95453. */
  95454. onTextureRemovedObservable: Observable<BaseTexture>;
  95455. /**
  95456. * An event triggered when render targets are about to be rendered
  95457. * Can happen multiple times per frame.
  95458. */
  95459. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  95460. /**
  95461. * An event triggered when render targets were rendered.
  95462. * Can happen multiple times per frame.
  95463. */
  95464. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  95465. /**
  95466. * An event triggered before calculating deterministic simulation step
  95467. */
  95468. onBeforeStepObservable: Observable<Scene>;
  95469. /**
  95470. * An event triggered after calculating deterministic simulation step
  95471. */
  95472. onAfterStepObservable: Observable<Scene>;
  95473. /**
  95474. * An event triggered when the activeCamera property is updated
  95475. */
  95476. onActiveCameraChanged: Observable<Scene>;
  95477. /**
  95478. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  95479. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95480. * 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)
  95481. */
  95482. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95483. /**
  95484. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  95485. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95486. * 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)
  95487. */
  95488. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95489. /**
  95490. * This Observable will when a mesh has been imported into the scene.
  95491. */
  95492. onMeshImportedObservable: Observable<AbstractMesh>;
  95493. /**
  95494. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  95495. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  95496. */
  95497. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  95498. /** @hidden */
  95499. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  95500. /**
  95501. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  95502. */
  95503. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  95504. /**
  95505. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  95506. */
  95507. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  95508. /**
  95509. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  95510. */
  95511. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  95512. /** Callback called when a pointer move is detected */
  95513. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95514. /** Callback called when a pointer down is detected */
  95515. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95516. /** Callback called when a pointer up is detected */
  95517. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  95518. /** Callback called when a pointer pick is detected */
  95519. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  95520. /**
  95521. * 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).
  95522. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  95523. */
  95524. onPrePointerObservable: Observable<PointerInfoPre>;
  95525. /**
  95526. * Observable event triggered each time an input event is received from the rendering canvas
  95527. */
  95528. onPointerObservable: Observable<PointerInfo>;
  95529. /**
  95530. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  95531. */
  95532. readonly unTranslatedPointer: Vector2;
  95533. /**
  95534. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  95535. */
  95536. static DragMovementThreshold: number;
  95537. /**
  95538. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  95539. */
  95540. static LongPressDelay: number;
  95541. /**
  95542. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  95543. */
  95544. static DoubleClickDelay: number;
  95545. /** If you need to check double click without raising a single click at first click, enable this flag */
  95546. static ExclusiveDoubleClickMode: boolean;
  95547. /** @hidden */
  95548. _mirroredCameraPosition: Nullable<Vector3>;
  95549. /**
  95550. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  95551. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  95552. */
  95553. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  95554. /**
  95555. * Observable event triggered each time an keyboard event is received from the hosting window
  95556. */
  95557. onKeyboardObservable: Observable<KeyboardInfo>;
  95558. private _useRightHandedSystem;
  95559. /**
  95560. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  95561. */
  95562. useRightHandedSystem: boolean;
  95563. private _timeAccumulator;
  95564. private _currentStepId;
  95565. private _currentInternalStep;
  95566. /**
  95567. * Sets the step Id used by deterministic lock step
  95568. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95569. * @param newStepId defines the step Id
  95570. */
  95571. setStepId(newStepId: number): void;
  95572. /**
  95573. * Gets the step Id used by deterministic lock step
  95574. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95575. * @returns the step Id
  95576. */
  95577. getStepId(): number;
  95578. /**
  95579. * Gets the internal step used by deterministic lock step
  95580. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95581. * @returns the internal step
  95582. */
  95583. getInternalStep(): number;
  95584. private _fogEnabled;
  95585. /**
  95586. * Gets or sets a boolean indicating if fog is enabled on this scene
  95587. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95588. * (Default is true)
  95589. */
  95590. fogEnabled: boolean;
  95591. private _fogMode;
  95592. /**
  95593. * Gets or sets the fog mode to use
  95594. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95595. * | mode | value |
  95596. * | --- | --- |
  95597. * | FOGMODE_NONE | 0 |
  95598. * | FOGMODE_EXP | 1 |
  95599. * | FOGMODE_EXP2 | 2 |
  95600. * | FOGMODE_LINEAR | 3 |
  95601. */
  95602. fogMode: number;
  95603. /**
  95604. * Gets or sets the fog color to use
  95605. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95606. * (Default is Color3(0.2, 0.2, 0.3))
  95607. */
  95608. fogColor: Color3;
  95609. /**
  95610. * Gets or sets the fog density to use
  95611. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95612. * (Default is 0.1)
  95613. */
  95614. fogDensity: number;
  95615. /**
  95616. * Gets or sets the fog start distance to use
  95617. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95618. * (Default is 0)
  95619. */
  95620. fogStart: number;
  95621. /**
  95622. * Gets or sets the fog end distance to use
  95623. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95624. * (Default is 1000)
  95625. */
  95626. fogEnd: number;
  95627. private _shadowsEnabled;
  95628. /**
  95629. * Gets or sets a boolean indicating if shadows are enabled on this scene
  95630. */
  95631. shadowsEnabled: boolean;
  95632. private _lightsEnabled;
  95633. /**
  95634. * Gets or sets a boolean indicating if lights are enabled on this scene
  95635. */
  95636. lightsEnabled: boolean;
  95637. /** All of the active cameras added to this scene. */
  95638. activeCameras: Camera[];
  95639. /** @hidden */
  95640. _activeCamera: Nullable<Camera>;
  95641. /** Gets or sets the current active camera */
  95642. activeCamera: Nullable<Camera>;
  95643. private _defaultMaterial;
  95644. /** The default material used on meshes when no material is affected */
  95645. /** The default material used on meshes when no material is affected */
  95646. defaultMaterial: Material;
  95647. private _texturesEnabled;
  95648. /**
  95649. * Gets or sets a boolean indicating if textures are enabled on this scene
  95650. */
  95651. texturesEnabled: boolean;
  95652. /**
  95653. * Gets or sets a boolean indicating if particles are enabled on this scene
  95654. */
  95655. particlesEnabled: boolean;
  95656. /**
  95657. * Gets or sets a boolean indicating if sprites are enabled on this scene
  95658. */
  95659. spritesEnabled: boolean;
  95660. private _skeletonsEnabled;
  95661. /**
  95662. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  95663. */
  95664. skeletonsEnabled: boolean;
  95665. /**
  95666. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  95667. */
  95668. lensFlaresEnabled: boolean;
  95669. /**
  95670. * Gets or sets a boolean indicating if collisions are enabled on this scene
  95671. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95672. */
  95673. collisionsEnabled: boolean;
  95674. private _collisionCoordinator;
  95675. /** @hidden */
  95676. readonly collisionCoordinator: ICollisionCoordinator;
  95677. /**
  95678. * Defines the gravity applied to this scene (used only for collisions)
  95679. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95680. */
  95681. gravity: Vector3;
  95682. /**
  95683. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  95684. */
  95685. postProcessesEnabled: boolean;
  95686. /**
  95687. * The list of postprocesses added to the scene
  95688. */
  95689. postProcesses: PostProcess[];
  95690. /**
  95691. * Gets the current postprocess manager
  95692. */
  95693. postProcessManager: PostProcessManager;
  95694. /**
  95695. * Gets or sets a boolean indicating if render targets are enabled on this scene
  95696. */
  95697. renderTargetsEnabled: boolean;
  95698. /**
  95699. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  95700. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  95701. */
  95702. dumpNextRenderTargets: boolean;
  95703. /**
  95704. * The list of user defined render targets added to the scene
  95705. */
  95706. customRenderTargets: RenderTargetTexture[];
  95707. /**
  95708. * Defines if texture loading must be delayed
  95709. * If true, textures will only be loaded when they need to be rendered
  95710. */
  95711. useDelayedTextureLoading: boolean;
  95712. /**
  95713. * Gets the list of meshes imported to the scene through SceneLoader
  95714. */
  95715. importedMeshesFiles: String[];
  95716. /**
  95717. * Gets or sets a boolean indicating if probes are enabled on this scene
  95718. */
  95719. probesEnabled: boolean;
  95720. /**
  95721. * Gets or sets the current offline provider to use to store scene data
  95722. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  95723. */
  95724. offlineProvider: IOfflineProvider;
  95725. /**
  95726. * Gets or sets the action manager associated with the scene
  95727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95728. */
  95729. actionManager: AbstractActionManager;
  95730. private _meshesForIntersections;
  95731. /**
  95732. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  95733. */
  95734. proceduralTexturesEnabled: boolean;
  95735. private _engine;
  95736. private _totalVertices;
  95737. /** @hidden */
  95738. _activeIndices: PerfCounter;
  95739. /** @hidden */
  95740. _activeParticles: PerfCounter;
  95741. /** @hidden */
  95742. _activeBones: PerfCounter;
  95743. private _animationRatio;
  95744. /** @hidden */
  95745. _animationTimeLast: number;
  95746. /** @hidden */
  95747. _animationTime: number;
  95748. /**
  95749. * Gets or sets a general scale for animation speed
  95750. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  95751. */
  95752. animationTimeScale: number;
  95753. /** @hidden */
  95754. _cachedMaterial: Nullable<Material>;
  95755. /** @hidden */
  95756. _cachedEffect: Nullable<Effect>;
  95757. /** @hidden */
  95758. _cachedVisibility: Nullable<number>;
  95759. private _renderId;
  95760. private _frameId;
  95761. private _executeWhenReadyTimeoutId;
  95762. private _intermediateRendering;
  95763. private _viewUpdateFlag;
  95764. private _projectionUpdateFlag;
  95765. /** @hidden */
  95766. _toBeDisposed: Nullable<IDisposable>[];
  95767. private _activeRequests;
  95768. /** @hidden */
  95769. _pendingData: any[];
  95770. private _isDisposed;
  95771. /**
  95772. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  95773. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  95774. */
  95775. dispatchAllSubMeshesOfActiveMeshes: boolean;
  95776. private _activeMeshes;
  95777. private _processedMaterials;
  95778. private _renderTargets;
  95779. /** @hidden */
  95780. _activeParticleSystems: SmartArray<IParticleSystem>;
  95781. private _activeSkeletons;
  95782. private _softwareSkinnedMeshes;
  95783. private _renderingManager;
  95784. /** @hidden */
  95785. _activeAnimatables: Animatable[];
  95786. private _transformMatrix;
  95787. private _sceneUbo;
  95788. /** @hidden */
  95789. _viewMatrix: Matrix;
  95790. private _projectionMatrix;
  95791. /** @hidden */
  95792. _forcedViewPosition: Nullable<Vector3>;
  95793. /** @hidden */
  95794. _frustumPlanes: Plane[];
  95795. /**
  95796. * Gets the list of frustum planes (built from the active camera)
  95797. */
  95798. readonly frustumPlanes: Plane[];
  95799. /**
  95800. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  95801. * This is useful if there are more lights that the maximum simulteanous authorized
  95802. */
  95803. requireLightSorting: boolean;
  95804. /** @hidden */
  95805. readonly useMaterialMeshMap: boolean;
  95806. /** @hidden */
  95807. readonly useClonedMeshhMap: boolean;
  95808. private _externalData;
  95809. private _uid;
  95810. /**
  95811. * @hidden
  95812. * Backing store of defined scene components.
  95813. */
  95814. _components: ISceneComponent[];
  95815. /**
  95816. * @hidden
  95817. * Backing store of defined scene components.
  95818. */
  95819. _serializableComponents: ISceneSerializableComponent[];
  95820. /**
  95821. * List of components to register on the next registration step.
  95822. */
  95823. private _transientComponents;
  95824. /**
  95825. * Registers the transient components if needed.
  95826. */
  95827. private _registerTransientComponents;
  95828. /**
  95829. * @hidden
  95830. * Add a component to the scene.
  95831. * Note that the ccomponent could be registered on th next frame if this is called after
  95832. * the register component stage.
  95833. * @param component Defines the component to add to the scene
  95834. */
  95835. _addComponent(component: ISceneComponent): void;
  95836. /**
  95837. * @hidden
  95838. * Gets a component from the scene.
  95839. * @param name defines the name of the component to retrieve
  95840. * @returns the component or null if not present
  95841. */
  95842. _getComponent(name: string): Nullable<ISceneComponent>;
  95843. /**
  95844. * @hidden
  95845. * Defines the actions happening before camera updates.
  95846. */
  95847. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  95848. /**
  95849. * @hidden
  95850. * Defines the actions happening before clear the canvas.
  95851. */
  95852. _beforeClearStage: Stage<SimpleStageAction>;
  95853. /**
  95854. * @hidden
  95855. * Defines the actions when collecting render targets for the frame.
  95856. */
  95857. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95858. /**
  95859. * @hidden
  95860. * Defines the actions happening for one camera in the frame.
  95861. */
  95862. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95863. /**
  95864. * @hidden
  95865. * Defines the actions happening during the per mesh ready checks.
  95866. */
  95867. _isReadyForMeshStage: Stage<MeshStageAction>;
  95868. /**
  95869. * @hidden
  95870. * Defines the actions happening before evaluate active mesh checks.
  95871. */
  95872. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  95873. /**
  95874. * @hidden
  95875. * Defines the actions happening during the evaluate sub mesh checks.
  95876. */
  95877. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  95878. /**
  95879. * @hidden
  95880. * Defines the actions happening during the active mesh stage.
  95881. */
  95882. _activeMeshStage: Stage<ActiveMeshStageAction>;
  95883. /**
  95884. * @hidden
  95885. * Defines the actions happening during the per camera render target step.
  95886. */
  95887. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  95888. /**
  95889. * @hidden
  95890. * Defines the actions happening just before the active camera is drawing.
  95891. */
  95892. _beforeCameraDrawStage: Stage<CameraStageAction>;
  95893. /**
  95894. * @hidden
  95895. * Defines the actions happening just before a render target is drawing.
  95896. */
  95897. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95898. /**
  95899. * @hidden
  95900. * Defines the actions happening just before a rendering group is drawing.
  95901. */
  95902. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95903. /**
  95904. * @hidden
  95905. * Defines the actions happening just before a mesh is drawing.
  95906. */
  95907. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95908. /**
  95909. * @hidden
  95910. * Defines the actions happening just after a mesh has been drawn.
  95911. */
  95912. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95913. /**
  95914. * @hidden
  95915. * Defines the actions happening just after a rendering group has been drawn.
  95916. */
  95917. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95918. /**
  95919. * @hidden
  95920. * Defines the actions happening just after the active camera has been drawn.
  95921. */
  95922. _afterCameraDrawStage: Stage<CameraStageAction>;
  95923. /**
  95924. * @hidden
  95925. * Defines the actions happening just after a render target has been drawn.
  95926. */
  95927. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95928. /**
  95929. * @hidden
  95930. * Defines the actions happening just after rendering all cameras and computing intersections.
  95931. */
  95932. _afterRenderStage: Stage<SimpleStageAction>;
  95933. /**
  95934. * @hidden
  95935. * Defines the actions happening when a pointer move event happens.
  95936. */
  95937. _pointerMoveStage: Stage<PointerMoveStageAction>;
  95938. /**
  95939. * @hidden
  95940. * Defines the actions happening when a pointer down event happens.
  95941. */
  95942. _pointerDownStage: Stage<PointerUpDownStageAction>;
  95943. /**
  95944. * @hidden
  95945. * Defines the actions happening when a pointer up event happens.
  95946. */
  95947. _pointerUpStage: Stage<PointerUpDownStageAction>;
  95948. /**
  95949. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  95950. */
  95951. private geometriesByUniqueId;
  95952. /**
  95953. * Creates a new Scene
  95954. * @param engine defines the engine to use to render this scene
  95955. * @param options defines the scene options
  95956. */
  95957. constructor(engine: Engine, options?: SceneOptions);
  95958. /**
  95959. * Gets a string idenfifying the name of the class
  95960. * @returns "Scene" string
  95961. */
  95962. getClassName(): string;
  95963. private _defaultMeshCandidates;
  95964. /**
  95965. * @hidden
  95966. */
  95967. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  95968. private _defaultSubMeshCandidates;
  95969. /**
  95970. * @hidden
  95971. */
  95972. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  95973. /**
  95974. * Sets the default candidate providers for the scene.
  95975. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  95976. * and getCollidingSubMeshCandidates to their default function
  95977. */
  95978. setDefaultCandidateProviders(): void;
  95979. /**
  95980. * Gets the mesh that is currently under the pointer
  95981. */
  95982. readonly meshUnderPointer: Nullable<AbstractMesh>;
  95983. /**
  95984. * Gets or sets the current on-screen X position of the pointer
  95985. */
  95986. pointerX: number;
  95987. /**
  95988. * Gets or sets the current on-screen Y position of the pointer
  95989. */
  95990. pointerY: number;
  95991. /**
  95992. * Gets the cached material (ie. the latest rendered one)
  95993. * @returns the cached material
  95994. */
  95995. getCachedMaterial(): Nullable<Material>;
  95996. /**
  95997. * Gets the cached effect (ie. the latest rendered one)
  95998. * @returns the cached effect
  95999. */
  96000. getCachedEffect(): Nullable<Effect>;
  96001. /**
  96002. * Gets the cached visibility state (ie. the latest rendered one)
  96003. * @returns the cached visibility state
  96004. */
  96005. getCachedVisibility(): Nullable<number>;
  96006. /**
  96007. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  96008. * @param material defines the current material
  96009. * @param effect defines the current effect
  96010. * @param visibility defines the current visibility state
  96011. * @returns true if one parameter is not cached
  96012. */
  96013. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  96014. /**
  96015. * Gets the engine associated with the scene
  96016. * @returns an Engine
  96017. */
  96018. getEngine(): Engine;
  96019. /**
  96020. * Gets the total number of vertices rendered per frame
  96021. * @returns the total number of vertices rendered per frame
  96022. */
  96023. getTotalVertices(): number;
  96024. /**
  96025. * Gets the performance counter for total vertices
  96026. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96027. */
  96028. readonly totalVerticesPerfCounter: PerfCounter;
  96029. /**
  96030. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  96031. * @returns the total number of active indices rendered per frame
  96032. */
  96033. getActiveIndices(): number;
  96034. /**
  96035. * Gets the performance counter for active indices
  96036. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96037. */
  96038. readonly totalActiveIndicesPerfCounter: PerfCounter;
  96039. /**
  96040. * Gets the total number of active particles rendered per frame
  96041. * @returns the total number of active particles rendered per frame
  96042. */
  96043. getActiveParticles(): number;
  96044. /**
  96045. * Gets the performance counter for active particles
  96046. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96047. */
  96048. readonly activeParticlesPerfCounter: PerfCounter;
  96049. /**
  96050. * Gets the total number of active bones rendered per frame
  96051. * @returns the total number of active bones rendered per frame
  96052. */
  96053. getActiveBones(): number;
  96054. /**
  96055. * Gets the performance counter for active bones
  96056. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96057. */
  96058. readonly activeBonesPerfCounter: PerfCounter;
  96059. /**
  96060. * Gets the array of active meshes
  96061. * @returns an array of AbstractMesh
  96062. */
  96063. getActiveMeshes(): SmartArray<AbstractMesh>;
  96064. /**
  96065. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  96066. * @returns a number
  96067. */
  96068. getAnimationRatio(): number;
  96069. /**
  96070. * Gets an unique Id for the current render phase
  96071. * @returns a number
  96072. */
  96073. getRenderId(): number;
  96074. /**
  96075. * Gets an unique Id for the current frame
  96076. * @returns a number
  96077. */
  96078. getFrameId(): number;
  96079. /** Call this function if you want to manually increment the render Id*/
  96080. incrementRenderId(): void;
  96081. private _createUbo;
  96082. /**
  96083. * Use this method to simulate a pointer move on a mesh
  96084. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96085. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96086. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96087. * @returns the current scene
  96088. */
  96089. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  96090. /**
  96091. * Use this method to simulate a pointer down on a mesh
  96092. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96093. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96094. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96095. * @returns the current scene
  96096. */
  96097. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  96098. /**
  96099. * Use this method to simulate a pointer up on a mesh
  96100. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96101. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96102. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96103. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  96104. * @returns the current scene
  96105. */
  96106. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  96107. /**
  96108. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  96109. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  96110. * @returns true if the pointer was captured
  96111. */
  96112. isPointerCaptured(pointerId?: number): boolean;
  96113. /**
  96114. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  96115. * @param attachUp defines if you want to attach events to pointerup
  96116. * @param attachDown defines if you want to attach events to pointerdown
  96117. * @param attachMove defines if you want to attach events to pointermove
  96118. */
  96119. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  96120. /** Detaches all event handlers*/
  96121. detachControl(): void;
  96122. /**
  96123. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  96124. * Delay loaded resources are not taking in account
  96125. * @return true if all required resources are ready
  96126. */
  96127. isReady(): boolean;
  96128. /** Resets all cached information relative to material (including effect and visibility) */
  96129. resetCachedMaterial(): void;
  96130. /**
  96131. * Registers a function to be called before every frame render
  96132. * @param func defines the function to register
  96133. */
  96134. registerBeforeRender(func: () => void): void;
  96135. /**
  96136. * Unregisters a function called before every frame render
  96137. * @param func defines the function to unregister
  96138. */
  96139. unregisterBeforeRender(func: () => void): void;
  96140. /**
  96141. * Registers a function to be called after every frame render
  96142. * @param func defines the function to register
  96143. */
  96144. registerAfterRender(func: () => void): void;
  96145. /**
  96146. * Unregisters a function called after every frame render
  96147. * @param func defines the function to unregister
  96148. */
  96149. unregisterAfterRender(func: () => void): void;
  96150. private _executeOnceBeforeRender;
  96151. /**
  96152. * The provided function will run before render once and will be disposed afterwards.
  96153. * A timeout delay can be provided so that the function will be executed in N ms.
  96154. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  96155. * @param func The function to be executed.
  96156. * @param timeout optional delay in ms
  96157. */
  96158. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  96159. /** @hidden */
  96160. _addPendingData(data: any): void;
  96161. /** @hidden */
  96162. _removePendingData(data: any): void;
  96163. /**
  96164. * Returns the number of items waiting to be loaded
  96165. * @returns the number of items waiting to be loaded
  96166. */
  96167. getWaitingItemsCount(): number;
  96168. /**
  96169. * Returns a boolean indicating if the scene is still loading data
  96170. */
  96171. readonly isLoading: boolean;
  96172. /**
  96173. * Registers a function to be executed when the scene is ready
  96174. * @param {Function} func - the function to be executed
  96175. */
  96176. executeWhenReady(func: () => void): void;
  96177. /**
  96178. * Returns a promise that resolves when the scene is ready
  96179. * @returns A promise that resolves when the scene is ready
  96180. */
  96181. whenReadyAsync(): Promise<void>;
  96182. /** @hidden */
  96183. _checkIsReady(): void;
  96184. /**
  96185. * Gets all animatable attached to the scene
  96186. */
  96187. readonly animatables: Animatable[];
  96188. /**
  96189. * Resets the last animation time frame.
  96190. * Useful to override when animations start running when loading a scene for the first time.
  96191. */
  96192. resetLastAnimationTimeFrame(): void;
  96193. /**
  96194. * Gets the current view matrix
  96195. * @returns a Matrix
  96196. */
  96197. getViewMatrix(): Matrix;
  96198. /**
  96199. * Gets the current projection matrix
  96200. * @returns a Matrix
  96201. */
  96202. getProjectionMatrix(): Matrix;
  96203. /**
  96204. * Gets the current transform matrix
  96205. * @returns a Matrix made of View * Projection
  96206. */
  96207. getTransformMatrix(): Matrix;
  96208. /**
  96209. * Sets the current transform matrix
  96210. * @param viewL defines the View matrix to use
  96211. * @param projectionL defines the Projection matrix to use
  96212. * @param viewR defines the right View matrix to use (if provided)
  96213. * @param projectionR defines the right Projection matrix to use (if provided)
  96214. */
  96215. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  96216. /**
  96217. * Gets the uniform buffer used to store scene data
  96218. * @returns a UniformBuffer
  96219. */
  96220. getSceneUniformBuffer(): UniformBuffer;
  96221. /**
  96222. * Gets an unique (relatively to the current scene) Id
  96223. * @returns an unique number for the scene
  96224. */
  96225. getUniqueId(): number;
  96226. /**
  96227. * Add a mesh to the list of scene's meshes
  96228. * @param newMesh defines the mesh to add
  96229. * @param recursive if all child meshes should also be added to the scene
  96230. */
  96231. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  96232. /**
  96233. * Remove a mesh for the list of scene's meshes
  96234. * @param toRemove defines the mesh to remove
  96235. * @param recursive if all child meshes should also be removed from the scene
  96236. * @returns the index where the mesh was in the mesh list
  96237. */
  96238. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  96239. /**
  96240. * Add a transform node to the list of scene's transform nodes
  96241. * @param newTransformNode defines the transform node to add
  96242. */
  96243. addTransformNode(newTransformNode: TransformNode): void;
  96244. /**
  96245. * Remove a transform node for the list of scene's transform nodes
  96246. * @param toRemove defines the transform node to remove
  96247. * @returns the index where the transform node was in the transform node list
  96248. */
  96249. removeTransformNode(toRemove: TransformNode): number;
  96250. /**
  96251. * Remove a skeleton for the list of scene's skeletons
  96252. * @param toRemove defines the skeleton to remove
  96253. * @returns the index where the skeleton was in the skeleton list
  96254. */
  96255. removeSkeleton(toRemove: Skeleton): number;
  96256. /**
  96257. * Remove a morph target for the list of scene's morph targets
  96258. * @param toRemove defines the morph target to remove
  96259. * @returns the index where the morph target was in the morph target list
  96260. */
  96261. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  96262. /**
  96263. * Remove a light for the list of scene's lights
  96264. * @param toRemove defines the light to remove
  96265. * @returns the index where the light was in the light list
  96266. */
  96267. removeLight(toRemove: Light): number;
  96268. /**
  96269. * Remove a camera for the list of scene's cameras
  96270. * @param toRemove defines the camera to remove
  96271. * @returns the index where the camera was in the camera list
  96272. */
  96273. removeCamera(toRemove: Camera): number;
  96274. /**
  96275. * Remove a particle system for the list of scene's particle systems
  96276. * @param toRemove defines the particle system to remove
  96277. * @returns the index where the particle system was in the particle system list
  96278. */
  96279. removeParticleSystem(toRemove: IParticleSystem): number;
  96280. /**
  96281. * Remove a animation for the list of scene's animations
  96282. * @param toRemove defines the animation to remove
  96283. * @returns the index where the animation was in the animation list
  96284. */
  96285. removeAnimation(toRemove: Animation): number;
  96286. /**
  96287. * Will stop the animation of the given target
  96288. * @param target - the target
  96289. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  96290. * @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)
  96291. */
  96292. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  96293. /**
  96294. * Removes the given animation group from this scene.
  96295. * @param toRemove The animation group to remove
  96296. * @returns The index of the removed animation group
  96297. */
  96298. removeAnimationGroup(toRemove: AnimationGroup): number;
  96299. /**
  96300. * Removes the given multi-material from this scene.
  96301. * @param toRemove The multi-material to remove
  96302. * @returns The index of the removed multi-material
  96303. */
  96304. removeMultiMaterial(toRemove: MultiMaterial): number;
  96305. /**
  96306. * Removes the given material from this scene.
  96307. * @param toRemove The material to remove
  96308. * @returns The index of the removed material
  96309. */
  96310. removeMaterial(toRemove: Material): number;
  96311. /**
  96312. * Removes the given action manager from this scene.
  96313. * @param toRemove The action manager to remove
  96314. * @returns The index of the removed action manager
  96315. */
  96316. removeActionManager(toRemove: AbstractActionManager): number;
  96317. /**
  96318. * Removes the given texture from this scene.
  96319. * @param toRemove The texture to remove
  96320. * @returns The index of the removed texture
  96321. */
  96322. removeTexture(toRemove: BaseTexture): number;
  96323. /**
  96324. * Adds the given light to this scene
  96325. * @param newLight The light to add
  96326. */
  96327. addLight(newLight: Light): void;
  96328. /**
  96329. * Sorts the list list based on light priorities
  96330. */
  96331. sortLightsByPriority(): void;
  96332. /**
  96333. * Adds the given camera to this scene
  96334. * @param newCamera The camera to add
  96335. */
  96336. addCamera(newCamera: Camera): void;
  96337. /**
  96338. * Adds the given skeleton to this scene
  96339. * @param newSkeleton The skeleton to add
  96340. */
  96341. addSkeleton(newSkeleton: Skeleton): void;
  96342. /**
  96343. * Adds the given particle system to this scene
  96344. * @param newParticleSystem The particle system to add
  96345. */
  96346. addParticleSystem(newParticleSystem: IParticleSystem): void;
  96347. /**
  96348. * Adds the given animation to this scene
  96349. * @param newAnimation The animation to add
  96350. */
  96351. addAnimation(newAnimation: Animation): void;
  96352. /**
  96353. * Adds the given animation group to this scene.
  96354. * @param newAnimationGroup The animation group to add
  96355. */
  96356. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  96357. /**
  96358. * Adds the given multi-material to this scene
  96359. * @param newMultiMaterial The multi-material to add
  96360. */
  96361. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  96362. /**
  96363. * Adds the given material to this scene
  96364. * @param newMaterial The material to add
  96365. */
  96366. addMaterial(newMaterial: Material): void;
  96367. /**
  96368. * Adds the given morph target to this scene
  96369. * @param newMorphTargetManager The morph target to add
  96370. */
  96371. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  96372. /**
  96373. * Adds the given geometry to this scene
  96374. * @param newGeometry The geometry to add
  96375. */
  96376. addGeometry(newGeometry: Geometry): void;
  96377. /**
  96378. * Adds the given action manager to this scene
  96379. * @param newActionManager The action manager to add
  96380. */
  96381. addActionManager(newActionManager: AbstractActionManager): void;
  96382. /**
  96383. * Adds the given texture to this scene.
  96384. * @param newTexture The texture to add
  96385. */
  96386. addTexture(newTexture: BaseTexture): void;
  96387. /**
  96388. * Switch active camera
  96389. * @param newCamera defines the new active camera
  96390. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  96391. */
  96392. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  96393. /**
  96394. * sets the active camera of the scene using its ID
  96395. * @param id defines the camera's ID
  96396. * @return the new active camera or null if none found.
  96397. */
  96398. setActiveCameraByID(id: string): Nullable<Camera>;
  96399. /**
  96400. * sets the active camera of the scene using its name
  96401. * @param name defines the camera's name
  96402. * @returns the new active camera or null if none found.
  96403. */
  96404. setActiveCameraByName(name: string): Nullable<Camera>;
  96405. /**
  96406. * get an animation group using its name
  96407. * @param name defines the material's name
  96408. * @return the animation group or null if none found.
  96409. */
  96410. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  96411. /**
  96412. * Get a material using its unique id
  96413. * @param uniqueId defines the material's unique id
  96414. * @return the material or null if none found.
  96415. */
  96416. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  96417. /**
  96418. * get a material using its id
  96419. * @param id defines the material's ID
  96420. * @return the material or null if none found.
  96421. */
  96422. getMaterialByID(id: string): Nullable<Material>;
  96423. /**
  96424. * Gets a the last added material using a given id
  96425. * @param id defines the material's ID
  96426. * @return the last material with the given id or null if none found.
  96427. */
  96428. getLastMaterialByID(id: string): Nullable<Material>;
  96429. /**
  96430. * Gets a material using its name
  96431. * @param name defines the material's name
  96432. * @return the material or null if none found.
  96433. */
  96434. getMaterialByName(name: string): Nullable<Material>;
  96435. /**
  96436. * Gets a camera using its id
  96437. * @param id defines the id to look for
  96438. * @returns the camera or null if not found
  96439. */
  96440. getCameraByID(id: string): Nullable<Camera>;
  96441. /**
  96442. * Gets a camera using its unique id
  96443. * @param uniqueId defines the unique id to look for
  96444. * @returns the camera or null if not found
  96445. */
  96446. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  96447. /**
  96448. * Gets a camera using its name
  96449. * @param name defines the camera's name
  96450. * @return the camera or null if none found.
  96451. */
  96452. getCameraByName(name: string): Nullable<Camera>;
  96453. /**
  96454. * Gets a bone using its id
  96455. * @param id defines the bone's id
  96456. * @return the bone or null if not found
  96457. */
  96458. getBoneByID(id: string): Nullable<Bone>;
  96459. /**
  96460. * Gets a bone using its id
  96461. * @param name defines the bone's name
  96462. * @return the bone or null if not found
  96463. */
  96464. getBoneByName(name: string): Nullable<Bone>;
  96465. /**
  96466. * Gets a light node using its name
  96467. * @param name defines the the light's name
  96468. * @return the light or null if none found.
  96469. */
  96470. getLightByName(name: string): Nullable<Light>;
  96471. /**
  96472. * Gets a light node using its id
  96473. * @param id defines the light's id
  96474. * @return the light or null if none found.
  96475. */
  96476. getLightByID(id: string): Nullable<Light>;
  96477. /**
  96478. * Gets a light node using its scene-generated unique ID
  96479. * @param uniqueId defines the light's unique id
  96480. * @return the light or null if none found.
  96481. */
  96482. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  96483. /**
  96484. * Gets a particle system by id
  96485. * @param id defines the particle system id
  96486. * @return the corresponding system or null if none found
  96487. */
  96488. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  96489. /**
  96490. * Gets a geometry using its ID
  96491. * @param id defines the geometry's id
  96492. * @return the geometry or null if none found.
  96493. */
  96494. getGeometryByID(id: string): Nullable<Geometry>;
  96495. private _getGeometryByUniqueID;
  96496. /**
  96497. * Add a new geometry to this scene
  96498. * @param geometry defines the geometry to be added to the scene.
  96499. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  96500. * @return a boolean defining if the geometry was added or not
  96501. */
  96502. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  96503. /**
  96504. * Removes an existing geometry
  96505. * @param geometry defines the geometry to be removed from the scene
  96506. * @return a boolean defining if the geometry was removed or not
  96507. */
  96508. removeGeometry(geometry: Geometry): boolean;
  96509. /**
  96510. * Gets the list of geometries attached to the scene
  96511. * @returns an array of Geometry
  96512. */
  96513. getGeometries(): Geometry[];
  96514. /**
  96515. * Gets the first added mesh found of a given ID
  96516. * @param id defines the id to search for
  96517. * @return the mesh found or null if not found at all
  96518. */
  96519. getMeshByID(id: string): Nullable<AbstractMesh>;
  96520. /**
  96521. * Gets a list of meshes using their id
  96522. * @param id defines the id to search for
  96523. * @returns a list of meshes
  96524. */
  96525. getMeshesByID(id: string): Array<AbstractMesh>;
  96526. /**
  96527. * Gets the first added transform node found of a given ID
  96528. * @param id defines the id to search for
  96529. * @return the found transform node or null if not found at all.
  96530. */
  96531. getTransformNodeByID(id: string): Nullable<TransformNode>;
  96532. /**
  96533. * Gets a transform node with its auto-generated unique id
  96534. * @param uniqueId efines the unique id to search for
  96535. * @return the found transform node or null if not found at all.
  96536. */
  96537. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  96538. /**
  96539. * Gets a list of transform nodes using their id
  96540. * @param id defines the id to search for
  96541. * @returns a list of transform nodes
  96542. */
  96543. getTransformNodesByID(id: string): Array<TransformNode>;
  96544. /**
  96545. * Gets a mesh with its auto-generated unique id
  96546. * @param uniqueId defines the unique id to search for
  96547. * @return the found mesh or null if not found at all.
  96548. */
  96549. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  96550. /**
  96551. * Gets a the last added mesh using a given id
  96552. * @param id defines the id to search for
  96553. * @return the found mesh or null if not found at all.
  96554. */
  96555. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  96556. /**
  96557. * Gets a the last added node (Mesh, Camera, Light) using a given id
  96558. * @param id defines the id to search for
  96559. * @return the found node or null if not found at all
  96560. */
  96561. getLastEntryByID(id: string): Nullable<Node>;
  96562. /**
  96563. * Gets a node (Mesh, Camera, Light) using a given id
  96564. * @param id defines the id to search for
  96565. * @return the found node or null if not found at all
  96566. */
  96567. getNodeByID(id: string): Nullable<Node>;
  96568. /**
  96569. * Gets a node (Mesh, Camera, Light) using a given name
  96570. * @param name defines the name to search for
  96571. * @return the found node or null if not found at all.
  96572. */
  96573. getNodeByName(name: string): Nullable<Node>;
  96574. /**
  96575. * Gets a mesh using a given name
  96576. * @param name defines the name to search for
  96577. * @return the found mesh or null if not found at all.
  96578. */
  96579. getMeshByName(name: string): Nullable<AbstractMesh>;
  96580. /**
  96581. * Gets a transform node using a given name
  96582. * @param name defines the name to search for
  96583. * @return the found transform node or null if not found at all.
  96584. */
  96585. getTransformNodeByName(name: string): Nullable<TransformNode>;
  96586. /**
  96587. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  96588. * @param id defines the id to search for
  96589. * @return the found skeleton or null if not found at all.
  96590. */
  96591. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  96592. /**
  96593. * Gets a skeleton using a given auto generated unique id
  96594. * @param uniqueId defines the unique id to search for
  96595. * @return the found skeleton or null if not found at all.
  96596. */
  96597. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  96598. /**
  96599. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  96600. * @param id defines the id to search for
  96601. * @return the found skeleton or null if not found at all.
  96602. */
  96603. getSkeletonById(id: string): Nullable<Skeleton>;
  96604. /**
  96605. * Gets a skeleton using a given name
  96606. * @param name defines the name to search for
  96607. * @return the found skeleton or null if not found at all.
  96608. */
  96609. getSkeletonByName(name: string): Nullable<Skeleton>;
  96610. /**
  96611. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  96612. * @param id defines the id to search for
  96613. * @return the found morph target manager or null if not found at all.
  96614. */
  96615. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  96616. /**
  96617. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  96618. * @param id defines the id to search for
  96619. * @return the found morph target or null if not found at all.
  96620. */
  96621. getMorphTargetById(id: string): Nullable<MorphTarget>;
  96622. /**
  96623. * Gets a boolean indicating if the given mesh is active
  96624. * @param mesh defines the mesh to look for
  96625. * @returns true if the mesh is in the active list
  96626. */
  96627. isActiveMesh(mesh: AbstractMesh): boolean;
  96628. /**
  96629. * Return a unique id as a string which can serve as an identifier for the scene
  96630. */
  96631. readonly uid: string;
  96632. /**
  96633. * Add an externaly attached data from its key.
  96634. * This method call will fail and return false, if such key already exists.
  96635. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  96636. * @param key the unique key that identifies the data
  96637. * @param data the data object to associate to the key for this Engine instance
  96638. * @return true if no such key were already present and the data was added successfully, false otherwise
  96639. */
  96640. addExternalData<T>(key: string, data: T): boolean;
  96641. /**
  96642. * Get an externaly attached data from its key
  96643. * @param key the unique key that identifies the data
  96644. * @return the associated data, if present (can be null), or undefined if not present
  96645. */
  96646. getExternalData<T>(key: string): Nullable<T>;
  96647. /**
  96648. * Get an externaly attached data from its key, create it using a factory if it's not already present
  96649. * @param key the unique key that identifies the data
  96650. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  96651. * @return the associated data, can be null if the factory returned null.
  96652. */
  96653. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  96654. /**
  96655. * Remove an externaly attached data from the Engine instance
  96656. * @param key the unique key that identifies the data
  96657. * @return true if the data was successfully removed, false if it doesn't exist
  96658. */
  96659. removeExternalData(key: string): boolean;
  96660. private _evaluateSubMesh;
  96661. /**
  96662. * Clear the processed materials smart array preventing retention point in material dispose.
  96663. */
  96664. freeProcessedMaterials(): void;
  96665. private _preventFreeActiveMeshesAndRenderingGroups;
  96666. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  96667. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  96668. * when disposing several meshes in a row or a hierarchy of meshes.
  96669. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  96670. */
  96671. blockfreeActiveMeshesAndRenderingGroups: boolean;
  96672. /**
  96673. * Clear the active meshes smart array preventing retention point in mesh dispose.
  96674. */
  96675. freeActiveMeshes(): void;
  96676. /**
  96677. * Clear the info related to rendering groups preventing retention points during dispose.
  96678. */
  96679. freeRenderingGroups(): void;
  96680. /** @hidden */
  96681. _isInIntermediateRendering(): boolean;
  96682. /**
  96683. * Lambda returning the list of potentially active meshes.
  96684. */
  96685. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  96686. /**
  96687. * Lambda returning the list of potentially active sub meshes.
  96688. */
  96689. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  96690. /**
  96691. * Lambda returning the list of potentially intersecting sub meshes.
  96692. */
  96693. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  96694. /**
  96695. * Lambda returning the list of potentially colliding sub meshes.
  96696. */
  96697. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  96698. private _activeMeshesFrozen;
  96699. /**
  96700. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  96701. * @returns the current scene
  96702. */
  96703. freezeActiveMeshes(): Scene;
  96704. /**
  96705. * Use this function to restart evaluating active meshes on every frame
  96706. * @returns the current scene
  96707. */
  96708. unfreezeActiveMeshes(): Scene;
  96709. private _evaluateActiveMeshes;
  96710. private _activeMesh;
  96711. /**
  96712. * Update the transform matrix to update from the current active camera
  96713. * @param force defines a boolean used to force the update even if cache is up to date
  96714. */
  96715. updateTransformMatrix(force?: boolean): void;
  96716. private _bindFrameBuffer;
  96717. /** @hidden */
  96718. _allowPostProcessClearColor: boolean;
  96719. /** @hidden */
  96720. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  96721. private _processSubCameras;
  96722. private _checkIntersections;
  96723. /** @hidden */
  96724. _advancePhysicsEngineStep(step: number): void;
  96725. /**
  96726. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  96727. */
  96728. getDeterministicFrameTime: () => number;
  96729. /** @hidden */
  96730. _animate(): void;
  96731. /** Execute all animations (for a frame) */
  96732. animate(): void;
  96733. /**
  96734. * Render the scene
  96735. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  96736. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  96737. */
  96738. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  96739. /**
  96740. * Freeze all materials
  96741. * A frozen material will not be updatable but should be faster to render
  96742. */
  96743. freezeMaterials(): void;
  96744. /**
  96745. * Unfreeze all materials
  96746. * A frozen material will not be updatable but should be faster to render
  96747. */
  96748. unfreezeMaterials(): void;
  96749. /**
  96750. * Releases all held ressources
  96751. */
  96752. dispose(): void;
  96753. /**
  96754. * Gets if the scene is already disposed
  96755. */
  96756. readonly isDisposed: boolean;
  96757. /**
  96758. * Call this function to reduce memory footprint of the scene.
  96759. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  96760. */
  96761. clearCachedVertexData(): void;
  96762. /**
  96763. * This function will remove the local cached buffer data from texture.
  96764. * It will save memory but will prevent the texture from being rebuilt
  96765. */
  96766. cleanCachedTextureBuffer(): void;
  96767. /**
  96768. * Get the world extend vectors with an optional filter
  96769. *
  96770. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  96771. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  96772. */
  96773. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  96774. min: Vector3;
  96775. max: Vector3;
  96776. };
  96777. /**
  96778. * Creates a ray that can be used to pick in the scene
  96779. * @param x defines the x coordinate of the origin (on-screen)
  96780. * @param y defines the y coordinate of the origin (on-screen)
  96781. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96782. * @param camera defines the camera to use for the picking
  96783. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96784. * @returns a Ray
  96785. */
  96786. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  96787. /**
  96788. * Creates a ray that can be used to pick in the scene
  96789. * @param x defines the x coordinate of the origin (on-screen)
  96790. * @param y defines the y coordinate of the origin (on-screen)
  96791. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96792. * @param result defines the ray where to store the picking ray
  96793. * @param camera defines the camera to use for the picking
  96794. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96795. * @returns the current scene
  96796. */
  96797. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  96798. /**
  96799. * Creates a ray that can be used to pick in the scene
  96800. * @param x defines the x coordinate of the origin (on-screen)
  96801. * @param y defines the y coordinate of the origin (on-screen)
  96802. * @param camera defines the camera to use for the picking
  96803. * @returns a Ray
  96804. */
  96805. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  96806. /**
  96807. * Creates a ray that can be used to pick in the scene
  96808. * @param x defines the x coordinate of the origin (on-screen)
  96809. * @param y defines the y coordinate of the origin (on-screen)
  96810. * @param result defines the ray where to store the picking ray
  96811. * @param camera defines the camera to use for the picking
  96812. * @returns the current scene
  96813. */
  96814. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  96815. /** Launch a ray to try to pick a mesh in the scene
  96816. * @param x position on screen
  96817. * @param y position on screen
  96818. * @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
  96819. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  96820. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96821. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96822. * @returns a PickingInfo
  96823. */
  96824. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96825. /** Use the given ray to pick a mesh in the scene
  96826. * @param ray The ray to use to pick meshes
  96827. * @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
  96828. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  96829. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96830. * @returns a PickingInfo
  96831. */
  96832. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96833. /**
  96834. * Launch a ray to try to pick a mesh in the scene
  96835. * @param x X position on screen
  96836. * @param y Y position on screen
  96837. * @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
  96838. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96839. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96840. * @returns an array of PickingInfo
  96841. */
  96842. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96843. /**
  96844. * Launch a ray to try to pick a mesh in the scene
  96845. * @param ray Ray to use
  96846. * @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
  96847. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96848. * @returns an array of PickingInfo
  96849. */
  96850. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96851. /**
  96852. * Force the value of meshUnderPointer
  96853. * @param mesh defines the mesh to use
  96854. */
  96855. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96856. /**
  96857. * Gets the mesh under the pointer
  96858. * @returns a Mesh or null if no mesh is under the pointer
  96859. */
  96860. getPointerOverMesh(): Nullable<AbstractMesh>;
  96861. /** @hidden */
  96862. _rebuildGeometries(): void;
  96863. /** @hidden */
  96864. _rebuildTextures(): void;
  96865. private _getByTags;
  96866. /**
  96867. * Get a list of meshes by tags
  96868. * @param tagsQuery defines the tags query to use
  96869. * @param forEach defines a predicate used to filter results
  96870. * @returns an array of Mesh
  96871. */
  96872. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  96873. /**
  96874. * Get a list of cameras by tags
  96875. * @param tagsQuery defines the tags query to use
  96876. * @param forEach defines a predicate used to filter results
  96877. * @returns an array of Camera
  96878. */
  96879. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  96880. /**
  96881. * Get a list of lights by tags
  96882. * @param tagsQuery defines the tags query to use
  96883. * @param forEach defines a predicate used to filter results
  96884. * @returns an array of Light
  96885. */
  96886. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  96887. /**
  96888. * Get a list of materials by tags
  96889. * @param tagsQuery defines the tags query to use
  96890. * @param forEach defines a predicate used to filter results
  96891. * @returns an array of Material
  96892. */
  96893. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  96894. /**
  96895. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96896. * This allowed control for front to back rendering or reversly depending of the special needs.
  96897. *
  96898. * @param renderingGroupId The rendering group id corresponding to its index
  96899. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96900. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96901. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96902. */
  96903. 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;
  96904. /**
  96905. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96906. *
  96907. * @param renderingGroupId The rendering group id corresponding to its index
  96908. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96909. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96910. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96911. */
  96912. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96913. /**
  96914. * Gets the current auto clear configuration for one rendering group of the rendering
  96915. * manager.
  96916. * @param index the rendering group index to get the information for
  96917. * @returns The auto clear setup for the requested rendering group
  96918. */
  96919. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  96920. private _blockMaterialDirtyMechanism;
  96921. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  96922. blockMaterialDirtyMechanism: boolean;
  96923. /**
  96924. * Will flag all materials as dirty to trigger new shader compilation
  96925. * @param flag defines the flag used to specify which material part must be marked as dirty
  96926. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  96927. */
  96928. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  96929. /** @hidden */
  96930. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  96931. /** @hidden */
  96932. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  96933. }
  96934. }
  96935. declare module BABYLON {
  96936. /**
  96937. * Set of assets to keep when moving a scene into an asset container.
  96938. */
  96939. export class KeepAssets extends AbstractScene {
  96940. }
  96941. /**
  96942. * Container with a set of assets that can be added or removed from a scene.
  96943. */
  96944. export class AssetContainer extends AbstractScene {
  96945. /**
  96946. * The scene the AssetContainer belongs to.
  96947. */
  96948. scene: Scene;
  96949. /**
  96950. * Instantiates an AssetContainer.
  96951. * @param scene The scene the AssetContainer belongs to.
  96952. */
  96953. constructor(scene: Scene);
  96954. /**
  96955. * Adds all the assets from the container to the scene.
  96956. */
  96957. addAllToScene(): void;
  96958. /**
  96959. * Removes all the assets in the container from the scene
  96960. */
  96961. removeAllFromScene(): void;
  96962. /**
  96963. * Disposes all the assets in the container
  96964. */
  96965. dispose(): void;
  96966. private _moveAssets;
  96967. /**
  96968. * Removes all the assets contained in the scene and adds them to the container.
  96969. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  96970. */
  96971. moveAllFromScene(keepAssets?: KeepAssets): void;
  96972. /**
  96973. * 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.
  96974. * @returns the root mesh
  96975. */
  96976. createRootMesh(): Mesh;
  96977. }
  96978. }
  96979. declare module BABYLON {
  96980. /**
  96981. * Defines how the parser contract is defined.
  96982. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  96983. */
  96984. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  96985. /**
  96986. * Defines how the individual parser contract is defined.
  96987. * These parser can parse an individual asset
  96988. */
  96989. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  96990. /**
  96991. * Base class of the scene acting as a container for the different elements composing a scene.
  96992. * This class is dynamically extended by the different components of the scene increasing
  96993. * flexibility and reducing coupling
  96994. */
  96995. export abstract class AbstractScene {
  96996. /**
  96997. * Stores the list of available parsers in the application.
  96998. */
  96999. private static _BabylonFileParsers;
  97000. /**
  97001. * Stores the list of available individual parsers in the application.
  97002. */
  97003. private static _IndividualBabylonFileParsers;
  97004. /**
  97005. * Adds a parser in the list of available ones
  97006. * @param name Defines the name of the parser
  97007. * @param parser Defines the parser to add
  97008. */
  97009. static AddParser(name: string, parser: BabylonFileParser): void;
  97010. /**
  97011. * Gets a general parser from the list of avaialble ones
  97012. * @param name Defines the name of the parser
  97013. * @returns the requested parser or null
  97014. */
  97015. static GetParser(name: string): Nullable<BabylonFileParser>;
  97016. /**
  97017. * Adds n individual parser in the list of available ones
  97018. * @param name Defines the name of the parser
  97019. * @param parser Defines the parser to add
  97020. */
  97021. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  97022. /**
  97023. * Gets an individual parser from the list of avaialble ones
  97024. * @param name Defines the name of the parser
  97025. * @returns the requested parser or null
  97026. */
  97027. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  97028. /**
  97029. * Parser json data and populate both a scene and its associated container object
  97030. * @param jsonData Defines the data to parse
  97031. * @param scene Defines the scene to parse the data for
  97032. * @param container Defines the container attached to the parsing sequence
  97033. * @param rootUrl Defines the root url of the data
  97034. */
  97035. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  97036. /**
  97037. * Gets the list of root nodes (ie. nodes with no parent)
  97038. */
  97039. rootNodes: Node[];
  97040. /** All of the cameras added to this scene
  97041. * @see http://doc.babylonjs.com/babylon101/cameras
  97042. */
  97043. cameras: Camera[];
  97044. /**
  97045. * All of the lights added to this scene
  97046. * @see http://doc.babylonjs.com/babylon101/lights
  97047. */
  97048. lights: Light[];
  97049. /**
  97050. * All of the (abstract) meshes added to this scene
  97051. */
  97052. meshes: AbstractMesh[];
  97053. /**
  97054. * The list of skeletons added to the scene
  97055. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  97056. */
  97057. skeletons: Skeleton[];
  97058. /**
  97059. * All of the particle systems added to this scene
  97060. * @see http://doc.babylonjs.com/babylon101/particles
  97061. */
  97062. particleSystems: IParticleSystem[];
  97063. /**
  97064. * Gets a list of Animations associated with the scene
  97065. */
  97066. animations: Animation[];
  97067. /**
  97068. * All of the animation groups added to this scene
  97069. * @see http://doc.babylonjs.com/how_to/group
  97070. */
  97071. animationGroups: AnimationGroup[];
  97072. /**
  97073. * All of the multi-materials added to this scene
  97074. * @see http://doc.babylonjs.com/how_to/multi_materials
  97075. */
  97076. multiMaterials: MultiMaterial[];
  97077. /**
  97078. * All of the materials added to this scene
  97079. * In the context of a Scene, it is not supposed to be modified manually.
  97080. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  97081. * Note also that the order of the Material wihin the array is not significant and might change.
  97082. * @see http://doc.babylonjs.com/babylon101/materials
  97083. */
  97084. materials: Material[];
  97085. /**
  97086. * The list of morph target managers added to the scene
  97087. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  97088. */
  97089. morphTargetManagers: MorphTargetManager[];
  97090. /**
  97091. * The list of geometries used in the scene.
  97092. */
  97093. geometries: Geometry[];
  97094. /**
  97095. * All of the tranform nodes added to this scene
  97096. * In the context of a Scene, it is not supposed to be modified manually.
  97097. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  97098. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  97099. * @see http://doc.babylonjs.com/how_to/transformnode
  97100. */
  97101. transformNodes: TransformNode[];
  97102. /**
  97103. * ActionManagers available on the scene.
  97104. */
  97105. actionManagers: AbstractActionManager[];
  97106. /**
  97107. * Textures to keep.
  97108. */
  97109. textures: BaseTexture[];
  97110. /**
  97111. * Environment texture for the scene
  97112. */
  97113. environmentTexture: Nullable<BaseTexture>;
  97114. }
  97115. }
  97116. declare module BABYLON {
  97117. /**
  97118. * Interface used to define options for Sound class
  97119. */
  97120. export interface ISoundOptions {
  97121. /**
  97122. * Does the sound autoplay once loaded.
  97123. */
  97124. autoplay?: boolean;
  97125. /**
  97126. * Does the sound loop after it finishes playing once.
  97127. */
  97128. loop?: boolean;
  97129. /**
  97130. * Sound's volume
  97131. */
  97132. volume?: number;
  97133. /**
  97134. * Is it a spatial sound?
  97135. */
  97136. spatialSound?: boolean;
  97137. /**
  97138. * Maximum distance to hear that sound
  97139. */
  97140. maxDistance?: number;
  97141. /**
  97142. * Uses user defined attenuation function
  97143. */
  97144. useCustomAttenuation?: boolean;
  97145. /**
  97146. * Define the roll off factor of spatial sounds.
  97147. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97148. */
  97149. rolloffFactor?: number;
  97150. /**
  97151. * Define the reference distance the sound should be heard perfectly.
  97152. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97153. */
  97154. refDistance?: number;
  97155. /**
  97156. * Define the distance attenuation model the sound will follow.
  97157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97158. */
  97159. distanceModel?: string;
  97160. /**
  97161. * Defines the playback speed (1 by default)
  97162. */
  97163. playbackRate?: number;
  97164. /**
  97165. * Defines if the sound is from a streaming source
  97166. */
  97167. streaming?: boolean;
  97168. /**
  97169. * Defines an optional length (in seconds) inside the sound file
  97170. */
  97171. length?: number;
  97172. /**
  97173. * Defines an optional offset (in seconds) inside the sound file
  97174. */
  97175. offset?: number;
  97176. /**
  97177. * If true, URLs will not be required to state the audio file codec to use.
  97178. */
  97179. skipCodecCheck?: boolean;
  97180. }
  97181. /**
  97182. * Defines a sound that can be played in the application.
  97183. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  97184. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97185. */
  97186. export class Sound {
  97187. /**
  97188. * The name of the sound in the scene.
  97189. */
  97190. name: string;
  97191. /**
  97192. * Does the sound autoplay once loaded.
  97193. */
  97194. autoplay: boolean;
  97195. /**
  97196. * Does the sound loop after it finishes playing once.
  97197. */
  97198. loop: boolean;
  97199. /**
  97200. * Does the sound use a custom attenuation curve to simulate the falloff
  97201. * happening when the source gets further away from the camera.
  97202. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  97203. */
  97204. useCustomAttenuation: boolean;
  97205. /**
  97206. * The sound track id this sound belongs to.
  97207. */
  97208. soundTrackId: number;
  97209. /**
  97210. * Is this sound currently played.
  97211. */
  97212. isPlaying: boolean;
  97213. /**
  97214. * Is this sound currently paused.
  97215. */
  97216. isPaused: boolean;
  97217. /**
  97218. * Does this sound enables spatial sound.
  97219. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97220. */
  97221. spatialSound: boolean;
  97222. /**
  97223. * Define the reference distance the sound should be heard perfectly.
  97224. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97225. */
  97226. refDistance: number;
  97227. /**
  97228. * Define the roll off factor of spatial sounds.
  97229. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97230. */
  97231. rolloffFactor: number;
  97232. /**
  97233. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  97234. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97235. */
  97236. maxDistance: number;
  97237. /**
  97238. * Define the distance attenuation model the sound will follow.
  97239. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97240. */
  97241. distanceModel: string;
  97242. /**
  97243. * @hidden
  97244. * Back Compat
  97245. **/
  97246. onended: () => any;
  97247. /**
  97248. * Observable event when the current playing sound finishes.
  97249. */
  97250. onEndedObservable: Observable<Sound>;
  97251. private _panningModel;
  97252. private _playbackRate;
  97253. private _streaming;
  97254. private _startTime;
  97255. private _startOffset;
  97256. private _position;
  97257. /** @hidden */
  97258. _positionInEmitterSpace: boolean;
  97259. private _localDirection;
  97260. private _volume;
  97261. private _isReadyToPlay;
  97262. private _isDirectional;
  97263. private _readyToPlayCallback;
  97264. private _audioBuffer;
  97265. private _soundSource;
  97266. private _streamingSource;
  97267. private _soundPanner;
  97268. private _soundGain;
  97269. private _inputAudioNode;
  97270. private _outputAudioNode;
  97271. private _coneInnerAngle;
  97272. private _coneOuterAngle;
  97273. private _coneOuterGain;
  97274. private _scene;
  97275. private _connectedTransformNode;
  97276. private _customAttenuationFunction;
  97277. private _registerFunc;
  97278. private _isOutputConnected;
  97279. private _htmlAudioElement;
  97280. private _urlType;
  97281. private _length?;
  97282. private _offset?;
  97283. /** @hidden */
  97284. static _SceneComponentInitialization: (scene: Scene) => void;
  97285. /**
  97286. * Create a sound and attach it to a scene
  97287. * @param name Name of your sound
  97288. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  97289. * @param scene defines the scene the sound belongs to
  97290. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  97291. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  97292. */
  97293. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  97294. /**
  97295. * Release the sound and its associated resources
  97296. */
  97297. dispose(): void;
  97298. /**
  97299. * Gets if the sounds is ready to be played or not.
  97300. * @returns true if ready, otherwise false
  97301. */
  97302. isReady(): boolean;
  97303. private _soundLoaded;
  97304. /**
  97305. * Sets the data of the sound from an audiobuffer
  97306. * @param audioBuffer The audioBuffer containing the data
  97307. */
  97308. setAudioBuffer(audioBuffer: AudioBuffer): void;
  97309. /**
  97310. * Updates the current sounds options such as maxdistance, loop...
  97311. * @param options A JSON object containing values named as the object properties
  97312. */
  97313. updateOptions(options: ISoundOptions): void;
  97314. private _createSpatialParameters;
  97315. private _updateSpatialParameters;
  97316. /**
  97317. * Switch the panning model to HRTF:
  97318. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97319. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97320. */
  97321. switchPanningModelToHRTF(): void;
  97322. /**
  97323. * Switch the panning model to Equal Power:
  97324. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97325. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97326. */
  97327. switchPanningModelToEqualPower(): void;
  97328. private _switchPanningModel;
  97329. /**
  97330. * Connect this sound to a sound track audio node like gain...
  97331. * @param soundTrackAudioNode the sound track audio node to connect to
  97332. */
  97333. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  97334. /**
  97335. * Transform this sound into a directional source
  97336. * @param coneInnerAngle Size of the inner cone in degree
  97337. * @param coneOuterAngle Size of the outer cone in degree
  97338. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  97339. */
  97340. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  97341. /**
  97342. * Gets or sets the inner angle for the directional cone.
  97343. */
  97344. /**
  97345. * Gets or sets the inner angle for the directional cone.
  97346. */
  97347. directionalConeInnerAngle: number;
  97348. /**
  97349. * Gets or sets the outer angle for the directional cone.
  97350. */
  97351. /**
  97352. * Gets or sets the outer angle for the directional cone.
  97353. */
  97354. directionalConeOuterAngle: number;
  97355. /**
  97356. * Sets the position of the emitter if spatial sound is enabled
  97357. * @param newPosition Defines the new posisiton
  97358. */
  97359. setPosition(newPosition: Vector3): void;
  97360. /**
  97361. * Sets the local direction of the emitter if spatial sound is enabled
  97362. * @param newLocalDirection Defines the new local direction
  97363. */
  97364. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  97365. private _updateDirection;
  97366. /** @hidden */
  97367. updateDistanceFromListener(): void;
  97368. /**
  97369. * Sets a new custom attenuation function for the sound.
  97370. * @param callback Defines the function used for the attenuation
  97371. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  97372. */
  97373. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  97374. /**
  97375. * Play the sound
  97376. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  97377. * @param offset (optional) Start the sound at a specific time in seconds
  97378. * @param length (optional) Sound duration (in seconds)
  97379. */
  97380. play(time?: number, offset?: number, length?: number): void;
  97381. private _onended;
  97382. /**
  97383. * Stop the sound
  97384. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  97385. */
  97386. stop(time?: number): void;
  97387. /**
  97388. * Put the sound in pause
  97389. */
  97390. pause(): void;
  97391. /**
  97392. * Sets a dedicated volume for this sounds
  97393. * @param newVolume Define the new volume of the sound
  97394. * @param time Define time for gradual change to new volume
  97395. */
  97396. setVolume(newVolume: number, time?: number): void;
  97397. /**
  97398. * Set the sound play back rate
  97399. * @param newPlaybackRate Define the playback rate the sound should be played at
  97400. */
  97401. setPlaybackRate(newPlaybackRate: number): void;
  97402. /**
  97403. * Gets the volume of the sound.
  97404. * @returns the volume of the sound
  97405. */
  97406. getVolume(): number;
  97407. /**
  97408. * Attach the sound to a dedicated mesh
  97409. * @param transformNode The transform node to connect the sound with
  97410. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  97411. */
  97412. attachToMesh(transformNode: TransformNode): void;
  97413. /**
  97414. * Detach the sound from the previously attached mesh
  97415. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  97416. */
  97417. detachFromMesh(): void;
  97418. private _onRegisterAfterWorldMatrixUpdate;
  97419. /**
  97420. * Clone the current sound in the scene.
  97421. * @returns the new sound clone
  97422. */
  97423. clone(): Nullable<Sound>;
  97424. /**
  97425. * Gets the current underlying audio buffer containing the data
  97426. * @returns the audio buffer
  97427. */
  97428. getAudioBuffer(): Nullable<AudioBuffer>;
  97429. /**
  97430. * Serializes the Sound in a JSON representation
  97431. * @returns the JSON representation of the sound
  97432. */
  97433. serialize(): any;
  97434. /**
  97435. * Parse a JSON representation of a sound to innstantiate in a given scene
  97436. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  97437. * @param scene Define the scene the new parsed sound should be created in
  97438. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  97439. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  97440. * @returns the newly parsed sound
  97441. */
  97442. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  97443. }
  97444. }
  97445. declare module BABYLON {
  97446. /**
  97447. * This defines an action helpful to play a defined sound on a triggered action.
  97448. */
  97449. export class PlaySoundAction extends Action {
  97450. private _sound;
  97451. /**
  97452. * Instantiate the action
  97453. * @param triggerOptions defines the trigger options
  97454. * @param sound defines the sound to play
  97455. * @param condition defines the trigger related conditions
  97456. */
  97457. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97458. /** @hidden */
  97459. _prepare(): void;
  97460. /**
  97461. * Execute the action and play the sound.
  97462. */
  97463. execute(): void;
  97464. /**
  97465. * Serializes the actions and its related information.
  97466. * @param parent defines the object to serialize in
  97467. * @returns the serialized object
  97468. */
  97469. serialize(parent: any): any;
  97470. }
  97471. /**
  97472. * This defines an action helpful to stop a defined sound on a triggered action.
  97473. */
  97474. export class StopSoundAction extends Action {
  97475. private _sound;
  97476. /**
  97477. * Instantiate the action
  97478. * @param triggerOptions defines the trigger options
  97479. * @param sound defines the sound to stop
  97480. * @param condition defines the trigger related conditions
  97481. */
  97482. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97483. /** @hidden */
  97484. _prepare(): void;
  97485. /**
  97486. * Execute the action and stop the sound.
  97487. */
  97488. execute(): void;
  97489. /**
  97490. * Serializes the actions and its related information.
  97491. * @param parent defines the object to serialize in
  97492. * @returns the serialized object
  97493. */
  97494. serialize(parent: any): any;
  97495. }
  97496. }
  97497. declare module BABYLON {
  97498. /**
  97499. * This defines an action responsible to change the value of a property
  97500. * by interpolating between its current value and the newly set one once triggered.
  97501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97502. */
  97503. export class InterpolateValueAction extends Action {
  97504. /**
  97505. * Defines the path of the property where the value should be interpolated
  97506. */
  97507. propertyPath: string;
  97508. /**
  97509. * Defines the target value at the end of the interpolation.
  97510. */
  97511. value: any;
  97512. /**
  97513. * Defines the time it will take for the property to interpolate to the value.
  97514. */
  97515. duration: number;
  97516. /**
  97517. * Defines if the other scene animations should be stopped when the action has been triggered
  97518. */
  97519. stopOtherAnimations?: boolean;
  97520. /**
  97521. * Defines a callback raised once the interpolation animation has been done.
  97522. */
  97523. onInterpolationDone?: () => void;
  97524. /**
  97525. * Observable triggered once the interpolation animation has been done.
  97526. */
  97527. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  97528. private _target;
  97529. private _effectiveTarget;
  97530. private _property;
  97531. /**
  97532. * Instantiate the action
  97533. * @param triggerOptions defines the trigger options
  97534. * @param target defines the object containing the value to interpolate
  97535. * @param propertyPath defines the path to the property in the target object
  97536. * @param value defines the target value at the end of the interpolation
  97537. * @param duration deines the time it will take for the property to interpolate to the value.
  97538. * @param condition defines the trigger related conditions
  97539. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  97540. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  97541. */
  97542. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  97543. /** @hidden */
  97544. _prepare(): void;
  97545. /**
  97546. * Execute the action starts the value interpolation.
  97547. */
  97548. execute(): void;
  97549. /**
  97550. * Serializes the actions and its related information.
  97551. * @param parent defines the object to serialize in
  97552. * @returns the serialized object
  97553. */
  97554. serialize(parent: any): any;
  97555. }
  97556. }
  97557. declare module BABYLON {
  97558. /**
  97559. * Options allowed during the creation of a sound track.
  97560. */
  97561. export interface ISoundTrackOptions {
  97562. /**
  97563. * The volume the sound track should take during creation
  97564. */
  97565. volume?: number;
  97566. /**
  97567. * Define if the sound track is the main sound track of the scene
  97568. */
  97569. mainTrack?: boolean;
  97570. }
  97571. /**
  97572. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  97573. * It will be also used in a future release to apply effects on a specific track.
  97574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97575. */
  97576. export class SoundTrack {
  97577. /**
  97578. * The unique identifier of the sound track in the scene.
  97579. */
  97580. id: number;
  97581. /**
  97582. * The list of sounds included in the sound track.
  97583. */
  97584. soundCollection: Array<Sound>;
  97585. private _outputAudioNode;
  97586. private _scene;
  97587. private _isMainTrack;
  97588. private _connectedAnalyser;
  97589. private _options;
  97590. private _isInitialized;
  97591. /**
  97592. * Creates a new sound track.
  97593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97594. * @param scene Define the scene the sound track belongs to
  97595. * @param options
  97596. */
  97597. constructor(scene: Scene, options?: ISoundTrackOptions);
  97598. private _initializeSoundTrackAudioGraph;
  97599. /**
  97600. * Release the sound track and its associated resources
  97601. */
  97602. dispose(): void;
  97603. /**
  97604. * Adds a sound to this sound track
  97605. * @param sound define the cound to add
  97606. * @ignoreNaming
  97607. */
  97608. AddSound(sound: Sound): void;
  97609. /**
  97610. * Removes a sound to this sound track
  97611. * @param sound define the cound to remove
  97612. * @ignoreNaming
  97613. */
  97614. RemoveSound(sound: Sound): void;
  97615. /**
  97616. * Set a global volume for the full sound track.
  97617. * @param newVolume Define the new volume of the sound track
  97618. */
  97619. setVolume(newVolume: number): void;
  97620. /**
  97621. * Switch the panning model to HRTF:
  97622. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97624. */
  97625. switchPanningModelToHRTF(): void;
  97626. /**
  97627. * Switch the panning model to Equal Power:
  97628. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97629. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97630. */
  97631. switchPanningModelToEqualPower(): void;
  97632. /**
  97633. * Connect the sound track to an audio analyser allowing some amazing
  97634. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97636. * @param analyser The analyser to connect to the engine
  97637. */
  97638. connectToAnalyser(analyser: Analyser): void;
  97639. }
  97640. }
  97641. declare module BABYLON {
  97642. interface AbstractScene {
  97643. /**
  97644. * The list of sounds used in the scene.
  97645. */
  97646. sounds: Nullable<Array<Sound>>;
  97647. }
  97648. interface Scene {
  97649. /**
  97650. * @hidden
  97651. * Backing field
  97652. */
  97653. _mainSoundTrack: SoundTrack;
  97654. /**
  97655. * The main sound track played by the scene.
  97656. * It cotains your primary collection of sounds.
  97657. */
  97658. mainSoundTrack: SoundTrack;
  97659. /**
  97660. * The list of sound tracks added to the scene
  97661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97662. */
  97663. soundTracks: Nullable<Array<SoundTrack>>;
  97664. /**
  97665. * Gets a sound using a given name
  97666. * @param name defines the name to search for
  97667. * @return the found sound or null if not found at all.
  97668. */
  97669. getSoundByName(name: string): Nullable<Sound>;
  97670. /**
  97671. * Gets or sets if audio support is enabled
  97672. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97673. */
  97674. audioEnabled: boolean;
  97675. /**
  97676. * Gets or sets if audio will be output to headphones
  97677. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97678. */
  97679. headphone: boolean;
  97680. }
  97681. /**
  97682. * Defines the sound scene component responsible to manage any sounds
  97683. * in a given scene.
  97684. */
  97685. export class AudioSceneComponent implements ISceneSerializableComponent {
  97686. /**
  97687. * The component name helpfull to identify the component in the list of scene components.
  97688. */
  97689. readonly name: string;
  97690. /**
  97691. * The scene the component belongs to.
  97692. */
  97693. scene: Scene;
  97694. private _audioEnabled;
  97695. /**
  97696. * Gets whether audio is enabled or not.
  97697. * Please use related enable/disable method to switch state.
  97698. */
  97699. readonly audioEnabled: boolean;
  97700. private _headphone;
  97701. /**
  97702. * Gets whether audio is outputing to headphone or not.
  97703. * Please use the according Switch methods to change output.
  97704. */
  97705. readonly headphone: boolean;
  97706. /**
  97707. * Creates a new instance of the component for the given scene
  97708. * @param scene Defines the scene to register the component in
  97709. */
  97710. constructor(scene: Scene);
  97711. /**
  97712. * Registers the component in a given scene
  97713. */
  97714. register(): void;
  97715. /**
  97716. * Rebuilds the elements related to this component in case of
  97717. * context lost for instance.
  97718. */
  97719. rebuild(): void;
  97720. /**
  97721. * Serializes the component data to the specified json object
  97722. * @param serializationObject The object to serialize to
  97723. */
  97724. serialize(serializationObject: any): void;
  97725. /**
  97726. * Adds all the elements from the container to the scene
  97727. * @param container the container holding the elements
  97728. */
  97729. addFromContainer(container: AbstractScene): void;
  97730. /**
  97731. * Removes all the elements in the container from the scene
  97732. * @param container contains the elements to remove
  97733. * @param dispose if the removed element should be disposed (default: false)
  97734. */
  97735. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  97736. /**
  97737. * Disposes the component and the associated ressources.
  97738. */
  97739. dispose(): void;
  97740. /**
  97741. * Disables audio in the associated scene.
  97742. */
  97743. disableAudio(): void;
  97744. /**
  97745. * Enables audio in the associated scene.
  97746. */
  97747. enableAudio(): void;
  97748. /**
  97749. * Switch audio to headphone output.
  97750. */
  97751. switchAudioModeForHeadphones(): void;
  97752. /**
  97753. * Switch audio to normal speakers.
  97754. */
  97755. switchAudioModeForNormalSpeakers(): void;
  97756. private _afterRender;
  97757. }
  97758. }
  97759. declare module BABYLON {
  97760. /**
  97761. * Wraps one or more Sound objects and selects one with random weight for playback.
  97762. */
  97763. export class WeightedSound {
  97764. /** When true a Sound will be selected and played when the current playing Sound completes. */
  97765. loop: boolean;
  97766. private _coneInnerAngle;
  97767. private _coneOuterAngle;
  97768. private _volume;
  97769. /** A Sound is currently playing. */
  97770. isPlaying: boolean;
  97771. /** A Sound is currently paused. */
  97772. isPaused: boolean;
  97773. private _sounds;
  97774. private _weights;
  97775. private _currentIndex?;
  97776. /**
  97777. * Creates a new WeightedSound from the list of sounds given.
  97778. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  97779. * @param sounds Array of Sounds that will be selected from.
  97780. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  97781. */
  97782. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  97783. /**
  97784. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  97785. */
  97786. /**
  97787. * The size of cone in degress for a directional sound in which there will be no attenuation.
  97788. */
  97789. directionalConeInnerAngle: number;
  97790. /**
  97791. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97792. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97793. */
  97794. /**
  97795. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97796. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97797. */
  97798. directionalConeOuterAngle: number;
  97799. /**
  97800. * Playback volume.
  97801. */
  97802. /**
  97803. * Playback volume.
  97804. */
  97805. volume: number;
  97806. private _onended;
  97807. /**
  97808. * Suspend playback
  97809. */
  97810. pause(): void;
  97811. /**
  97812. * Stop playback
  97813. */
  97814. stop(): void;
  97815. /**
  97816. * Start playback.
  97817. * @param startOffset Position the clip head at a specific time in seconds.
  97818. */
  97819. play(startOffset?: number): void;
  97820. }
  97821. }
  97822. declare module BABYLON {
  97823. /**
  97824. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  97825. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97826. */
  97827. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  97828. /**
  97829. * Gets the name of the behavior.
  97830. */
  97831. readonly name: string;
  97832. /**
  97833. * The easing function used by animations
  97834. */
  97835. static EasingFunction: BackEase;
  97836. /**
  97837. * The easing mode used by animations
  97838. */
  97839. static EasingMode: number;
  97840. /**
  97841. * The duration of the animation, in milliseconds
  97842. */
  97843. transitionDuration: number;
  97844. /**
  97845. * Length of the distance animated by the transition when lower radius is reached
  97846. */
  97847. lowerRadiusTransitionRange: number;
  97848. /**
  97849. * Length of the distance animated by the transition when upper radius is reached
  97850. */
  97851. upperRadiusTransitionRange: number;
  97852. private _autoTransitionRange;
  97853. /**
  97854. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97855. */
  97856. /**
  97857. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97858. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  97859. */
  97860. autoTransitionRange: boolean;
  97861. private _attachedCamera;
  97862. private _onAfterCheckInputsObserver;
  97863. private _onMeshTargetChangedObserver;
  97864. /**
  97865. * Initializes the behavior.
  97866. */
  97867. init(): void;
  97868. /**
  97869. * Attaches the behavior to its arc rotate camera.
  97870. * @param camera Defines the camera to attach the behavior to
  97871. */
  97872. attach(camera: ArcRotateCamera): void;
  97873. /**
  97874. * Detaches the behavior from its current arc rotate camera.
  97875. */
  97876. detach(): void;
  97877. private _radiusIsAnimating;
  97878. private _radiusBounceTransition;
  97879. private _animatables;
  97880. private _cachedWheelPrecision;
  97881. /**
  97882. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  97883. * @param radiusLimit The limit to check against.
  97884. * @return Bool to indicate if at limit.
  97885. */
  97886. private _isRadiusAtLimit;
  97887. /**
  97888. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  97889. * @param radiusDelta The delta by which to animate to. Can be negative.
  97890. */
  97891. private _applyBoundRadiusAnimation;
  97892. /**
  97893. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  97894. */
  97895. protected _clearAnimationLocks(): void;
  97896. /**
  97897. * Stops and removes all animations that have been applied to the camera
  97898. */
  97899. stopAllAnimations(): void;
  97900. }
  97901. }
  97902. declare module BABYLON {
  97903. /**
  97904. * 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.
  97905. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97906. */
  97907. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  97908. /**
  97909. * Gets the name of the behavior.
  97910. */
  97911. readonly name: string;
  97912. private _mode;
  97913. private _radiusScale;
  97914. private _positionScale;
  97915. private _defaultElevation;
  97916. private _elevationReturnTime;
  97917. private _elevationReturnWaitTime;
  97918. private _zoomStopsAnimation;
  97919. private _framingTime;
  97920. /**
  97921. * The easing function used by animations
  97922. */
  97923. static EasingFunction: ExponentialEase;
  97924. /**
  97925. * The easing mode used by animations
  97926. */
  97927. static EasingMode: number;
  97928. /**
  97929. * Sets the current mode used by the behavior
  97930. */
  97931. /**
  97932. * Gets current mode used by the behavior.
  97933. */
  97934. mode: number;
  97935. /**
  97936. * Sets the scale applied to the radius (1 by default)
  97937. */
  97938. /**
  97939. * Gets the scale applied to the radius
  97940. */
  97941. radiusScale: number;
  97942. /**
  97943. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97944. */
  97945. /**
  97946. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97947. */
  97948. positionScale: number;
  97949. /**
  97950. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97951. * behaviour is triggered, in radians.
  97952. */
  97953. /**
  97954. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97955. * behaviour is triggered, in radians.
  97956. */
  97957. defaultElevation: number;
  97958. /**
  97959. * Sets the time (in milliseconds) taken to return to the default beta position.
  97960. * Negative value indicates camera should not return to default.
  97961. */
  97962. /**
  97963. * Gets the time (in milliseconds) taken to return to the default beta position.
  97964. * Negative value indicates camera should not return to default.
  97965. */
  97966. elevationReturnTime: number;
  97967. /**
  97968. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97969. */
  97970. /**
  97971. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97972. */
  97973. elevationReturnWaitTime: number;
  97974. /**
  97975. * Sets the flag that indicates if user zooming should stop animation.
  97976. */
  97977. /**
  97978. * Gets the flag that indicates if user zooming should stop animation.
  97979. */
  97980. zoomStopsAnimation: boolean;
  97981. /**
  97982. * Sets the transition time when framing the mesh, in milliseconds
  97983. */
  97984. /**
  97985. * Gets the transition time when framing the mesh, in milliseconds
  97986. */
  97987. framingTime: number;
  97988. /**
  97989. * Define if the behavior should automatically change the configured
  97990. * camera limits and sensibilities.
  97991. */
  97992. autoCorrectCameraLimitsAndSensibility: boolean;
  97993. private _onPrePointerObservableObserver;
  97994. private _onAfterCheckInputsObserver;
  97995. private _onMeshTargetChangedObserver;
  97996. private _attachedCamera;
  97997. private _isPointerDown;
  97998. private _lastInteractionTime;
  97999. /**
  98000. * Initializes the behavior.
  98001. */
  98002. init(): void;
  98003. /**
  98004. * Attaches the behavior to its arc rotate camera.
  98005. * @param camera Defines the camera to attach the behavior to
  98006. */
  98007. attach(camera: ArcRotateCamera): void;
  98008. /**
  98009. * Detaches the behavior from its current arc rotate camera.
  98010. */
  98011. detach(): void;
  98012. private _animatables;
  98013. private _betaIsAnimating;
  98014. private _betaTransition;
  98015. private _radiusTransition;
  98016. private _vectorTransition;
  98017. /**
  98018. * Targets the given mesh and updates zoom level accordingly.
  98019. * @param mesh The mesh to target.
  98020. * @param radius Optional. If a cached radius position already exists, overrides default.
  98021. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  98022. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98023. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98024. */
  98025. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98026. /**
  98027. * Targets the given mesh with its children and updates zoom level accordingly.
  98028. * @param mesh The mesh to target.
  98029. * @param radius Optional. If a cached radius position already exists, overrides default.
  98030. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  98031. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98032. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98033. */
  98034. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98035. /**
  98036. * Targets the given meshes with their children and updates zoom level accordingly.
  98037. * @param meshes The mesh to target.
  98038. * @param radius Optional. If a cached radius position already exists, overrides default.
  98039. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  98040. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98041. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98042. */
  98043. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98044. /**
  98045. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  98046. * @param minimumWorld Determines the smaller position of the bounding box extend
  98047. * @param maximumWorld Determines the bigger position of the bounding box extend
  98048. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98049. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98050. */
  98051. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98052. /**
  98053. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  98054. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  98055. * frustum width.
  98056. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  98057. * to fully enclose the mesh in the viewing frustum.
  98058. */
  98059. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  98060. /**
  98061. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  98062. * is automatically returned to its default position (expected to be above ground plane).
  98063. */
  98064. private _maintainCameraAboveGround;
  98065. /**
  98066. * Returns the frustum slope based on the canvas ratio and camera FOV
  98067. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  98068. */
  98069. private _getFrustumSlope;
  98070. /**
  98071. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  98072. */
  98073. private _clearAnimationLocks;
  98074. /**
  98075. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  98076. */
  98077. private _applyUserInteraction;
  98078. /**
  98079. * Stops and removes all animations that have been applied to the camera
  98080. */
  98081. stopAllAnimations(): void;
  98082. /**
  98083. * Gets a value indicating if the user is moving the camera
  98084. */
  98085. readonly isUserIsMoving: boolean;
  98086. /**
  98087. * The camera can move all the way towards the mesh.
  98088. */
  98089. static IgnoreBoundsSizeMode: number;
  98090. /**
  98091. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  98092. */
  98093. static FitFrustumSidesMode: number;
  98094. }
  98095. }
  98096. declare module BABYLON {
  98097. /**
  98098. * Base class for Camera Pointer Inputs.
  98099. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  98100. * for example usage.
  98101. */
  98102. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  98103. /**
  98104. * Defines the camera the input is attached to.
  98105. */
  98106. abstract camera: Camera;
  98107. /**
  98108. * Whether keyboard modifier keys are pressed at time of last mouse event.
  98109. */
  98110. protected _altKey: boolean;
  98111. protected _ctrlKey: boolean;
  98112. protected _metaKey: boolean;
  98113. protected _shiftKey: boolean;
  98114. /**
  98115. * Which mouse buttons were pressed at time of last mouse event.
  98116. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  98117. */
  98118. protected _buttonsPressed: number;
  98119. /**
  98120. * Defines the buttons associated with the input to handle camera move.
  98121. */
  98122. buttons: number[];
  98123. /**
  98124. * Attach the input controls to a specific dom element to get the input from.
  98125. * @param element Defines the element the controls should be listened from
  98126. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98127. */
  98128. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98129. /**
  98130. * Detach the current controls from the specified dom element.
  98131. * @param element Defines the element to stop listening the inputs from
  98132. */
  98133. detachControl(element: Nullable<HTMLElement>): void;
  98134. /**
  98135. * Gets the class name of the current input.
  98136. * @returns the class name
  98137. */
  98138. getClassName(): string;
  98139. /**
  98140. * Get the friendly name associated with the input class.
  98141. * @returns the input friendly name
  98142. */
  98143. getSimpleName(): string;
  98144. /**
  98145. * Called on pointer POINTERDOUBLETAP event.
  98146. * Override this method to provide functionality on POINTERDOUBLETAP event.
  98147. */
  98148. protected onDoubleTap(type: string): void;
  98149. /**
  98150. * Called on pointer POINTERMOVE event if only a single touch is active.
  98151. * Override this method to provide functionality.
  98152. */
  98153. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  98154. /**
  98155. * Called on pointer POINTERMOVE event if multiple touches are active.
  98156. * Override this method to provide functionality.
  98157. */
  98158. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  98159. /**
  98160. * Called on JS contextmenu event.
  98161. * Override this method to provide functionality.
  98162. */
  98163. protected onContextMenu(evt: PointerEvent): void;
  98164. /**
  98165. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  98166. * press.
  98167. * Override this method to provide functionality.
  98168. */
  98169. protected onButtonDown(evt: PointerEvent): void;
  98170. /**
  98171. * Called each time a new POINTERUP event occurs. Ie, for each button
  98172. * release.
  98173. * Override this method to provide functionality.
  98174. */
  98175. protected onButtonUp(evt: PointerEvent): void;
  98176. /**
  98177. * Called when window becomes inactive.
  98178. * Override this method to provide functionality.
  98179. */
  98180. protected onLostFocus(): void;
  98181. private _pointerInput;
  98182. private _observer;
  98183. private _onLostFocus;
  98184. private pointA;
  98185. private pointB;
  98186. }
  98187. }
  98188. declare module BABYLON {
  98189. /**
  98190. * Manage the pointers inputs to control an arc rotate camera.
  98191. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98192. */
  98193. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  98194. /**
  98195. * Defines the camera the input is attached to.
  98196. */
  98197. camera: ArcRotateCamera;
  98198. /**
  98199. * Gets the class name of the current input.
  98200. * @returns the class name
  98201. */
  98202. getClassName(): string;
  98203. /**
  98204. * Defines the buttons associated with the input to handle camera move.
  98205. */
  98206. buttons: number[];
  98207. /**
  98208. * Defines the pointer angular sensibility along the X axis or how fast is
  98209. * the camera rotating.
  98210. */
  98211. angularSensibilityX: number;
  98212. /**
  98213. * Defines the pointer angular sensibility along the Y axis or how fast is
  98214. * the camera rotating.
  98215. */
  98216. angularSensibilityY: number;
  98217. /**
  98218. * Defines the pointer pinch precision or how fast is the camera zooming.
  98219. */
  98220. pinchPrecision: number;
  98221. /**
  98222. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  98223. * from 0.
  98224. * It defines the percentage of current camera.radius to use as delta when
  98225. * pinch zoom is used.
  98226. */
  98227. pinchDeltaPercentage: number;
  98228. /**
  98229. * Defines the pointer panning sensibility or how fast is the camera moving.
  98230. */
  98231. panningSensibility: number;
  98232. /**
  98233. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  98234. */
  98235. multiTouchPanning: boolean;
  98236. /**
  98237. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  98238. * zoom (pinch) through multitouch.
  98239. */
  98240. multiTouchPanAndZoom: boolean;
  98241. /**
  98242. * Revers pinch action direction.
  98243. */
  98244. pinchInwards: boolean;
  98245. private _isPanClick;
  98246. private _twoFingerActivityCount;
  98247. private _isPinching;
  98248. /**
  98249. * Called on pointer POINTERMOVE event if only a single touch is active.
  98250. */
  98251. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  98252. /**
  98253. * Called on pointer POINTERDOUBLETAP event.
  98254. */
  98255. protected onDoubleTap(type: string): void;
  98256. /**
  98257. * Called on pointer POINTERMOVE event if multiple touches are active.
  98258. */
  98259. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  98260. /**
  98261. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  98262. * press.
  98263. */
  98264. protected onButtonDown(evt: PointerEvent): void;
  98265. /**
  98266. * Called each time a new POINTERUP event occurs. Ie, for each button
  98267. * release.
  98268. */
  98269. protected onButtonUp(evt: PointerEvent): void;
  98270. /**
  98271. * Called when window becomes inactive.
  98272. */
  98273. protected onLostFocus(): void;
  98274. }
  98275. }
  98276. declare module BABYLON {
  98277. /**
  98278. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  98279. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98280. */
  98281. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  98282. /**
  98283. * Defines the camera the input is attached to.
  98284. */
  98285. camera: ArcRotateCamera;
  98286. /**
  98287. * Defines the list of key codes associated with the up action (increase alpha)
  98288. */
  98289. keysUp: number[];
  98290. /**
  98291. * Defines the list of key codes associated with the down action (decrease alpha)
  98292. */
  98293. keysDown: number[];
  98294. /**
  98295. * Defines the list of key codes associated with the left action (increase beta)
  98296. */
  98297. keysLeft: number[];
  98298. /**
  98299. * Defines the list of key codes associated with the right action (decrease beta)
  98300. */
  98301. keysRight: number[];
  98302. /**
  98303. * Defines the list of key codes associated with the reset action.
  98304. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  98305. */
  98306. keysReset: number[];
  98307. /**
  98308. * Defines the panning sensibility of the inputs.
  98309. * (How fast is the camera paning)
  98310. */
  98311. panningSensibility: number;
  98312. /**
  98313. * Defines the zooming sensibility of the inputs.
  98314. * (How fast is the camera zooming)
  98315. */
  98316. zoomingSensibility: number;
  98317. /**
  98318. * Defines wether maintaining the alt key down switch the movement mode from
  98319. * orientation to zoom.
  98320. */
  98321. useAltToZoom: boolean;
  98322. /**
  98323. * Rotation speed of the camera
  98324. */
  98325. angularSpeed: number;
  98326. private _keys;
  98327. private _ctrlPressed;
  98328. private _altPressed;
  98329. private _onCanvasBlurObserver;
  98330. private _onKeyboardObserver;
  98331. private _engine;
  98332. private _scene;
  98333. /**
  98334. * Attach the input controls to a specific dom element to get the input from.
  98335. * @param element Defines the element the controls should be listened from
  98336. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98337. */
  98338. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98339. /**
  98340. * Detach the current controls from the specified dom element.
  98341. * @param element Defines the element to stop listening the inputs from
  98342. */
  98343. detachControl(element: Nullable<HTMLElement>): void;
  98344. /**
  98345. * Update the current camera state depending on the inputs that have been used this frame.
  98346. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98347. */
  98348. checkInputs(): void;
  98349. /**
  98350. * Gets the class name of the current intput.
  98351. * @returns the class name
  98352. */
  98353. getClassName(): string;
  98354. /**
  98355. * Get the friendly name associated with the input class.
  98356. * @returns the input friendly name
  98357. */
  98358. getSimpleName(): string;
  98359. }
  98360. }
  98361. declare module BABYLON {
  98362. /**
  98363. * Manage the mouse wheel inputs to control an arc rotate camera.
  98364. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98365. */
  98366. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  98367. /**
  98368. * Defines the camera the input is attached to.
  98369. */
  98370. camera: ArcRotateCamera;
  98371. /**
  98372. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98373. */
  98374. wheelPrecision: number;
  98375. /**
  98376. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  98377. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  98378. */
  98379. wheelDeltaPercentage: number;
  98380. private _wheel;
  98381. private _observer;
  98382. private computeDeltaFromMouseWheelLegacyEvent;
  98383. /**
  98384. * Attach the input controls to a specific dom element to get the input from.
  98385. * @param element Defines the element the controls should be listened from
  98386. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98387. */
  98388. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98389. /**
  98390. * Detach the current controls from the specified dom element.
  98391. * @param element Defines the element to stop listening the inputs from
  98392. */
  98393. detachControl(element: Nullable<HTMLElement>): void;
  98394. /**
  98395. * Gets the class name of the current intput.
  98396. * @returns the class name
  98397. */
  98398. getClassName(): string;
  98399. /**
  98400. * Get the friendly name associated with the input class.
  98401. * @returns the input friendly name
  98402. */
  98403. getSimpleName(): string;
  98404. }
  98405. }
  98406. declare module BABYLON {
  98407. /**
  98408. * Default Inputs manager for the ArcRotateCamera.
  98409. * It groups all the default supported inputs for ease of use.
  98410. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98411. */
  98412. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  98413. /**
  98414. * Instantiates a new ArcRotateCameraInputsManager.
  98415. * @param camera Defines the camera the inputs belong to
  98416. */
  98417. constructor(camera: ArcRotateCamera);
  98418. /**
  98419. * Add mouse wheel input support to the input manager.
  98420. * @returns the current input manager
  98421. */
  98422. addMouseWheel(): ArcRotateCameraInputsManager;
  98423. /**
  98424. * Add pointers input support to the input manager.
  98425. * @returns the current input manager
  98426. */
  98427. addPointers(): ArcRotateCameraInputsManager;
  98428. /**
  98429. * Add keyboard input support to the input manager.
  98430. * @returns the current input manager
  98431. */
  98432. addKeyboard(): ArcRotateCameraInputsManager;
  98433. }
  98434. }
  98435. declare module BABYLON {
  98436. /**
  98437. * This represents an orbital type of camera.
  98438. *
  98439. * 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.
  98440. * 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.
  98441. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  98442. */
  98443. export class ArcRotateCamera extends TargetCamera {
  98444. /**
  98445. * Defines the rotation angle of the camera along the longitudinal axis.
  98446. */
  98447. alpha: number;
  98448. /**
  98449. * Defines the rotation angle of the camera along the latitudinal axis.
  98450. */
  98451. beta: number;
  98452. /**
  98453. * Defines the radius of the camera from it s target point.
  98454. */
  98455. radius: number;
  98456. protected _target: Vector3;
  98457. protected _targetHost: Nullable<AbstractMesh>;
  98458. /**
  98459. * Defines the target point of the camera.
  98460. * The camera looks towards it form the radius distance.
  98461. */
  98462. target: Vector3;
  98463. /**
  98464. * Define the current local position of the camera in the scene
  98465. */
  98466. position: Vector3;
  98467. protected _upVector: Vector3;
  98468. protected _upToYMatrix: Matrix;
  98469. protected _YToUpMatrix: Matrix;
  98470. /**
  98471. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  98472. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  98473. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  98474. */
  98475. upVector: Vector3;
  98476. /**
  98477. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  98478. */
  98479. setMatUp(): void;
  98480. /**
  98481. * Current inertia value on the longitudinal axis.
  98482. * The bigger this number the longer it will take for the camera to stop.
  98483. */
  98484. inertialAlphaOffset: number;
  98485. /**
  98486. * Current inertia value on the latitudinal axis.
  98487. * The bigger this number the longer it will take for the camera to stop.
  98488. */
  98489. inertialBetaOffset: number;
  98490. /**
  98491. * Current inertia value on the radius axis.
  98492. * The bigger this number the longer it will take for the camera to stop.
  98493. */
  98494. inertialRadiusOffset: number;
  98495. /**
  98496. * Minimum allowed angle on the longitudinal axis.
  98497. * This can help limiting how the Camera is able to move in the scene.
  98498. */
  98499. lowerAlphaLimit: Nullable<number>;
  98500. /**
  98501. * Maximum allowed angle on the longitudinal axis.
  98502. * This can help limiting how the Camera is able to move in the scene.
  98503. */
  98504. upperAlphaLimit: Nullable<number>;
  98505. /**
  98506. * Minimum allowed angle on the latitudinal axis.
  98507. * This can help limiting how the Camera is able to move in the scene.
  98508. */
  98509. lowerBetaLimit: number;
  98510. /**
  98511. * Maximum allowed angle on the latitudinal axis.
  98512. * This can help limiting how the Camera is able to move in the scene.
  98513. */
  98514. upperBetaLimit: number;
  98515. /**
  98516. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  98517. * This can help limiting how the Camera is able to move in the scene.
  98518. */
  98519. lowerRadiusLimit: Nullable<number>;
  98520. /**
  98521. * Maximum allowed distance of the camera to the target (The camera can not get further).
  98522. * This can help limiting how the Camera is able to move in the scene.
  98523. */
  98524. upperRadiusLimit: Nullable<number>;
  98525. /**
  98526. * Defines the current inertia value used during panning of the camera along the X axis.
  98527. */
  98528. inertialPanningX: number;
  98529. /**
  98530. * Defines the current inertia value used during panning of the camera along the Y axis.
  98531. */
  98532. inertialPanningY: number;
  98533. /**
  98534. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  98535. * Basically if your fingers moves away from more than this distance you will be considered
  98536. * in pinch mode.
  98537. */
  98538. pinchToPanMaxDistance: number;
  98539. /**
  98540. * Defines the maximum distance the camera can pan.
  98541. * This could help keeping the cammera always in your scene.
  98542. */
  98543. panningDistanceLimit: Nullable<number>;
  98544. /**
  98545. * Defines the target of the camera before paning.
  98546. */
  98547. panningOriginTarget: Vector3;
  98548. /**
  98549. * Defines the value of the inertia used during panning.
  98550. * 0 would mean stop inertia and one would mean no decelleration at all.
  98551. */
  98552. panningInertia: number;
  98553. /**
  98554. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  98555. */
  98556. angularSensibilityX: number;
  98557. /**
  98558. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  98559. */
  98560. angularSensibilityY: number;
  98561. /**
  98562. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  98563. */
  98564. pinchPrecision: number;
  98565. /**
  98566. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  98567. * It will be used instead of pinchDeltaPrecision if different from 0.
  98568. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98569. */
  98570. pinchDeltaPercentage: number;
  98571. /**
  98572. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  98573. */
  98574. panningSensibility: number;
  98575. /**
  98576. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  98577. */
  98578. keysUp: number[];
  98579. /**
  98580. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  98581. */
  98582. keysDown: number[];
  98583. /**
  98584. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  98585. */
  98586. keysLeft: number[];
  98587. /**
  98588. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  98589. */
  98590. keysRight: number[];
  98591. /**
  98592. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98593. */
  98594. wheelPrecision: number;
  98595. /**
  98596. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  98597. * It will be used instead of pinchDeltaPrecision if different from 0.
  98598. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98599. */
  98600. wheelDeltaPercentage: number;
  98601. /**
  98602. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  98603. */
  98604. zoomOnFactor: number;
  98605. /**
  98606. * Defines a screen offset for the camera position.
  98607. */
  98608. targetScreenOffset: Vector2;
  98609. /**
  98610. * Allows the camera to be completely reversed.
  98611. * If false the camera can not arrive upside down.
  98612. */
  98613. allowUpsideDown: boolean;
  98614. /**
  98615. * Define if double tap/click is used to restore the previously saved state of the camera.
  98616. */
  98617. useInputToRestoreState: boolean;
  98618. /** @hidden */
  98619. _viewMatrix: Matrix;
  98620. /** @hidden */
  98621. _useCtrlForPanning: boolean;
  98622. /** @hidden */
  98623. _panningMouseButton: number;
  98624. /**
  98625. * Defines the input associated to the camera.
  98626. */
  98627. inputs: ArcRotateCameraInputsManager;
  98628. /** @hidden */
  98629. _reset: () => void;
  98630. /**
  98631. * Defines the allowed panning axis.
  98632. */
  98633. panningAxis: Vector3;
  98634. protected _localDirection: Vector3;
  98635. protected _transformedDirection: Vector3;
  98636. private _bouncingBehavior;
  98637. /**
  98638. * Gets the bouncing behavior of the camera if it has been enabled.
  98639. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98640. */
  98641. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  98642. /**
  98643. * Defines if the bouncing behavior of the camera is enabled on the camera.
  98644. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98645. */
  98646. useBouncingBehavior: boolean;
  98647. private _framingBehavior;
  98648. /**
  98649. * Gets the framing behavior of the camera if it has been enabled.
  98650. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98651. */
  98652. readonly framingBehavior: Nullable<FramingBehavior>;
  98653. /**
  98654. * Defines if the framing behavior of the camera is enabled on the camera.
  98655. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98656. */
  98657. useFramingBehavior: boolean;
  98658. private _autoRotationBehavior;
  98659. /**
  98660. * Gets the auto rotation behavior of the camera if it has been enabled.
  98661. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98662. */
  98663. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  98664. /**
  98665. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  98666. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98667. */
  98668. useAutoRotationBehavior: boolean;
  98669. /**
  98670. * Observable triggered when the mesh target has been changed on the camera.
  98671. */
  98672. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  98673. /**
  98674. * Event raised when the camera is colliding with a mesh.
  98675. */
  98676. onCollide: (collidedMesh: AbstractMesh) => void;
  98677. /**
  98678. * Defines whether the camera should check collision with the objects oh the scene.
  98679. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  98680. */
  98681. checkCollisions: boolean;
  98682. /**
  98683. * Defines the collision radius of the camera.
  98684. * This simulates a sphere around the camera.
  98685. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98686. */
  98687. collisionRadius: Vector3;
  98688. protected _collider: Collider;
  98689. protected _previousPosition: Vector3;
  98690. protected _collisionVelocity: Vector3;
  98691. protected _newPosition: Vector3;
  98692. protected _previousAlpha: number;
  98693. protected _previousBeta: number;
  98694. protected _previousRadius: number;
  98695. protected _collisionTriggered: boolean;
  98696. protected _targetBoundingCenter: Nullable<Vector3>;
  98697. private _computationVector;
  98698. /**
  98699. * Instantiates a new ArcRotateCamera in a given scene
  98700. * @param name Defines the name of the camera
  98701. * @param alpha Defines the camera rotation along the logitudinal axis
  98702. * @param beta Defines the camera rotation along the latitudinal axis
  98703. * @param radius Defines the camera distance from its target
  98704. * @param target Defines the camera target
  98705. * @param scene Defines the scene the camera belongs to
  98706. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98707. */
  98708. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98709. /** @hidden */
  98710. _initCache(): void;
  98711. /** @hidden */
  98712. _updateCache(ignoreParentClass?: boolean): void;
  98713. protected _getTargetPosition(): Vector3;
  98714. private _storedAlpha;
  98715. private _storedBeta;
  98716. private _storedRadius;
  98717. private _storedTarget;
  98718. /**
  98719. * Stores the current state of the camera (alpha, beta, radius and target)
  98720. * @returns the camera itself
  98721. */
  98722. storeState(): Camera;
  98723. /**
  98724. * @hidden
  98725. * Restored camera state. You must call storeState() first
  98726. */
  98727. _restoreStateValues(): boolean;
  98728. /** @hidden */
  98729. _isSynchronizedViewMatrix(): boolean;
  98730. /**
  98731. * Attached controls to the current camera.
  98732. * @param element Defines the element the controls should be listened from
  98733. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98734. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  98735. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  98736. */
  98737. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  98738. /**
  98739. * Detach the current controls from the camera.
  98740. * The camera will stop reacting to inputs.
  98741. * @param element Defines the element to stop listening the inputs from
  98742. */
  98743. detachControl(element: HTMLElement): void;
  98744. /** @hidden */
  98745. _checkInputs(): void;
  98746. protected _checkLimits(): void;
  98747. /**
  98748. * Rebuilds angles (alpha, beta) and radius from the give position and target
  98749. */
  98750. rebuildAnglesAndRadius(): void;
  98751. /**
  98752. * Use a position to define the current camera related information like aplha, beta and radius
  98753. * @param position Defines the position to set the camera at
  98754. */
  98755. setPosition(position: Vector3): void;
  98756. /**
  98757. * Defines the target the camera should look at.
  98758. * This will automatically adapt alpha beta and radius to fit within the new target.
  98759. * @param target Defines the new target as a Vector or a mesh
  98760. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  98761. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  98762. */
  98763. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  98764. /** @hidden */
  98765. _getViewMatrix(): Matrix;
  98766. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  98767. /**
  98768. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  98769. * @param meshes Defines the mesh to zoom on
  98770. * @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)
  98771. */
  98772. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  98773. /**
  98774. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  98775. * The target will be changed but the radius
  98776. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  98777. * @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)
  98778. */
  98779. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  98780. min: Vector3;
  98781. max: Vector3;
  98782. distance: number;
  98783. }, doNotUpdateMaxZ?: boolean): void;
  98784. /**
  98785. * @override
  98786. * Override Camera.createRigCamera
  98787. */
  98788. createRigCamera(name: string, cameraIndex: number): Camera;
  98789. /**
  98790. * @hidden
  98791. * @override
  98792. * Override Camera._updateRigCameras
  98793. */
  98794. _updateRigCameras(): void;
  98795. /**
  98796. * Destroy the camera and release the current resources hold by it.
  98797. */
  98798. dispose(): void;
  98799. /**
  98800. * Gets the current object class name.
  98801. * @return the class name
  98802. */
  98803. getClassName(): string;
  98804. }
  98805. }
  98806. declare module BABYLON {
  98807. /**
  98808. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  98809. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98810. */
  98811. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  98812. /**
  98813. * Gets the name of the behavior.
  98814. */
  98815. readonly name: string;
  98816. private _zoomStopsAnimation;
  98817. private _idleRotationSpeed;
  98818. private _idleRotationWaitTime;
  98819. private _idleRotationSpinupTime;
  98820. /**
  98821. * Sets the flag that indicates if user zooming should stop animation.
  98822. */
  98823. /**
  98824. * Gets the flag that indicates if user zooming should stop animation.
  98825. */
  98826. zoomStopsAnimation: boolean;
  98827. /**
  98828. * Sets the default speed at which the camera rotates around the model.
  98829. */
  98830. /**
  98831. * Gets the default speed at which the camera rotates around the model.
  98832. */
  98833. idleRotationSpeed: number;
  98834. /**
  98835. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  98836. */
  98837. /**
  98838. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  98839. */
  98840. idleRotationWaitTime: number;
  98841. /**
  98842. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98843. */
  98844. /**
  98845. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98846. */
  98847. idleRotationSpinupTime: number;
  98848. /**
  98849. * Gets a value indicating if the camera is currently rotating because of this behavior
  98850. */
  98851. readonly rotationInProgress: boolean;
  98852. private _onPrePointerObservableObserver;
  98853. private _onAfterCheckInputsObserver;
  98854. private _attachedCamera;
  98855. private _isPointerDown;
  98856. private _lastFrameTime;
  98857. private _lastInteractionTime;
  98858. private _cameraRotationSpeed;
  98859. /**
  98860. * Initializes the behavior.
  98861. */
  98862. init(): void;
  98863. /**
  98864. * Attaches the behavior to its arc rotate camera.
  98865. * @param camera Defines the camera to attach the behavior to
  98866. */
  98867. attach(camera: ArcRotateCamera): void;
  98868. /**
  98869. * Detaches the behavior from its current arc rotate camera.
  98870. */
  98871. detach(): void;
  98872. /**
  98873. * Returns true if user is scrolling.
  98874. * @return true if user is scrolling.
  98875. */
  98876. private _userIsZooming;
  98877. private _lastFrameRadius;
  98878. private _shouldAnimationStopForInteraction;
  98879. /**
  98880. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  98881. */
  98882. private _applyUserInteraction;
  98883. private _userIsMoving;
  98884. }
  98885. }
  98886. declare module BABYLON {
  98887. /**
  98888. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  98889. */
  98890. export class AttachToBoxBehavior implements Behavior<Mesh> {
  98891. private ui;
  98892. /**
  98893. * The name of the behavior
  98894. */
  98895. name: string;
  98896. /**
  98897. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  98898. */
  98899. distanceAwayFromFace: number;
  98900. /**
  98901. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  98902. */
  98903. distanceAwayFromBottomOfFace: number;
  98904. private _faceVectors;
  98905. private _target;
  98906. private _scene;
  98907. private _onRenderObserver;
  98908. private _tmpMatrix;
  98909. private _tmpVector;
  98910. /**
  98911. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  98912. * @param ui The transform node that should be attched to the mesh
  98913. */
  98914. constructor(ui: TransformNode);
  98915. /**
  98916. * Initializes the behavior
  98917. */
  98918. init(): void;
  98919. private _closestFace;
  98920. private _zeroVector;
  98921. private _lookAtTmpMatrix;
  98922. private _lookAtToRef;
  98923. /**
  98924. * Attaches the AttachToBoxBehavior to the passed in mesh
  98925. * @param target The mesh that the specified node will be attached to
  98926. */
  98927. attach(target: Mesh): void;
  98928. /**
  98929. * Detaches the behavior from the mesh
  98930. */
  98931. detach(): void;
  98932. }
  98933. }
  98934. declare module BABYLON {
  98935. /**
  98936. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  98937. */
  98938. export class FadeInOutBehavior implements Behavior<Mesh> {
  98939. /**
  98940. * Time in milliseconds to delay before fading in (Default: 0)
  98941. */
  98942. delay: number;
  98943. /**
  98944. * Time in milliseconds for the mesh to fade in (Default: 300)
  98945. */
  98946. fadeInTime: number;
  98947. private _millisecondsPerFrame;
  98948. private _hovered;
  98949. private _hoverValue;
  98950. private _ownerNode;
  98951. /**
  98952. * Instatiates the FadeInOutBehavior
  98953. */
  98954. constructor();
  98955. /**
  98956. * The name of the behavior
  98957. */
  98958. readonly name: string;
  98959. /**
  98960. * Initializes the behavior
  98961. */
  98962. init(): void;
  98963. /**
  98964. * Attaches the fade behavior on the passed in mesh
  98965. * @param ownerNode The mesh that will be faded in/out once attached
  98966. */
  98967. attach(ownerNode: Mesh): void;
  98968. /**
  98969. * Detaches the behavior from the mesh
  98970. */
  98971. detach(): void;
  98972. /**
  98973. * Triggers the mesh to begin fading in or out
  98974. * @param value if the object should fade in or out (true to fade in)
  98975. */
  98976. fadeIn(value: boolean): void;
  98977. private _update;
  98978. private _setAllVisibility;
  98979. }
  98980. }
  98981. declare module BABYLON {
  98982. /**
  98983. * Class containing a set of static utilities functions for managing Pivots
  98984. * @hidden
  98985. */
  98986. export class PivotTools {
  98987. private static _PivotCached;
  98988. private static _OldPivotPoint;
  98989. private static _PivotTranslation;
  98990. private static _PivotTmpVector;
  98991. /** @hidden */
  98992. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  98993. /** @hidden */
  98994. static _RestorePivotPoint(mesh: AbstractMesh): void;
  98995. }
  98996. }
  98997. declare module BABYLON {
  98998. /**
  98999. * Class containing static functions to help procedurally build meshes
  99000. */
  99001. export class PlaneBuilder {
  99002. /**
  99003. * Creates a plane mesh
  99004. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  99005. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  99006. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  99007. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99008. * * 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
  99009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99010. * @param name defines the name of the mesh
  99011. * @param options defines the options used to create the mesh
  99012. * @param scene defines the hosting scene
  99013. * @returns the plane mesh
  99014. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  99015. */
  99016. static CreatePlane(name: string, options: {
  99017. size?: number;
  99018. width?: number;
  99019. height?: number;
  99020. sideOrientation?: number;
  99021. frontUVs?: Vector4;
  99022. backUVs?: Vector4;
  99023. updatable?: boolean;
  99024. sourcePlane?: Plane;
  99025. }, scene?: Nullable<Scene>): Mesh;
  99026. }
  99027. }
  99028. declare module BABYLON {
  99029. /**
  99030. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  99031. */
  99032. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  99033. private static _AnyMouseID;
  99034. /**
  99035. * Abstract mesh the behavior is set on
  99036. */
  99037. attachedNode: AbstractMesh;
  99038. private _dragPlane;
  99039. private _scene;
  99040. private _pointerObserver;
  99041. private _beforeRenderObserver;
  99042. private static _planeScene;
  99043. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  99044. /**
  99045. * 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)
  99046. */
  99047. maxDragAngle: number;
  99048. /**
  99049. * @hidden
  99050. */
  99051. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  99052. /**
  99053. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  99054. */
  99055. currentDraggingPointerID: number;
  99056. /**
  99057. * The last position where the pointer hit the drag plane in world space
  99058. */
  99059. lastDragPosition: Vector3;
  99060. /**
  99061. * If the behavior is currently in a dragging state
  99062. */
  99063. dragging: boolean;
  99064. /**
  99065. * 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)
  99066. */
  99067. dragDeltaRatio: number;
  99068. /**
  99069. * If the drag plane orientation should be updated during the dragging (Default: true)
  99070. */
  99071. updateDragPlane: boolean;
  99072. private _debugMode;
  99073. private _moving;
  99074. /**
  99075. * Fires each time the attached mesh is dragged with the pointer
  99076. * * delta between last drag position and current drag position in world space
  99077. * * dragDistance along the drag axis
  99078. * * dragPlaneNormal normal of the current drag plane used during the drag
  99079. * * dragPlanePoint in world space where the drag intersects the drag plane
  99080. */
  99081. onDragObservable: Observable<{
  99082. delta: Vector3;
  99083. dragPlanePoint: Vector3;
  99084. dragPlaneNormal: Vector3;
  99085. dragDistance: number;
  99086. pointerId: number;
  99087. }>;
  99088. /**
  99089. * Fires each time a drag begins (eg. mouse down on mesh)
  99090. */
  99091. onDragStartObservable: Observable<{
  99092. dragPlanePoint: Vector3;
  99093. pointerId: number;
  99094. }>;
  99095. /**
  99096. * Fires each time a drag ends (eg. mouse release after drag)
  99097. */
  99098. onDragEndObservable: Observable<{
  99099. dragPlanePoint: Vector3;
  99100. pointerId: number;
  99101. }>;
  99102. /**
  99103. * If the attached mesh should be moved when dragged
  99104. */
  99105. moveAttached: boolean;
  99106. /**
  99107. * If the drag behavior will react to drag events (Default: true)
  99108. */
  99109. enabled: boolean;
  99110. /**
  99111. * If pointer events should start and release the drag (Default: true)
  99112. */
  99113. startAndReleaseDragOnPointerEvents: boolean;
  99114. /**
  99115. * If camera controls should be detached during the drag
  99116. */
  99117. detachCameraControls: boolean;
  99118. /**
  99119. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  99120. */
  99121. useObjectOrienationForDragging: boolean;
  99122. private _options;
  99123. /**
  99124. * Creates a pointer drag behavior that can be attached to a mesh
  99125. * @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)
  99126. */
  99127. constructor(options?: {
  99128. dragAxis?: Vector3;
  99129. dragPlaneNormal?: Vector3;
  99130. });
  99131. /**
  99132. * Predicate to determine if it is valid to move the object to a new position when it is moved
  99133. */
  99134. validateDrag: (targetPosition: Vector3) => boolean;
  99135. /**
  99136. * The name of the behavior
  99137. */
  99138. readonly name: string;
  99139. /**
  99140. * Initializes the behavior
  99141. */
  99142. init(): void;
  99143. private _tmpVector;
  99144. private _alternatePickedPoint;
  99145. private _worldDragAxis;
  99146. private _targetPosition;
  99147. private _attachedElement;
  99148. /**
  99149. * Attaches the drag behavior the passed in mesh
  99150. * @param ownerNode The mesh that will be dragged around once attached
  99151. */
  99152. attach(ownerNode: AbstractMesh): void;
  99153. /**
  99154. * Force relase the drag action by code.
  99155. */
  99156. releaseDrag(): void;
  99157. private _startDragRay;
  99158. private _lastPointerRay;
  99159. /**
  99160. * Simulates the start of a pointer drag event on the behavior
  99161. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  99162. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  99163. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  99164. */
  99165. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  99166. private _startDrag;
  99167. private _dragDelta;
  99168. private _moveDrag;
  99169. private _pickWithRayOnDragPlane;
  99170. private _pointA;
  99171. private _pointB;
  99172. private _pointC;
  99173. private _lineA;
  99174. private _lineB;
  99175. private _localAxis;
  99176. private _lookAt;
  99177. private _updateDragPlanePosition;
  99178. /**
  99179. * Detaches the behavior from the mesh
  99180. */
  99181. detach(): void;
  99182. }
  99183. }
  99184. declare module BABYLON {
  99185. /**
  99186. * A behavior that when attached to a mesh will allow the mesh to be scaled
  99187. */
  99188. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  99189. private _dragBehaviorA;
  99190. private _dragBehaviorB;
  99191. private _startDistance;
  99192. private _initialScale;
  99193. private _targetScale;
  99194. private _ownerNode;
  99195. private _sceneRenderObserver;
  99196. /**
  99197. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  99198. */
  99199. constructor();
  99200. /**
  99201. * The name of the behavior
  99202. */
  99203. readonly name: string;
  99204. /**
  99205. * Initializes the behavior
  99206. */
  99207. init(): void;
  99208. private _getCurrentDistance;
  99209. /**
  99210. * Attaches the scale behavior the passed in mesh
  99211. * @param ownerNode The mesh that will be scaled around once attached
  99212. */
  99213. attach(ownerNode: Mesh): void;
  99214. /**
  99215. * Detaches the behavior from the mesh
  99216. */
  99217. detach(): void;
  99218. }
  99219. }
  99220. declare module BABYLON {
  99221. /**
  99222. * 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
  99223. */
  99224. export class SixDofDragBehavior implements Behavior<Mesh> {
  99225. private static _virtualScene;
  99226. private _ownerNode;
  99227. private _sceneRenderObserver;
  99228. private _scene;
  99229. private _targetPosition;
  99230. private _virtualOriginMesh;
  99231. private _virtualDragMesh;
  99232. private _pointerObserver;
  99233. private _moving;
  99234. private _startingOrientation;
  99235. /**
  99236. * 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)
  99237. */
  99238. private zDragFactor;
  99239. /**
  99240. * If the object should rotate to face the drag origin
  99241. */
  99242. rotateDraggedObject: boolean;
  99243. /**
  99244. * If the behavior is currently in a dragging state
  99245. */
  99246. dragging: boolean;
  99247. /**
  99248. * 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)
  99249. */
  99250. dragDeltaRatio: number;
  99251. /**
  99252. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  99253. */
  99254. currentDraggingPointerID: number;
  99255. /**
  99256. * If camera controls should be detached during the drag
  99257. */
  99258. detachCameraControls: boolean;
  99259. /**
  99260. * Fires each time a drag starts
  99261. */
  99262. onDragStartObservable: Observable<{}>;
  99263. /**
  99264. * Fires each time a drag ends (eg. mouse release after drag)
  99265. */
  99266. onDragEndObservable: Observable<{}>;
  99267. /**
  99268. * 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
  99269. */
  99270. constructor();
  99271. /**
  99272. * The name of the behavior
  99273. */
  99274. readonly name: string;
  99275. /**
  99276. * Initializes the behavior
  99277. */
  99278. init(): void;
  99279. /**
  99280. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  99281. */
  99282. private readonly _pointerCamera;
  99283. /**
  99284. * Attaches the scale behavior the passed in mesh
  99285. * @param ownerNode The mesh that will be scaled around once attached
  99286. */
  99287. attach(ownerNode: Mesh): void;
  99288. /**
  99289. * Detaches the behavior from the mesh
  99290. */
  99291. detach(): void;
  99292. }
  99293. }
  99294. declare module BABYLON {
  99295. /**
  99296. * Class used to apply inverse kinematics to bones
  99297. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  99298. */
  99299. export class BoneIKController {
  99300. private static _tmpVecs;
  99301. private static _tmpQuat;
  99302. private static _tmpMats;
  99303. /**
  99304. * Gets or sets the target mesh
  99305. */
  99306. targetMesh: AbstractMesh;
  99307. /** Gets or sets the mesh used as pole */
  99308. poleTargetMesh: AbstractMesh;
  99309. /**
  99310. * Gets or sets the bone used as pole
  99311. */
  99312. poleTargetBone: Nullable<Bone>;
  99313. /**
  99314. * Gets or sets the target position
  99315. */
  99316. targetPosition: Vector3;
  99317. /**
  99318. * Gets or sets the pole target position
  99319. */
  99320. poleTargetPosition: Vector3;
  99321. /**
  99322. * Gets or sets the pole target local offset
  99323. */
  99324. poleTargetLocalOffset: Vector3;
  99325. /**
  99326. * Gets or sets the pole angle
  99327. */
  99328. poleAngle: number;
  99329. /**
  99330. * Gets or sets the mesh associated with the controller
  99331. */
  99332. mesh: AbstractMesh;
  99333. /**
  99334. * 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)
  99335. */
  99336. slerpAmount: number;
  99337. private _bone1Quat;
  99338. private _bone1Mat;
  99339. private _bone2Ang;
  99340. private _bone1;
  99341. private _bone2;
  99342. private _bone1Length;
  99343. private _bone2Length;
  99344. private _maxAngle;
  99345. private _maxReach;
  99346. private _rightHandedSystem;
  99347. private _bendAxis;
  99348. private _slerping;
  99349. private _adjustRoll;
  99350. /**
  99351. * Gets or sets maximum allowed angle
  99352. */
  99353. maxAngle: number;
  99354. /**
  99355. * Creates a new BoneIKController
  99356. * @param mesh defines the mesh to control
  99357. * @param bone defines the bone to control
  99358. * @param options defines options to set up the controller
  99359. */
  99360. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  99361. targetMesh?: AbstractMesh;
  99362. poleTargetMesh?: AbstractMesh;
  99363. poleTargetBone?: Bone;
  99364. poleTargetLocalOffset?: Vector3;
  99365. poleAngle?: number;
  99366. bendAxis?: Vector3;
  99367. maxAngle?: number;
  99368. slerpAmount?: number;
  99369. });
  99370. private _setMaxAngle;
  99371. /**
  99372. * Force the controller to update the bones
  99373. */
  99374. update(): void;
  99375. }
  99376. }
  99377. declare module BABYLON {
  99378. /**
  99379. * Class used to make a bone look toward a point in space
  99380. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  99381. */
  99382. export class BoneLookController {
  99383. private static _tmpVecs;
  99384. private static _tmpQuat;
  99385. private static _tmpMats;
  99386. /**
  99387. * The target Vector3 that the bone will look at
  99388. */
  99389. target: Vector3;
  99390. /**
  99391. * The mesh that the bone is attached to
  99392. */
  99393. mesh: AbstractMesh;
  99394. /**
  99395. * The bone that will be looking to the target
  99396. */
  99397. bone: Bone;
  99398. /**
  99399. * The up axis of the coordinate system that is used when the bone is rotated
  99400. */
  99401. upAxis: Vector3;
  99402. /**
  99403. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  99404. */
  99405. upAxisSpace: Space;
  99406. /**
  99407. * Used to make an adjustment to the yaw of the bone
  99408. */
  99409. adjustYaw: number;
  99410. /**
  99411. * Used to make an adjustment to the pitch of the bone
  99412. */
  99413. adjustPitch: number;
  99414. /**
  99415. * Used to make an adjustment to the roll of the bone
  99416. */
  99417. adjustRoll: number;
  99418. /**
  99419. * 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)
  99420. */
  99421. slerpAmount: number;
  99422. private _minYaw;
  99423. private _maxYaw;
  99424. private _minPitch;
  99425. private _maxPitch;
  99426. private _minYawSin;
  99427. private _minYawCos;
  99428. private _maxYawSin;
  99429. private _maxYawCos;
  99430. private _midYawConstraint;
  99431. private _minPitchTan;
  99432. private _maxPitchTan;
  99433. private _boneQuat;
  99434. private _slerping;
  99435. private _transformYawPitch;
  99436. private _transformYawPitchInv;
  99437. private _firstFrameSkipped;
  99438. private _yawRange;
  99439. private _fowardAxis;
  99440. /**
  99441. * Gets or sets the minimum yaw angle that the bone can look to
  99442. */
  99443. minYaw: number;
  99444. /**
  99445. * Gets or sets the maximum yaw angle that the bone can look to
  99446. */
  99447. maxYaw: number;
  99448. /**
  99449. * Gets or sets the minimum pitch angle that the bone can look to
  99450. */
  99451. minPitch: number;
  99452. /**
  99453. * Gets or sets the maximum pitch angle that the bone can look to
  99454. */
  99455. maxPitch: number;
  99456. /**
  99457. * Create a BoneLookController
  99458. * @param mesh the mesh that the bone belongs to
  99459. * @param bone the bone that will be looking to the target
  99460. * @param target the target Vector3 to look at
  99461. * @param options optional settings:
  99462. * * maxYaw: the maximum angle the bone will yaw to
  99463. * * minYaw: the minimum angle the bone will yaw to
  99464. * * maxPitch: the maximum angle the bone will pitch to
  99465. * * minPitch: the minimum angle the bone will yaw to
  99466. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  99467. * * upAxis: the up axis of the coordinate system
  99468. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  99469. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  99470. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  99471. * * adjustYaw: used to make an adjustment to the yaw of the bone
  99472. * * adjustPitch: used to make an adjustment to the pitch of the bone
  99473. * * adjustRoll: used to make an adjustment to the roll of the bone
  99474. **/
  99475. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  99476. maxYaw?: number;
  99477. minYaw?: number;
  99478. maxPitch?: number;
  99479. minPitch?: number;
  99480. slerpAmount?: number;
  99481. upAxis?: Vector3;
  99482. upAxisSpace?: Space;
  99483. yawAxis?: Vector3;
  99484. pitchAxis?: Vector3;
  99485. adjustYaw?: number;
  99486. adjustPitch?: number;
  99487. adjustRoll?: number;
  99488. });
  99489. /**
  99490. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  99491. */
  99492. update(): void;
  99493. private _getAngleDiff;
  99494. private _getAngleBetween;
  99495. private _isAngleBetween;
  99496. }
  99497. }
  99498. declare module BABYLON {
  99499. /**
  99500. * Manage the gamepad inputs to control an arc rotate camera.
  99501. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99502. */
  99503. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  99504. /**
  99505. * Defines the camera the input is attached to.
  99506. */
  99507. camera: ArcRotateCamera;
  99508. /**
  99509. * Defines the gamepad the input is gathering event from.
  99510. */
  99511. gamepad: Nullable<Gamepad>;
  99512. /**
  99513. * Defines the gamepad rotation sensiblity.
  99514. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  99515. */
  99516. gamepadRotationSensibility: number;
  99517. /**
  99518. * Defines the gamepad move sensiblity.
  99519. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  99520. */
  99521. gamepadMoveSensibility: number;
  99522. private _onGamepadConnectedObserver;
  99523. private _onGamepadDisconnectedObserver;
  99524. /**
  99525. * Attach the input controls to a specific dom element to get the input from.
  99526. * @param element Defines the element the controls should be listened from
  99527. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99528. */
  99529. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99530. /**
  99531. * Detach the current controls from the specified dom element.
  99532. * @param element Defines the element to stop listening the inputs from
  99533. */
  99534. detachControl(element: Nullable<HTMLElement>): void;
  99535. /**
  99536. * Update the current camera state depending on the inputs that have been used this frame.
  99537. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99538. */
  99539. checkInputs(): void;
  99540. /**
  99541. * Gets the class name of the current intput.
  99542. * @returns the class name
  99543. */
  99544. getClassName(): string;
  99545. /**
  99546. * Get the friendly name associated with the input class.
  99547. * @returns the input friendly name
  99548. */
  99549. getSimpleName(): string;
  99550. }
  99551. }
  99552. declare module BABYLON {
  99553. interface ArcRotateCameraInputsManager {
  99554. /**
  99555. * Add orientation input support to the input manager.
  99556. * @returns the current input manager
  99557. */
  99558. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  99559. }
  99560. /**
  99561. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  99562. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99563. */
  99564. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  99565. /**
  99566. * Defines the camera the input is attached to.
  99567. */
  99568. camera: ArcRotateCamera;
  99569. /**
  99570. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  99571. */
  99572. alphaCorrection: number;
  99573. /**
  99574. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  99575. */
  99576. gammaCorrection: number;
  99577. private _alpha;
  99578. private _gamma;
  99579. private _dirty;
  99580. private _deviceOrientationHandler;
  99581. /**
  99582. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  99583. */
  99584. constructor();
  99585. /**
  99586. * Attach the input controls to a specific dom element to get the input from.
  99587. * @param element Defines the element the controls should be listened from
  99588. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99589. */
  99590. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99591. /** @hidden */
  99592. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  99593. /**
  99594. * Update the current camera state depending on the inputs that have been used this frame.
  99595. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99596. */
  99597. checkInputs(): void;
  99598. /**
  99599. * Detach the current controls from the specified dom element.
  99600. * @param element Defines the element to stop listening the inputs from
  99601. */
  99602. detachControl(element: Nullable<HTMLElement>): void;
  99603. /**
  99604. * Gets the class name of the current intput.
  99605. * @returns the class name
  99606. */
  99607. getClassName(): string;
  99608. /**
  99609. * Get the friendly name associated with the input class.
  99610. * @returns the input friendly name
  99611. */
  99612. getSimpleName(): string;
  99613. }
  99614. }
  99615. declare module BABYLON {
  99616. /**
  99617. * Listen to mouse events to control the camera.
  99618. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99619. */
  99620. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  99621. /**
  99622. * Defines the camera the input is attached to.
  99623. */
  99624. camera: FlyCamera;
  99625. /**
  99626. * Defines if touch is enabled. (Default is true.)
  99627. */
  99628. touchEnabled: boolean;
  99629. /**
  99630. * Defines the buttons associated with the input to handle camera rotation.
  99631. */
  99632. buttons: number[];
  99633. /**
  99634. * Assign buttons for Yaw control.
  99635. */
  99636. buttonsYaw: number[];
  99637. /**
  99638. * Assign buttons for Pitch control.
  99639. */
  99640. buttonsPitch: number[];
  99641. /**
  99642. * Assign buttons for Roll control.
  99643. */
  99644. buttonsRoll: number[];
  99645. /**
  99646. * Detect if any button is being pressed while mouse is moved.
  99647. * -1 = Mouse locked.
  99648. * 0 = Left button.
  99649. * 1 = Middle Button.
  99650. * 2 = Right Button.
  99651. */
  99652. activeButton: number;
  99653. /**
  99654. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  99655. * Higher values reduce its sensitivity.
  99656. */
  99657. angularSensibility: number;
  99658. private _mousemoveCallback;
  99659. private _observer;
  99660. private _rollObserver;
  99661. private previousPosition;
  99662. private noPreventDefault;
  99663. private element;
  99664. /**
  99665. * Listen to mouse events to control the camera.
  99666. * @param touchEnabled Define if touch is enabled. (Default is true.)
  99667. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99668. */
  99669. constructor(touchEnabled?: boolean);
  99670. /**
  99671. * Attach the mouse control to the HTML DOM element.
  99672. * @param element Defines the element that listens to the input events.
  99673. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  99674. */
  99675. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99676. /**
  99677. * Detach the current controls from the specified dom element.
  99678. * @param element Defines the element to stop listening the inputs from
  99679. */
  99680. detachControl(element: Nullable<HTMLElement>): void;
  99681. /**
  99682. * Gets the class name of the current input.
  99683. * @returns the class name.
  99684. */
  99685. getClassName(): string;
  99686. /**
  99687. * Get the friendly name associated with the input class.
  99688. * @returns the input's friendly name.
  99689. */
  99690. getSimpleName(): string;
  99691. private _pointerInput;
  99692. private _onMouseMove;
  99693. /**
  99694. * Rotate camera by mouse offset.
  99695. */
  99696. private rotateCamera;
  99697. }
  99698. }
  99699. declare module BABYLON {
  99700. /**
  99701. * Default Inputs manager for the FlyCamera.
  99702. * It groups all the default supported inputs for ease of use.
  99703. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99704. */
  99705. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  99706. /**
  99707. * Instantiates a new FlyCameraInputsManager.
  99708. * @param camera Defines the camera the inputs belong to.
  99709. */
  99710. constructor(camera: FlyCamera);
  99711. /**
  99712. * Add keyboard input support to the input manager.
  99713. * @returns the new FlyCameraKeyboardMoveInput().
  99714. */
  99715. addKeyboard(): FlyCameraInputsManager;
  99716. /**
  99717. * Add mouse input support to the input manager.
  99718. * @param touchEnabled Enable touch screen support.
  99719. * @returns the new FlyCameraMouseInput().
  99720. */
  99721. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  99722. }
  99723. }
  99724. declare module BABYLON {
  99725. /**
  99726. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99727. * such as in a 3D Space Shooter or a Flight Simulator.
  99728. */
  99729. export class FlyCamera extends TargetCamera {
  99730. /**
  99731. * Define the collision ellipsoid of the camera.
  99732. * This is helpful for simulating a camera body, like a player's body.
  99733. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99734. */
  99735. ellipsoid: Vector3;
  99736. /**
  99737. * Define an offset for the position of the ellipsoid around the camera.
  99738. * This can be helpful if the camera is attached away from the player's body center,
  99739. * such as at its head.
  99740. */
  99741. ellipsoidOffset: Vector3;
  99742. /**
  99743. * Enable or disable collisions of the camera with the rest of the scene objects.
  99744. */
  99745. checkCollisions: boolean;
  99746. /**
  99747. * Enable or disable gravity on the camera.
  99748. */
  99749. applyGravity: boolean;
  99750. /**
  99751. * Define the current direction the camera is moving to.
  99752. */
  99753. cameraDirection: Vector3;
  99754. /**
  99755. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  99756. * This overrides and empties cameraRotation.
  99757. */
  99758. rotationQuaternion: Quaternion;
  99759. /**
  99760. * Track Roll to maintain the wanted Rolling when looking around.
  99761. */
  99762. _trackRoll: number;
  99763. /**
  99764. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  99765. */
  99766. rollCorrect: number;
  99767. /**
  99768. * Mimic a banked turn, Rolling the camera when Yawing.
  99769. * It's recommended to use rollCorrect = 10 for faster banking correction.
  99770. */
  99771. bankedTurn: boolean;
  99772. /**
  99773. * Limit in radians for how much Roll banking will add. (Default: 90°)
  99774. */
  99775. bankedTurnLimit: number;
  99776. /**
  99777. * Value of 0 disables the banked Roll.
  99778. * Value of 1 is equal to the Yaw angle in radians.
  99779. */
  99780. bankedTurnMultiplier: number;
  99781. /**
  99782. * The inputs manager loads all the input sources, such as keyboard and mouse.
  99783. */
  99784. inputs: FlyCameraInputsManager;
  99785. /**
  99786. * Gets the input sensibility for mouse input.
  99787. * Higher values reduce sensitivity.
  99788. */
  99789. /**
  99790. * Sets the input sensibility for a mouse input.
  99791. * Higher values reduce sensitivity.
  99792. */
  99793. angularSensibility: number;
  99794. /**
  99795. * Get the keys for camera movement forward.
  99796. */
  99797. /**
  99798. * Set the keys for camera movement forward.
  99799. */
  99800. keysForward: number[];
  99801. /**
  99802. * Get the keys for camera movement backward.
  99803. */
  99804. keysBackward: number[];
  99805. /**
  99806. * Get the keys for camera movement up.
  99807. */
  99808. /**
  99809. * Set the keys for camera movement up.
  99810. */
  99811. keysUp: number[];
  99812. /**
  99813. * Get the keys for camera movement down.
  99814. */
  99815. /**
  99816. * Set the keys for camera movement down.
  99817. */
  99818. keysDown: number[];
  99819. /**
  99820. * Get the keys for camera movement left.
  99821. */
  99822. /**
  99823. * Set the keys for camera movement left.
  99824. */
  99825. keysLeft: number[];
  99826. /**
  99827. * Set the keys for camera movement right.
  99828. */
  99829. /**
  99830. * Set the keys for camera movement right.
  99831. */
  99832. keysRight: number[];
  99833. /**
  99834. * Event raised when the camera collides with a mesh in the scene.
  99835. */
  99836. onCollide: (collidedMesh: AbstractMesh) => void;
  99837. private _collider;
  99838. private _needMoveForGravity;
  99839. private _oldPosition;
  99840. private _diffPosition;
  99841. private _newPosition;
  99842. /** @hidden */
  99843. _localDirection: Vector3;
  99844. /** @hidden */
  99845. _transformedDirection: Vector3;
  99846. /**
  99847. * Instantiates a FlyCamera.
  99848. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99849. * such as in a 3D Space Shooter or a Flight Simulator.
  99850. * @param name Define the name of the camera in the scene.
  99851. * @param position Define the starting position of the camera in the scene.
  99852. * @param scene Define the scene the camera belongs to.
  99853. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  99854. */
  99855. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99856. /**
  99857. * Attach a control to the HTML DOM element.
  99858. * @param element Defines the element that listens to the input events.
  99859. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  99860. */
  99861. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99862. /**
  99863. * Detach a control from the HTML DOM element.
  99864. * The camera will stop reacting to that input.
  99865. * @param element Defines the element that listens to the input events.
  99866. */
  99867. detachControl(element: HTMLElement): void;
  99868. private _collisionMask;
  99869. /**
  99870. * Get the mask that the camera ignores in collision events.
  99871. */
  99872. /**
  99873. * Set the mask that the camera ignores in collision events.
  99874. */
  99875. collisionMask: number;
  99876. /** @hidden */
  99877. _collideWithWorld(displacement: Vector3): void;
  99878. /** @hidden */
  99879. private _onCollisionPositionChange;
  99880. /** @hidden */
  99881. _checkInputs(): void;
  99882. /** @hidden */
  99883. _decideIfNeedsToMove(): boolean;
  99884. /** @hidden */
  99885. _updatePosition(): void;
  99886. /**
  99887. * Restore the Roll to its target value at the rate specified.
  99888. * @param rate - Higher means slower restoring.
  99889. * @hidden
  99890. */
  99891. restoreRoll(rate: number): void;
  99892. /**
  99893. * Destroy the camera and release the current resources held by it.
  99894. */
  99895. dispose(): void;
  99896. /**
  99897. * Get the current object class name.
  99898. * @returns the class name.
  99899. */
  99900. getClassName(): string;
  99901. }
  99902. }
  99903. declare module BABYLON {
  99904. /**
  99905. * Listen to keyboard events to control the camera.
  99906. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99907. */
  99908. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  99909. /**
  99910. * Defines the camera the input is attached to.
  99911. */
  99912. camera: FlyCamera;
  99913. /**
  99914. * The list of keyboard keys used to control the forward move of the camera.
  99915. */
  99916. keysForward: number[];
  99917. /**
  99918. * The list of keyboard keys used to control the backward move of the camera.
  99919. */
  99920. keysBackward: number[];
  99921. /**
  99922. * The list of keyboard keys used to control the forward move of the camera.
  99923. */
  99924. keysUp: number[];
  99925. /**
  99926. * The list of keyboard keys used to control the backward move of the camera.
  99927. */
  99928. keysDown: number[];
  99929. /**
  99930. * The list of keyboard keys used to control the right strafe move of the camera.
  99931. */
  99932. keysRight: number[];
  99933. /**
  99934. * The list of keyboard keys used to control the left strafe move of the camera.
  99935. */
  99936. keysLeft: number[];
  99937. private _keys;
  99938. private _onCanvasBlurObserver;
  99939. private _onKeyboardObserver;
  99940. private _engine;
  99941. private _scene;
  99942. /**
  99943. * Attach the input controls to a specific dom element to get the input from.
  99944. * @param element Defines the element the controls should be listened from
  99945. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99946. */
  99947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99948. /**
  99949. * Detach the current controls from the specified dom element.
  99950. * @param element Defines the element to stop listening the inputs from
  99951. */
  99952. detachControl(element: Nullable<HTMLElement>): void;
  99953. /**
  99954. * Gets the class name of the current intput.
  99955. * @returns the class name
  99956. */
  99957. getClassName(): string;
  99958. /** @hidden */
  99959. _onLostFocus(e: FocusEvent): void;
  99960. /**
  99961. * Get the friendly name associated with the input class.
  99962. * @returns the input friendly name
  99963. */
  99964. getSimpleName(): string;
  99965. /**
  99966. * Update the current camera state depending on the inputs that have been used this frame.
  99967. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99968. */
  99969. checkInputs(): void;
  99970. }
  99971. }
  99972. declare module BABYLON {
  99973. /**
  99974. * Manage the mouse wheel inputs to control a follow camera.
  99975. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99976. */
  99977. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  99978. /**
  99979. * Defines the camera the input is attached to.
  99980. */
  99981. camera: FollowCamera;
  99982. /**
  99983. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  99984. */
  99985. axisControlRadius: boolean;
  99986. /**
  99987. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  99988. */
  99989. axisControlHeight: boolean;
  99990. /**
  99991. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  99992. */
  99993. axisControlRotation: boolean;
  99994. /**
  99995. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  99996. * relation to mouseWheel events.
  99997. */
  99998. wheelPrecision: number;
  99999. /**
  100000. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  100001. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  100002. */
  100003. wheelDeltaPercentage: number;
  100004. private _wheel;
  100005. private _observer;
  100006. /**
  100007. * Attach the input controls to a specific dom element to get the input from.
  100008. * @param element Defines the element the controls should be listened from
  100009. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100010. */
  100011. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100012. /**
  100013. * Detach the current controls from the specified dom element.
  100014. * @param element Defines the element to stop listening the inputs from
  100015. */
  100016. detachControl(element: Nullable<HTMLElement>): void;
  100017. /**
  100018. * Gets the class name of the current intput.
  100019. * @returns the class name
  100020. */
  100021. getClassName(): string;
  100022. /**
  100023. * Get the friendly name associated with the input class.
  100024. * @returns the input friendly name
  100025. */
  100026. getSimpleName(): string;
  100027. }
  100028. }
  100029. declare module BABYLON {
  100030. /**
  100031. * Manage the pointers inputs to control an follow camera.
  100032. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100033. */
  100034. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  100035. /**
  100036. * Defines the camera the input is attached to.
  100037. */
  100038. camera: FollowCamera;
  100039. /**
  100040. * Gets the class name of the current input.
  100041. * @returns the class name
  100042. */
  100043. getClassName(): string;
  100044. /**
  100045. * Defines the pointer angular sensibility along the X axis or how fast is
  100046. * the camera rotating.
  100047. * A negative number will reverse the axis direction.
  100048. */
  100049. angularSensibilityX: number;
  100050. /**
  100051. * Defines the pointer angular sensibility along the Y axis or how fast is
  100052. * the camera rotating.
  100053. * A negative number will reverse the axis direction.
  100054. */
  100055. angularSensibilityY: number;
  100056. /**
  100057. * Defines the pointer pinch precision or how fast is the camera zooming.
  100058. * A negative number will reverse the axis direction.
  100059. */
  100060. pinchPrecision: number;
  100061. /**
  100062. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  100063. * from 0.
  100064. * It defines the percentage of current camera.radius to use as delta when
  100065. * pinch zoom is used.
  100066. */
  100067. pinchDeltaPercentage: number;
  100068. /**
  100069. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  100070. */
  100071. axisXControlRadius: boolean;
  100072. /**
  100073. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  100074. */
  100075. axisXControlHeight: boolean;
  100076. /**
  100077. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  100078. */
  100079. axisXControlRotation: boolean;
  100080. /**
  100081. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  100082. */
  100083. axisYControlRadius: boolean;
  100084. /**
  100085. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  100086. */
  100087. axisYControlHeight: boolean;
  100088. /**
  100089. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  100090. */
  100091. axisYControlRotation: boolean;
  100092. /**
  100093. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  100094. */
  100095. axisPinchControlRadius: boolean;
  100096. /**
  100097. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  100098. */
  100099. axisPinchControlHeight: boolean;
  100100. /**
  100101. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  100102. */
  100103. axisPinchControlRotation: boolean;
  100104. /**
  100105. * Log error messages if basic misconfiguration has occurred.
  100106. */
  100107. warningEnable: boolean;
  100108. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  100109. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  100110. private _warningCounter;
  100111. private _warning;
  100112. }
  100113. }
  100114. declare module BABYLON {
  100115. /**
  100116. * Default Inputs manager for the FollowCamera.
  100117. * It groups all the default supported inputs for ease of use.
  100118. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100119. */
  100120. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  100121. /**
  100122. * Instantiates a new FollowCameraInputsManager.
  100123. * @param camera Defines the camera the inputs belong to
  100124. */
  100125. constructor(camera: FollowCamera);
  100126. /**
  100127. * Add keyboard input support to the input manager.
  100128. * @returns the current input manager
  100129. */
  100130. addKeyboard(): FollowCameraInputsManager;
  100131. /**
  100132. * Add mouse wheel input support to the input manager.
  100133. * @returns the current input manager
  100134. */
  100135. addMouseWheel(): FollowCameraInputsManager;
  100136. /**
  100137. * Add pointers input support to the input manager.
  100138. * @returns the current input manager
  100139. */
  100140. addPointers(): FollowCameraInputsManager;
  100141. /**
  100142. * Add orientation input support to the input manager.
  100143. * @returns the current input manager
  100144. */
  100145. addVRDeviceOrientation(): FollowCameraInputsManager;
  100146. }
  100147. }
  100148. declare module BABYLON {
  100149. /**
  100150. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  100151. * an arc rotate version arcFollowCamera are available.
  100152. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100153. */
  100154. export class FollowCamera extends TargetCamera {
  100155. /**
  100156. * Distance the follow camera should follow an object at
  100157. */
  100158. radius: number;
  100159. /**
  100160. * Minimum allowed distance of the camera to the axis of rotation
  100161. * (The camera can not get closer).
  100162. * This can help limiting how the Camera is able to move in the scene.
  100163. */
  100164. lowerRadiusLimit: Nullable<number>;
  100165. /**
  100166. * Maximum allowed distance of the camera to the axis of rotation
  100167. * (The camera can not get further).
  100168. * This can help limiting how the Camera is able to move in the scene.
  100169. */
  100170. upperRadiusLimit: Nullable<number>;
  100171. /**
  100172. * Define a rotation offset between the camera and the object it follows
  100173. */
  100174. rotationOffset: number;
  100175. /**
  100176. * Minimum allowed angle to camera position relative to target object.
  100177. * This can help limiting how the Camera is able to move in the scene.
  100178. */
  100179. lowerRotationOffsetLimit: Nullable<number>;
  100180. /**
  100181. * Maximum allowed angle to camera position relative to target object.
  100182. * This can help limiting how the Camera is able to move in the scene.
  100183. */
  100184. upperRotationOffsetLimit: Nullable<number>;
  100185. /**
  100186. * Define a height offset between the camera and the object it follows.
  100187. * It can help following an object from the top (like a car chaing a plane)
  100188. */
  100189. heightOffset: number;
  100190. /**
  100191. * Minimum allowed height of camera position relative to target object.
  100192. * This can help limiting how the Camera is able to move in the scene.
  100193. */
  100194. lowerHeightOffsetLimit: Nullable<number>;
  100195. /**
  100196. * Maximum allowed height of camera position relative to target object.
  100197. * This can help limiting how the Camera is able to move in the scene.
  100198. */
  100199. upperHeightOffsetLimit: Nullable<number>;
  100200. /**
  100201. * Define how fast the camera can accelerate to follow it s target.
  100202. */
  100203. cameraAcceleration: number;
  100204. /**
  100205. * Define the speed limit of the camera following an object.
  100206. */
  100207. maxCameraSpeed: number;
  100208. /**
  100209. * Define the target of the camera.
  100210. */
  100211. lockedTarget: Nullable<AbstractMesh>;
  100212. /**
  100213. * Defines the input associated with the camera.
  100214. */
  100215. inputs: FollowCameraInputsManager;
  100216. /**
  100217. * Instantiates the follow camera.
  100218. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100219. * @param name Define the name of the camera in the scene
  100220. * @param position Define the position of the camera
  100221. * @param scene Define the scene the camera belong to
  100222. * @param lockedTarget Define the target of the camera
  100223. */
  100224. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  100225. private _follow;
  100226. /**
  100227. * Attached controls to the current camera.
  100228. * @param element Defines the element the controls should be listened from
  100229. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100230. */
  100231. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100232. /**
  100233. * Detach the current controls from the camera.
  100234. * The camera will stop reacting to inputs.
  100235. * @param element Defines the element to stop listening the inputs from
  100236. */
  100237. detachControl(element: HTMLElement): void;
  100238. /** @hidden */
  100239. _checkInputs(): void;
  100240. private _checkLimits;
  100241. /**
  100242. * Gets the camera class name.
  100243. * @returns the class name
  100244. */
  100245. getClassName(): string;
  100246. }
  100247. /**
  100248. * Arc Rotate version of the follow camera.
  100249. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  100250. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100251. */
  100252. export class ArcFollowCamera extends TargetCamera {
  100253. /** The longitudinal angle of the camera */
  100254. alpha: number;
  100255. /** The latitudinal angle of the camera */
  100256. beta: number;
  100257. /** The radius of the camera from its target */
  100258. radius: number;
  100259. /** Define the camera target (the messh it should follow) */
  100260. target: Nullable<AbstractMesh>;
  100261. private _cartesianCoordinates;
  100262. /**
  100263. * Instantiates a new ArcFollowCamera
  100264. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100265. * @param name Define the name of the camera
  100266. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  100267. * @param beta Define the rotation angle of the camera around the elevation axis
  100268. * @param radius Define the radius of the camera from its target point
  100269. * @param target Define the target of the camera
  100270. * @param scene Define the scene the camera belongs to
  100271. */
  100272. constructor(name: string,
  100273. /** The longitudinal angle of the camera */
  100274. alpha: number,
  100275. /** The latitudinal angle of the camera */
  100276. beta: number,
  100277. /** The radius of the camera from its target */
  100278. radius: number,
  100279. /** Define the camera target (the messh it should follow) */
  100280. target: Nullable<AbstractMesh>, scene: Scene);
  100281. private _follow;
  100282. /** @hidden */
  100283. _checkInputs(): void;
  100284. /**
  100285. * Returns the class name of the object.
  100286. * It is mostly used internally for serialization purposes.
  100287. */
  100288. getClassName(): string;
  100289. }
  100290. }
  100291. declare module BABYLON {
  100292. /**
  100293. * Manage the keyboard inputs to control the movement of a follow camera.
  100294. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100295. */
  100296. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  100297. /**
  100298. * Defines the camera the input is attached to.
  100299. */
  100300. camera: FollowCamera;
  100301. /**
  100302. * Defines the list of key codes associated with the up action (increase heightOffset)
  100303. */
  100304. keysHeightOffsetIncr: number[];
  100305. /**
  100306. * Defines the list of key codes associated with the down action (decrease heightOffset)
  100307. */
  100308. keysHeightOffsetDecr: number[];
  100309. /**
  100310. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  100311. */
  100312. keysHeightOffsetModifierAlt: boolean;
  100313. /**
  100314. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  100315. */
  100316. keysHeightOffsetModifierCtrl: boolean;
  100317. /**
  100318. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  100319. */
  100320. keysHeightOffsetModifierShift: boolean;
  100321. /**
  100322. * Defines the list of key codes associated with the left action (increase rotationOffset)
  100323. */
  100324. keysRotationOffsetIncr: number[];
  100325. /**
  100326. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  100327. */
  100328. keysRotationOffsetDecr: number[];
  100329. /**
  100330. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  100331. */
  100332. keysRotationOffsetModifierAlt: boolean;
  100333. /**
  100334. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  100335. */
  100336. keysRotationOffsetModifierCtrl: boolean;
  100337. /**
  100338. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  100339. */
  100340. keysRotationOffsetModifierShift: boolean;
  100341. /**
  100342. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  100343. */
  100344. keysRadiusIncr: number[];
  100345. /**
  100346. * Defines the list of key codes associated with the zoom-out action (increase radius)
  100347. */
  100348. keysRadiusDecr: number[];
  100349. /**
  100350. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  100351. */
  100352. keysRadiusModifierAlt: boolean;
  100353. /**
  100354. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  100355. */
  100356. keysRadiusModifierCtrl: boolean;
  100357. /**
  100358. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  100359. */
  100360. keysRadiusModifierShift: boolean;
  100361. /**
  100362. * Defines the rate of change of heightOffset.
  100363. */
  100364. heightSensibility: number;
  100365. /**
  100366. * Defines the rate of change of rotationOffset.
  100367. */
  100368. rotationSensibility: number;
  100369. /**
  100370. * Defines the rate of change of radius.
  100371. */
  100372. radiusSensibility: number;
  100373. private _keys;
  100374. private _ctrlPressed;
  100375. private _altPressed;
  100376. private _shiftPressed;
  100377. private _onCanvasBlurObserver;
  100378. private _onKeyboardObserver;
  100379. private _engine;
  100380. private _scene;
  100381. /**
  100382. * Attach the input controls to a specific dom element to get the input from.
  100383. * @param element Defines the element the controls should be listened from
  100384. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100385. */
  100386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100387. /**
  100388. * Detach the current controls from the specified dom element.
  100389. * @param element Defines the element to stop listening the inputs from
  100390. */
  100391. detachControl(element: Nullable<HTMLElement>): void;
  100392. /**
  100393. * Update the current camera state depending on the inputs that have been used this frame.
  100394. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100395. */
  100396. checkInputs(): void;
  100397. /**
  100398. * Gets the class name of the current input.
  100399. * @returns the class name
  100400. */
  100401. getClassName(): string;
  100402. /**
  100403. * Get the friendly name associated with the input class.
  100404. * @returns the input friendly name
  100405. */
  100406. getSimpleName(): string;
  100407. /**
  100408. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100409. * allow modification of the heightOffset value.
  100410. */
  100411. private _modifierHeightOffset;
  100412. /**
  100413. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100414. * allow modification of the rotationOffset value.
  100415. */
  100416. private _modifierRotationOffset;
  100417. /**
  100418. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100419. * allow modification of the radius value.
  100420. */
  100421. private _modifierRadius;
  100422. }
  100423. }
  100424. declare module BABYLON {
  100425. interface FreeCameraInputsManager {
  100426. /**
  100427. * @hidden
  100428. */
  100429. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  100430. /**
  100431. * Add orientation input support to the input manager.
  100432. * @returns the current input manager
  100433. */
  100434. addDeviceOrientation(): FreeCameraInputsManager;
  100435. }
  100436. /**
  100437. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  100438. * Screen rotation is taken into account.
  100439. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100440. */
  100441. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  100442. private _camera;
  100443. private _screenOrientationAngle;
  100444. private _constantTranform;
  100445. private _screenQuaternion;
  100446. private _alpha;
  100447. private _beta;
  100448. private _gamma;
  100449. /**
  100450. * Can be used to detect if a device orientation sensor is availible on a device
  100451. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  100452. * @returns a promise that will resolve on orientation change
  100453. */
  100454. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  100455. /**
  100456. * @hidden
  100457. */
  100458. _onDeviceOrientationChangedObservable: Observable<void>;
  100459. /**
  100460. * Instantiates a new input
  100461. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100462. */
  100463. constructor();
  100464. /**
  100465. * Define the camera controlled by the input.
  100466. */
  100467. camera: FreeCamera;
  100468. /**
  100469. * Attach the input controls to a specific dom element to get the input from.
  100470. * @param element Defines the element the controls should be listened from
  100471. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100472. */
  100473. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100474. private _orientationChanged;
  100475. private _deviceOrientation;
  100476. /**
  100477. * Detach the current controls from the specified dom element.
  100478. * @param element Defines the element to stop listening the inputs from
  100479. */
  100480. detachControl(element: Nullable<HTMLElement>): void;
  100481. /**
  100482. * Update the current camera state depending on the inputs that have been used this frame.
  100483. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100484. */
  100485. checkInputs(): void;
  100486. /**
  100487. * Gets the class name of the current intput.
  100488. * @returns the class name
  100489. */
  100490. getClassName(): string;
  100491. /**
  100492. * Get the friendly name associated with the input class.
  100493. * @returns the input friendly name
  100494. */
  100495. getSimpleName(): string;
  100496. }
  100497. }
  100498. declare module BABYLON {
  100499. /**
  100500. * Manage the gamepad inputs to control a free camera.
  100501. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100502. */
  100503. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  100504. /**
  100505. * Define the camera the input is attached to.
  100506. */
  100507. camera: FreeCamera;
  100508. /**
  100509. * Define the Gamepad controlling the input
  100510. */
  100511. gamepad: Nullable<Gamepad>;
  100512. /**
  100513. * Defines the gamepad rotation sensiblity.
  100514. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100515. */
  100516. gamepadAngularSensibility: number;
  100517. /**
  100518. * Defines the gamepad move sensiblity.
  100519. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100520. */
  100521. gamepadMoveSensibility: number;
  100522. private _onGamepadConnectedObserver;
  100523. private _onGamepadDisconnectedObserver;
  100524. private _cameraTransform;
  100525. private _deltaTransform;
  100526. private _vector3;
  100527. private _vector2;
  100528. /**
  100529. * Attach the input controls to a specific dom element to get the input from.
  100530. * @param element Defines the element the controls should be listened from
  100531. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100532. */
  100533. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100534. /**
  100535. * Detach the current controls from the specified dom element.
  100536. * @param element Defines the element to stop listening the inputs from
  100537. */
  100538. detachControl(element: Nullable<HTMLElement>): void;
  100539. /**
  100540. * Update the current camera state depending on the inputs that have been used this frame.
  100541. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100542. */
  100543. checkInputs(): void;
  100544. /**
  100545. * Gets the class name of the current intput.
  100546. * @returns the class name
  100547. */
  100548. getClassName(): string;
  100549. /**
  100550. * Get the friendly name associated with the input class.
  100551. * @returns the input friendly name
  100552. */
  100553. getSimpleName(): string;
  100554. }
  100555. }
  100556. declare module BABYLON {
  100557. /**
  100558. * Defines the potential axis of a Joystick
  100559. */
  100560. export enum JoystickAxis {
  100561. /** X axis */
  100562. X = 0,
  100563. /** Y axis */
  100564. Y = 1,
  100565. /** Z axis */
  100566. Z = 2
  100567. }
  100568. /**
  100569. * Class used to define virtual joystick (used in touch mode)
  100570. */
  100571. export class VirtualJoystick {
  100572. /**
  100573. * Gets or sets a boolean indicating that left and right values must be inverted
  100574. */
  100575. reverseLeftRight: boolean;
  100576. /**
  100577. * Gets or sets a boolean indicating that up and down values must be inverted
  100578. */
  100579. reverseUpDown: boolean;
  100580. /**
  100581. * Gets the offset value for the position (ie. the change of the position value)
  100582. */
  100583. deltaPosition: Vector3;
  100584. /**
  100585. * Gets a boolean indicating if the virtual joystick was pressed
  100586. */
  100587. pressed: boolean;
  100588. /**
  100589. * Canvas the virtual joystick will render onto, default z-index of this is 5
  100590. */
  100591. static Canvas: Nullable<HTMLCanvasElement>;
  100592. private static _globalJoystickIndex;
  100593. private static vjCanvasContext;
  100594. private static vjCanvasWidth;
  100595. private static vjCanvasHeight;
  100596. private static halfWidth;
  100597. private _action;
  100598. private _axisTargetedByLeftAndRight;
  100599. private _axisTargetedByUpAndDown;
  100600. private _joystickSensibility;
  100601. private _inversedSensibility;
  100602. private _joystickPointerID;
  100603. private _joystickColor;
  100604. private _joystickPointerPos;
  100605. private _joystickPreviousPointerPos;
  100606. private _joystickPointerStartPos;
  100607. private _deltaJoystickVector;
  100608. private _leftJoystick;
  100609. private _touches;
  100610. private _onPointerDownHandlerRef;
  100611. private _onPointerMoveHandlerRef;
  100612. private _onPointerUpHandlerRef;
  100613. private _onResize;
  100614. /**
  100615. * Creates a new virtual joystick
  100616. * @param leftJoystick defines that the joystick is for left hand (false by default)
  100617. */
  100618. constructor(leftJoystick?: boolean);
  100619. /**
  100620. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  100621. * @param newJoystickSensibility defines the new sensibility
  100622. */
  100623. setJoystickSensibility(newJoystickSensibility: number): void;
  100624. private _onPointerDown;
  100625. private _onPointerMove;
  100626. private _onPointerUp;
  100627. /**
  100628. * Change the color of the virtual joystick
  100629. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  100630. */
  100631. setJoystickColor(newColor: string): void;
  100632. /**
  100633. * Defines a callback to call when the joystick is touched
  100634. * @param action defines the callback
  100635. */
  100636. setActionOnTouch(action: () => any): void;
  100637. /**
  100638. * Defines which axis you'd like to control for left & right
  100639. * @param axis defines the axis to use
  100640. */
  100641. setAxisForLeftRight(axis: JoystickAxis): void;
  100642. /**
  100643. * Defines which axis you'd like to control for up & down
  100644. * @param axis defines the axis to use
  100645. */
  100646. setAxisForUpDown(axis: JoystickAxis): void;
  100647. private _drawVirtualJoystick;
  100648. /**
  100649. * Release internal HTML canvas
  100650. */
  100651. releaseCanvas(): void;
  100652. }
  100653. }
  100654. declare module BABYLON {
  100655. interface FreeCameraInputsManager {
  100656. /**
  100657. * Add virtual joystick input support to the input manager.
  100658. * @returns the current input manager
  100659. */
  100660. addVirtualJoystick(): FreeCameraInputsManager;
  100661. }
  100662. /**
  100663. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  100664. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100665. */
  100666. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  100667. /**
  100668. * Defines the camera the input is attached to.
  100669. */
  100670. camera: FreeCamera;
  100671. private _leftjoystick;
  100672. private _rightjoystick;
  100673. /**
  100674. * Gets the left stick of the virtual joystick.
  100675. * @returns The virtual Joystick
  100676. */
  100677. getLeftJoystick(): VirtualJoystick;
  100678. /**
  100679. * Gets the right stick of the virtual joystick.
  100680. * @returns The virtual Joystick
  100681. */
  100682. getRightJoystick(): VirtualJoystick;
  100683. /**
  100684. * Update the current camera state depending on the inputs that have been used this frame.
  100685. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100686. */
  100687. checkInputs(): void;
  100688. /**
  100689. * Attach the input controls to a specific dom element to get the input from.
  100690. * @param element Defines the element the controls should be listened from
  100691. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100692. */
  100693. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100694. /**
  100695. * Detach the current controls from the specified dom element.
  100696. * @param element Defines the element to stop listening the inputs from
  100697. */
  100698. detachControl(element: Nullable<HTMLElement>): void;
  100699. /**
  100700. * Gets the class name of the current intput.
  100701. * @returns the class name
  100702. */
  100703. getClassName(): string;
  100704. /**
  100705. * Get the friendly name associated with the input class.
  100706. * @returns the input friendly name
  100707. */
  100708. getSimpleName(): string;
  100709. }
  100710. }
  100711. declare module BABYLON {
  100712. /**
  100713. * This represents a FPS type of camera controlled by touch.
  100714. * This is like a universal camera minus the Gamepad controls.
  100715. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100716. */
  100717. export class TouchCamera extends FreeCamera {
  100718. /**
  100719. * Defines the touch sensibility for rotation.
  100720. * The higher the faster.
  100721. */
  100722. touchAngularSensibility: number;
  100723. /**
  100724. * Defines the touch sensibility for move.
  100725. * The higher the faster.
  100726. */
  100727. touchMoveSensibility: number;
  100728. /**
  100729. * Instantiates a new touch camera.
  100730. * This represents a FPS type of camera controlled by touch.
  100731. * This is like a universal camera minus the Gamepad controls.
  100732. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100733. * @param name Define the name of the camera in the scene
  100734. * @param position Define the start position of the camera in the scene
  100735. * @param scene Define the scene the camera belongs to
  100736. */
  100737. constructor(name: string, position: Vector3, scene: Scene);
  100738. /**
  100739. * Gets the current object class name.
  100740. * @return the class name
  100741. */
  100742. getClassName(): string;
  100743. /** @hidden */
  100744. _setupInputs(): void;
  100745. }
  100746. }
  100747. declare module BABYLON {
  100748. /**
  100749. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  100750. * being tilted forward or back and left or right.
  100751. */
  100752. export class DeviceOrientationCamera extends FreeCamera {
  100753. private _initialQuaternion;
  100754. private _quaternionCache;
  100755. private _tmpDragQuaternion;
  100756. /**
  100757. * Creates a new device orientation camera
  100758. * @param name The name of the camera
  100759. * @param position The start position camera
  100760. * @param scene The scene the camera belongs to
  100761. */
  100762. constructor(name: string, position: Vector3, scene: Scene);
  100763. /**
  100764. * @hidden
  100765. * Disabled pointer input on first orientation sensor update (Default: true)
  100766. */
  100767. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  100768. private _dragFactor;
  100769. /**
  100770. * Enabled turning on the y axis when the orientation sensor is active
  100771. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  100772. */
  100773. enableHorizontalDragging(dragFactor?: number): void;
  100774. /**
  100775. * Gets the current instance class name ("DeviceOrientationCamera").
  100776. * This helps avoiding instanceof at run time.
  100777. * @returns the class name
  100778. */
  100779. getClassName(): string;
  100780. /**
  100781. * @hidden
  100782. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  100783. */
  100784. _checkInputs(): void;
  100785. /**
  100786. * Reset the camera to its default orientation on the specified axis only.
  100787. * @param axis The axis to reset
  100788. */
  100789. resetToCurrentRotation(axis?: Axis): void;
  100790. }
  100791. }
  100792. declare module BABYLON {
  100793. /**
  100794. * Defines supported buttons for XBox360 compatible gamepads
  100795. */
  100796. export enum Xbox360Button {
  100797. /** A */
  100798. A = 0,
  100799. /** B */
  100800. B = 1,
  100801. /** X */
  100802. X = 2,
  100803. /** Y */
  100804. Y = 3,
  100805. /** Start */
  100806. Start = 4,
  100807. /** Back */
  100808. Back = 5,
  100809. /** Left button */
  100810. LB = 6,
  100811. /** Right button */
  100812. RB = 7,
  100813. /** Left stick */
  100814. LeftStick = 8,
  100815. /** Right stick */
  100816. RightStick = 9
  100817. }
  100818. /** Defines values for XBox360 DPad */
  100819. export enum Xbox360Dpad {
  100820. /** Up */
  100821. Up = 0,
  100822. /** Down */
  100823. Down = 1,
  100824. /** Left */
  100825. Left = 2,
  100826. /** Right */
  100827. Right = 3
  100828. }
  100829. /**
  100830. * Defines a XBox360 gamepad
  100831. */
  100832. export class Xbox360Pad extends Gamepad {
  100833. private _leftTrigger;
  100834. private _rightTrigger;
  100835. private _onlefttriggerchanged;
  100836. private _onrighttriggerchanged;
  100837. private _onbuttondown;
  100838. private _onbuttonup;
  100839. private _ondpaddown;
  100840. private _ondpadup;
  100841. /** Observable raised when a button is pressed */
  100842. onButtonDownObservable: Observable<Xbox360Button>;
  100843. /** Observable raised when a button is released */
  100844. onButtonUpObservable: Observable<Xbox360Button>;
  100845. /** Observable raised when a pad is pressed */
  100846. onPadDownObservable: Observable<Xbox360Dpad>;
  100847. /** Observable raised when a pad is released */
  100848. onPadUpObservable: Observable<Xbox360Dpad>;
  100849. private _buttonA;
  100850. private _buttonB;
  100851. private _buttonX;
  100852. private _buttonY;
  100853. private _buttonBack;
  100854. private _buttonStart;
  100855. private _buttonLB;
  100856. private _buttonRB;
  100857. private _buttonLeftStick;
  100858. private _buttonRightStick;
  100859. private _dPadUp;
  100860. private _dPadDown;
  100861. private _dPadLeft;
  100862. private _dPadRight;
  100863. private _isXboxOnePad;
  100864. /**
  100865. * Creates a new XBox360 gamepad object
  100866. * @param id defines the id of this gamepad
  100867. * @param index defines its index
  100868. * @param gamepad defines the internal HTML gamepad object
  100869. * @param xboxOne defines if it is a XBox One gamepad
  100870. */
  100871. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  100872. /**
  100873. * Defines the callback to call when left trigger is pressed
  100874. * @param callback defines the callback to use
  100875. */
  100876. onlefttriggerchanged(callback: (value: number) => void): void;
  100877. /**
  100878. * Defines the callback to call when right trigger is pressed
  100879. * @param callback defines the callback to use
  100880. */
  100881. onrighttriggerchanged(callback: (value: number) => void): void;
  100882. /**
  100883. * Gets the left trigger value
  100884. */
  100885. /**
  100886. * Sets the left trigger value
  100887. */
  100888. leftTrigger: number;
  100889. /**
  100890. * Gets the right trigger value
  100891. */
  100892. /**
  100893. * Sets the right trigger value
  100894. */
  100895. rightTrigger: number;
  100896. /**
  100897. * Defines the callback to call when a button is pressed
  100898. * @param callback defines the callback to use
  100899. */
  100900. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  100901. /**
  100902. * Defines the callback to call when a button is released
  100903. * @param callback defines the callback to use
  100904. */
  100905. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  100906. /**
  100907. * Defines the callback to call when a pad is pressed
  100908. * @param callback defines the callback to use
  100909. */
  100910. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  100911. /**
  100912. * Defines the callback to call when a pad is released
  100913. * @param callback defines the callback to use
  100914. */
  100915. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  100916. private _setButtonValue;
  100917. private _setDPadValue;
  100918. /**
  100919. * Gets the value of the `A` button
  100920. */
  100921. /**
  100922. * Sets the value of the `A` button
  100923. */
  100924. buttonA: number;
  100925. /**
  100926. * Gets the value of the `B` button
  100927. */
  100928. /**
  100929. * Sets the value of the `B` button
  100930. */
  100931. buttonB: number;
  100932. /**
  100933. * Gets the value of the `X` button
  100934. */
  100935. /**
  100936. * Sets the value of the `X` button
  100937. */
  100938. buttonX: number;
  100939. /**
  100940. * Gets the value of the `Y` button
  100941. */
  100942. /**
  100943. * Sets the value of the `Y` button
  100944. */
  100945. buttonY: number;
  100946. /**
  100947. * Gets the value of the `Start` button
  100948. */
  100949. /**
  100950. * Sets the value of the `Start` button
  100951. */
  100952. buttonStart: number;
  100953. /**
  100954. * Gets the value of the `Back` button
  100955. */
  100956. /**
  100957. * Sets the value of the `Back` button
  100958. */
  100959. buttonBack: number;
  100960. /**
  100961. * Gets the value of the `Left` button
  100962. */
  100963. /**
  100964. * Sets the value of the `Left` button
  100965. */
  100966. buttonLB: number;
  100967. /**
  100968. * Gets the value of the `Right` button
  100969. */
  100970. /**
  100971. * Sets the value of the `Right` button
  100972. */
  100973. buttonRB: number;
  100974. /**
  100975. * Gets the value of the Left joystick
  100976. */
  100977. /**
  100978. * Sets the value of the Left joystick
  100979. */
  100980. buttonLeftStick: number;
  100981. /**
  100982. * Gets the value of the Right joystick
  100983. */
  100984. /**
  100985. * Sets the value of the Right joystick
  100986. */
  100987. buttonRightStick: number;
  100988. /**
  100989. * Gets the value of D-pad up
  100990. */
  100991. /**
  100992. * Sets the value of D-pad up
  100993. */
  100994. dPadUp: number;
  100995. /**
  100996. * Gets the value of D-pad down
  100997. */
  100998. /**
  100999. * Sets the value of D-pad down
  101000. */
  101001. dPadDown: number;
  101002. /**
  101003. * Gets the value of D-pad left
  101004. */
  101005. /**
  101006. * Sets the value of D-pad left
  101007. */
  101008. dPadLeft: number;
  101009. /**
  101010. * Gets the value of D-pad right
  101011. */
  101012. /**
  101013. * Sets the value of D-pad right
  101014. */
  101015. dPadRight: number;
  101016. /**
  101017. * Force the gamepad to synchronize with device values
  101018. */
  101019. update(): void;
  101020. /**
  101021. * Disposes the gamepad
  101022. */
  101023. dispose(): void;
  101024. }
  101025. }
  101026. declare module BABYLON {
  101027. /**
  101028. * Manager for handling gamepads
  101029. */
  101030. export class GamepadManager {
  101031. private _scene?;
  101032. private _babylonGamepads;
  101033. private _oneGamepadConnected;
  101034. /** @hidden */
  101035. _isMonitoring: boolean;
  101036. private _gamepadEventSupported;
  101037. private _gamepadSupport;
  101038. /**
  101039. * observable to be triggered when the gamepad controller has been connected
  101040. */
  101041. onGamepadConnectedObservable: Observable<Gamepad>;
  101042. /**
  101043. * observable to be triggered when the gamepad controller has been disconnected
  101044. */
  101045. onGamepadDisconnectedObservable: Observable<Gamepad>;
  101046. private _onGamepadConnectedEvent;
  101047. private _onGamepadDisconnectedEvent;
  101048. /**
  101049. * Initializes the gamepad manager
  101050. * @param _scene BabylonJS scene
  101051. */
  101052. constructor(_scene?: Scene | undefined);
  101053. /**
  101054. * The gamepads in the game pad manager
  101055. */
  101056. readonly gamepads: Gamepad[];
  101057. /**
  101058. * Get the gamepad controllers based on type
  101059. * @param type The type of gamepad controller
  101060. * @returns Nullable gamepad
  101061. */
  101062. getGamepadByType(type?: number): Nullable<Gamepad>;
  101063. /**
  101064. * Disposes the gamepad manager
  101065. */
  101066. dispose(): void;
  101067. private _addNewGamepad;
  101068. private _startMonitoringGamepads;
  101069. private _stopMonitoringGamepads;
  101070. /** @hidden */
  101071. _checkGamepadsStatus(): void;
  101072. private _updateGamepadObjects;
  101073. }
  101074. }
  101075. declare module BABYLON {
  101076. interface Scene {
  101077. /** @hidden */
  101078. _gamepadManager: Nullable<GamepadManager>;
  101079. /**
  101080. * Gets the gamepad manager associated with the scene
  101081. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  101082. */
  101083. gamepadManager: GamepadManager;
  101084. }
  101085. /**
  101086. * Interface representing a free camera inputs manager
  101087. */
  101088. interface FreeCameraInputsManager {
  101089. /**
  101090. * Adds gamepad input support to the FreeCameraInputsManager.
  101091. * @returns the FreeCameraInputsManager
  101092. */
  101093. addGamepad(): FreeCameraInputsManager;
  101094. }
  101095. /**
  101096. * Interface representing an arc rotate camera inputs manager
  101097. */
  101098. interface ArcRotateCameraInputsManager {
  101099. /**
  101100. * Adds gamepad input support to the ArcRotateCamera InputManager.
  101101. * @returns the camera inputs manager
  101102. */
  101103. addGamepad(): ArcRotateCameraInputsManager;
  101104. }
  101105. /**
  101106. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  101107. */
  101108. export class GamepadSystemSceneComponent implements ISceneComponent {
  101109. /**
  101110. * The component name helpfull to identify the component in the list of scene components.
  101111. */
  101112. readonly name: string;
  101113. /**
  101114. * The scene the component belongs to.
  101115. */
  101116. scene: Scene;
  101117. /**
  101118. * Creates a new instance of the component for the given scene
  101119. * @param scene Defines the scene to register the component in
  101120. */
  101121. constructor(scene: Scene);
  101122. /**
  101123. * Registers the component in a given scene
  101124. */
  101125. register(): void;
  101126. /**
  101127. * Rebuilds the elements related to this component in case of
  101128. * context lost for instance.
  101129. */
  101130. rebuild(): void;
  101131. /**
  101132. * Disposes the component and the associated ressources
  101133. */
  101134. dispose(): void;
  101135. private _beforeCameraUpdate;
  101136. }
  101137. }
  101138. declare module BABYLON {
  101139. /**
  101140. * 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,
  101141. * which still works and will still be found in many Playgrounds.
  101142. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101143. */
  101144. export class UniversalCamera extends TouchCamera {
  101145. /**
  101146. * Defines the gamepad rotation sensiblity.
  101147. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  101148. */
  101149. gamepadAngularSensibility: number;
  101150. /**
  101151. * Defines the gamepad move sensiblity.
  101152. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  101153. */
  101154. gamepadMoveSensibility: number;
  101155. /**
  101156. * 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,
  101157. * which still works and will still be found in many Playgrounds.
  101158. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101159. * @param name Define the name of the camera in the scene
  101160. * @param position Define the start position of the camera in the scene
  101161. * @param scene Define the scene the camera belongs to
  101162. */
  101163. constructor(name: string, position: Vector3, scene: Scene);
  101164. /**
  101165. * Gets the current object class name.
  101166. * @return the class name
  101167. */
  101168. getClassName(): string;
  101169. }
  101170. }
  101171. declare module BABYLON {
  101172. /**
  101173. * This represents a FPS type of camera. This is only here for back compat purpose.
  101174. * Please use the UniversalCamera instead as both are identical.
  101175. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101176. */
  101177. export class GamepadCamera extends UniversalCamera {
  101178. /**
  101179. * Instantiates a new Gamepad Camera
  101180. * This represents a FPS type of camera. This is only here for back compat purpose.
  101181. * Please use the UniversalCamera instead as both are identical.
  101182. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101183. * @param name Define the name of the camera in the scene
  101184. * @param position Define the start position of the camera in the scene
  101185. * @param scene Define the scene the camera belongs to
  101186. */
  101187. constructor(name: string, position: Vector3, scene: Scene);
  101188. /**
  101189. * Gets the current object class name.
  101190. * @return the class name
  101191. */
  101192. getClassName(): string;
  101193. }
  101194. }
  101195. declare module BABYLON {
  101196. /** @hidden */
  101197. export var passPixelShader: {
  101198. name: string;
  101199. shader: string;
  101200. };
  101201. }
  101202. declare module BABYLON {
  101203. /** @hidden */
  101204. export var passCubePixelShader: {
  101205. name: string;
  101206. shader: string;
  101207. };
  101208. }
  101209. declare module BABYLON {
  101210. /**
  101211. * PassPostProcess which produces an output the same as it's input
  101212. */
  101213. export class PassPostProcess extends PostProcess {
  101214. /**
  101215. * Creates the PassPostProcess
  101216. * @param name The name of the effect.
  101217. * @param options The required width/height ratio to downsize to before computing the render pass.
  101218. * @param camera The camera to apply the render pass to.
  101219. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101220. * @param engine The engine which the post process will be applied. (default: current engine)
  101221. * @param reusable If the post process can be reused on the same frame. (default: false)
  101222. * @param textureType The type of texture to be used when performing the post processing.
  101223. * @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)
  101224. */
  101225. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  101226. }
  101227. /**
  101228. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  101229. */
  101230. export class PassCubePostProcess extends PostProcess {
  101231. private _face;
  101232. /**
  101233. * Gets or sets the cube face to display.
  101234. * * 0 is +X
  101235. * * 1 is -X
  101236. * * 2 is +Y
  101237. * * 3 is -Y
  101238. * * 4 is +Z
  101239. * * 5 is -Z
  101240. */
  101241. face: number;
  101242. /**
  101243. * Creates the PassCubePostProcess
  101244. * @param name The name of the effect.
  101245. * @param options The required width/height ratio to downsize to before computing the render pass.
  101246. * @param camera The camera to apply the render pass to.
  101247. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101248. * @param engine The engine which the post process will be applied. (default: current engine)
  101249. * @param reusable If the post process can be reused on the same frame. (default: false)
  101250. * @param textureType The type of texture to be used when performing the post processing.
  101251. * @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)
  101252. */
  101253. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  101254. }
  101255. }
  101256. declare module BABYLON {
  101257. /** @hidden */
  101258. export var anaglyphPixelShader: {
  101259. name: string;
  101260. shader: string;
  101261. };
  101262. }
  101263. declare module BABYLON {
  101264. /**
  101265. * Postprocess used to generate anaglyphic rendering
  101266. */
  101267. export class AnaglyphPostProcess extends PostProcess {
  101268. private _passedProcess;
  101269. /**
  101270. * Creates a new AnaglyphPostProcess
  101271. * @param name defines postprocess name
  101272. * @param options defines creation options or target ratio scale
  101273. * @param rigCameras defines cameras using this postprocess
  101274. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  101275. * @param engine defines hosting engine
  101276. * @param reusable defines if the postprocess will be reused multiple times per frame
  101277. */
  101278. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  101279. }
  101280. }
  101281. declare module BABYLON {
  101282. /**
  101283. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  101284. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101285. */
  101286. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  101287. /**
  101288. * Creates a new AnaglyphArcRotateCamera
  101289. * @param name defines camera name
  101290. * @param alpha defines alpha angle (in radians)
  101291. * @param beta defines beta angle (in radians)
  101292. * @param radius defines radius
  101293. * @param target defines camera target
  101294. * @param interaxialDistance defines distance between each color axis
  101295. * @param scene defines the hosting scene
  101296. */
  101297. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  101298. /**
  101299. * Gets camera class name
  101300. * @returns AnaglyphArcRotateCamera
  101301. */
  101302. getClassName(): string;
  101303. }
  101304. }
  101305. declare module BABYLON {
  101306. /**
  101307. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  101308. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101309. */
  101310. export class AnaglyphFreeCamera extends FreeCamera {
  101311. /**
  101312. * Creates a new AnaglyphFreeCamera
  101313. * @param name defines camera name
  101314. * @param position defines initial position
  101315. * @param interaxialDistance defines distance between each color axis
  101316. * @param scene defines the hosting scene
  101317. */
  101318. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101319. /**
  101320. * Gets camera class name
  101321. * @returns AnaglyphFreeCamera
  101322. */
  101323. getClassName(): string;
  101324. }
  101325. }
  101326. declare module BABYLON {
  101327. /**
  101328. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  101329. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101330. */
  101331. export class AnaglyphGamepadCamera extends GamepadCamera {
  101332. /**
  101333. * Creates a new AnaglyphGamepadCamera
  101334. * @param name defines camera name
  101335. * @param position defines initial position
  101336. * @param interaxialDistance defines distance between each color axis
  101337. * @param scene defines the hosting scene
  101338. */
  101339. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101340. /**
  101341. * Gets camera class name
  101342. * @returns AnaglyphGamepadCamera
  101343. */
  101344. getClassName(): string;
  101345. }
  101346. }
  101347. declare module BABYLON {
  101348. /**
  101349. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  101350. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101351. */
  101352. export class AnaglyphUniversalCamera extends UniversalCamera {
  101353. /**
  101354. * Creates a new AnaglyphUniversalCamera
  101355. * @param name defines camera name
  101356. * @param position defines initial position
  101357. * @param interaxialDistance defines distance between each color axis
  101358. * @param scene defines the hosting scene
  101359. */
  101360. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101361. /**
  101362. * Gets camera class name
  101363. * @returns AnaglyphUniversalCamera
  101364. */
  101365. getClassName(): string;
  101366. }
  101367. }
  101368. declare module BABYLON {
  101369. /** @hidden */
  101370. export var stereoscopicInterlacePixelShader: {
  101371. name: string;
  101372. shader: string;
  101373. };
  101374. }
  101375. declare module BABYLON {
  101376. /**
  101377. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  101378. */
  101379. export class StereoscopicInterlacePostProcess extends PostProcess {
  101380. private _stepSize;
  101381. private _passedProcess;
  101382. /**
  101383. * Initializes a StereoscopicInterlacePostProcess
  101384. * @param name The name of the effect.
  101385. * @param rigCameras The rig cameras to be appled to the post process
  101386. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  101387. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101388. * @param engine The engine which the post process will be applied. (default: current engine)
  101389. * @param reusable If the post process can be reused on the same frame. (default: false)
  101390. */
  101391. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  101392. }
  101393. }
  101394. declare module BABYLON {
  101395. /**
  101396. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  101397. * @see http://doc.babylonjs.com/features/cameras
  101398. */
  101399. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  101400. /**
  101401. * Creates a new StereoscopicArcRotateCamera
  101402. * @param name defines camera name
  101403. * @param alpha defines alpha angle (in radians)
  101404. * @param beta defines beta angle (in radians)
  101405. * @param radius defines radius
  101406. * @param target defines camera target
  101407. * @param interaxialDistance defines distance between each color axis
  101408. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101409. * @param scene defines the hosting scene
  101410. */
  101411. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101412. /**
  101413. * Gets camera class name
  101414. * @returns StereoscopicArcRotateCamera
  101415. */
  101416. getClassName(): string;
  101417. }
  101418. }
  101419. declare module BABYLON {
  101420. /**
  101421. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  101422. * @see http://doc.babylonjs.com/features/cameras
  101423. */
  101424. export class StereoscopicFreeCamera extends FreeCamera {
  101425. /**
  101426. * Creates a new StereoscopicFreeCamera
  101427. * @param name defines camera name
  101428. * @param position defines initial position
  101429. * @param interaxialDistance defines distance between each color axis
  101430. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101431. * @param scene defines the hosting scene
  101432. */
  101433. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101434. /**
  101435. * Gets camera class name
  101436. * @returns StereoscopicFreeCamera
  101437. */
  101438. getClassName(): string;
  101439. }
  101440. }
  101441. declare module BABYLON {
  101442. /**
  101443. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  101444. * @see http://doc.babylonjs.com/features/cameras
  101445. */
  101446. export class StereoscopicGamepadCamera extends GamepadCamera {
  101447. /**
  101448. * Creates a new StereoscopicGamepadCamera
  101449. * @param name defines camera name
  101450. * @param position defines initial position
  101451. * @param interaxialDistance defines distance between each color axis
  101452. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101453. * @param scene defines the hosting scene
  101454. */
  101455. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101456. /**
  101457. * Gets camera class name
  101458. * @returns StereoscopicGamepadCamera
  101459. */
  101460. getClassName(): string;
  101461. }
  101462. }
  101463. declare module BABYLON {
  101464. /**
  101465. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  101466. * @see http://doc.babylonjs.com/features/cameras
  101467. */
  101468. export class StereoscopicUniversalCamera extends UniversalCamera {
  101469. /**
  101470. * Creates a new StereoscopicUniversalCamera
  101471. * @param name defines camera name
  101472. * @param position defines initial position
  101473. * @param interaxialDistance defines distance between each color axis
  101474. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101475. * @param scene defines the hosting scene
  101476. */
  101477. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101478. /**
  101479. * Gets camera class name
  101480. * @returns StereoscopicUniversalCamera
  101481. */
  101482. getClassName(): string;
  101483. }
  101484. }
  101485. declare module BABYLON {
  101486. /**
  101487. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  101488. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101489. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101490. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101491. */
  101492. export class VirtualJoysticksCamera extends FreeCamera {
  101493. /**
  101494. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  101495. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101496. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101497. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101498. * @param name Define the name of the camera in the scene
  101499. * @param position Define the start position of the camera in the scene
  101500. * @param scene Define the scene the camera belongs to
  101501. */
  101502. constructor(name: string, position: Vector3, scene: Scene);
  101503. /**
  101504. * Gets the current object class name.
  101505. * @return the class name
  101506. */
  101507. getClassName(): string;
  101508. }
  101509. }
  101510. declare module BABYLON {
  101511. /**
  101512. * This represents all the required metrics to create a VR camera.
  101513. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  101514. */
  101515. export class VRCameraMetrics {
  101516. /**
  101517. * Define the horizontal resolution off the screen.
  101518. */
  101519. hResolution: number;
  101520. /**
  101521. * Define the vertical resolution off the screen.
  101522. */
  101523. vResolution: number;
  101524. /**
  101525. * Define the horizontal screen size.
  101526. */
  101527. hScreenSize: number;
  101528. /**
  101529. * Define the vertical screen size.
  101530. */
  101531. vScreenSize: number;
  101532. /**
  101533. * Define the vertical screen center position.
  101534. */
  101535. vScreenCenter: number;
  101536. /**
  101537. * Define the distance of the eyes to the screen.
  101538. */
  101539. eyeToScreenDistance: number;
  101540. /**
  101541. * Define the distance between both lenses
  101542. */
  101543. lensSeparationDistance: number;
  101544. /**
  101545. * Define the distance between both viewer's eyes.
  101546. */
  101547. interpupillaryDistance: number;
  101548. /**
  101549. * Define the distortion factor of the VR postprocess.
  101550. * Please, touch with care.
  101551. */
  101552. distortionK: number[];
  101553. /**
  101554. * Define the chromatic aberration correction factors for the VR post process.
  101555. */
  101556. chromaAbCorrection: number[];
  101557. /**
  101558. * Define the scale factor of the post process.
  101559. * The smaller the better but the slower.
  101560. */
  101561. postProcessScaleFactor: number;
  101562. /**
  101563. * Define an offset for the lens center.
  101564. */
  101565. lensCenterOffset: number;
  101566. /**
  101567. * Define if the current vr camera should compensate the distortion of the lense or not.
  101568. */
  101569. compensateDistortion: boolean;
  101570. /**
  101571. * Defines if multiview should be enabled when rendering (Default: false)
  101572. */
  101573. multiviewEnabled: boolean;
  101574. /**
  101575. * Gets the rendering aspect ratio based on the provided resolutions.
  101576. */
  101577. readonly aspectRatio: number;
  101578. /**
  101579. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  101580. */
  101581. readonly aspectRatioFov: number;
  101582. /**
  101583. * @hidden
  101584. */
  101585. readonly leftHMatrix: Matrix;
  101586. /**
  101587. * @hidden
  101588. */
  101589. readonly rightHMatrix: Matrix;
  101590. /**
  101591. * @hidden
  101592. */
  101593. readonly leftPreViewMatrix: Matrix;
  101594. /**
  101595. * @hidden
  101596. */
  101597. readonly rightPreViewMatrix: Matrix;
  101598. /**
  101599. * Get the default VRMetrics based on the most generic setup.
  101600. * @returns the default vr metrics
  101601. */
  101602. static GetDefault(): VRCameraMetrics;
  101603. }
  101604. }
  101605. declare module BABYLON {
  101606. /** @hidden */
  101607. export var vrDistortionCorrectionPixelShader: {
  101608. name: string;
  101609. shader: string;
  101610. };
  101611. }
  101612. declare module BABYLON {
  101613. /**
  101614. * VRDistortionCorrectionPostProcess used for mobile VR
  101615. */
  101616. export class VRDistortionCorrectionPostProcess extends PostProcess {
  101617. private _isRightEye;
  101618. private _distortionFactors;
  101619. private _postProcessScaleFactor;
  101620. private _lensCenterOffset;
  101621. private _scaleIn;
  101622. private _scaleFactor;
  101623. private _lensCenter;
  101624. /**
  101625. * Initializes the VRDistortionCorrectionPostProcess
  101626. * @param name The name of the effect.
  101627. * @param camera The camera to apply the render pass to.
  101628. * @param isRightEye If this is for the right eye distortion
  101629. * @param vrMetrics All the required metrics for the VR camera
  101630. */
  101631. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  101632. }
  101633. }
  101634. declare module BABYLON {
  101635. /**
  101636. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  101637. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101638. */
  101639. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  101640. /**
  101641. * Creates a new VRDeviceOrientationArcRotateCamera
  101642. * @param name defines camera name
  101643. * @param alpha defines the camera rotation along the logitudinal axis
  101644. * @param beta defines the camera rotation along the latitudinal axis
  101645. * @param radius defines the camera distance from its target
  101646. * @param target defines the camera target
  101647. * @param scene defines the scene the camera belongs to
  101648. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101649. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101650. */
  101651. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101652. /**
  101653. * Gets camera class name
  101654. * @returns VRDeviceOrientationArcRotateCamera
  101655. */
  101656. getClassName(): string;
  101657. }
  101658. }
  101659. declare module BABYLON {
  101660. /**
  101661. * Camera used to simulate VR rendering (based on FreeCamera)
  101662. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101663. */
  101664. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  101665. /**
  101666. * Creates a new VRDeviceOrientationFreeCamera
  101667. * @param name defines camera name
  101668. * @param position defines the start position of the camera
  101669. * @param scene defines the scene the camera belongs to
  101670. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101671. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101672. */
  101673. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101674. /**
  101675. * Gets camera class name
  101676. * @returns VRDeviceOrientationFreeCamera
  101677. */
  101678. getClassName(): string;
  101679. }
  101680. }
  101681. declare module BABYLON {
  101682. /**
  101683. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  101684. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101685. */
  101686. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  101687. /**
  101688. * Creates a new VRDeviceOrientationGamepadCamera
  101689. * @param name defines camera name
  101690. * @param position defines the start position of the camera
  101691. * @param scene defines the scene the camera belongs to
  101692. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101693. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101694. */
  101695. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101696. /**
  101697. * Gets camera class name
  101698. * @returns VRDeviceOrientationGamepadCamera
  101699. */
  101700. getClassName(): string;
  101701. }
  101702. }
  101703. declare module BABYLON {
  101704. /**
  101705. * Base class of materials working in push mode in babylon JS
  101706. * @hidden
  101707. */
  101708. export class PushMaterial extends Material {
  101709. protected _activeEffect: Effect;
  101710. protected _normalMatrix: Matrix;
  101711. /**
  101712. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  101713. * This means that the material can keep using a previous shader while a new one is being compiled.
  101714. * This is mostly used when shader parallel compilation is supported (true by default)
  101715. */
  101716. allowShaderHotSwapping: boolean;
  101717. constructor(name: string, scene: Scene);
  101718. getEffect(): Effect;
  101719. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101720. /**
  101721. * Binds the given world matrix to the active effect
  101722. *
  101723. * @param world the matrix to bind
  101724. */
  101725. bindOnlyWorldMatrix(world: Matrix): void;
  101726. /**
  101727. * Binds the given normal matrix to the active effect
  101728. *
  101729. * @param normalMatrix the matrix to bind
  101730. */
  101731. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101732. bind(world: Matrix, mesh?: Mesh): void;
  101733. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101734. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101735. }
  101736. }
  101737. declare module BABYLON {
  101738. /**
  101739. * This groups all the flags used to control the materials channel.
  101740. */
  101741. export class MaterialFlags {
  101742. private static _DiffuseTextureEnabled;
  101743. /**
  101744. * Are diffuse textures enabled in the application.
  101745. */
  101746. static DiffuseTextureEnabled: boolean;
  101747. private static _AmbientTextureEnabled;
  101748. /**
  101749. * Are ambient textures enabled in the application.
  101750. */
  101751. static AmbientTextureEnabled: boolean;
  101752. private static _OpacityTextureEnabled;
  101753. /**
  101754. * Are opacity textures enabled in the application.
  101755. */
  101756. static OpacityTextureEnabled: boolean;
  101757. private static _ReflectionTextureEnabled;
  101758. /**
  101759. * Are reflection textures enabled in the application.
  101760. */
  101761. static ReflectionTextureEnabled: boolean;
  101762. private static _EmissiveTextureEnabled;
  101763. /**
  101764. * Are emissive textures enabled in the application.
  101765. */
  101766. static EmissiveTextureEnabled: boolean;
  101767. private static _SpecularTextureEnabled;
  101768. /**
  101769. * Are specular textures enabled in the application.
  101770. */
  101771. static SpecularTextureEnabled: boolean;
  101772. private static _BumpTextureEnabled;
  101773. /**
  101774. * Are bump textures enabled in the application.
  101775. */
  101776. static BumpTextureEnabled: boolean;
  101777. private static _LightmapTextureEnabled;
  101778. /**
  101779. * Are lightmap textures enabled in the application.
  101780. */
  101781. static LightmapTextureEnabled: boolean;
  101782. private static _RefractionTextureEnabled;
  101783. /**
  101784. * Are refraction textures enabled in the application.
  101785. */
  101786. static RefractionTextureEnabled: boolean;
  101787. private static _ColorGradingTextureEnabled;
  101788. /**
  101789. * Are color grading textures enabled in the application.
  101790. */
  101791. static ColorGradingTextureEnabled: boolean;
  101792. private static _FresnelEnabled;
  101793. /**
  101794. * Are fresnels enabled in the application.
  101795. */
  101796. static FresnelEnabled: boolean;
  101797. private static _ClearCoatTextureEnabled;
  101798. /**
  101799. * Are clear coat textures enabled in the application.
  101800. */
  101801. static ClearCoatTextureEnabled: boolean;
  101802. private static _ClearCoatBumpTextureEnabled;
  101803. /**
  101804. * Are clear coat bump textures enabled in the application.
  101805. */
  101806. static ClearCoatBumpTextureEnabled: boolean;
  101807. private static _ClearCoatTintTextureEnabled;
  101808. /**
  101809. * Are clear coat tint textures enabled in the application.
  101810. */
  101811. static ClearCoatTintTextureEnabled: boolean;
  101812. private static _SheenTextureEnabled;
  101813. /**
  101814. * Are sheen textures enabled in the application.
  101815. */
  101816. static SheenTextureEnabled: boolean;
  101817. private static _AnisotropicTextureEnabled;
  101818. /**
  101819. * Are anisotropic textures enabled in the application.
  101820. */
  101821. static AnisotropicTextureEnabled: boolean;
  101822. private static _ThicknessTextureEnabled;
  101823. /**
  101824. * Are thickness textures enabled in the application.
  101825. */
  101826. static ThicknessTextureEnabled: boolean;
  101827. }
  101828. }
  101829. declare module BABYLON {
  101830. /** @hidden */
  101831. export var defaultFragmentDeclaration: {
  101832. name: string;
  101833. shader: string;
  101834. };
  101835. }
  101836. declare module BABYLON {
  101837. /** @hidden */
  101838. export var defaultUboDeclaration: {
  101839. name: string;
  101840. shader: string;
  101841. };
  101842. }
  101843. declare module BABYLON {
  101844. /** @hidden */
  101845. export var lightFragmentDeclaration: {
  101846. name: string;
  101847. shader: string;
  101848. };
  101849. }
  101850. declare module BABYLON {
  101851. /** @hidden */
  101852. export var lightUboDeclaration: {
  101853. name: string;
  101854. shader: string;
  101855. };
  101856. }
  101857. declare module BABYLON {
  101858. /** @hidden */
  101859. export var lightsFragmentFunctions: {
  101860. name: string;
  101861. shader: string;
  101862. };
  101863. }
  101864. declare module BABYLON {
  101865. /** @hidden */
  101866. export var shadowsFragmentFunctions: {
  101867. name: string;
  101868. shader: string;
  101869. };
  101870. }
  101871. declare module BABYLON {
  101872. /** @hidden */
  101873. export var fresnelFunction: {
  101874. name: string;
  101875. shader: string;
  101876. };
  101877. }
  101878. declare module BABYLON {
  101879. /** @hidden */
  101880. export var reflectionFunction: {
  101881. name: string;
  101882. shader: string;
  101883. };
  101884. }
  101885. declare module BABYLON {
  101886. /** @hidden */
  101887. export var bumpFragmentFunctions: {
  101888. name: string;
  101889. shader: string;
  101890. };
  101891. }
  101892. declare module BABYLON {
  101893. /** @hidden */
  101894. export var logDepthDeclaration: {
  101895. name: string;
  101896. shader: string;
  101897. };
  101898. }
  101899. declare module BABYLON {
  101900. /** @hidden */
  101901. export var bumpFragment: {
  101902. name: string;
  101903. shader: string;
  101904. };
  101905. }
  101906. declare module BABYLON {
  101907. /** @hidden */
  101908. export var depthPrePass: {
  101909. name: string;
  101910. shader: string;
  101911. };
  101912. }
  101913. declare module BABYLON {
  101914. /** @hidden */
  101915. export var lightFragment: {
  101916. name: string;
  101917. shader: string;
  101918. };
  101919. }
  101920. declare module BABYLON {
  101921. /** @hidden */
  101922. export var logDepthFragment: {
  101923. name: string;
  101924. shader: string;
  101925. };
  101926. }
  101927. declare module BABYLON {
  101928. /** @hidden */
  101929. export var defaultPixelShader: {
  101930. name: string;
  101931. shader: string;
  101932. };
  101933. }
  101934. declare module BABYLON {
  101935. /** @hidden */
  101936. export var defaultVertexDeclaration: {
  101937. name: string;
  101938. shader: string;
  101939. };
  101940. }
  101941. declare module BABYLON {
  101942. /** @hidden */
  101943. export var bumpVertexDeclaration: {
  101944. name: string;
  101945. shader: string;
  101946. };
  101947. }
  101948. declare module BABYLON {
  101949. /** @hidden */
  101950. export var bumpVertex: {
  101951. name: string;
  101952. shader: string;
  101953. };
  101954. }
  101955. declare module BABYLON {
  101956. /** @hidden */
  101957. export var fogVertex: {
  101958. name: string;
  101959. shader: string;
  101960. };
  101961. }
  101962. declare module BABYLON {
  101963. /** @hidden */
  101964. export var shadowsVertex: {
  101965. name: string;
  101966. shader: string;
  101967. };
  101968. }
  101969. declare module BABYLON {
  101970. /** @hidden */
  101971. export var pointCloudVertex: {
  101972. name: string;
  101973. shader: string;
  101974. };
  101975. }
  101976. declare module BABYLON {
  101977. /** @hidden */
  101978. export var logDepthVertex: {
  101979. name: string;
  101980. shader: string;
  101981. };
  101982. }
  101983. declare module BABYLON {
  101984. /** @hidden */
  101985. export var defaultVertexShader: {
  101986. name: string;
  101987. shader: string;
  101988. };
  101989. }
  101990. declare module BABYLON {
  101991. /** @hidden */
  101992. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  101993. MAINUV1: boolean;
  101994. MAINUV2: boolean;
  101995. DIFFUSE: boolean;
  101996. DIFFUSEDIRECTUV: number;
  101997. AMBIENT: boolean;
  101998. AMBIENTDIRECTUV: number;
  101999. OPACITY: boolean;
  102000. OPACITYDIRECTUV: number;
  102001. OPACITYRGB: boolean;
  102002. REFLECTION: boolean;
  102003. EMISSIVE: boolean;
  102004. EMISSIVEDIRECTUV: number;
  102005. SPECULAR: boolean;
  102006. SPECULARDIRECTUV: number;
  102007. BUMP: boolean;
  102008. BUMPDIRECTUV: number;
  102009. PARALLAX: boolean;
  102010. PARALLAXOCCLUSION: boolean;
  102011. SPECULAROVERALPHA: boolean;
  102012. CLIPPLANE: boolean;
  102013. CLIPPLANE2: boolean;
  102014. CLIPPLANE3: boolean;
  102015. CLIPPLANE4: boolean;
  102016. ALPHATEST: boolean;
  102017. DEPTHPREPASS: boolean;
  102018. ALPHAFROMDIFFUSE: boolean;
  102019. POINTSIZE: boolean;
  102020. FOG: boolean;
  102021. SPECULARTERM: boolean;
  102022. DIFFUSEFRESNEL: boolean;
  102023. OPACITYFRESNEL: boolean;
  102024. REFLECTIONFRESNEL: boolean;
  102025. REFRACTIONFRESNEL: boolean;
  102026. EMISSIVEFRESNEL: boolean;
  102027. FRESNEL: boolean;
  102028. NORMAL: boolean;
  102029. UV1: boolean;
  102030. UV2: boolean;
  102031. VERTEXCOLOR: boolean;
  102032. VERTEXALPHA: boolean;
  102033. NUM_BONE_INFLUENCERS: number;
  102034. BonesPerMesh: number;
  102035. BONETEXTURE: boolean;
  102036. INSTANCES: boolean;
  102037. GLOSSINESS: boolean;
  102038. ROUGHNESS: boolean;
  102039. EMISSIVEASILLUMINATION: boolean;
  102040. LINKEMISSIVEWITHDIFFUSE: boolean;
  102041. REFLECTIONFRESNELFROMSPECULAR: boolean;
  102042. LIGHTMAP: boolean;
  102043. LIGHTMAPDIRECTUV: number;
  102044. OBJECTSPACE_NORMALMAP: boolean;
  102045. USELIGHTMAPASSHADOWMAP: boolean;
  102046. REFLECTIONMAP_3D: boolean;
  102047. REFLECTIONMAP_SPHERICAL: boolean;
  102048. REFLECTIONMAP_PLANAR: boolean;
  102049. REFLECTIONMAP_CUBIC: boolean;
  102050. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  102051. REFLECTIONMAP_PROJECTION: boolean;
  102052. REFLECTIONMAP_SKYBOX: boolean;
  102053. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  102054. REFLECTIONMAP_EXPLICIT: boolean;
  102055. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  102056. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  102057. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  102058. INVERTCUBICMAP: boolean;
  102059. LOGARITHMICDEPTH: boolean;
  102060. REFRACTION: boolean;
  102061. REFRACTIONMAP_3D: boolean;
  102062. REFLECTIONOVERALPHA: boolean;
  102063. TWOSIDEDLIGHTING: boolean;
  102064. SHADOWFLOAT: boolean;
  102065. MORPHTARGETS: boolean;
  102066. MORPHTARGETS_NORMAL: boolean;
  102067. MORPHTARGETS_TANGENT: boolean;
  102068. MORPHTARGETS_UV: boolean;
  102069. NUM_MORPH_INFLUENCERS: number;
  102070. NONUNIFORMSCALING: boolean;
  102071. PREMULTIPLYALPHA: boolean;
  102072. IMAGEPROCESSING: boolean;
  102073. VIGNETTE: boolean;
  102074. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102075. VIGNETTEBLENDMODEOPAQUE: boolean;
  102076. TONEMAPPING: boolean;
  102077. TONEMAPPING_ACES: boolean;
  102078. CONTRAST: boolean;
  102079. COLORCURVES: boolean;
  102080. COLORGRADING: boolean;
  102081. COLORGRADING3D: boolean;
  102082. SAMPLER3DGREENDEPTH: boolean;
  102083. SAMPLER3DBGRMAP: boolean;
  102084. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102085. MULTIVIEW: boolean;
  102086. /**
  102087. * If the reflection texture on this material is in linear color space
  102088. * @hidden
  102089. */
  102090. IS_REFLECTION_LINEAR: boolean;
  102091. /**
  102092. * If the refraction texture on this material is in linear color space
  102093. * @hidden
  102094. */
  102095. IS_REFRACTION_LINEAR: boolean;
  102096. EXPOSURE: boolean;
  102097. constructor();
  102098. setReflectionMode(modeToEnable: string): void;
  102099. }
  102100. /**
  102101. * This is the default material used in Babylon. It is the best trade off between quality
  102102. * and performances.
  102103. * @see http://doc.babylonjs.com/babylon101/materials
  102104. */
  102105. export class StandardMaterial extends PushMaterial {
  102106. private _diffuseTexture;
  102107. /**
  102108. * The basic texture of the material as viewed under a light.
  102109. */
  102110. diffuseTexture: Nullable<BaseTexture>;
  102111. private _ambientTexture;
  102112. /**
  102113. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  102114. */
  102115. ambientTexture: Nullable<BaseTexture>;
  102116. private _opacityTexture;
  102117. /**
  102118. * Define the transparency of the material from a texture.
  102119. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  102120. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  102121. */
  102122. opacityTexture: Nullable<BaseTexture>;
  102123. private _reflectionTexture;
  102124. /**
  102125. * Define the texture used to display the reflection.
  102126. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102127. */
  102128. reflectionTexture: Nullable<BaseTexture>;
  102129. private _emissiveTexture;
  102130. /**
  102131. * Define texture of the material as if self lit.
  102132. * This will be mixed in the final result even in the absence of light.
  102133. */
  102134. emissiveTexture: Nullable<BaseTexture>;
  102135. private _specularTexture;
  102136. /**
  102137. * Define how the color and intensity of the highlight given by the light in the material.
  102138. */
  102139. specularTexture: Nullable<BaseTexture>;
  102140. private _bumpTexture;
  102141. /**
  102142. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  102143. * 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.
  102144. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  102145. */
  102146. bumpTexture: Nullable<BaseTexture>;
  102147. private _lightmapTexture;
  102148. /**
  102149. * Complex lighting can be computationally expensive to compute at runtime.
  102150. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  102151. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  102152. */
  102153. lightmapTexture: Nullable<BaseTexture>;
  102154. private _refractionTexture;
  102155. /**
  102156. * Define the texture used to display the refraction.
  102157. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102158. */
  102159. refractionTexture: Nullable<BaseTexture>;
  102160. /**
  102161. * The color of the material lit by the environmental background lighting.
  102162. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  102163. */
  102164. ambientColor: Color3;
  102165. /**
  102166. * The basic color of the material as viewed under a light.
  102167. */
  102168. diffuseColor: Color3;
  102169. /**
  102170. * Define how the color and intensity of the highlight given by the light in the material.
  102171. */
  102172. specularColor: Color3;
  102173. /**
  102174. * Define the color of the material as if self lit.
  102175. * This will be mixed in the final result even in the absence of light.
  102176. */
  102177. emissiveColor: Color3;
  102178. /**
  102179. * Defines how sharp are the highlights in the material.
  102180. * The bigger the value the sharper giving a more glossy feeling to the result.
  102181. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  102182. */
  102183. specularPower: number;
  102184. private _useAlphaFromDiffuseTexture;
  102185. /**
  102186. * Does the transparency come from the diffuse texture alpha channel.
  102187. */
  102188. useAlphaFromDiffuseTexture: boolean;
  102189. private _useEmissiveAsIllumination;
  102190. /**
  102191. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  102192. */
  102193. useEmissiveAsIllumination: boolean;
  102194. private _linkEmissiveWithDiffuse;
  102195. /**
  102196. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  102197. * the emissive level when the final color is close to one.
  102198. */
  102199. linkEmissiveWithDiffuse: boolean;
  102200. private _useSpecularOverAlpha;
  102201. /**
  102202. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  102203. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102204. */
  102205. useSpecularOverAlpha: boolean;
  102206. private _useReflectionOverAlpha;
  102207. /**
  102208. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102209. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102210. */
  102211. useReflectionOverAlpha: boolean;
  102212. private _disableLighting;
  102213. /**
  102214. * Does lights from the scene impacts this material.
  102215. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  102216. */
  102217. disableLighting: boolean;
  102218. private _useObjectSpaceNormalMap;
  102219. /**
  102220. * Allows using an object space normal map (instead of tangent space).
  102221. */
  102222. useObjectSpaceNormalMap: boolean;
  102223. private _useParallax;
  102224. /**
  102225. * Is parallax enabled or not.
  102226. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102227. */
  102228. useParallax: boolean;
  102229. private _useParallaxOcclusion;
  102230. /**
  102231. * Is parallax occlusion enabled or not.
  102232. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  102233. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102234. */
  102235. useParallaxOcclusion: boolean;
  102236. /**
  102237. * 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.
  102238. */
  102239. parallaxScaleBias: number;
  102240. private _roughness;
  102241. /**
  102242. * Helps to define how blurry the reflections should appears in the material.
  102243. */
  102244. roughness: number;
  102245. /**
  102246. * In case of refraction, define the value of the index of refraction.
  102247. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102248. */
  102249. indexOfRefraction: number;
  102250. /**
  102251. * Invert the refraction texture alongside the y axis.
  102252. * It can be useful with procedural textures or probe for instance.
  102253. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102254. */
  102255. invertRefractionY: boolean;
  102256. /**
  102257. * Defines the alpha limits in alpha test mode.
  102258. */
  102259. alphaCutOff: number;
  102260. private _useLightmapAsShadowmap;
  102261. /**
  102262. * In case of light mapping, define whether the map contains light or shadow informations.
  102263. */
  102264. useLightmapAsShadowmap: boolean;
  102265. private _diffuseFresnelParameters;
  102266. /**
  102267. * Define the diffuse fresnel parameters of the material.
  102268. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102269. */
  102270. diffuseFresnelParameters: FresnelParameters;
  102271. private _opacityFresnelParameters;
  102272. /**
  102273. * Define the opacity fresnel parameters of the material.
  102274. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102275. */
  102276. opacityFresnelParameters: FresnelParameters;
  102277. private _reflectionFresnelParameters;
  102278. /**
  102279. * Define the reflection fresnel parameters of the material.
  102280. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102281. */
  102282. reflectionFresnelParameters: FresnelParameters;
  102283. private _refractionFresnelParameters;
  102284. /**
  102285. * Define the refraction fresnel parameters of the material.
  102286. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102287. */
  102288. refractionFresnelParameters: FresnelParameters;
  102289. private _emissiveFresnelParameters;
  102290. /**
  102291. * Define the emissive fresnel parameters of the material.
  102292. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102293. */
  102294. emissiveFresnelParameters: FresnelParameters;
  102295. private _useReflectionFresnelFromSpecular;
  102296. /**
  102297. * If true automatically deducts the fresnels values from the material specularity.
  102298. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102299. */
  102300. useReflectionFresnelFromSpecular: boolean;
  102301. private _useGlossinessFromSpecularMapAlpha;
  102302. /**
  102303. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  102304. */
  102305. useGlossinessFromSpecularMapAlpha: boolean;
  102306. private _maxSimultaneousLights;
  102307. /**
  102308. * Defines the maximum number of lights that can be used in the material
  102309. */
  102310. maxSimultaneousLights: number;
  102311. private _invertNormalMapX;
  102312. /**
  102313. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102314. */
  102315. invertNormalMapX: boolean;
  102316. private _invertNormalMapY;
  102317. /**
  102318. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102319. */
  102320. invertNormalMapY: boolean;
  102321. private _twoSidedLighting;
  102322. /**
  102323. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102324. */
  102325. twoSidedLighting: boolean;
  102326. /**
  102327. * Default configuration related to image processing available in the standard Material.
  102328. */
  102329. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102330. /**
  102331. * Gets the image processing configuration used either in this material.
  102332. */
  102333. /**
  102334. * Sets the Default image processing configuration used either in the this material.
  102335. *
  102336. * If sets to null, the scene one is in use.
  102337. */
  102338. imageProcessingConfiguration: ImageProcessingConfiguration;
  102339. /**
  102340. * Keep track of the image processing observer to allow dispose and replace.
  102341. */
  102342. private _imageProcessingObserver;
  102343. /**
  102344. * Attaches a new image processing configuration to the Standard Material.
  102345. * @param configuration
  102346. */
  102347. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102348. /**
  102349. * Gets wether the color curves effect is enabled.
  102350. */
  102351. /**
  102352. * Sets wether the color curves effect is enabled.
  102353. */
  102354. cameraColorCurvesEnabled: boolean;
  102355. /**
  102356. * Gets wether the color grading effect is enabled.
  102357. */
  102358. /**
  102359. * Gets wether the color grading effect is enabled.
  102360. */
  102361. cameraColorGradingEnabled: boolean;
  102362. /**
  102363. * Gets wether tonemapping is enabled or not.
  102364. */
  102365. /**
  102366. * Sets wether tonemapping is enabled or not
  102367. */
  102368. cameraToneMappingEnabled: boolean;
  102369. /**
  102370. * The camera exposure used on this material.
  102371. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102372. * This corresponds to a photographic exposure.
  102373. */
  102374. /**
  102375. * The camera exposure used on this material.
  102376. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102377. * This corresponds to a photographic exposure.
  102378. */
  102379. cameraExposure: number;
  102380. /**
  102381. * Gets The camera contrast used on this material.
  102382. */
  102383. /**
  102384. * Sets The camera contrast used on this material.
  102385. */
  102386. cameraContrast: number;
  102387. /**
  102388. * Gets the Color Grading 2D Lookup Texture.
  102389. */
  102390. /**
  102391. * Sets the Color Grading 2D Lookup Texture.
  102392. */
  102393. cameraColorGradingTexture: Nullable<BaseTexture>;
  102394. /**
  102395. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102396. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102397. * 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;
  102398. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102399. */
  102400. /**
  102401. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102402. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102403. * 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;
  102404. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102405. */
  102406. cameraColorCurves: Nullable<ColorCurves>;
  102407. /**
  102408. * Custom callback helping to override the default shader used in the material.
  102409. */
  102410. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  102411. protected _renderTargets: SmartArray<RenderTargetTexture>;
  102412. protected _worldViewProjectionMatrix: Matrix;
  102413. protected _globalAmbientColor: Color3;
  102414. protected _useLogarithmicDepth: boolean;
  102415. /**
  102416. * Instantiates a new standard material.
  102417. * This is the default material used in Babylon. It is the best trade off between quality
  102418. * and performances.
  102419. * @see http://doc.babylonjs.com/babylon101/materials
  102420. * @param name Define the name of the material in the scene
  102421. * @param scene Define the scene the material belong to
  102422. */
  102423. constructor(name: string, scene: Scene);
  102424. /**
  102425. * Gets a boolean indicating that current material needs to register RTT
  102426. */
  102427. readonly hasRenderTargetTextures: boolean;
  102428. /**
  102429. * Gets the current class name of the material e.g. "StandardMaterial"
  102430. * Mainly use in serialization.
  102431. * @returns the class name
  102432. */
  102433. getClassName(): string;
  102434. /**
  102435. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  102436. * You can try switching to logarithmic depth.
  102437. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  102438. */
  102439. useLogarithmicDepth: boolean;
  102440. /**
  102441. * Specifies if the material will require alpha blending
  102442. * @returns a boolean specifying if alpha blending is needed
  102443. */
  102444. needAlphaBlending(): boolean;
  102445. /**
  102446. * Specifies if this material should be rendered in alpha test mode
  102447. * @returns a boolean specifying if an alpha test is needed.
  102448. */
  102449. needAlphaTesting(): boolean;
  102450. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  102451. /**
  102452. * Get the texture used for alpha test purpose.
  102453. * @returns the diffuse texture in case of the standard material.
  102454. */
  102455. getAlphaTestTexture(): Nullable<BaseTexture>;
  102456. /**
  102457. * Get if the submesh is ready to be used and all its information available.
  102458. * Child classes can use it to update shaders
  102459. * @param mesh defines the mesh to check
  102460. * @param subMesh defines which submesh to check
  102461. * @param useInstances specifies that instances should be used
  102462. * @returns a boolean indicating that the submesh is ready or not
  102463. */
  102464. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102465. /**
  102466. * Builds the material UBO layouts.
  102467. * Used internally during the effect preparation.
  102468. */
  102469. buildUniformLayout(): void;
  102470. /**
  102471. * Unbinds the material from the mesh
  102472. */
  102473. unbind(): void;
  102474. /**
  102475. * Binds the submesh to this material by preparing the effect and shader to draw
  102476. * @param world defines the world transformation matrix
  102477. * @param mesh defines the mesh containing the submesh
  102478. * @param subMesh defines the submesh to bind the material to
  102479. */
  102480. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102481. /**
  102482. * Get the list of animatables in the material.
  102483. * @returns the list of animatables object used in the material
  102484. */
  102485. getAnimatables(): IAnimatable[];
  102486. /**
  102487. * Gets the active textures from the material
  102488. * @returns an array of textures
  102489. */
  102490. getActiveTextures(): BaseTexture[];
  102491. /**
  102492. * Specifies if the material uses a texture
  102493. * @param texture defines the texture to check against the material
  102494. * @returns a boolean specifying if the material uses the texture
  102495. */
  102496. hasTexture(texture: BaseTexture): boolean;
  102497. /**
  102498. * Disposes the material
  102499. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102500. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102501. */
  102502. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102503. /**
  102504. * Makes a duplicate of the material, and gives it a new name
  102505. * @param name defines the new name for the duplicated material
  102506. * @returns the cloned material
  102507. */
  102508. clone(name: string): StandardMaterial;
  102509. /**
  102510. * Serializes this material in a JSON representation
  102511. * @returns the serialized material object
  102512. */
  102513. serialize(): any;
  102514. /**
  102515. * Creates a standard material from parsed material data
  102516. * @param source defines the JSON representation of the material
  102517. * @param scene defines the hosting scene
  102518. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102519. * @returns a new standard material
  102520. */
  102521. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  102522. /**
  102523. * Are diffuse textures enabled in the application.
  102524. */
  102525. static DiffuseTextureEnabled: boolean;
  102526. /**
  102527. * Are ambient textures enabled in the application.
  102528. */
  102529. static AmbientTextureEnabled: boolean;
  102530. /**
  102531. * Are opacity textures enabled in the application.
  102532. */
  102533. static OpacityTextureEnabled: boolean;
  102534. /**
  102535. * Are reflection textures enabled in the application.
  102536. */
  102537. static ReflectionTextureEnabled: boolean;
  102538. /**
  102539. * Are emissive textures enabled in the application.
  102540. */
  102541. static EmissiveTextureEnabled: boolean;
  102542. /**
  102543. * Are specular textures enabled in the application.
  102544. */
  102545. static SpecularTextureEnabled: boolean;
  102546. /**
  102547. * Are bump textures enabled in the application.
  102548. */
  102549. static BumpTextureEnabled: boolean;
  102550. /**
  102551. * Are lightmap textures enabled in the application.
  102552. */
  102553. static LightmapTextureEnabled: boolean;
  102554. /**
  102555. * Are refraction textures enabled in the application.
  102556. */
  102557. static RefractionTextureEnabled: boolean;
  102558. /**
  102559. * Are color grading textures enabled in the application.
  102560. */
  102561. static ColorGradingTextureEnabled: boolean;
  102562. /**
  102563. * Are fresnels enabled in the application.
  102564. */
  102565. static FresnelEnabled: boolean;
  102566. }
  102567. }
  102568. declare module BABYLON {
  102569. /**
  102570. * A class extending Texture allowing drawing on a texture
  102571. * @see http://doc.babylonjs.com/how_to/dynamictexture
  102572. */
  102573. export class DynamicTexture extends Texture {
  102574. private _generateMipMaps;
  102575. private _canvas;
  102576. private _context;
  102577. private _engine;
  102578. /**
  102579. * Creates a DynamicTexture
  102580. * @param name defines the name of the texture
  102581. * @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
  102582. * @param scene defines the scene where you want the texture
  102583. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  102584. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  102585. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  102586. */
  102587. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  102588. /**
  102589. * Get the current class name of the texture useful for serialization or dynamic coding.
  102590. * @returns "DynamicTexture"
  102591. */
  102592. getClassName(): string;
  102593. /**
  102594. * Gets the current state of canRescale
  102595. */
  102596. readonly canRescale: boolean;
  102597. private _recreate;
  102598. /**
  102599. * Scales the texture
  102600. * @param ratio the scale factor to apply to both width and height
  102601. */
  102602. scale(ratio: number): void;
  102603. /**
  102604. * Resizes the texture
  102605. * @param width the new width
  102606. * @param height the new height
  102607. */
  102608. scaleTo(width: number, height: number): void;
  102609. /**
  102610. * Gets the context of the canvas used by the texture
  102611. * @returns the canvas context of the dynamic texture
  102612. */
  102613. getContext(): CanvasRenderingContext2D;
  102614. /**
  102615. * Clears the texture
  102616. */
  102617. clear(): void;
  102618. /**
  102619. * Updates the texture
  102620. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102621. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  102622. */
  102623. update(invertY?: boolean, premulAlpha?: boolean): void;
  102624. /**
  102625. * Draws text onto the texture
  102626. * @param text defines the text to be drawn
  102627. * @param x defines the placement of the text from the left
  102628. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  102629. * @param font defines the font to be used with font-style, font-size, font-name
  102630. * @param color defines the color used for the text
  102631. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  102632. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102633. * @param update defines whether texture is immediately update (default is true)
  102634. */
  102635. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  102636. /**
  102637. * Clones the texture
  102638. * @returns the clone of the texture.
  102639. */
  102640. clone(): DynamicTexture;
  102641. /**
  102642. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  102643. * @returns a serialized dynamic texture object
  102644. */
  102645. serialize(): any;
  102646. /** @hidden */
  102647. _rebuild(): void;
  102648. }
  102649. }
  102650. declare module BABYLON {
  102651. /** @hidden */
  102652. export var imageProcessingPixelShader: {
  102653. name: string;
  102654. shader: string;
  102655. };
  102656. }
  102657. declare module BABYLON {
  102658. /**
  102659. * ImageProcessingPostProcess
  102660. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  102661. */
  102662. export class ImageProcessingPostProcess extends PostProcess {
  102663. /**
  102664. * Default configuration related to image processing available in the PBR Material.
  102665. */
  102666. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102667. /**
  102668. * Gets the image processing configuration used either in this material.
  102669. */
  102670. /**
  102671. * Sets the Default image processing configuration used either in the this material.
  102672. *
  102673. * If sets to null, the scene one is in use.
  102674. */
  102675. imageProcessingConfiguration: ImageProcessingConfiguration;
  102676. /**
  102677. * Keep track of the image processing observer to allow dispose and replace.
  102678. */
  102679. private _imageProcessingObserver;
  102680. /**
  102681. * Attaches a new image processing configuration to the PBR Material.
  102682. * @param configuration
  102683. */
  102684. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102685. /**
  102686. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102687. */
  102688. /**
  102689. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102690. */
  102691. colorCurves: Nullable<ColorCurves>;
  102692. /**
  102693. * Gets wether the color curves effect is enabled.
  102694. */
  102695. /**
  102696. * Sets wether the color curves effect is enabled.
  102697. */
  102698. colorCurvesEnabled: boolean;
  102699. /**
  102700. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102701. */
  102702. /**
  102703. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102704. */
  102705. colorGradingTexture: Nullable<BaseTexture>;
  102706. /**
  102707. * Gets wether the color grading effect is enabled.
  102708. */
  102709. /**
  102710. * Gets wether the color grading effect is enabled.
  102711. */
  102712. colorGradingEnabled: boolean;
  102713. /**
  102714. * Gets exposure used in the effect.
  102715. */
  102716. /**
  102717. * Sets exposure used in the effect.
  102718. */
  102719. exposure: number;
  102720. /**
  102721. * Gets wether tonemapping is enabled or not.
  102722. */
  102723. /**
  102724. * Sets wether tonemapping is enabled or not
  102725. */
  102726. toneMappingEnabled: boolean;
  102727. /**
  102728. * Gets the type of tone mapping effect.
  102729. */
  102730. /**
  102731. * Sets the type of tone mapping effect.
  102732. */
  102733. toneMappingType: number;
  102734. /**
  102735. * Gets contrast used in the effect.
  102736. */
  102737. /**
  102738. * Sets contrast used in the effect.
  102739. */
  102740. contrast: number;
  102741. /**
  102742. * Gets Vignette stretch size.
  102743. */
  102744. /**
  102745. * Sets Vignette stretch size.
  102746. */
  102747. vignetteStretch: number;
  102748. /**
  102749. * Gets Vignette centre X Offset.
  102750. */
  102751. /**
  102752. * Sets Vignette centre X Offset.
  102753. */
  102754. vignetteCentreX: number;
  102755. /**
  102756. * Gets Vignette centre Y Offset.
  102757. */
  102758. /**
  102759. * Sets Vignette centre Y Offset.
  102760. */
  102761. vignetteCentreY: number;
  102762. /**
  102763. * Gets Vignette weight or intensity of the vignette effect.
  102764. */
  102765. /**
  102766. * Sets Vignette weight or intensity of the vignette effect.
  102767. */
  102768. vignetteWeight: number;
  102769. /**
  102770. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102771. * if vignetteEnabled is set to true.
  102772. */
  102773. /**
  102774. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102775. * if vignetteEnabled is set to true.
  102776. */
  102777. vignetteColor: Color4;
  102778. /**
  102779. * Gets Camera field of view used by the Vignette effect.
  102780. */
  102781. /**
  102782. * Sets Camera field of view used by the Vignette effect.
  102783. */
  102784. vignetteCameraFov: number;
  102785. /**
  102786. * Gets the vignette blend mode allowing different kind of effect.
  102787. */
  102788. /**
  102789. * Sets the vignette blend mode allowing different kind of effect.
  102790. */
  102791. vignetteBlendMode: number;
  102792. /**
  102793. * Gets wether the vignette effect is enabled.
  102794. */
  102795. /**
  102796. * Sets wether the vignette effect is enabled.
  102797. */
  102798. vignetteEnabled: boolean;
  102799. private _fromLinearSpace;
  102800. /**
  102801. * Gets wether the input of the processing is in Gamma or Linear Space.
  102802. */
  102803. /**
  102804. * Sets wether the input of the processing is in Gamma or Linear Space.
  102805. */
  102806. fromLinearSpace: boolean;
  102807. /**
  102808. * Defines cache preventing GC.
  102809. */
  102810. private _defines;
  102811. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  102812. /**
  102813. * "ImageProcessingPostProcess"
  102814. * @returns "ImageProcessingPostProcess"
  102815. */
  102816. getClassName(): string;
  102817. protected _updateParameters(): void;
  102818. dispose(camera?: Camera): void;
  102819. }
  102820. }
  102821. declare module BABYLON {
  102822. /**
  102823. * Class containing static functions to help procedurally build meshes
  102824. */
  102825. export class GroundBuilder {
  102826. /**
  102827. * Creates a ground mesh
  102828. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  102829. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  102830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102831. * @param name defines the name of the mesh
  102832. * @param options defines the options used to create the mesh
  102833. * @param scene defines the hosting scene
  102834. * @returns the ground mesh
  102835. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  102836. */
  102837. static CreateGround(name: string, options: {
  102838. width?: number;
  102839. height?: number;
  102840. subdivisions?: number;
  102841. subdivisionsX?: number;
  102842. subdivisionsY?: number;
  102843. updatable?: boolean;
  102844. }, scene: any): Mesh;
  102845. /**
  102846. * Creates a tiled ground mesh
  102847. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  102848. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  102849. * * 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
  102850. * * 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
  102851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102852. * @param name defines the name of the mesh
  102853. * @param options defines the options used to create the mesh
  102854. * @param scene defines the hosting scene
  102855. * @returns the tiled ground mesh
  102856. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  102857. */
  102858. static CreateTiledGround(name: string, options: {
  102859. xmin: number;
  102860. zmin: number;
  102861. xmax: number;
  102862. zmax: number;
  102863. subdivisions?: {
  102864. w: number;
  102865. h: number;
  102866. };
  102867. precision?: {
  102868. w: number;
  102869. h: number;
  102870. };
  102871. updatable?: boolean;
  102872. }, scene?: Nullable<Scene>): Mesh;
  102873. /**
  102874. * Creates a ground mesh from a height map
  102875. * * The parameter `url` sets the URL of the height map image resource.
  102876. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  102877. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  102878. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  102879. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  102880. * * 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.
  102881. * * 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).
  102882. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  102883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102884. * @param name defines the name of the mesh
  102885. * @param url defines the url to the height map
  102886. * @param options defines the options used to create the mesh
  102887. * @param scene defines the hosting scene
  102888. * @returns the ground mesh
  102889. * @see https://doc.babylonjs.com/babylon101/height_map
  102890. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  102891. */
  102892. static CreateGroundFromHeightMap(name: string, url: string, options: {
  102893. width?: number;
  102894. height?: number;
  102895. subdivisions?: number;
  102896. minHeight?: number;
  102897. maxHeight?: number;
  102898. colorFilter?: Color3;
  102899. alphaFilter?: number;
  102900. updatable?: boolean;
  102901. onReady?: (mesh: GroundMesh) => void;
  102902. }, scene?: Nullable<Scene>): GroundMesh;
  102903. }
  102904. }
  102905. declare module BABYLON {
  102906. /**
  102907. * Class containing static functions to help procedurally build meshes
  102908. */
  102909. export class TorusBuilder {
  102910. /**
  102911. * Creates a torus mesh
  102912. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  102913. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  102914. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  102915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102916. * * 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
  102917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102918. * @param name defines the name of the mesh
  102919. * @param options defines the options used to create the mesh
  102920. * @param scene defines the hosting scene
  102921. * @returns the torus mesh
  102922. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  102923. */
  102924. static CreateTorus(name: string, options: {
  102925. diameter?: number;
  102926. thickness?: number;
  102927. tessellation?: number;
  102928. updatable?: boolean;
  102929. sideOrientation?: number;
  102930. frontUVs?: Vector4;
  102931. backUVs?: Vector4;
  102932. }, scene: any): Mesh;
  102933. }
  102934. }
  102935. declare module BABYLON {
  102936. /**
  102937. * Class containing static functions to help procedurally build meshes
  102938. */
  102939. export class CylinderBuilder {
  102940. /**
  102941. * Creates a cylinder or a cone mesh
  102942. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  102943. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  102944. * * 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.
  102945. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  102946. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  102947. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  102948. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  102949. * * 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).
  102950. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  102951. * * 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).
  102952. * * 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
  102953. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  102954. * * 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
  102955. * * 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.
  102956. * * If `enclose` is false, a ring surface is one element.
  102957. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  102958. * * 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
  102959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102960. * * 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
  102961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102962. * @param name defines the name of the mesh
  102963. * @param options defines the options used to create the mesh
  102964. * @param scene defines the hosting scene
  102965. * @returns the cylinder mesh
  102966. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  102967. */
  102968. static CreateCylinder(name: string, options: {
  102969. height?: number;
  102970. diameterTop?: number;
  102971. diameterBottom?: number;
  102972. diameter?: number;
  102973. tessellation?: number;
  102974. subdivisions?: number;
  102975. arc?: number;
  102976. faceColors?: Color4[];
  102977. faceUV?: Vector4[];
  102978. updatable?: boolean;
  102979. hasRings?: boolean;
  102980. enclose?: boolean;
  102981. cap?: number;
  102982. sideOrientation?: number;
  102983. frontUVs?: Vector4;
  102984. backUVs?: Vector4;
  102985. }, scene: any): Mesh;
  102986. }
  102987. }
  102988. declare module BABYLON {
  102989. /**
  102990. * Options to modify the vr teleportation behavior.
  102991. */
  102992. export interface VRTeleportationOptions {
  102993. /**
  102994. * The name of the mesh which should be used as the teleportation floor. (default: null)
  102995. */
  102996. floorMeshName?: string;
  102997. /**
  102998. * A list of meshes to be used as the teleportation floor. (default: empty)
  102999. */
  103000. floorMeshes?: Mesh[];
  103001. }
  103002. /**
  103003. * Options to modify the vr experience helper's behavior.
  103004. */
  103005. export interface VRExperienceHelperOptions extends WebVROptions {
  103006. /**
  103007. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  103008. */
  103009. createDeviceOrientationCamera?: boolean;
  103010. /**
  103011. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  103012. */
  103013. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  103014. /**
  103015. * Uses the main button on the controller to toggle the laser casted. (default: true)
  103016. */
  103017. laserToggle?: boolean;
  103018. /**
  103019. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  103020. */
  103021. floorMeshes?: Mesh[];
  103022. /**
  103023. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  103024. */
  103025. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  103026. }
  103027. /**
  103028. * Event containing information after VR has been entered
  103029. */
  103030. export class OnAfterEnteringVRObservableEvent {
  103031. /**
  103032. * If entering vr was successful
  103033. */
  103034. success: boolean;
  103035. }
  103036. /**
  103037. * Helps to quickly add VR support to an existing scene.
  103038. * See http://doc.babylonjs.com/how_to/webvr_helper
  103039. */
  103040. export class VRExperienceHelper {
  103041. /** Options to modify the vr experience helper's behavior. */
  103042. webVROptions: VRExperienceHelperOptions;
  103043. private _scene;
  103044. private _position;
  103045. private _btnVR;
  103046. private _btnVRDisplayed;
  103047. private _webVRsupported;
  103048. private _webVRready;
  103049. private _webVRrequesting;
  103050. private _webVRpresenting;
  103051. private _hasEnteredVR;
  103052. private _fullscreenVRpresenting;
  103053. private _canvas;
  103054. private _webVRCamera;
  103055. private _vrDeviceOrientationCamera;
  103056. private _deviceOrientationCamera;
  103057. private _existingCamera;
  103058. private _onKeyDown;
  103059. private _onVrDisplayPresentChange;
  103060. private _onVRDisplayChanged;
  103061. private _onVRRequestPresentStart;
  103062. private _onVRRequestPresentComplete;
  103063. /**
  103064. * Observable raised right before entering VR.
  103065. */
  103066. onEnteringVRObservable: Observable<VRExperienceHelper>;
  103067. /**
  103068. * Observable raised when entering VR has completed.
  103069. */
  103070. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  103071. /**
  103072. * Observable raised when exiting VR.
  103073. */
  103074. onExitingVRObservable: Observable<VRExperienceHelper>;
  103075. /**
  103076. * Observable raised when controller mesh is loaded.
  103077. */
  103078. onControllerMeshLoadedObservable: Observable<WebVRController>;
  103079. /** Return this.onEnteringVRObservable
  103080. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  103081. */
  103082. readonly onEnteringVR: Observable<VRExperienceHelper>;
  103083. /** Return this.onExitingVRObservable
  103084. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  103085. */
  103086. readonly onExitingVR: Observable<VRExperienceHelper>;
  103087. /** Return this.onControllerMeshLoadedObservable
  103088. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  103089. */
  103090. readonly onControllerMeshLoaded: Observable<WebVRController>;
  103091. private _rayLength;
  103092. private _useCustomVRButton;
  103093. private _teleportationRequested;
  103094. private _teleportActive;
  103095. private _floorMeshName;
  103096. private _floorMeshesCollection;
  103097. private _rotationAllowed;
  103098. private _teleportBackwardsVector;
  103099. private _teleportationTarget;
  103100. private _isDefaultTeleportationTarget;
  103101. private _postProcessMove;
  103102. private _teleportationFillColor;
  103103. private _teleportationBorderColor;
  103104. private _rotationAngle;
  103105. private _haloCenter;
  103106. private _cameraGazer;
  103107. private _padSensibilityUp;
  103108. private _padSensibilityDown;
  103109. private _leftController;
  103110. private _rightController;
  103111. /**
  103112. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  103113. */
  103114. onNewMeshSelected: Observable<AbstractMesh>;
  103115. /**
  103116. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  103117. */
  103118. onNewMeshPicked: Observable<PickingInfo>;
  103119. private _circleEase;
  103120. /**
  103121. * Observable raised before camera teleportation
  103122. */
  103123. onBeforeCameraTeleport: Observable<Vector3>;
  103124. /**
  103125. * Observable raised after camera teleportation
  103126. */
  103127. onAfterCameraTeleport: Observable<Vector3>;
  103128. /**
  103129. * Observable raised when current selected mesh gets unselected
  103130. */
  103131. onSelectedMeshUnselected: Observable<AbstractMesh>;
  103132. private _raySelectionPredicate;
  103133. /**
  103134. * To be optionaly changed by user to define custom ray selection
  103135. */
  103136. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  103137. /**
  103138. * To be optionaly changed by user to define custom selection logic (after ray selection)
  103139. */
  103140. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  103141. /**
  103142. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  103143. */
  103144. teleportationEnabled: boolean;
  103145. private _defaultHeight;
  103146. private _teleportationInitialized;
  103147. private _interactionsEnabled;
  103148. private _interactionsRequested;
  103149. private _displayGaze;
  103150. private _displayLaserPointer;
  103151. /**
  103152. * The mesh used to display where the user is going to teleport.
  103153. */
  103154. /**
  103155. * Sets the mesh to be used to display where the user is going to teleport.
  103156. */
  103157. teleportationTarget: Mesh;
  103158. /**
  103159. * 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
  103160. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  103161. * See http://doc.babylonjs.com/resources/baking_transformations
  103162. */
  103163. gazeTrackerMesh: Mesh;
  103164. /**
  103165. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  103166. */
  103167. updateGazeTrackerScale: boolean;
  103168. /**
  103169. * If the gaze trackers color should be updated when selecting meshes
  103170. */
  103171. updateGazeTrackerColor: boolean;
  103172. /**
  103173. * The gaze tracking mesh corresponding to the left controller
  103174. */
  103175. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  103176. /**
  103177. * The gaze tracking mesh corresponding to the right controller
  103178. */
  103179. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  103180. /**
  103181. * If the ray of the gaze should be displayed.
  103182. */
  103183. /**
  103184. * Sets if the ray of the gaze should be displayed.
  103185. */
  103186. displayGaze: boolean;
  103187. /**
  103188. * If the ray of the LaserPointer should be displayed.
  103189. */
  103190. /**
  103191. * Sets if the ray of the LaserPointer should be displayed.
  103192. */
  103193. displayLaserPointer: boolean;
  103194. /**
  103195. * The deviceOrientationCamera used as the camera when not in VR.
  103196. */
  103197. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  103198. /**
  103199. * Based on the current WebVR support, returns the current VR camera used.
  103200. */
  103201. readonly currentVRCamera: Nullable<Camera>;
  103202. /**
  103203. * The webVRCamera which is used when in VR.
  103204. */
  103205. readonly webVRCamera: WebVRFreeCamera;
  103206. /**
  103207. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  103208. */
  103209. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  103210. private readonly _teleportationRequestInitiated;
  103211. /**
  103212. * Defines wether or not Pointer lock should be requested when switching to
  103213. * full screen.
  103214. */
  103215. requestPointerLockOnFullScreen: boolean;
  103216. /**
  103217. * Instantiates a VRExperienceHelper.
  103218. * Helps to quickly add VR support to an existing scene.
  103219. * @param scene The scene the VRExperienceHelper belongs to.
  103220. * @param webVROptions Options to modify the vr experience helper's behavior.
  103221. */
  103222. constructor(scene: Scene,
  103223. /** Options to modify the vr experience helper's behavior. */
  103224. webVROptions?: VRExperienceHelperOptions);
  103225. private _onDefaultMeshLoaded;
  103226. private _onResize;
  103227. private _onFullscreenChange;
  103228. /**
  103229. * Gets a value indicating if we are currently in VR mode.
  103230. */
  103231. readonly isInVRMode: boolean;
  103232. private onVrDisplayPresentChange;
  103233. private onVRDisplayChanged;
  103234. private moveButtonToBottomRight;
  103235. private displayVRButton;
  103236. private updateButtonVisibility;
  103237. private _cachedAngularSensibility;
  103238. /**
  103239. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  103240. * Otherwise, will use the fullscreen API.
  103241. */
  103242. enterVR(): void;
  103243. /**
  103244. * Attempt to exit VR, or fullscreen.
  103245. */
  103246. exitVR(): void;
  103247. /**
  103248. * The position of the vr experience helper.
  103249. */
  103250. /**
  103251. * Sets the position of the vr experience helper.
  103252. */
  103253. position: Vector3;
  103254. /**
  103255. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  103256. */
  103257. enableInteractions(): void;
  103258. private readonly _noControllerIsActive;
  103259. private beforeRender;
  103260. private _isTeleportationFloor;
  103261. /**
  103262. * Adds a floor mesh to be used for teleportation.
  103263. * @param floorMesh the mesh to be used for teleportation.
  103264. */
  103265. addFloorMesh(floorMesh: Mesh): void;
  103266. /**
  103267. * Removes a floor mesh from being used for teleportation.
  103268. * @param floorMesh the mesh to be removed.
  103269. */
  103270. removeFloorMesh(floorMesh: Mesh): void;
  103271. /**
  103272. * Enables interactions and teleportation using the VR controllers and gaze.
  103273. * @param vrTeleportationOptions options to modify teleportation behavior.
  103274. */
  103275. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  103276. private _onNewGamepadConnected;
  103277. private _tryEnableInteractionOnController;
  103278. private _onNewGamepadDisconnected;
  103279. private _enableInteractionOnController;
  103280. private _checkTeleportWithRay;
  103281. private _checkRotate;
  103282. private _checkTeleportBackwards;
  103283. private _enableTeleportationOnController;
  103284. private _createTeleportationCircles;
  103285. private _displayTeleportationTarget;
  103286. private _hideTeleportationTarget;
  103287. private _rotateCamera;
  103288. private _moveTeleportationSelectorTo;
  103289. private _workingVector;
  103290. private _workingQuaternion;
  103291. private _workingMatrix;
  103292. /**
  103293. * Teleports the users feet to the desired location
  103294. * @param location The location where the user's feet should be placed
  103295. */
  103296. teleportCamera(location: Vector3): void;
  103297. private _convertNormalToDirectionOfRay;
  103298. private _castRayAndSelectObject;
  103299. private _notifySelectedMeshUnselected;
  103300. /**
  103301. * Sets the color of the laser ray from the vr controllers.
  103302. * @param color new color for the ray.
  103303. */
  103304. changeLaserColor(color: Color3): void;
  103305. /**
  103306. * Sets the color of the ray from the vr headsets gaze.
  103307. * @param color new color for the ray.
  103308. */
  103309. changeGazeColor(color: Color3): void;
  103310. /**
  103311. * Exits VR and disposes of the vr experience helper
  103312. */
  103313. dispose(): void;
  103314. /**
  103315. * Gets the name of the VRExperienceHelper class
  103316. * @returns "VRExperienceHelper"
  103317. */
  103318. getClassName(): string;
  103319. }
  103320. }
  103321. declare module BABYLON {
  103322. /**
  103323. * Manages an XRSession to work with Babylon's engine
  103324. * @see https://doc.babylonjs.com/how_to/webxr
  103325. */
  103326. export class WebXRSessionManager implements IDisposable {
  103327. private scene;
  103328. /**
  103329. * Fires every time a new xrFrame arrives which can be used to update the camera
  103330. */
  103331. onXRFrameObservable: Observable<any>;
  103332. /**
  103333. * Fires when the xr session is ended either by the device or manually done
  103334. */
  103335. onXRSessionEnded: Observable<any>;
  103336. /**
  103337. * Underlying xr session
  103338. */
  103339. session: XRSession;
  103340. /**
  103341. * Type of reference space used when creating the session
  103342. */
  103343. referenceSpace: XRReferenceSpace;
  103344. /** @hidden */
  103345. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  103346. /**
  103347. * Current XR frame
  103348. */
  103349. currentFrame: Nullable<XRFrame>;
  103350. private _xrNavigator;
  103351. private baseLayer;
  103352. /**
  103353. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  103354. * @param scene The scene which the session should be created for
  103355. */
  103356. constructor(scene: Scene);
  103357. /**
  103358. * Initializes the manager
  103359. * After initialization enterXR can be called to start an XR session
  103360. * @returns Promise which resolves after it is initialized
  103361. */
  103362. initializeAsync(): Promise<void>;
  103363. /**
  103364. * Initializes an xr session
  103365. * @param xrSessionMode mode to initialize
  103366. * @returns a promise which will resolve once the session has been initialized
  103367. */
  103368. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  103369. /**
  103370. * Sets the reference space on the xr session
  103371. * @param referenceSpace space to set
  103372. * @returns a promise that will resolve once the reference space has been set
  103373. */
  103374. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  103375. /**
  103376. * Updates the render state of the session
  103377. * @param state state to set
  103378. * @returns a promise that resolves once the render state has been updated
  103379. */
  103380. updateRenderStateAsync(state: any): Promise<void>;
  103381. /**
  103382. * Starts rendering to the xr layer
  103383. * @returns a promise that will resolve once rendering has started
  103384. */
  103385. startRenderingToXRAsync(): Promise<void>;
  103386. /**
  103387. * Stops the xrSession and restores the renderloop
  103388. * @returns Promise which resolves after it exits XR
  103389. */
  103390. exitXRAsync(): Promise<unknown>;
  103391. /**
  103392. * Checks if a session would be supported for the creation options specified
  103393. * @param sessionMode session mode to check if supported eg. immersive-vr
  103394. * @returns true if supported
  103395. */
  103396. supportsSessionAsync(sessionMode: XRSessionMode): any;
  103397. /**
  103398. * @hidden
  103399. * Converts the render layer of xrSession to a render target
  103400. * @param session session to create render target for
  103401. * @param scene scene the new render target should be created for
  103402. */
  103403. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  103404. /**
  103405. * Disposes of the session manager
  103406. */
  103407. dispose(): void;
  103408. }
  103409. }
  103410. declare module BABYLON {
  103411. /**
  103412. * WebXR Camera which holds the views for the xrSession
  103413. * @see https://doc.babylonjs.com/how_to/webxr
  103414. */
  103415. export class WebXRCamera extends FreeCamera {
  103416. private static _TmpMatrix;
  103417. /**
  103418. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  103419. * @param name the name of the camera
  103420. * @param scene the scene to add the camera to
  103421. */
  103422. constructor(name: string, scene: Scene);
  103423. private _updateNumberOfRigCameras;
  103424. /** @hidden */
  103425. _updateForDualEyeDebugging(pupilDistance?: number): void;
  103426. /**
  103427. * Updates the cameras position from the current pose information of the XR session
  103428. * @param xrSessionManager the session containing pose information
  103429. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  103430. */
  103431. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  103432. }
  103433. }
  103434. declare module BABYLON {
  103435. /**
  103436. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  103437. */
  103438. export class WebXRManagedOutputCanvas implements IDisposable {
  103439. private helper;
  103440. private _canvas;
  103441. /**
  103442. * xrpresent context of the canvas which can be used to display/mirror xr content
  103443. */
  103444. canvasContext: WebGLRenderingContext;
  103445. /**
  103446. * xr layer for the canvas
  103447. */
  103448. xrLayer: Nullable<XRWebGLLayer>;
  103449. /**
  103450. * Initializes the xr layer for the session
  103451. * @param xrSession xr session
  103452. * @returns a promise that will resolve once the XR Layer has been created
  103453. */
  103454. initializeXRLayerAsync(xrSession: any): any;
  103455. /**
  103456. * Initializes the canvas to be added/removed upon entering/exiting xr
  103457. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  103458. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  103459. */
  103460. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  103461. /**
  103462. * Disposes of the object
  103463. */
  103464. dispose(): void;
  103465. private _setManagedOutputCanvas;
  103466. private _addCanvas;
  103467. private _removeCanvas;
  103468. }
  103469. }
  103470. declare module BABYLON {
  103471. /**
  103472. * States of the webXR experience
  103473. */
  103474. export enum WebXRState {
  103475. /**
  103476. * Transitioning to being in XR mode
  103477. */
  103478. ENTERING_XR = 0,
  103479. /**
  103480. * Transitioning to non XR mode
  103481. */
  103482. EXITING_XR = 1,
  103483. /**
  103484. * In XR mode and presenting
  103485. */
  103486. IN_XR = 2,
  103487. /**
  103488. * Not entered XR mode
  103489. */
  103490. NOT_IN_XR = 3
  103491. }
  103492. /**
  103493. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  103494. * @see https://doc.babylonjs.com/how_to/webxr
  103495. */
  103496. export class WebXRExperienceHelper implements IDisposable {
  103497. private scene;
  103498. /**
  103499. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  103500. */
  103501. container: AbstractMesh;
  103502. /**
  103503. * Camera used to render xr content
  103504. */
  103505. camera: WebXRCamera;
  103506. /**
  103507. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  103508. */
  103509. state: WebXRState;
  103510. private _setState;
  103511. private static _TmpVector;
  103512. /**
  103513. * Fires when the state of the experience helper has changed
  103514. */
  103515. onStateChangedObservable: Observable<WebXRState>;
  103516. /** Session manager used to keep track of xr session */
  103517. sessionManager: WebXRSessionManager;
  103518. private _nonVRCamera;
  103519. private _originalSceneAutoClear;
  103520. private _supported;
  103521. /**
  103522. * Creates the experience helper
  103523. * @param scene the scene to attach the experience helper to
  103524. * @returns a promise for the experience helper
  103525. */
  103526. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  103527. /**
  103528. * Creates a WebXRExperienceHelper
  103529. * @param scene The scene the helper should be created in
  103530. */
  103531. private constructor();
  103532. /**
  103533. * Exits XR mode and returns the scene to its original state
  103534. * @returns promise that resolves after xr mode has exited
  103535. */
  103536. exitXRAsync(): Promise<unknown>;
  103537. /**
  103538. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  103539. * @param sessionCreationOptions options for the XR session
  103540. * @param referenceSpaceType frame of reference of the XR session
  103541. * @param outputCanvas the output canvas that will be used to enter XR mode
  103542. * @returns promise that resolves after xr mode has entered
  103543. */
  103544. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  103545. /**
  103546. * Updates the global position of the camera by moving the camera's container
  103547. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  103548. * @param position The desired global position of the camera
  103549. */
  103550. setPositionOfCameraUsingContainer(position: Vector3): void;
  103551. /**
  103552. * Rotates the xr camera by rotating the camera's container around the camera's position
  103553. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  103554. * @param rotation the desired quaternion rotation to apply to the camera
  103555. */
  103556. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  103557. /**
  103558. * Disposes of the experience helper
  103559. */
  103560. dispose(): void;
  103561. }
  103562. }
  103563. declare module BABYLON {
  103564. /**
  103565. * Button which can be used to enter a different mode of XR
  103566. */
  103567. export class WebXREnterExitUIButton {
  103568. /** button element */
  103569. element: HTMLElement;
  103570. /** XR initialization options for the button */
  103571. sessionMode: XRSessionMode;
  103572. /** Reference space type */
  103573. referenceSpaceType: XRReferenceSpaceType;
  103574. /**
  103575. * Creates a WebXREnterExitUIButton
  103576. * @param element button element
  103577. * @param sessionMode XR initialization session mode
  103578. * @param referenceSpaceType the type of reference space to be used
  103579. */
  103580. constructor(
  103581. /** button element */
  103582. element: HTMLElement,
  103583. /** XR initialization options for the button */
  103584. sessionMode: XRSessionMode,
  103585. /** Reference space type */
  103586. referenceSpaceType: XRReferenceSpaceType);
  103587. /**
  103588. * Overwritable function which can be used to update the button's visuals when the state changes
  103589. * @param activeButton the current active button in the UI
  103590. */
  103591. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  103592. }
  103593. /**
  103594. * Options to create the webXR UI
  103595. */
  103596. export class WebXREnterExitUIOptions {
  103597. /**
  103598. * Context to enter xr with
  103599. */
  103600. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  103601. /**
  103602. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  103603. */
  103604. customButtons?: Array<WebXREnterExitUIButton>;
  103605. }
  103606. /**
  103607. * UI to allow the user to enter/exit XR mode
  103608. */
  103609. export class WebXREnterExitUI implements IDisposable {
  103610. private scene;
  103611. private _overlay;
  103612. private _buttons;
  103613. private _activeButton;
  103614. /**
  103615. * Fired every time the active button is changed.
  103616. *
  103617. * When xr is entered via a button that launches xr that button will be the callback parameter
  103618. *
  103619. * When exiting xr the callback parameter will be null)
  103620. */
  103621. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  103622. /**
  103623. * Creates UI to allow the user to enter/exit XR mode
  103624. * @param scene the scene to add the ui to
  103625. * @param helper the xr experience helper to enter/exit xr with
  103626. * @param options options to configure the UI
  103627. * @returns the created ui
  103628. */
  103629. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  103630. private constructor();
  103631. private _updateButtons;
  103632. /**
  103633. * Disposes of the object
  103634. */
  103635. dispose(): void;
  103636. }
  103637. }
  103638. declare module BABYLON {
  103639. /**
  103640. * Represents an XR input
  103641. */
  103642. export class WebXRController {
  103643. private scene;
  103644. /** The underlying input source for the controller */
  103645. inputSource: XRInputSource;
  103646. private parentContainer;
  103647. /**
  103648. * 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
  103649. */
  103650. grip?: AbstractMesh;
  103651. /**
  103652. * Pointer which can be used to select objects or attach a visible laser to
  103653. */
  103654. pointer: AbstractMesh;
  103655. /**
  103656. * Event that fires when the controller is removed/disposed
  103657. */
  103658. onDisposeObservable: Observable<{}>;
  103659. private _tmpMatrix;
  103660. private _tmpQuaternion;
  103661. private _tmpVector;
  103662. /**
  103663. * Creates the controller
  103664. * @see https://doc.babylonjs.com/how_to/webxr
  103665. * @param scene the scene which the controller should be associated to
  103666. * @param inputSource the underlying input source for the controller
  103667. * @param parentContainer parent that the controller meshes should be children of
  103668. */
  103669. constructor(scene: Scene,
  103670. /** The underlying input source for the controller */
  103671. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  103672. /**
  103673. * Updates the controller pose based on the given XRFrame
  103674. * @param xrFrame xr frame to update the pose with
  103675. * @param referenceSpace reference space to use
  103676. */
  103677. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  103678. /**
  103679. * Gets a world space ray coming from the controller
  103680. * @param result the resulting ray
  103681. */
  103682. getWorldPointerRayToRef(result: Ray): void;
  103683. /**
  103684. * Disposes of the object
  103685. */
  103686. dispose(): void;
  103687. }
  103688. }
  103689. declare module BABYLON {
  103690. /**
  103691. * XR input used to track XR inputs such as controllers/rays
  103692. */
  103693. export class WebXRInput implements IDisposable {
  103694. /**
  103695. * Base experience the input listens to
  103696. */
  103697. baseExperience: WebXRExperienceHelper;
  103698. /**
  103699. * XR controllers being tracked
  103700. */
  103701. controllers: Array<WebXRController>;
  103702. private _frameObserver;
  103703. private _stateObserver;
  103704. /**
  103705. * Event when a controller has been connected/added
  103706. */
  103707. onControllerAddedObservable: Observable<WebXRController>;
  103708. /**
  103709. * Event when a controller has been removed/disconnected
  103710. */
  103711. onControllerRemovedObservable: Observable<WebXRController>;
  103712. /**
  103713. * Initializes the WebXRInput
  103714. * @param baseExperience experience helper which the input should be created for
  103715. */
  103716. constructor(
  103717. /**
  103718. * Base experience the input listens to
  103719. */
  103720. baseExperience: WebXRExperienceHelper);
  103721. private _onInputSourcesChange;
  103722. private _addAndRemoveControllers;
  103723. /**
  103724. * Disposes of the object
  103725. */
  103726. dispose(): void;
  103727. }
  103728. }
  103729. declare module BABYLON {
  103730. /**
  103731. * Enables teleportation
  103732. */
  103733. export class WebXRControllerTeleportation {
  103734. private _teleportationFillColor;
  103735. private _teleportationBorderColor;
  103736. private _tmpRay;
  103737. private _tmpVector;
  103738. /**
  103739. * Creates a WebXRControllerTeleportation
  103740. * @param input input manager to add teleportation to
  103741. * @param floorMeshes floormeshes which can be teleported to
  103742. */
  103743. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  103744. }
  103745. }
  103746. declare module BABYLON {
  103747. /**
  103748. * Handles pointer input automatically for the pointer of XR controllers
  103749. */
  103750. export class WebXRControllerPointerSelection {
  103751. private static _idCounter;
  103752. private _tmpRay;
  103753. /**
  103754. * Creates a WebXRControllerPointerSelection
  103755. * @param input input manager to setup pointer selection
  103756. */
  103757. constructor(input: WebXRInput);
  103758. private _convertNormalToDirectionOfRay;
  103759. private _updatePointerDistance;
  103760. }
  103761. }
  103762. declare module BABYLON {
  103763. /**
  103764. * Class used to represent data loading progression
  103765. */
  103766. export class SceneLoaderProgressEvent {
  103767. /** defines if data length to load can be evaluated */
  103768. readonly lengthComputable: boolean;
  103769. /** defines the loaded data length */
  103770. readonly loaded: number;
  103771. /** defines the data length to load */
  103772. readonly total: number;
  103773. /**
  103774. * Create a new progress event
  103775. * @param lengthComputable defines if data length to load can be evaluated
  103776. * @param loaded defines the loaded data length
  103777. * @param total defines the data length to load
  103778. */
  103779. constructor(
  103780. /** defines if data length to load can be evaluated */
  103781. lengthComputable: boolean,
  103782. /** defines the loaded data length */
  103783. loaded: number,
  103784. /** defines the data length to load */
  103785. total: number);
  103786. /**
  103787. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  103788. * @param event defines the source event
  103789. * @returns a new SceneLoaderProgressEvent
  103790. */
  103791. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  103792. }
  103793. /**
  103794. * Interface used by SceneLoader plugins to define supported file extensions
  103795. */
  103796. export interface ISceneLoaderPluginExtensions {
  103797. /**
  103798. * Defines the list of supported extensions
  103799. */
  103800. [extension: string]: {
  103801. isBinary: boolean;
  103802. };
  103803. }
  103804. /**
  103805. * Interface used by SceneLoader plugin factory
  103806. */
  103807. export interface ISceneLoaderPluginFactory {
  103808. /**
  103809. * Defines the name of the factory
  103810. */
  103811. name: string;
  103812. /**
  103813. * Function called to create a new plugin
  103814. * @return the new plugin
  103815. */
  103816. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  103817. /**
  103818. * Boolean indicating if the plugin can direct load specific data
  103819. */
  103820. canDirectLoad?: (data: string) => boolean;
  103821. }
  103822. /**
  103823. * Interface used to define a SceneLoader plugin
  103824. */
  103825. export interface ISceneLoaderPlugin {
  103826. /**
  103827. * The friendly name of this plugin.
  103828. */
  103829. name: string;
  103830. /**
  103831. * The file extensions supported by this plugin.
  103832. */
  103833. extensions: string | ISceneLoaderPluginExtensions;
  103834. /**
  103835. * Import meshes into a scene.
  103836. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  103837. * @param scene The scene to import into
  103838. * @param data The data to import
  103839. * @param rootUrl The root url for scene and resources
  103840. * @param meshes The meshes array to import into
  103841. * @param particleSystems The particle systems array to import into
  103842. * @param skeletons The skeletons array to import into
  103843. * @param onError The callback when import fails
  103844. * @returns True if successful or false otherwise
  103845. */
  103846. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  103847. /**
  103848. * Load into a scene.
  103849. * @param scene The scene to load into
  103850. * @param data The data to import
  103851. * @param rootUrl The root url for scene and resources
  103852. * @param onError The callback when import fails
  103853. * @returns true if successful or false otherwise
  103854. */
  103855. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  103856. /**
  103857. * The callback that returns true if the data can be directly loaded.
  103858. */
  103859. canDirectLoad?: (data: string) => boolean;
  103860. /**
  103861. * The callback that allows custom handling of the root url based on the response url.
  103862. */
  103863. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  103864. /**
  103865. * Load into an asset container.
  103866. * @param scene The scene to load into
  103867. * @param data The data to import
  103868. * @param rootUrl The root url for scene and resources
  103869. * @param onError The callback when import fails
  103870. * @returns The loaded asset container
  103871. */
  103872. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  103873. }
  103874. /**
  103875. * Interface used to define an async SceneLoader plugin
  103876. */
  103877. export interface ISceneLoaderPluginAsync {
  103878. /**
  103879. * The friendly name of this plugin.
  103880. */
  103881. name: string;
  103882. /**
  103883. * The file extensions supported by this plugin.
  103884. */
  103885. extensions: string | ISceneLoaderPluginExtensions;
  103886. /**
  103887. * Import meshes into a scene.
  103888. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  103889. * @param scene The scene to import into
  103890. * @param data The data to import
  103891. * @param rootUrl The root url for scene and resources
  103892. * @param onProgress The callback when the load progresses
  103893. * @param fileName Defines the name of the file to load
  103894. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  103895. */
  103896. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  103897. meshes: AbstractMesh[];
  103898. particleSystems: IParticleSystem[];
  103899. skeletons: Skeleton[];
  103900. animationGroups: AnimationGroup[];
  103901. }>;
  103902. /**
  103903. * Load into a scene.
  103904. * @param scene The scene to load into
  103905. * @param data The data to import
  103906. * @param rootUrl The root url for scene and resources
  103907. * @param onProgress The callback when the load progresses
  103908. * @param fileName Defines the name of the file to load
  103909. * @returns Nothing
  103910. */
  103911. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  103912. /**
  103913. * The callback that returns true if the data can be directly loaded.
  103914. */
  103915. canDirectLoad?: (data: string) => boolean;
  103916. /**
  103917. * The callback that allows custom handling of the root url based on the response url.
  103918. */
  103919. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  103920. /**
  103921. * Load into an asset container.
  103922. * @param scene The scene to load into
  103923. * @param data The data to import
  103924. * @param rootUrl The root url for scene and resources
  103925. * @param onProgress The callback when the load progresses
  103926. * @param fileName Defines the name of the file to load
  103927. * @returns The loaded asset container
  103928. */
  103929. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  103930. }
  103931. /**
  103932. * Class used to load scene from various file formats using registered plugins
  103933. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  103934. */
  103935. export class SceneLoader {
  103936. /**
  103937. * No logging while loading
  103938. */
  103939. static readonly NO_LOGGING: number;
  103940. /**
  103941. * Minimal logging while loading
  103942. */
  103943. static readonly MINIMAL_LOGGING: number;
  103944. /**
  103945. * Summary logging while loading
  103946. */
  103947. static readonly SUMMARY_LOGGING: number;
  103948. /**
  103949. * Detailled logging while loading
  103950. */
  103951. static readonly DETAILED_LOGGING: number;
  103952. /**
  103953. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  103954. */
  103955. static ForceFullSceneLoadingForIncremental: boolean;
  103956. /**
  103957. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  103958. */
  103959. static ShowLoadingScreen: boolean;
  103960. /**
  103961. * Defines the current logging level (while loading the scene)
  103962. * @ignorenaming
  103963. */
  103964. static loggingLevel: number;
  103965. /**
  103966. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  103967. */
  103968. static CleanBoneMatrixWeights: boolean;
  103969. /**
  103970. * Event raised when a plugin is used to load a scene
  103971. */
  103972. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  103973. private static _registeredPlugins;
  103974. private static _getDefaultPlugin;
  103975. private static _getPluginForExtension;
  103976. private static _getPluginForDirectLoad;
  103977. private static _getPluginForFilename;
  103978. private static _getDirectLoad;
  103979. private static _loadData;
  103980. private static _getFileInfo;
  103981. /**
  103982. * Gets a plugin that can load the given extension
  103983. * @param extension defines the extension to load
  103984. * @returns a plugin or null if none works
  103985. */
  103986. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  103987. /**
  103988. * Gets a boolean indicating that the given extension can be loaded
  103989. * @param extension defines the extension to load
  103990. * @returns true if the extension is supported
  103991. */
  103992. static IsPluginForExtensionAvailable(extension: string): boolean;
  103993. /**
  103994. * Adds a new plugin to the list of registered plugins
  103995. * @param plugin defines the plugin to add
  103996. */
  103997. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  103998. /**
  103999. * Import meshes into a scene
  104000. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104001. * @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)
  104002. * @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)
  104003. * @param scene the instance of BABYLON.Scene to append to
  104004. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  104005. * @param onProgress a callback with a progress event for each file being loaded
  104006. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104007. * @param pluginExtension the extension used to determine the plugin
  104008. * @returns The loaded plugin
  104009. */
  104010. 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>;
  104011. /**
  104012. * Import meshes into a scene
  104013. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104014. * @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)
  104015. * @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)
  104016. * @param scene the instance of BABYLON.Scene to append to
  104017. * @param onProgress a callback with a progress event for each file being loaded
  104018. * @param pluginExtension the extension used to determine the plugin
  104019. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  104020. */
  104021. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  104022. meshes: AbstractMesh[];
  104023. particleSystems: IParticleSystem[];
  104024. skeletons: Skeleton[];
  104025. animationGroups: AnimationGroup[];
  104026. }>;
  104027. /**
  104028. * Load a scene
  104029. * @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)
  104030. * @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)
  104031. * @param engine is the instance of BABYLON.Engine to use to create the scene
  104032. * @param onSuccess a callback with the scene when import succeeds
  104033. * @param onProgress a callback with a progress event for each file being loaded
  104034. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104035. * @param pluginExtension the extension used to determine the plugin
  104036. * @returns The loaded plugin
  104037. */
  104038. 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>;
  104039. /**
  104040. * Load a scene
  104041. * @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)
  104042. * @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)
  104043. * @param engine is the instance of BABYLON.Engine to use to create the scene
  104044. * @param onProgress a callback with a progress event for each file being loaded
  104045. * @param pluginExtension the extension used to determine the plugin
  104046. * @returns The loaded scene
  104047. */
  104048. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  104049. /**
  104050. * Append a scene
  104051. * @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)
  104052. * @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)
  104053. * @param scene is the instance of BABYLON.Scene to append to
  104054. * @param onSuccess a callback with the scene when import succeeds
  104055. * @param onProgress a callback with a progress event for each file being loaded
  104056. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104057. * @param pluginExtension the extension used to determine the plugin
  104058. * @returns The loaded plugin
  104059. */
  104060. 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>;
  104061. /**
  104062. * Append a scene
  104063. * @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)
  104064. * @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)
  104065. * @param scene is the instance of BABYLON.Scene to append to
  104066. * @param onProgress a callback with a progress event for each file being loaded
  104067. * @param pluginExtension the extension used to determine the plugin
  104068. * @returns The given scene
  104069. */
  104070. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  104071. /**
  104072. * Load a scene into an asset container
  104073. * @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)
  104074. * @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)
  104075. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  104076. * @param onSuccess a callback with the scene when import succeeds
  104077. * @param onProgress a callback with a progress event for each file being loaded
  104078. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104079. * @param pluginExtension the extension used to determine the plugin
  104080. * @returns The loaded plugin
  104081. */
  104082. 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>;
  104083. /**
  104084. * Load a scene into an asset container
  104085. * @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)
  104086. * @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)
  104087. * @param scene is the instance of Scene to append to
  104088. * @param onProgress a callback with a progress event for each file being loaded
  104089. * @param pluginExtension the extension used to determine the plugin
  104090. * @returns The loaded asset container
  104091. */
  104092. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  104093. }
  104094. }
  104095. declare module BABYLON {
  104096. /**
  104097. * Generic Controller
  104098. */
  104099. export class GenericController extends WebVRController {
  104100. /**
  104101. * Base Url for the controller model.
  104102. */
  104103. static readonly MODEL_BASE_URL: string;
  104104. /**
  104105. * File name for the controller model.
  104106. */
  104107. static readonly MODEL_FILENAME: string;
  104108. /**
  104109. * Creates a new GenericController from a gamepad
  104110. * @param vrGamepad the gamepad that the controller should be created from
  104111. */
  104112. constructor(vrGamepad: any);
  104113. /**
  104114. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104115. * @param scene scene in which to add meshes
  104116. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104117. */
  104118. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  104119. /**
  104120. * Called once for each button that changed state since the last frame
  104121. * @param buttonIdx Which button index changed
  104122. * @param state New state of the button
  104123. * @param changes Which properties on the state changed since last frame
  104124. */
  104125. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104126. }
  104127. }
  104128. declare module BABYLON {
  104129. /**
  104130. * Defines the WindowsMotionController object that the state of the windows motion controller
  104131. */
  104132. export class WindowsMotionController extends WebVRController {
  104133. /**
  104134. * The base url used to load the left and right controller models
  104135. */
  104136. static MODEL_BASE_URL: string;
  104137. /**
  104138. * The name of the left controller model file
  104139. */
  104140. static MODEL_LEFT_FILENAME: string;
  104141. /**
  104142. * The name of the right controller model file
  104143. */
  104144. static MODEL_RIGHT_FILENAME: string;
  104145. /**
  104146. * The controller name prefix for this controller type
  104147. */
  104148. static readonly GAMEPAD_ID_PREFIX: string;
  104149. /**
  104150. * The controller id pattern for this controller type
  104151. */
  104152. private static readonly GAMEPAD_ID_PATTERN;
  104153. private _loadedMeshInfo;
  104154. private readonly _mapping;
  104155. /**
  104156. * Fired when the trackpad on this controller is clicked
  104157. */
  104158. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  104159. /**
  104160. * Fired when the trackpad on this controller is modified
  104161. */
  104162. onTrackpadValuesChangedObservable: Observable<StickValues>;
  104163. /**
  104164. * The current x and y values of this controller's trackpad
  104165. */
  104166. trackpad: StickValues;
  104167. /**
  104168. * Creates a new WindowsMotionController from a gamepad
  104169. * @param vrGamepad the gamepad that the controller should be created from
  104170. */
  104171. constructor(vrGamepad: any);
  104172. /**
  104173. * Fired when the trigger on this controller is modified
  104174. */
  104175. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104176. /**
  104177. * Fired when the menu button on this controller is modified
  104178. */
  104179. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104180. /**
  104181. * Fired when the grip button on this controller is modified
  104182. */
  104183. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104184. /**
  104185. * Fired when the thumbstick button on this controller is modified
  104186. */
  104187. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104188. /**
  104189. * Fired when the touchpad button on this controller is modified
  104190. */
  104191. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104192. /**
  104193. * Fired when the touchpad values on this controller are modified
  104194. */
  104195. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  104196. private _updateTrackpad;
  104197. /**
  104198. * Called once per frame by the engine.
  104199. */
  104200. update(): void;
  104201. /**
  104202. * Called once for each button that changed state since the last frame
  104203. * @param buttonIdx Which button index changed
  104204. * @param state New state of the button
  104205. * @param changes Which properties on the state changed since last frame
  104206. */
  104207. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104208. /**
  104209. * Moves the buttons on the controller mesh based on their current state
  104210. * @param buttonName the name of the button to move
  104211. * @param buttonValue the value of the button which determines the buttons new position
  104212. */
  104213. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  104214. /**
  104215. * Moves the axis on the controller mesh based on its current state
  104216. * @param axis the index of the axis
  104217. * @param axisValue the value of the axis which determines the meshes new position
  104218. * @hidden
  104219. */
  104220. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  104221. /**
  104222. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104223. * @param scene scene in which to add meshes
  104224. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104225. */
  104226. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  104227. /**
  104228. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  104229. * can be transformed by button presses and axes values, based on this._mapping.
  104230. *
  104231. * @param scene scene in which the meshes exist
  104232. * @param meshes list of meshes that make up the controller model to process
  104233. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  104234. */
  104235. private processModel;
  104236. private createMeshInfo;
  104237. /**
  104238. * Gets the ray of the controller in the direction the controller is pointing
  104239. * @param length the length the resulting ray should be
  104240. * @returns a ray in the direction the controller is pointing
  104241. */
  104242. getForwardRay(length?: number): Ray;
  104243. /**
  104244. * Disposes of the controller
  104245. */
  104246. dispose(): void;
  104247. }
  104248. }
  104249. declare module BABYLON {
  104250. /**
  104251. * Oculus Touch Controller
  104252. */
  104253. export class OculusTouchController extends WebVRController {
  104254. /**
  104255. * Base Url for the controller model.
  104256. */
  104257. static MODEL_BASE_URL: string;
  104258. /**
  104259. * File name for the left controller model.
  104260. */
  104261. static MODEL_LEFT_FILENAME: string;
  104262. /**
  104263. * File name for the right controller model.
  104264. */
  104265. static MODEL_RIGHT_FILENAME: string;
  104266. /**
  104267. * Base Url for the Quest controller model.
  104268. */
  104269. static QUEST_MODEL_BASE_URL: string;
  104270. /**
  104271. * @hidden
  104272. * If the controllers are running on a device that needs the updated Quest controller models
  104273. */
  104274. static _IsQuest: boolean;
  104275. /**
  104276. * Fired when the secondary trigger on this controller is modified
  104277. */
  104278. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  104279. /**
  104280. * Fired when the thumb rest on this controller is modified
  104281. */
  104282. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  104283. /**
  104284. * Creates a new OculusTouchController from a gamepad
  104285. * @param vrGamepad the gamepad that the controller should be created from
  104286. */
  104287. constructor(vrGamepad: any);
  104288. /**
  104289. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104290. * @param scene scene in which to add meshes
  104291. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104292. */
  104293. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  104294. /**
  104295. * Fired when the A button on this controller is modified
  104296. */
  104297. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104298. /**
  104299. * Fired when the B button on this controller is modified
  104300. */
  104301. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104302. /**
  104303. * Fired when the X button on this controller is modified
  104304. */
  104305. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104306. /**
  104307. * Fired when the Y button on this controller is modified
  104308. */
  104309. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104310. /**
  104311. * Called once for each button that changed state since the last frame
  104312. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  104313. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  104314. * 2) secondary trigger (same)
  104315. * 3) A (right) X (left), touch, pressed = value
  104316. * 4) B / Y
  104317. * 5) thumb rest
  104318. * @param buttonIdx Which button index changed
  104319. * @param state New state of the button
  104320. * @param changes Which properties on the state changed since last frame
  104321. */
  104322. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104323. }
  104324. }
  104325. declare module BABYLON {
  104326. /**
  104327. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  104328. */
  104329. export class WebXRControllerModelLoader {
  104330. /**
  104331. * Creates the WebXRControllerModelLoader
  104332. * @param input xr input that creates the controllers
  104333. */
  104334. constructor(input: WebXRInput);
  104335. }
  104336. }
  104337. declare module BABYLON {
  104338. /**
  104339. * Contains an array of blocks representing the octree
  104340. */
  104341. export interface IOctreeContainer<T> {
  104342. /**
  104343. * Blocks within the octree
  104344. */
  104345. blocks: Array<OctreeBlock<T>>;
  104346. }
  104347. /**
  104348. * Class used to store a cell in an octree
  104349. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  104350. */
  104351. export class OctreeBlock<T> {
  104352. /**
  104353. * Gets the content of the current block
  104354. */
  104355. entries: T[];
  104356. /**
  104357. * Gets the list of block children
  104358. */
  104359. blocks: Array<OctreeBlock<T>>;
  104360. private _depth;
  104361. private _maxDepth;
  104362. private _capacity;
  104363. private _minPoint;
  104364. private _maxPoint;
  104365. private _boundingVectors;
  104366. private _creationFunc;
  104367. /**
  104368. * Creates a new block
  104369. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  104370. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  104371. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  104372. * @param depth defines the current depth of this block in the octree
  104373. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  104374. * @param creationFunc defines a callback to call when an element is added to the block
  104375. */
  104376. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  104377. /**
  104378. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  104379. */
  104380. readonly capacity: number;
  104381. /**
  104382. * Gets the minimum vector (in world space) of the block's bounding box
  104383. */
  104384. readonly minPoint: Vector3;
  104385. /**
  104386. * Gets the maximum vector (in world space) of the block's bounding box
  104387. */
  104388. readonly maxPoint: Vector3;
  104389. /**
  104390. * Add a new element to this block
  104391. * @param entry defines the element to add
  104392. */
  104393. addEntry(entry: T): void;
  104394. /**
  104395. * Remove an element from this block
  104396. * @param entry defines the element to remove
  104397. */
  104398. removeEntry(entry: T): void;
  104399. /**
  104400. * Add an array of elements to this block
  104401. * @param entries defines the array of elements to add
  104402. */
  104403. addEntries(entries: T[]): void;
  104404. /**
  104405. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  104406. * @param frustumPlanes defines the frustum planes to test
  104407. * @param selection defines the array to store current content if selection is positive
  104408. * @param allowDuplicate defines if the selection array can contains duplicated entries
  104409. */
  104410. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  104411. /**
  104412. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  104413. * @param sphereCenter defines the bounding sphere center
  104414. * @param sphereRadius defines the bounding sphere radius
  104415. * @param selection defines the array to store current content if selection is positive
  104416. * @param allowDuplicate defines if the selection array can contains duplicated entries
  104417. */
  104418. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  104419. /**
  104420. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  104421. * @param ray defines the ray to test with
  104422. * @param selection defines the array to store current content if selection is positive
  104423. */
  104424. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  104425. /**
  104426. * Subdivide the content into child blocks (this block will then be empty)
  104427. */
  104428. createInnerBlocks(): void;
  104429. /**
  104430. * @hidden
  104431. */
  104432. 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;
  104433. }
  104434. }
  104435. declare module BABYLON {
  104436. /**
  104437. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  104438. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  104439. */
  104440. export class Octree<T> {
  104441. /** 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.) */
  104442. maxDepth: number;
  104443. /**
  104444. * Blocks within the octree containing objects
  104445. */
  104446. blocks: Array<OctreeBlock<T>>;
  104447. /**
  104448. * Content stored in the octree
  104449. */
  104450. dynamicContent: T[];
  104451. private _maxBlockCapacity;
  104452. private _selectionContent;
  104453. private _creationFunc;
  104454. /**
  104455. * Creates a octree
  104456. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  104457. * @param creationFunc function to be used to instatiate the octree
  104458. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  104459. * @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.)
  104460. */
  104461. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  104462. /** 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.) */
  104463. maxDepth?: number);
  104464. /**
  104465. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  104466. * @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);
  104467. * @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);
  104468. * @param entries meshes to be added to the octree blocks
  104469. */
  104470. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  104471. /**
  104472. * Adds a mesh to the octree
  104473. * @param entry Mesh to add to the octree
  104474. */
  104475. addMesh(entry: T): void;
  104476. /**
  104477. * Remove an element from the octree
  104478. * @param entry defines the element to remove
  104479. */
  104480. removeMesh(entry: T): void;
  104481. /**
  104482. * Selects an array of meshes within the frustum
  104483. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  104484. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  104485. * @returns array of meshes within the frustum
  104486. */
  104487. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  104488. /**
  104489. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  104490. * @param sphereCenter defines the bounding sphere center
  104491. * @param sphereRadius defines the bounding sphere radius
  104492. * @param allowDuplicate defines if the selection array can contains duplicated entries
  104493. * @returns an array of objects that intersect the sphere
  104494. */
  104495. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  104496. /**
  104497. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  104498. * @param ray defines the ray to test with
  104499. * @returns array of intersected objects
  104500. */
  104501. intersectsRay(ray: Ray): SmartArray<T>;
  104502. /**
  104503. * Adds a mesh into the octree block if it intersects the block
  104504. */
  104505. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  104506. /**
  104507. * Adds a submesh into the octree block if it intersects the block
  104508. */
  104509. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  104510. }
  104511. }
  104512. declare module BABYLON {
  104513. interface Scene {
  104514. /**
  104515. * @hidden
  104516. * Backing Filed
  104517. */
  104518. _selectionOctree: Octree<AbstractMesh>;
  104519. /**
  104520. * Gets the octree used to boost mesh selection (picking)
  104521. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  104522. */
  104523. selectionOctree: Octree<AbstractMesh>;
  104524. /**
  104525. * Creates or updates the octree used to boost selection (picking)
  104526. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  104527. * @param maxCapacity defines the maximum capacity per leaf
  104528. * @param maxDepth defines the maximum depth of the octree
  104529. * @returns an octree of AbstractMesh
  104530. */
  104531. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  104532. }
  104533. interface AbstractMesh {
  104534. /**
  104535. * @hidden
  104536. * Backing Field
  104537. */
  104538. _submeshesOctree: Octree<SubMesh>;
  104539. /**
  104540. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  104541. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  104542. * @param maxCapacity defines the maximum size of each block (64 by default)
  104543. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  104544. * @returns the new octree
  104545. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  104546. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  104547. */
  104548. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  104549. }
  104550. /**
  104551. * Defines the octree scene component responsible to manage any octrees
  104552. * in a given scene.
  104553. */
  104554. export class OctreeSceneComponent {
  104555. /**
  104556. * The component name help to identify the component in the list of scene components.
  104557. */
  104558. readonly name: string;
  104559. /**
  104560. * The scene the component belongs to.
  104561. */
  104562. scene: Scene;
  104563. /**
  104564. * Indicates if the meshes have been checked to make sure they are isEnabled()
  104565. */
  104566. readonly checksIsEnabled: boolean;
  104567. /**
  104568. * Creates a new instance of the component for the given scene
  104569. * @param scene Defines the scene to register the component in
  104570. */
  104571. constructor(scene: Scene);
  104572. /**
  104573. * Registers the component in a given scene
  104574. */
  104575. register(): void;
  104576. /**
  104577. * Return the list of active meshes
  104578. * @returns the list of active meshes
  104579. */
  104580. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  104581. /**
  104582. * Return the list of active sub meshes
  104583. * @param mesh The mesh to get the candidates sub meshes from
  104584. * @returns the list of active sub meshes
  104585. */
  104586. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  104587. private _tempRay;
  104588. /**
  104589. * Return the list of sub meshes intersecting with a given local ray
  104590. * @param mesh defines the mesh to find the submesh for
  104591. * @param localRay defines the ray in local space
  104592. * @returns the list of intersecting sub meshes
  104593. */
  104594. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  104595. /**
  104596. * Return the list of sub meshes colliding with a collider
  104597. * @param mesh defines the mesh to find the submesh for
  104598. * @param collider defines the collider to evaluate the collision against
  104599. * @returns the list of colliding sub meshes
  104600. */
  104601. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  104602. /**
  104603. * Rebuilds the elements related to this component in case of
  104604. * context lost for instance.
  104605. */
  104606. rebuild(): void;
  104607. /**
  104608. * Disposes the component and the associated ressources.
  104609. */
  104610. dispose(): void;
  104611. }
  104612. }
  104613. declare module BABYLON {
  104614. /**
  104615. * Renders a layer on top of an existing scene
  104616. */
  104617. export class UtilityLayerRenderer implements IDisposable {
  104618. /** the original scene that will be rendered on top of */
  104619. originalScene: Scene;
  104620. private _pointerCaptures;
  104621. private _lastPointerEvents;
  104622. private static _DefaultUtilityLayer;
  104623. private static _DefaultKeepDepthUtilityLayer;
  104624. private _sharedGizmoLight;
  104625. private _renderCamera;
  104626. /**
  104627. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  104628. * @returns the camera that is used when rendering the utility layer
  104629. */
  104630. getRenderCamera(): Nullable<Camera>;
  104631. /**
  104632. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  104633. * @param cam the camera that should be used when rendering the utility layer
  104634. */
  104635. setRenderCamera(cam: Nullable<Camera>): void;
  104636. /**
  104637. * @hidden
  104638. * Light which used by gizmos to get light shading
  104639. */
  104640. _getSharedGizmoLight(): HemisphericLight;
  104641. /**
  104642. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  104643. */
  104644. pickUtilitySceneFirst: boolean;
  104645. /**
  104646. * 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)
  104647. */
  104648. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  104649. /**
  104650. * 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)
  104651. */
  104652. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  104653. /**
  104654. * The scene that is rendered on top of the original scene
  104655. */
  104656. utilityLayerScene: Scene;
  104657. /**
  104658. * If the utility layer should automatically be rendered on top of existing scene
  104659. */
  104660. shouldRender: boolean;
  104661. /**
  104662. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  104663. */
  104664. onlyCheckPointerDownEvents: boolean;
  104665. /**
  104666. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  104667. */
  104668. processAllEvents: boolean;
  104669. /**
  104670. * Observable raised when the pointer move from the utility layer scene to the main scene
  104671. */
  104672. onPointerOutObservable: Observable<number>;
  104673. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  104674. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  104675. private _afterRenderObserver;
  104676. private _sceneDisposeObserver;
  104677. private _originalPointerObserver;
  104678. /**
  104679. * Instantiates a UtilityLayerRenderer
  104680. * @param originalScene the original scene that will be rendered on top of
  104681. * @param handleEvents boolean indicating if the utility layer should handle events
  104682. */
  104683. constructor(
  104684. /** the original scene that will be rendered on top of */
  104685. originalScene: Scene, handleEvents?: boolean);
  104686. private _notifyObservers;
  104687. /**
  104688. * Renders the utility layers scene on top of the original scene
  104689. */
  104690. render(): void;
  104691. /**
  104692. * Disposes of the renderer
  104693. */
  104694. dispose(): void;
  104695. private _updateCamera;
  104696. }
  104697. }
  104698. declare module BABYLON {
  104699. /**
  104700. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  104701. */
  104702. export class Gizmo implements IDisposable {
  104703. /** The utility layer the gizmo will be added to */
  104704. gizmoLayer: UtilityLayerRenderer;
  104705. /**
  104706. * The root mesh of the gizmo
  104707. */
  104708. _rootMesh: Mesh;
  104709. private _attachedMesh;
  104710. /**
  104711. * Ratio for the scale of the gizmo (Default: 1)
  104712. */
  104713. scaleRatio: number;
  104714. /**
  104715. * If a custom mesh has been set (Default: false)
  104716. */
  104717. protected _customMeshSet: boolean;
  104718. /**
  104719. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  104720. * * When set, interactions will be enabled
  104721. */
  104722. attachedMesh: Nullable<AbstractMesh>;
  104723. /**
  104724. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  104725. * @param mesh The mesh to replace the default mesh of the gizmo
  104726. */
  104727. setCustomMesh(mesh: Mesh): void;
  104728. /**
  104729. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  104730. */
  104731. updateGizmoRotationToMatchAttachedMesh: boolean;
  104732. /**
  104733. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  104734. */
  104735. updateGizmoPositionToMatchAttachedMesh: boolean;
  104736. /**
  104737. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  104738. */
  104739. protected _updateScale: boolean;
  104740. protected _interactionsEnabled: boolean;
  104741. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104742. private _beforeRenderObserver;
  104743. private _tempVector;
  104744. /**
  104745. * Creates a gizmo
  104746. * @param gizmoLayer The utility layer the gizmo will be added to
  104747. */
  104748. constructor(
  104749. /** The utility layer the gizmo will be added to */
  104750. gizmoLayer?: UtilityLayerRenderer);
  104751. /**
  104752. * Updates the gizmo to match the attached mesh's position/rotation
  104753. */
  104754. protected _update(): void;
  104755. /**
  104756. * Disposes of the gizmo
  104757. */
  104758. dispose(): void;
  104759. }
  104760. }
  104761. declare module BABYLON {
  104762. /**
  104763. * Single plane drag gizmo
  104764. */
  104765. export class PlaneDragGizmo extends Gizmo {
  104766. /**
  104767. * Drag behavior responsible for the gizmos dragging interactions
  104768. */
  104769. dragBehavior: PointerDragBehavior;
  104770. private _pointerObserver;
  104771. /**
  104772. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104773. */
  104774. snapDistance: number;
  104775. /**
  104776. * Event that fires each time the gizmo snaps to a new location.
  104777. * * snapDistance is the the change in distance
  104778. */
  104779. onSnapObservable: Observable<{
  104780. snapDistance: number;
  104781. }>;
  104782. private _plane;
  104783. private _coloredMaterial;
  104784. private _hoverMaterial;
  104785. private _isEnabled;
  104786. private _parent;
  104787. /** @hidden */
  104788. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  104789. /** @hidden */
  104790. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  104791. /**
  104792. * Creates a PlaneDragGizmo
  104793. * @param gizmoLayer The utility layer the gizmo will be added to
  104794. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  104795. * @param color The color of the gizmo
  104796. */
  104797. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  104798. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104799. /**
  104800. * If the gizmo is enabled
  104801. */
  104802. isEnabled: boolean;
  104803. /**
  104804. * Disposes of the gizmo
  104805. */
  104806. dispose(): void;
  104807. }
  104808. }
  104809. declare module BABYLON {
  104810. /**
  104811. * Gizmo that enables dragging a mesh along 3 axis
  104812. */
  104813. export class PositionGizmo extends Gizmo {
  104814. /**
  104815. * Internal gizmo used for interactions on the x axis
  104816. */
  104817. xGizmo: AxisDragGizmo;
  104818. /**
  104819. * Internal gizmo used for interactions on the y axis
  104820. */
  104821. yGizmo: AxisDragGizmo;
  104822. /**
  104823. * Internal gizmo used for interactions on the z axis
  104824. */
  104825. zGizmo: AxisDragGizmo;
  104826. /**
  104827. * Internal gizmo used for interactions on the yz plane
  104828. */
  104829. xPlaneGizmo: PlaneDragGizmo;
  104830. /**
  104831. * Internal gizmo used for interactions on the xz plane
  104832. */
  104833. yPlaneGizmo: PlaneDragGizmo;
  104834. /**
  104835. * Internal gizmo used for interactions on the xy plane
  104836. */
  104837. zPlaneGizmo: PlaneDragGizmo;
  104838. /**
  104839. * private variables
  104840. */
  104841. private _meshAttached;
  104842. private _updateGizmoRotationToMatchAttachedMesh;
  104843. private _snapDistance;
  104844. private _scaleRatio;
  104845. /** Fires an event when any of it's sub gizmos are dragged */
  104846. onDragStartObservable: Observable<unknown>;
  104847. /** Fires an event when any of it's sub gizmos are released from dragging */
  104848. onDragEndObservable: Observable<unknown>;
  104849. /**
  104850. * If set to true, planar drag is enabled
  104851. */
  104852. private _planarGizmoEnabled;
  104853. attachedMesh: Nullable<AbstractMesh>;
  104854. /**
  104855. * Creates a PositionGizmo
  104856. * @param gizmoLayer The utility layer the gizmo will be added to
  104857. */
  104858. constructor(gizmoLayer?: UtilityLayerRenderer);
  104859. /**
  104860. * If the planar drag gizmo is enabled
  104861. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  104862. */
  104863. planarGizmoEnabled: boolean;
  104864. updateGizmoRotationToMatchAttachedMesh: boolean;
  104865. /**
  104866. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104867. */
  104868. snapDistance: number;
  104869. /**
  104870. * Ratio for the scale of the gizmo (Default: 1)
  104871. */
  104872. scaleRatio: number;
  104873. /**
  104874. * Disposes of the gizmo
  104875. */
  104876. dispose(): void;
  104877. /**
  104878. * CustomMeshes are not supported by this gizmo
  104879. * @param mesh The mesh to replace the default mesh of the gizmo
  104880. */
  104881. setCustomMesh(mesh: Mesh): void;
  104882. }
  104883. }
  104884. declare module BABYLON {
  104885. /**
  104886. * Single axis drag gizmo
  104887. */
  104888. export class AxisDragGizmo extends Gizmo {
  104889. /**
  104890. * Drag behavior responsible for the gizmos dragging interactions
  104891. */
  104892. dragBehavior: PointerDragBehavior;
  104893. private _pointerObserver;
  104894. /**
  104895. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104896. */
  104897. snapDistance: number;
  104898. /**
  104899. * Event that fires each time the gizmo snaps to a new location.
  104900. * * snapDistance is the the change in distance
  104901. */
  104902. onSnapObservable: Observable<{
  104903. snapDistance: number;
  104904. }>;
  104905. private _isEnabled;
  104906. private _parent;
  104907. private _arrow;
  104908. private _coloredMaterial;
  104909. private _hoverMaterial;
  104910. /** @hidden */
  104911. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  104912. /** @hidden */
  104913. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  104914. /**
  104915. * Creates an AxisDragGizmo
  104916. * @param gizmoLayer The utility layer the gizmo will be added to
  104917. * @param dragAxis The axis which the gizmo will be able to drag on
  104918. * @param color The color of the gizmo
  104919. */
  104920. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  104921. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104922. /**
  104923. * If the gizmo is enabled
  104924. */
  104925. isEnabled: boolean;
  104926. /**
  104927. * Disposes of the gizmo
  104928. */
  104929. dispose(): void;
  104930. }
  104931. }
  104932. declare module BABYLON.Debug {
  104933. /**
  104934. * The Axes viewer will show 3 axes in a specific point in space
  104935. */
  104936. export class AxesViewer {
  104937. private _xAxis;
  104938. private _yAxis;
  104939. private _zAxis;
  104940. private _scaleLinesFactor;
  104941. private _instanced;
  104942. /**
  104943. * Gets the hosting scene
  104944. */
  104945. scene: Scene;
  104946. /**
  104947. * Gets or sets a number used to scale line length
  104948. */
  104949. scaleLines: number;
  104950. /** Gets the node hierarchy used to render x-axis */
  104951. readonly xAxis: TransformNode;
  104952. /** Gets the node hierarchy used to render y-axis */
  104953. readonly yAxis: TransformNode;
  104954. /** Gets the node hierarchy used to render z-axis */
  104955. readonly zAxis: TransformNode;
  104956. /**
  104957. * Creates a new AxesViewer
  104958. * @param scene defines the hosting scene
  104959. * @param scaleLines defines a number used to scale line length (1 by default)
  104960. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  104961. * @param xAxis defines the node hierarchy used to render the x-axis
  104962. * @param yAxis defines the node hierarchy used to render the y-axis
  104963. * @param zAxis defines the node hierarchy used to render the z-axis
  104964. */
  104965. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  104966. /**
  104967. * Force the viewer to update
  104968. * @param position defines the position of the viewer
  104969. * @param xaxis defines the x axis of the viewer
  104970. * @param yaxis defines the y axis of the viewer
  104971. * @param zaxis defines the z axis of the viewer
  104972. */
  104973. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  104974. /**
  104975. * Creates an instance of this axes viewer.
  104976. * @returns a new axes viewer with instanced meshes
  104977. */
  104978. createInstance(): AxesViewer;
  104979. /** Releases resources */
  104980. dispose(): void;
  104981. private static _SetRenderingGroupId;
  104982. }
  104983. }
  104984. declare module BABYLON.Debug {
  104985. /**
  104986. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  104987. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  104988. */
  104989. export class BoneAxesViewer extends AxesViewer {
  104990. /**
  104991. * Gets or sets the target mesh where to display the axes viewer
  104992. */
  104993. mesh: Nullable<Mesh>;
  104994. /**
  104995. * Gets or sets the target bone where to display the axes viewer
  104996. */
  104997. bone: Nullable<Bone>;
  104998. /** Gets current position */
  104999. pos: Vector3;
  105000. /** Gets direction of X axis */
  105001. xaxis: Vector3;
  105002. /** Gets direction of Y axis */
  105003. yaxis: Vector3;
  105004. /** Gets direction of Z axis */
  105005. zaxis: Vector3;
  105006. /**
  105007. * Creates a new BoneAxesViewer
  105008. * @param scene defines the hosting scene
  105009. * @param bone defines the target bone
  105010. * @param mesh defines the target mesh
  105011. * @param scaleLines defines a scaling factor for line length (1 by default)
  105012. */
  105013. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  105014. /**
  105015. * Force the viewer to update
  105016. */
  105017. update(): void;
  105018. /** Releases resources */
  105019. dispose(): void;
  105020. }
  105021. }
  105022. declare module BABYLON {
  105023. /**
  105024. * Interface used to define scene explorer extensibility option
  105025. */
  105026. export interface IExplorerExtensibilityOption {
  105027. /**
  105028. * Define the option label
  105029. */
  105030. label: string;
  105031. /**
  105032. * Defines the action to execute on click
  105033. */
  105034. action: (entity: any) => void;
  105035. }
  105036. /**
  105037. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  105038. */
  105039. export interface IExplorerExtensibilityGroup {
  105040. /**
  105041. * Defines a predicate to test if a given type mut be extended
  105042. */
  105043. predicate: (entity: any) => boolean;
  105044. /**
  105045. * Gets the list of options added to a type
  105046. */
  105047. entries: IExplorerExtensibilityOption[];
  105048. }
  105049. /**
  105050. * Interface used to define the options to use to create the Inspector
  105051. */
  105052. export interface IInspectorOptions {
  105053. /**
  105054. * Display in overlay mode (default: false)
  105055. */
  105056. overlay?: boolean;
  105057. /**
  105058. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  105059. */
  105060. globalRoot?: HTMLElement;
  105061. /**
  105062. * Display the Scene explorer
  105063. */
  105064. showExplorer?: boolean;
  105065. /**
  105066. * Display the property inspector
  105067. */
  105068. showInspector?: boolean;
  105069. /**
  105070. * Display in embed mode (both panes on the right)
  105071. */
  105072. embedMode?: boolean;
  105073. /**
  105074. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  105075. */
  105076. handleResize?: boolean;
  105077. /**
  105078. * Allow the panes to popup (default: true)
  105079. */
  105080. enablePopup?: boolean;
  105081. /**
  105082. * Allow the panes to be closed by users (default: true)
  105083. */
  105084. enableClose?: boolean;
  105085. /**
  105086. * Optional list of extensibility entries
  105087. */
  105088. explorerExtensibility?: IExplorerExtensibilityGroup[];
  105089. /**
  105090. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  105091. */
  105092. inspectorURL?: string;
  105093. }
  105094. interface Scene {
  105095. /**
  105096. * @hidden
  105097. * Backing field
  105098. */
  105099. _debugLayer: DebugLayer;
  105100. /**
  105101. * Gets the debug layer (aka Inspector) associated with the scene
  105102. * @see http://doc.babylonjs.com/features/playground_debuglayer
  105103. */
  105104. debugLayer: DebugLayer;
  105105. }
  105106. /**
  105107. * The debug layer (aka Inspector) is the go to tool in order to better understand
  105108. * what is happening in your scene
  105109. * @see http://doc.babylonjs.com/features/playground_debuglayer
  105110. */
  105111. export class DebugLayer {
  105112. /**
  105113. * Define the url to get the inspector script from.
  105114. * By default it uses the babylonjs CDN.
  105115. * @ignoreNaming
  105116. */
  105117. static InspectorURL: string;
  105118. private _scene;
  105119. private BJSINSPECTOR;
  105120. private _onPropertyChangedObservable?;
  105121. /**
  105122. * Observable triggered when a property is changed through the inspector.
  105123. */
  105124. readonly onPropertyChangedObservable: any;
  105125. /**
  105126. * Instantiates a new debug layer.
  105127. * The debug layer (aka Inspector) is the go to tool in order to better understand
  105128. * what is happening in your scene
  105129. * @see http://doc.babylonjs.com/features/playground_debuglayer
  105130. * @param scene Defines the scene to inspect
  105131. */
  105132. constructor(scene: Scene);
  105133. /** Creates the inspector window. */
  105134. private _createInspector;
  105135. /**
  105136. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  105137. * @param entity defines the entity to select
  105138. * @param lineContainerTitle defines the specific block to highlight
  105139. */
  105140. select(entity: any, lineContainerTitle?: string): void;
  105141. /** Get the inspector from bundle or global */
  105142. private _getGlobalInspector;
  105143. /**
  105144. * Get if the inspector is visible or not.
  105145. * @returns true if visible otherwise, false
  105146. */
  105147. isVisible(): boolean;
  105148. /**
  105149. * Hide the inspector and close its window.
  105150. */
  105151. hide(): void;
  105152. /**
  105153. * Launch the debugLayer.
  105154. * @param config Define the configuration of the inspector
  105155. * @return a promise fulfilled when the debug layer is visible
  105156. */
  105157. show(config?: IInspectorOptions): Promise<DebugLayer>;
  105158. }
  105159. }
  105160. declare module BABYLON {
  105161. /**
  105162. * Class containing static functions to help procedurally build meshes
  105163. */
  105164. export class BoxBuilder {
  105165. /**
  105166. * Creates a box mesh
  105167. * * The parameter `size` sets the size (float) of each box side (default 1)
  105168. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  105169. * * 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)
  105170. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105171. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105172. * * 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
  105173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105174. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  105175. * @param name defines the name of the mesh
  105176. * @param options defines the options used to create the mesh
  105177. * @param scene defines the hosting scene
  105178. * @returns the box mesh
  105179. */
  105180. static CreateBox(name: string, options: {
  105181. size?: number;
  105182. width?: number;
  105183. height?: number;
  105184. depth?: number;
  105185. faceUV?: Vector4[];
  105186. faceColors?: Color4[];
  105187. sideOrientation?: number;
  105188. frontUVs?: Vector4;
  105189. backUVs?: Vector4;
  105190. wrap?: boolean;
  105191. topBaseAt?: number;
  105192. bottomBaseAt?: number;
  105193. updatable?: boolean;
  105194. }, scene?: Nullable<Scene>): Mesh;
  105195. }
  105196. }
  105197. declare module BABYLON {
  105198. /**
  105199. * Class containing static functions to help procedurally build meshes
  105200. */
  105201. export class SphereBuilder {
  105202. /**
  105203. * Creates a sphere mesh
  105204. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  105205. * * 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`)
  105206. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  105207. * * 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
  105208. * * 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)
  105209. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105210. * * 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
  105211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105212. * @param name defines the name of the mesh
  105213. * @param options defines the options used to create the mesh
  105214. * @param scene defines the hosting scene
  105215. * @returns the sphere mesh
  105216. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  105217. */
  105218. static CreateSphere(name: string, options: {
  105219. segments?: number;
  105220. diameter?: number;
  105221. diameterX?: number;
  105222. diameterY?: number;
  105223. diameterZ?: number;
  105224. arc?: number;
  105225. slice?: number;
  105226. sideOrientation?: number;
  105227. frontUVs?: Vector4;
  105228. backUVs?: Vector4;
  105229. updatable?: boolean;
  105230. }, scene: any): Mesh;
  105231. }
  105232. }
  105233. declare module BABYLON.Debug {
  105234. /**
  105235. * Used to show the physics impostor around the specific mesh
  105236. */
  105237. export class PhysicsViewer {
  105238. /** @hidden */
  105239. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  105240. /** @hidden */
  105241. protected _meshes: Array<Nullable<AbstractMesh>>;
  105242. /** @hidden */
  105243. protected _scene: Nullable<Scene>;
  105244. /** @hidden */
  105245. protected _numMeshes: number;
  105246. /** @hidden */
  105247. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  105248. private _renderFunction;
  105249. private _utilityLayer;
  105250. private _debugBoxMesh;
  105251. private _debugSphereMesh;
  105252. private _debugCylinderMesh;
  105253. private _debugMaterial;
  105254. private _debugMeshMeshes;
  105255. /**
  105256. * Creates a new PhysicsViewer
  105257. * @param scene defines the hosting scene
  105258. */
  105259. constructor(scene: Scene);
  105260. /** @hidden */
  105261. protected _updateDebugMeshes(): void;
  105262. /**
  105263. * Renders a specified physic impostor
  105264. * @param impostor defines the impostor to render
  105265. * @param targetMesh defines the mesh represented by the impostor
  105266. * @returns the new debug mesh used to render the impostor
  105267. */
  105268. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  105269. /**
  105270. * Hides a specified physic impostor
  105271. * @param impostor defines the impostor to hide
  105272. */
  105273. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  105274. private _getDebugMaterial;
  105275. private _getDebugBoxMesh;
  105276. private _getDebugSphereMesh;
  105277. private _getDebugCylinderMesh;
  105278. private _getDebugMeshMesh;
  105279. private _getDebugMesh;
  105280. /** Releases all resources */
  105281. dispose(): void;
  105282. }
  105283. }
  105284. declare module BABYLON {
  105285. /**
  105286. * Class containing static functions to help procedurally build meshes
  105287. */
  105288. export class LinesBuilder {
  105289. /**
  105290. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  105291. * * 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
  105292. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  105293. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  105294. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  105295. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  105296. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  105297. * * 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
  105298. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  105299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105300. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  105301. * @param name defines the name of the new line system
  105302. * @param options defines the options used to create the line system
  105303. * @param scene defines the hosting scene
  105304. * @returns a new line system mesh
  105305. */
  105306. static CreateLineSystem(name: string, options: {
  105307. lines: Vector3[][];
  105308. updatable?: boolean;
  105309. instance?: Nullable<LinesMesh>;
  105310. colors?: Nullable<Color4[][]>;
  105311. useVertexAlpha?: boolean;
  105312. }, scene: Nullable<Scene>): LinesMesh;
  105313. /**
  105314. * Creates a line mesh
  105315. * 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
  105316. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  105317. * * The parameter `points` is an array successive Vector3
  105318. * * 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
  105319. * * The optional parameter `colors` is an array of successive Color4, one per line point
  105320. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  105321. * * When updating an instance, remember that only point positions can change, not the number of points
  105322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105323. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  105324. * @param name defines the name of the new line system
  105325. * @param options defines the options used to create the line system
  105326. * @param scene defines the hosting scene
  105327. * @returns a new line mesh
  105328. */
  105329. static CreateLines(name: string, options: {
  105330. points: Vector3[];
  105331. updatable?: boolean;
  105332. instance?: Nullable<LinesMesh>;
  105333. colors?: Color4[];
  105334. useVertexAlpha?: boolean;
  105335. }, scene?: Nullable<Scene>): LinesMesh;
  105336. /**
  105337. * Creates a dashed line mesh
  105338. * * 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
  105339. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  105340. * * The parameter `points` is an array successive Vector3
  105341. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  105342. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  105343. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  105344. * * 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
  105345. * * When updating an instance, remember that only point positions can change, not the number of points
  105346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105347. * @param name defines the name of the mesh
  105348. * @param options defines the options used to create the mesh
  105349. * @param scene defines the hosting scene
  105350. * @returns the dashed line mesh
  105351. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  105352. */
  105353. static CreateDashedLines(name: string, options: {
  105354. points: Vector3[];
  105355. dashSize?: number;
  105356. gapSize?: number;
  105357. dashNb?: number;
  105358. updatable?: boolean;
  105359. instance?: LinesMesh;
  105360. }, scene?: Nullable<Scene>): LinesMesh;
  105361. }
  105362. }
  105363. declare module BABYLON {
  105364. /**
  105365. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  105366. * in order to better appreciate the issue one might have.
  105367. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  105368. */
  105369. export class RayHelper {
  105370. /**
  105371. * Defines the ray we are currently tryin to visualize.
  105372. */
  105373. ray: Nullable<Ray>;
  105374. private _renderPoints;
  105375. private _renderLine;
  105376. private _renderFunction;
  105377. private _scene;
  105378. private _updateToMeshFunction;
  105379. private _attachedToMesh;
  105380. private _meshSpaceDirection;
  105381. private _meshSpaceOrigin;
  105382. /**
  105383. * Helper function to create a colored helper in a scene in one line.
  105384. * @param ray Defines the ray we are currently tryin to visualize
  105385. * @param scene Defines the scene the ray is used in
  105386. * @param color Defines the color we want to see the ray in
  105387. * @returns The newly created ray helper.
  105388. */
  105389. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  105390. /**
  105391. * Instantiate a new ray helper.
  105392. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  105393. * in order to better appreciate the issue one might have.
  105394. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  105395. * @param ray Defines the ray we are currently tryin to visualize
  105396. */
  105397. constructor(ray: Ray);
  105398. /**
  105399. * Shows the ray we are willing to debug.
  105400. * @param scene Defines the scene the ray needs to be rendered in
  105401. * @param color Defines the color the ray needs to be rendered in
  105402. */
  105403. show(scene: Scene, color?: Color3): void;
  105404. /**
  105405. * Hides the ray we are debugging.
  105406. */
  105407. hide(): void;
  105408. private _render;
  105409. /**
  105410. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  105411. * @param mesh Defines the mesh we want the helper attached to
  105412. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  105413. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  105414. * @param length Defines the length of the ray
  105415. */
  105416. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  105417. /**
  105418. * Detach the ray helper from the mesh it has previously been attached to.
  105419. */
  105420. detachFromMesh(): void;
  105421. private _updateToMesh;
  105422. /**
  105423. * Dispose the helper and release its associated resources.
  105424. */
  105425. dispose(): void;
  105426. }
  105427. }
  105428. declare module BABYLON.Debug {
  105429. /**
  105430. * Class used to render a debug view of a given skeleton
  105431. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  105432. */
  105433. export class SkeletonViewer {
  105434. /** defines the skeleton to render */
  105435. skeleton: Skeleton;
  105436. /** defines the mesh attached to the skeleton */
  105437. mesh: AbstractMesh;
  105438. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  105439. autoUpdateBonesMatrices: boolean;
  105440. /** defines the rendering group id to use with the viewer */
  105441. renderingGroupId: number;
  105442. /** Gets or sets the color used to render the skeleton */
  105443. color: Color3;
  105444. private _scene;
  105445. private _debugLines;
  105446. private _debugMesh;
  105447. private _isEnabled;
  105448. private _renderFunction;
  105449. private _utilityLayer;
  105450. /**
  105451. * Returns the mesh used to render the bones
  105452. */
  105453. readonly debugMesh: Nullable<LinesMesh>;
  105454. /**
  105455. * Creates a new SkeletonViewer
  105456. * @param skeleton defines the skeleton to render
  105457. * @param mesh defines the mesh attached to the skeleton
  105458. * @param scene defines the hosting scene
  105459. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  105460. * @param renderingGroupId defines the rendering group id to use with the viewer
  105461. */
  105462. constructor(
  105463. /** defines the skeleton to render */
  105464. skeleton: Skeleton,
  105465. /** defines the mesh attached to the skeleton */
  105466. mesh: AbstractMesh, scene: Scene,
  105467. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  105468. autoUpdateBonesMatrices?: boolean,
  105469. /** defines the rendering group id to use with the viewer */
  105470. renderingGroupId?: number);
  105471. /** Gets or sets a boolean indicating if the viewer is enabled */
  105472. isEnabled: boolean;
  105473. private _getBonePosition;
  105474. private _getLinesForBonesWithLength;
  105475. private _getLinesForBonesNoLength;
  105476. /** Update the viewer to sync with current skeleton state */
  105477. update(): void;
  105478. /** Release associated resources */
  105479. dispose(): void;
  105480. }
  105481. }
  105482. declare module BABYLON {
  105483. /**
  105484. * Options to create the null engine
  105485. */
  105486. export class NullEngineOptions {
  105487. /**
  105488. * Render width (Default: 512)
  105489. */
  105490. renderWidth: number;
  105491. /**
  105492. * Render height (Default: 256)
  105493. */
  105494. renderHeight: number;
  105495. /**
  105496. * Texture size (Default: 512)
  105497. */
  105498. textureSize: number;
  105499. /**
  105500. * If delta time between frames should be constant
  105501. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105502. */
  105503. deterministicLockstep: boolean;
  105504. /**
  105505. * Maximum about of steps between frames (Default: 4)
  105506. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105507. */
  105508. lockstepMaxSteps: number;
  105509. }
  105510. /**
  105511. * The null engine class provides support for headless version of babylon.js.
  105512. * This can be used in server side scenario or for testing purposes
  105513. */
  105514. export class NullEngine extends Engine {
  105515. private _options;
  105516. /**
  105517. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105518. */
  105519. isDeterministicLockStep(): boolean;
  105520. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  105521. getLockstepMaxSteps(): number;
  105522. /**
  105523. * Sets hardware scaling, used to save performance if needed
  105524. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  105525. */
  105526. getHardwareScalingLevel(): number;
  105527. constructor(options?: NullEngineOptions);
  105528. createVertexBuffer(vertices: FloatArray): DataBuffer;
  105529. createIndexBuffer(indices: IndicesArray): DataBuffer;
  105530. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  105531. getRenderWidth(useScreen?: boolean): number;
  105532. getRenderHeight(useScreen?: boolean): number;
  105533. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  105534. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  105535. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  105536. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  105537. bindSamplers(effect: Effect): void;
  105538. enableEffect(effect: Effect): void;
  105539. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  105540. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  105541. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  105542. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  105543. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  105544. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  105545. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  105546. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  105547. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  105548. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  105549. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  105550. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  105551. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  105552. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  105553. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  105554. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  105555. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  105556. setFloat(uniform: WebGLUniformLocation, value: number): void;
  105557. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  105558. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  105559. setBool(uniform: WebGLUniformLocation, bool: number): void;
  105560. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  105561. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  105562. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  105563. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  105564. bindBuffers(vertexBuffers: {
  105565. [key: string]: VertexBuffer;
  105566. }, indexBuffer: DataBuffer, effect: Effect): void;
  105567. wipeCaches(bruteForce?: boolean): void;
  105568. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  105569. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  105570. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  105571. /** @hidden */
  105572. _createTexture(): WebGLTexture;
  105573. /** @hidden */
  105574. _releaseTexture(texture: InternalTexture): void;
  105575. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  105576. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  105577. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  105578. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  105579. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  105580. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  105581. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  105582. areAllEffectsReady(): boolean;
  105583. /**
  105584. * @hidden
  105585. * Get the current error code of the webGL context
  105586. * @returns the error code
  105587. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105588. */
  105589. getError(): number;
  105590. /** @hidden */
  105591. _getUnpackAlignement(): number;
  105592. /** @hidden */
  105593. _unpackFlipY(value: boolean): void;
  105594. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  105595. /**
  105596. * Updates a dynamic vertex buffer.
  105597. * @param vertexBuffer the vertex buffer to update
  105598. * @param data the data used to update the vertex buffer
  105599. * @param byteOffset the byte offset of the data (optional)
  105600. * @param byteLength the byte length of the data (optional)
  105601. */
  105602. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  105603. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  105604. /** @hidden */
  105605. _bindTexture(channel: number, texture: InternalTexture): void;
  105606. /** @hidden */
  105607. _releaseBuffer(buffer: DataBuffer): boolean;
  105608. releaseEffects(): void;
  105609. displayLoadingUI(): void;
  105610. hideLoadingUI(): void;
  105611. /** @hidden */
  105612. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105613. /** @hidden */
  105614. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105615. /** @hidden */
  105616. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105617. /** @hidden */
  105618. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  105619. }
  105620. }
  105621. declare module BABYLON {
  105622. /** @hidden */
  105623. export class _OcclusionDataStorage {
  105624. /** @hidden */
  105625. occlusionInternalRetryCounter: number;
  105626. /** @hidden */
  105627. isOcclusionQueryInProgress: boolean;
  105628. /** @hidden */
  105629. isOccluded: boolean;
  105630. /** @hidden */
  105631. occlusionRetryCount: number;
  105632. /** @hidden */
  105633. occlusionType: number;
  105634. /** @hidden */
  105635. occlusionQueryAlgorithmType: number;
  105636. }
  105637. interface Engine {
  105638. /**
  105639. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  105640. * @return the new query
  105641. */
  105642. createQuery(): WebGLQuery;
  105643. /**
  105644. * Delete and release a webGL query
  105645. * @param query defines the query to delete
  105646. * @return the current engine
  105647. */
  105648. deleteQuery(query: WebGLQuery): Engine;
  105649. /**
  105650. * Check if a given query has resolved and got its value
  105651. * @param query defines the query to check
  105652. * @returns true if the query got its value
  105653. */
  105654. isQueryResultAvailable(query: WebGLQuery): boolean;
  105655. /**
  105656. * Gets the value of a given query
  105657. * @param query defines the query to check
  105658. * @returns the value of the query
  105659. */
  105660. getQueryResult(query: WebGLQuery): number;
  105661. /**
  105662. * Initiates an occlusion query
  105663. * @param algorithmType defines the algorithm to use
  105664. * @param query defines the query to use
  105665. * @returns the current engine
  105666. * @see http://doc.babylonjs.com/features/occlusionquery
  105667. */
  105668. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  105669. /**
  105670. * Ends an occlusion query
  105671. * @see http://doc.babylonjs.com/features/occlusionquery
  105672. * @param algorithmType defines the algorithm to use
  105673. * @returns the current engine
  105674. */
  105675. endOcclusionQuery(algorithmType: number): Engine;
  105676. /**
  105677. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  105678. * Please note that only one query can be issued at a time
  105679. * @returns a time token used to track the time span
  105680. */
  105681. startTimeQuery(): Nullable<_TimeToken>;
  105682. /**
  105683. * Ends a time query
  105684. * @param token defines the token used to measure the time span
  105685. * @returns the time spent (in ns)
  105686. */
  105687. endTimeQuery(token: _TimeToken): int;
  105688. /** @hidden */
  105689. _currentNonTimestampToken: Nullable<_TimeToken>;
  105690. /** @hidden */
  105691. _createTimeQuery(): WebGLQuery;
  105692. /** @hidden */
  105693. _deleteTimeQuery(query: WebGLQuery): void;
  105694. /** @hidden */
  105695. _getGlAlgorithmType(algorithmType: number): number;
  105696. /** @hidden */
  105697. _getTimeQueryResult(query: WebGLQuery): any;
  105698. /** @hidden */
  105699. _getTimeQueryAvailability(query: WebGLQuery): any;
  105700. }
  105701. interface AbstractMesh {
  105702. /**
  105703. * Backing filed
  105704. * @hidden
  105705. */
  105706. __occlusionDataStorage: _OcclusionDataStorage;
  105707. /**
  105708. * Access property
  105709. * @hidden
  105710. */
  105711. _occlusionDataStorage: _OcclusionDataStorage;
  105712. /**
  105713. * 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.
  105714. * The default value is -1 which means don't break the query and wait till the result
  105715. * @see http://doc.babylonjs.com/features/occlusionquery
  105716. */
  105717. occlusionRetryCount: number;
  105718. /**
  105719. * 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:
  105720. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  105721. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  105722. * * 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.
  105723. * @see http://doc.babylonjs.com/features/occlusionquery
  105724. */
  105725. occlusionType: number;
  105726. /**
  105727. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  105728. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  105729. * * 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.
  105730. * @see http://doc.babylonjs.com/features/occlusionquery
  105731. */
  105732. occlusionQueryAlgorithmType: number;
  105733. /**
  105734. * 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
  105735. * @see http://doc.babylonjs.com/features/occlusionquery
  105736. */
  105737. isOccluded: boolean;
  105738. /**
  105739. * Flag to check the progress status of the query
  105740. * @see http://doc.babylonjs.com/features/occlusionquery
  105741. */
  105742. isOcclusionQueryInProgress: boolean;
  105743. }
  105744. }
  105745. declare module BABYLON {
  105746. /** @hidden */
  105747. export var _forceTransformFeedbackToBundle: boolean;
  105748. interface Engine {
  105749. /**
  105750. * Creates a webGL transform feedback object
  105751. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  105752. * @returns the webGL transform feedback object
  105753. */
  105754. createTransformFeedback(): WebGLTransformFeedback;
  105755. /**
  105756. * Delete a webGL transform feedback object
  105757. * @param value defines the webGL transform feedback object to delete
  105758. */
  105759. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  105760. /**
  105761. * Bind a webGL transform feedback object to the webgl context
  105762. * @param value defines the webGL transform feedback object to bind
  105763. */
  105764. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  105765. /**
  105766. * Begins a transform feedback operation
  105767. * @param usePoints defines if points or triangles must be used
  105768. */
  105769. beginTransformFeedback(usePoints: boolean): void;
  105770. /**
  105771. * Ends a transform feedback operation
  105772. */
  105773. endTransformFeedback(): void;
  105774. /**
  105775. * Specify the varyings to use with transform feedback
  105776. * @param program defines the associated webGL program
  105777. * @param value defines the list of strings representing the varying names
  105778. */
  105779. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  105780. /**
  105781. * Bind a webGL buffer for a transform feedback operation
  105782. * @param value defines the webGL buffer to bind
  105783. */
  105784. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  105785. }
  105786. }
  105787. declare module BABYLON {
  105788. /**
  105789. * Creation options of the multi render target texture.
  105790. */
  105791. export interface IMultiRenderTargetOptions {
  105792. /**
  105793. * Define if the texture needs to create mip maps after render.
  105794. */
  105795. generateMipMaps?: boolean;
  105796. /**
  105797. * Define the types of all the draw buffers we want to create
  105798. */
  105799. types?: number[];
  105800. /**
  105801. * Define the sampling modes of all the draw buffers we want to create
  105802. */
  105803. samplingModes?: number[];
  105804. /**
  105805. * Define if a depth buffer is required
  105806. */
  105807. generateDepthBuffer?: boolean;
  105808. /**
  105809. * Define if a stencil buffer is required
  105810. */
  105811. generateStencilBuffer?: boolean;
  105812. /**
  105813. * Define if a depth texture is required instead of a depth buffer
  105814. */
  105815. generateDepthTexture?: boolean;
  105816. /**
  105817. * Define the number of desired draw buffers
  105818. */
  105819. textureCount?: number;
  105820. /**
  105821. * Define if aspect ratio should be adapted to the texture or stay the scene one
  105822. */
  105823. doNotChangeAspectRatio?: boolean;
  105824. /**
  105825. * Define the default type of the buffers we are creating
  105826. */
  105827. defaultType?: number;
  105828. }
  105829. /**
  105830. * A multi render target, like a render target provides the ability to render to a texture.
  105831. * Unlike the render target, it can render to several draw buffers in one draw.
  105832. * This is specially interesting in deferred rendering or for any effects requiring more than
  105833. * just one color from a single pass.
  105834. */
  105835. export class MultiRenderTarget extends RenderTargetTexture {
  105836. private _internalTextures;
  105837. private _textures;
  105838. private _multiRenderTargetOptions;
  105839. /**
  105840. * Get if draw buffers are currently supported by the used hardware and browser.
  105841. */
  105842. readonly isSupported: boolean;
  105843. /**
  105844. * Get the list of textures generated by the multi render target.
  105845. */
  105846. readonly textures: Texture[];
  105847. /**
  105848. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  105849. */
  105850. readonly depthTexture: Texture;
  105851. /**
  105852. * Set the wrapping mode on U of all the textures we are rendering to.
  105853. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  105854. */
  105855. wrapU: number;
  105856. /**
  105857. * Set the wrapping mode on V of all the textures we are rendering to.
  105858. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  105859. */
  105860. wrapV: number;
  105861. /**
  105862. * Instantiate a new multi render target texture.
  105863. * A multi render target, like a render target provides the ability to render to a texture.
  105864. * Unlike the render target, it can render to several draw buffers in one draw.
  105865. * This is specially interesting in deferred rendering or for any effects requiring more than
  105866. * just one color from a single pass.
  105867. * @param name Define the name of the texture
  105868. * @param size Define the size of the buffers to render to
  105869. * @param count Define the number of target we are rendering into
  105870. * @param scene Define the scene the texture belongs to
  105871. * @param options Define the options used to create the multi render target
  105872. */
  105873. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  105874. /** @hidden */
  105875. _rebuild(): void;
  105876. private _createInternalTextures;
  105877. private _createTextures;
  105878. /**
  105879. * Define the number of samples used if MSAA is enabled.
  105880. */
  105881. samples: number;
  105882. /**
  105883. * Resize all the textures in the multi render target.
  105884. * Be carrefull as it will recreate all the data in the new texture.
  105885. * @param size Define the new size
  105886. */
  105887. resize(size: any): void;
  105888. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  105889. /**
  105890. * Dispose the render targets and their associated resources
  105891. */
  105892. dispose(): void;
  105893. /**
  105894. * Release all the underlying texture used as draw buffers.
  105895. */
  105896. releaseInternalTextures(): void;
  105897. }
  105898. }
  105899. declare module BABYLON {
  105900. interface Engine {
  105901. /**
  105902. * Unbind a list of render target textures from the webGL context
  105903. * This is used only when drawBuffer extension or webGL2 are active
  105904. * @param textures defines the render target textures to unbind
  105905. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  105906. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  105907. */
  105908. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  105909. /**
  105910. * Create a multi render target texture
  105911. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  105912. * @param size defines the size of the texture
  105913. * @param options defines the creation options
  105914. * @returns the cube texture as an InternalTexture
  105915. */
  105916. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  105917. /**
  105918. * Update the sample count for a given multiple render target texture
  105919. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  105920. * @param textures defines the textures to update
  105921. * @param samples defines the sample count to set
  105922. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  105923. */
  105924. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  105925. }
  105926. }
  105927. declare module BABYLON {
  105928. /**
  105929. * Gather the list of clipboard event types as constants.
  105930. */
  105931. export class ClipboardEventTypes {
  105932. /**
  105933. * The clipboard event is fired when a copy command is active (pressed).
  105934. */
  105935. static readonly COPY: number;
  105936. /**
  105937. * The clipboard event is fired when a cut command is active (pressed).
  105938. */
  105939. static readonly CUT: number;
  105940. /**
  105941. * The clipboard event is fired when a paste command is active (pressed).
  105942. */
  105943. static readonly PASTE: number;
  105944. }
  105945. /**
  105946. * This class is used to store clipboard related info for the onClipboardObservable event.
  105947. */
  105948. export class ClipboardInfo {
  105949. /**
  105950. * Defines the type of event (BABYLON.ClipboardEventTypes)
  105951. */
  105952. type: number;
  105953. /**
  105954. * Defines the related dom event
  105955. */
  105956. event: ClipboardEvent;
  105957. /**
  105958. *Creates an instance of ClipboardInfo.
  105959. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  105960. * @param event Defines the related dom event
  105961. */
  105962. constructor(
  105963. /**
  105964. * Defines the type of event (BABYLON.ClipboardEventTypes)
  105965. */
  105966. type: number,
  105967. /**
  105968. * Defines the related dom event
  105969. */
  105970. event: ClipboardEvent);
  105971. /**
  105972. * Get the clipboard event's type from the keycode.
  105973. * @param keyCode Defines the keyCode for the current keyboard event.
  105974. * @return {number}
  105975. */
  105976. static GetTypeFromCharacter(keyCode: number): number;
  105977. }
  105978. }
  105979. declare module BABYLON {
  105980. /**
  105981. * Google Daydream controller
  105982. */
  105983. export class DaydreamController extends WebVRController {
  105984. /**
  105985. * Base Url for the controller model.
  105986. */
  105987. static MODEL_BASE_URL: string;
  105988. /**
  105989. * File name for the controller model.
  105990. */
  105991. static MODEL_FILENAME: string;
  105992. /**
  105993. * Gamepad Id prefix used to identify Daydream Controller.
  105994. */
  105995. static readonly GAMEPAD_ID_PREFIX: string;
  105996. /**
  105997. * Creates a new DaydreamController from a gamepad
  105998. * @param vrGamepad the gamepad that the controller should be created from
  105999. */
  106000. constructor(vrGamepad: any);
  106001. /**
  106002. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106003. * @param scene scene in which to add meshes
  106004. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106005. */
  106006. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106007. /**
  106008. * Called once for each button that changed state since the last frame
  106009. * @param buttonIdx Which button index changed
  106010. * @param state New state of the button
  106011. * @param changes Which properties on the state changed since last frame
  106012. */
  106013. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106014. }
  106015. }
  106016. declare module BABYLON {
  106017. /**
  106018. * Gear VR Controller
  106019. */
  106020. export class GearVRController extends WebVRController {
  106021. /**
  106022. * Base Url for the controller model.
  106023. */
  106024. static MODEL_BASE_URL: string;
  106025. /**
  106026. * File name for the controller model.
  106027. */
  106028. static MODEL_FILENAME: string;
  106029. /**
  106030. * Gamepad Id prefix used to identify this controller.
  106031. */
  106032. static readonly GAMEPAD_ID_PREFIX: string;
  106033. private readonly _buttonIndexToObservableNameMap;
  106034. /**
  106035. * Creates a new GearVRController from a gamepad
  106036. * @param vrGamepad the gamepad that the controller should be created from
  106037. */
  106038. constructor(vrGamepad: any);
  106039. /**
  106040. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106041. * @param scene scene in which to add meshes
  106042. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106043. */
  106044. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106045. /**
  106046. * Called once for each button that changed state since the last frame
  106047. * @param buttonIdx Which button index changed
  106048. * @param state New state of the button
  106049. * @param changes Which properties on the state changed since last frame
  106050. */
  106051. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106052. }
  106053. }
  106054. declare module BABYLON {
  106055. /**
  106056. * Vive Controller
  106057. */
  106058. export class ViveController extends WebVRController {
  106059. /**
  106060. * Base Url for the controller model.
  106061. */
  106062. static MODEL_BASE_URL: string;
  106063. /**
  106064. * File name for the controller model.
  106065. */
  106066. static MODEL_FILENAME: string;
  106067. /**
  106068. * Creates a new ViveController from a gamepad
  106069. * @param vrGamepad the gamepad that the controller should be created from
  106070. */
  106071. constructor(vrGamepad: any);
  106072. /**
  106073. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106074. * @param scene scene in which to add meshes
  106075. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106076. */
  106077. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106078. /**
  106079. * Fired when the left button on this controller is modified
  106080. */
  106081. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106082. /**
  106083. * Fired when the right button on this controller is modified
  106084. */
  106085. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106086. /**
  106087. * Fired when the menu button on this controller is modified
  106088. */
  106089. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106090. /**
  106091. * Called once for each button that changed state since the last frame
  106092. * Vive mapping:
  106093. * 0: touchpad
  106094. * 1: trigger
  106095. * 2: left AND right buttons
  106096. * 3: menu button
  106097. * @param buttonIdx Which button index changed
  106098. * @param state New state of the button
  106099. * @param changes Which properties on the state changed since last frame
  106100. */
  106101. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106102. }
  106103. }
  106104. declare module BABYLON {
  106105. /**
  106106. * Class containing static functions to help procedurally build meshes
  106107. */
  106108. export class PolyhedronBuilder {
  106109. /**
  106110. * Creates a polyhedron mesh
  106111. * * 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
  106112. * * The parameter `size` (positive float, default 1) sets the polygon size
  106113. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106114. * * 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`
  106115. * * 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
  106116. * * 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)`)
  106117. * * 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
  106118. * * 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
  106119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106120. * * 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
  106121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106122. * @param name defines the name of the mesh
  106123. * @param options defines the options used to create the mesh
  106124. * @param scene defines the hosting scene
  106125. * @returns the polyhedron mesh
  106126. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  106127. */
  106128. static CreatePolyhedron(name: string, options: {
  106129. type?: number;
  106130. size?: number;
  106131. sizeX?: number;
  106132. sizeY?: number;
  106133. sizeZ?: number;
  106134. custom?: any;
  106135. faceUV?: Vector4[];
  106136. faceColors?: Color4[];
  106137. flat?: boolean;
  106138. updatable?: boolean;
  106139. sideOrientation?: number;
  106140. frontUVs?: Vector4;
  106141. backUVs?: Vector4;
  106142. }, scene?: Nullable<Scene>): Mesh;
  106143. }
  106144. }
  106145. declare module BABYLON {
  106146. /**
  106147. * Gizmo that enables scaling a mesh along 3 axis
  106148. */
  106149. export class ScaleGizmo extends Gizmo {
  106150. /**
  106151. * Internal gizmo used for interactions on the x axis
  106152. */
  106153. xGizmo: AxisScaleGizmo;
  106154. /**
  106155. * Internal gizmo used for interactions on the y axis
  106156. */
  106157. yGizmo: AxisScaleGizmo;
  106158. /**
  106159. * Internal gizmo used for interactions on the z axis
  106160. */
  106161. zGizmo: AxisScaleGizmo;
  106162. /**
  106163. * Internal gizmo used to scale all axis equally
  106164. */
  106165. uniformScaleGizmo: AxisScaleGizmo;
  106166. private _meshAttached;
  106167. private _updateGizmoRotationToMatchAttachedMesh;
  106168. private _snapDistance;
  106169. private _scaleRatio;
  106170. private _uniformScalingMesh;
  106171. private _octahedron;
  106172. /** Fires an event when any of it's sub gizmos are dragged */
  106173. onDragStartObservable: Observable<unknown>;
  106174. /** Fires an event when any of it's sub gizmos are released from dragging */
  106175. onDragEndObservable: Observable<unknown>;
  106176. attachedMesh: Nullable<AbstractMesh>;
  106177. /**
  106178. * Creates a ScaleGizmo
  106179. * @param gizmoLayer The utility layer the gizmo will be added to
  106180. */
  106181. constructor(gizmoLayer?: UtilityLayerRenderer);
  106182. updateGizmoRotationToMatchAttachedMesh: boolean;
  106183. /**
  106184. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106185. */
  106186. snapDistance: number;
  106187. /**
  106188. * Ratio for the scale of the gizmo (Default: 1)
  106189. */
  106190. scaleRatio: number;
  106191. /**
  106192. * Disposes of the gizmo
  106193. */
  106194. dispose(): void;
  106195. }
  106196. }
  106197. declare module BABYLON {
  106198. /**
  106199. * Single axis scale gizmo
  106200. */
  106201. export class AxisScaleGizmo extends Gizmo {
  106202. /**
  106203. * Drag behavior responsible for the gizmos dragging interactions
  106204. */
  106205. dragBehavior: PointerDragBehavior;
  106206. private _pointerObserver;
  106207. /**
  106208. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106209. */
  106210. snapDistance: number;
  106211. /**
  106212. * Event that fires each time the gizmo snaps to a new location.
  106213. * * snapDistance is the the change in distance
  106214. */
  106215. onSnapObservable: Observable<{
  106216. snapDistance: number;
  106217. }>;
  106218. /**
  106219. * If the scaling operation should be done on all axis (default: false)
  106220. */
  106221. uniformScaling: boolean;
  106222. private _isEnabled;
  106223. private _parent;
  106224. private _arrow;
  106225. private _coloredMaterial;
  106226. private _hoverMaterial;
  106227. /**
  106228. * Creates an AxisScaleGizmo
  106229. * @param gizmoLayer The utility layer the gizmo will be added to
  106230. * @param dragAxis The axis which the gizmo will be able to scale on
  106231. * @param color The color of the gizmo
  106232. */
  106233. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  106234. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106235. /**
  106236. * If the gizmo is enabled
  106237. */
  106238. isEnabled: boolean;
  106239. /**
  106240. * Disposes of the gizmo
  106241. */
  106242. dispose(): void;
  106243. /**
  106244. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  106245. * @param mesh The mesh to replace the default mesh of the gizmo
  106246. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  106247. */
  106248. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  106249. }
  106250. }
  106251. declare module BABYLON {
  106252. /**
  106253. * Bounding box gizmo
  106254. */
  106255. export class BoundingBoxGizmo extends Gizmo {
  106256. private _lineBoundingBox;
  106257. private _rotateSpheresParent;
  106258. private _scaleBoxesParent;
  106259. private _boundingDimensions;
  106260. private _renderObserver;
  106261. private _pointerObserver;
  106262. private _scaleDragSpeed;
  106263. private _tmpQuaternion;
  106264. private _tmpVector;
  106265. private _tmpRotationMatrix;
  106266. /**
  106267. * 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)
  106268. */
  106269. ignoreChildren: boolean;
  106270. /**
  106271. * 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)
  106272. */
  106273. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  106274. /**
  106275. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  106276. */
  106277. rotationSphereSize: number;
  106278. /**
  106279. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  106280. */
  106281. scaleBoxSize: number;
  106282. /**
  106283. * 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)
  106284. */
  106285. fixedDragMeshScreenSize: boolean;
  106286. /**
  106287. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  106288. */
  106289. fixedDragMeshScreenSizeDistanceFactor: number;
  106290. /**
  106291. * Fired when a rotation sphere or scale box is dragged
  106292. */
  106293. onDragStartObservable: Observable<{}>;
  106294. /**
  106295. * Fired when a scale box is dragged
  106296. */
  106297. onScaleBoxDragObservable: Observable<{}>;
  106298. /**
  106299. * Fired when a scale box drag is ended
  106300. */
  106301. onScaleBoxDragEndObservable: Observable<{}>;
  106302. /**
  106303. * Fired when a rotation sphere is dragged
  106304. */
  106305. onRotationSphereDragObservable: Observable<{}>;
  106306. /**
  106307. * Fired when a rotation sphere drag is ended
  106308. */
  106309. onRotationSphereDragEndObservable: Observable<{}>;
  106310. /**
  106311. * 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)
  106312. */
  106313. scalePivot: Nullable<Vector3>;
  106314. /**
  106315. * Mesh used as a pivot to rotate the attached mesh
  106316. */
  106317. private _anchorMesh;
  106318. private _existingMeshScale;
  106319. private _dragMesh;
  106320. private pointerDragBehavior;
  106321. private coloredMaterial;
  106322. private hoverColoredMaterial;
  106323. /**
  106324. * Sets the color of the bounding box gizmo
  106325. * @param color the color to set
  106326. */
  106327. setColor(color: Color3): void;
  106328. /**
  106329. * Creates an BoundingBoxGizmo
  106330. * @param gizmoLayer The utility layer the gizmo will be added to
  106331. * @param color The color of the gizmo
  106332. */
  106333. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  106334. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106335. private _selectNode;
  106336. /**
  106337. * Updates the bounding box information for the Gizmo
  106338. */
  106339. updateBoundingBox(): void;
  106340. private _updateRotationSpheres;
  106341. private _updateScaleBoxes;
  106342. /**
  106343. * Enables rotation on the specified axis and disables rotation on the others
  106344. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  106345. */
  106346. setEnabledRotationAxis(axis: string): void;
  106347. /**
  106348. * Enables/disables scaling
  106349. * @param enable if scaling should be enabled
  106350. */
  106351. setEnabledScaling(enable: boolean): void;
  106352. private _updateDummy;
  106353. /**
  106354. * Enables a pointer drag behavior on the bounding box of the gizmo
  106355. */
  106356. enableDragBehavior(): void;
  106357. /**
  106358. * Disposes of the gizmo
  106359. */
  106360. dispose(): void;
  106361. /**
  106362. * 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)
  106363. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  106364. * @returns the bounding box mesh with the passed in mesh as a child
  106365. */
  106366. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  106367. /**
  106368. * CustomMeshes are not supported by this gizmo
  106369. * @param mesh The mesh to replace the default mesh of the gizmo
  106370. */
  106371. setCustomMesh(mesh: Mesh): void;
  106372. }
  106373. }
  106374. declare module BABYLON {
  106375. /**
  106376. * Single plane rotation gizmo
  106377. */
  106378. export class PlaneRotationGizmo extends Gizmo {
  106379. /**
  106380. * Drag behavior responsible for the gizmos dragging interactions
  106381. */
  106382. dragBehavior: PointerDragBehavior;
  106383. private _pointerObserver;
  106384. /**
  106385. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  106386. */
  106387. snapDistance: number;
  106388. /**
  106389. * Event that fires each time the gizmo snaps to a new location.
  106390. * * snapDistance is the the change in distance
  106391. */
  106392. onSnapObservable: Observable<{
  106393. snapDistance: number;
  106394. }>;
  106395. private _isEnabled;
  106396. private _parent;
  106397. /**
  106398. * Creates a PlaneRotationGizmo
  106399. * @param gizmoLayer The utility layer the gizmo will be added to
  106400. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  106401. * @param color The color of the gizmo
  106402. * @param tessellation Amount of tessellation to be used when creating rotation circles
  106403. */
  106404. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  106405. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106406. /**
  106407. * If the gizmo is enabled
  106408. */
  106409. isEnabled: boolean;
  106410. /**
  106411. * Disposes of the gizmo
  106412. */
  106413. dispose(): void;
  106414. }
  106415. }
  106416. declare module BABYLON {
  106417. /**
  106418. * Gizmo that enables rotating a mesh along 3 axis
  106419. */
  106420. export class RotationGizmo extends Gizmo {
  106421. /**
  106422. * Internal gizmo used for interactions on the x axis
  106423. */
  106424. xGizmo: PlaneRotationGizmo;
  106425. /**
  106426. * Internal gizmo used for interactions on the y axis
  106427. */
  106428. yGizmo: PlaneRotationGizmo;
  106429. /**
  106430. * Internal gizmo used for interactions on the z axis
  106431. */
  106432. zGizmo: PlaneRotationGizmo;
  106433. /** Fires an event when any of it's sub gizmos are dragged */
  106434. onDragStartObservable: Observable<unknown>;
  106435. /** Fires an event when any of it's sub gizmos are released from dragging */
  106436. onDragEndObservable: Observable<unknown>;
  106437. private _meshAttached;
  106438. attachedMesh: Nullable<AbstractMesh>;
  106439. /**
  106440. * Creates a RotationGizmo
  106441. * @param gizmoLayer The utility layer the gizmo will be added to
  106442. * @param tessellation Amount of tessellation to be used when creating rotation circles
  106443. */
  106444. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  106445. updateGizmoRotationToMatchAttachedMesh: boolean;
  106446. /**
  106447. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106448. */
  106449. snapDistance: number;
  106450. /**
  106451. * Ratio for the scale of the gizmo (Default: 1)
  106452. */
  106453. scaleRatio: number;
  106454. /**
  106455. * Disposes of the gizmo
  106456. */
  106457. dispose(): void;
  106458. /**
  106459. * CustomMeshes are not supported by this gizmo
  106460. * @param mesh The mesh to replace the default mesh of the gizmo
  106461. */
  106462. setCustomMesh(mesh: Mesh): void;
  106463. }
  106464. }
  106465. declare module BABYLON {
  106466. /**
  106467. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  106468. */
  106469. export class GizmoManager implements IDisposable {
  106470. private scene;
  106471. /**
  106472. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  106473. */
  106474. gizmos: {
  106475. positionGizmo: Nullable<PositionGizmo>;
  106476. rotationGizmo: Nullable<RotationGizmo>;
  106477. scaleGizmo: Nullable<ScaleGizmo>;
  106478. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  106479. };
  106480. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  106481. clearGizmoOnEmptyPointerEvent: boolean;
  106482. /** Fires an event when the manager is attached to a mesh */
  106483. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  106484. private _gizmosEnabled;
  106485. private _pointerObserver;
  106486. private _attachedMesh;
  106487. private _boundingBoxColor;
  106488. private _defaultUtilityLayer;
  106489. private _defaultKeepDepthUtilityLayer;
  106490. /**
  106491. * When bounding box gizmo is enabled, this can be used to track drag/end events
  106492. */
  106493. boundingBoxDragBehavior: SixDofDragBehavior;
  106494. /**
  106495. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  106496. */
  106497. attachableMeshes: Nullable<Array<AbstractMesh>>;
  106498. /**
  106499. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  106500. */
  106501. usePointerToAttachGizmos: boolean;
  106502. /**
  106503. * Utility layer that the bounding box gizmo belongs to
  106504. */
  106505. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  106506. /**
  106507. * Utility layer that all gizmos besides bounding box belong to
  106508. */
  106509. readonly utilityLayer: UtilityLayerRenderer;
  106510. /**
  106511. * Instatiates a gizmo manager
  106512. * @param scene the scene to overlay the gizmos on top of
  106513. */
  106514. constructor(scene: Scene);
  106515. /**
  106516. * Attaches a set of gizmos to the specified mesh
  106517. * @param mesh The mesh the gizmo's should be attached to
  106518. */
  106519. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  106520. /**
  106521. * If the position gizmo is enabled
  106522. */
  106523. positionGizmoEnabled: boolean;
  106524. /**
  106525. * If the rotation gizmo is enabled
  106526. */
  106527. rotationGizmoEnabled: boolean;
  106528. /**
  106529. * If the scale gizmo is enabled
  106530. */
  106531. scaleGizmoEnabled: boolean;
  106532. /**
  106533. * If the boundingBox gizmo is enabled
  106534. */
  106535. boundingBoxGizmoEnabled: boolean;
  106536. /**
  106537. * Disposes of the gizmo manager
  106538. */
  106539. dispose(): void;
  106540. }
  106541. }
  106542. declare module BABYLON {
  106543. /**
  106544. * A directional light is defined by a direction (what a surprise!).
  106545. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  106546. * 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.
  106547. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106548. */
  106549. export class DirectionalLight extends ShadowLight {
  106550. private _shadowFrustumSize;
  106551. /**
  106552. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  106553. */
  106554. /**
  106555. * Specifies a fix frustum size for the shadow generation.
  106556. */
  106557. shadowFrustumSize: number;
  106558. private _shadowOrthoScale;
  106559. /**
  106560. * Gets the shadow projection scale against the optimal computed one.
  106561. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106562. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106563. */
  106564. /**
  106565. * Sets the shadow projection scale against the optimal computed one.
  106566. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106567. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106568. */
  106569. shadowOrthoScale: number;
  106570. /**
  106571. * Automatically compute the projection matrix to best fit (including all the casters)
  106572. * on each frame.
  106573. */
  106574. autoUpdateExtends: boolean;
  106575. private _orthoLeft;
  106576. private _orthoRight;
  106577. private _orthoTop;
  106578. private _orthoBottom;
  106579. /**
  106580. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  106581. * The directional light is emitted from everywhere in the given direction.
  106582. * It can cast shadows.
  106583. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106584. * @param name The friendly name of the light
  106585. * @param direction The direction of the light
  106586. * @param scene The scene the light belongs to
  106587. */
  106588. constructor(name: string, direction: Vector3, scene: Scene);
  106589. /**
  106590. * Returns the string "DirectionalLight".
  106591. * @return The class name
  106592. */
  106593. getClassName(): string;
  106594. /**
  106595. * Returns the integer 1.
  106596. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106597. */
  106598. getTypeID(): number;
  106599. /**
  106600. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  106601. * Returns the DirectionalLight Shadow projection matrix.
  106602. */
  106603. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106604. /**
  106605. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  106606. * Returns the DirectionalLight Shadow projection matrix.
  106607. */
  106608. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  106609. /**
  106610. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  106611. * Returns the DirectionalLight Shadow projection matrix.
  106612. */
  106613. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106614. protected _buildUniformLayout(): void;
  106615. /**
  106616. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  106617. * @param effect The effect to update
  106618. * @param lightIndex The index of the light in the effect to update
  106619. * @returns The directional light
  106620. */
  106621. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  106622. /**
  106623. * Gets the minZ used for shadow according to both the scene and the light.
  106624. *
  106625. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106626. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106627. * @param activeCamera The camera we are returning the min for
  106628. * @returns the depth min z
  106629. */
  106630. getDepthMinZ(activeCamera: Camera): number;
  106631. /**
  106632. * Gets the maxZ used for shadow according to both the scene and the light.
  106633. *
  106634. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106635. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106636. * @param activeCamera The camera we are returning the max for
  106637. * @returns the depth max z
  106638. */
  106639. getDepthMaxZ(activeCamera: Camera): number;
  106640. /**
  106641. * Prepares the list of defines specific to the light type.
  106642. * @param defines the list of defines
  106643. * @param lightIndex defines the index of the light for the effect
  106644. */
  106645. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106646. }
  106647. }
  106648. declare module BABYLON {
  106649. /**
  106650. * Class containing static functions to help procedurally build meshes
  106651. */
  106652. export class HemisphereBuilder {
  106653. /**
  106654. * Creates a hemisphere mesh
  106655. * @param name defines the name of the mesh
  106656. * @param options defines the options used to create the mesh
  106657. * @param scene defines the hosting scene
  106658. * @returns the hemisphere mesh
  106659. */
  106660. static CreateHemisphere(name: string, options: {
  106661. segments?: number;
  106662. diameter?: number;
  106663. sideOrientation?: number;
  106664. }, scene: any): Mesh;
  106665. }
  106666. }
  106667. declare module BABYLON {
  106668. /**
  106669. * A spot light is defined by a position, a direction, an angle, and an exponent.
  106670. * These values define a cone of light starting from the position, emitting toward the direction.
  106671. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  106672. * and the exponent defines the speed of the decay of the light with distance (reach).
  106673. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106674. */
  106675. export class SpotLight extends ShadowLight {
  106676. private _angle;
  106677. private _innerAngle;
  106678. private _cosHalfAngle;
  106679. private _lightAngleScale;
  106680. private _lightAngleOffset;
  106681. /**
  106682. * Gets the cone angle of the spot light in Radians.
  106683. */
  106684. /**
  106685. * Sets the cone angle of the spot light in Radians.
  106686. */
  106687. angle: number;
  106688. /**
  106689. * Only used in gltf falloff mode, this defines the angle where
  106690. * the directional falloff will start before cutting at angle which could be seen
  106691. * as outer angle.
  106692. */
  106693. /**
  106694. * Only used in gltf falloff mode, this defines the angle where
  106695. * the directional falloff will start before cutting at angle which could be seen
  106696. * as outer angle.
  106697. */
  106698. innerAngle: number;
  106699. private _shadowAngleScale;
  106700. /**
  106701. * Allows scaling the angle of the light for shadow generation only.
  106702. */
  106703. /**
  106704. * Allows scaling the angle of the light for shadow generation only.
  106705. */
  106706. shadowAngleScale: number;
  106707. /**
  106708. * The light decay speed with the distance from the emission spot.
  106709. */
  106710. exponent: number;
  106711. private _projectionTextureMatrix;
  106712. /**
  106713. * Allows reading the projecton texture
  106714. */
  106715. readonly projectionTextureMatrix: Matrix;
  106716. protected _projectionTextureLightNear: number;
  106717. /**
  106718. * Gets the near clip of the Spotlight for texture projection.
  106719. */
  106720. /**
  106721. * Sets the near clip of the Spotlight for texture projection.
  106722. */
  106723. projectionTextureLightNear: number;
  106724. protected _projectionTextureLightFar: number;
  106725. /**
  106726. * Gets the far clip of the Spotlight for texture projection.
  106727. */
  106728. /**
  106729. * Sets the far clip of the Spotlight for texture projection.
  106730. */
  106731. projectionTextureLightFar: number;
  106732. protected _projectionTextureUpDirection: Vector3;
  106733. /**
  106734. * Gets the Up vector of the Spotlight for texture projection.
  106735. */
  106736. /**
  106737. * Sets the Up vector of the Spotlight for texture projection.
  106738. */
  106739. projectionTextureUpDirection: Vector3;
  106740. private _projectionTexture;
  106741. /**
  106742. * Gets the projection texture of the light.
  106743. */
  106744. /**
  106745. * Sets the projection texture of the light.
  106746. */
  106747. projectionTexture: Nullable<BaseTexture>;
  106748. private _projectionTextureViewLightDirty;
  106749. private _projectionTextureProjectionLightDirty;
  106750. private _projectionTextureDirty;
  106751. private _projectionTextureViewTargetVector;
  106752. private _projectionTextureViewLightMatrix;
  106753. private _projectionTextureProjectionLightMatrix;
  106754. private _projectionTextureScalingMatrix;
  106755. /**
  106756. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  106757. * It can cast shadows.
  106758. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106759. * @param name The light friendly name
  106760. * @param position The position of the spot light in the scene
  106761. * @param direction The direction of the light in the scene
  106762. * @param angle The cone angle of the light in Radians
  106763. * @param exponent The light decay speed with the distance from the emission spot
  106764. * @param scene The scene the lights belongs to
  106765. */
  106766. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  106767. /**
  106768. * Returns the string "SpotLight".
  106769. * @returns the class name
  106770. */
  106771. getClassName(): string;
  106772. /**
  106773. * Returns the integer 2.
  106774. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106775. */
  106776. getTypeID(): number;
  106777. /**
  106778. * Overrides the direction setter to recompute the projection texture view light Matrix.
  106779. */
  106780. protected _setDirection(value: Vector3): void;
  106781. /**
  106782. * Overrides the position setter to recompute the projection texture view light Matrix.
  106783. */
  106784. protected _setPosition(value: Vector3): void;
  106785. /**
  106786. * 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.
  106787. * Returns the SpotLight.
  106788. */
  106789. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106790. protected _computeProjectionTextureViewLightMatrix(): void;
  106791. protected _computeProjectionTextureProjectionLightMatrix(): void;
  106792. /**
  106793. * Main function for light texture projection matrix computing.
  106794. */
  106795. protected _computeProjectionTextureMatrix(): void;
  106796. protected _buildUniformLayout(): void;
  106797. private _computeAngleValues;
  106798. /**
  106799. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  106800. * @param effect The effect to update
  106801. * @param lightIndex The index of the light in the effect to update
  106802. * @returns The spot light
  106803. */
  106804. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  106805. /**
  106806. * Disposes the light and the associated resources.
  106807. */
  106808. dispose(): void;
  106809. /**
  106810. * Prepares the list of defines specific to the light type.
  106811. * @param defines the list of defines
  106812. * @param lightIndex defines the index of the light for the effect
  106813. */
  106814. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106815. }
  106816. }
  106817. declare module BABYLON {
  106818. /**
  106819. * Gizmo that enables viewing a light
  106820. */
  106821. export class LightGizmo extends Gizmo {
  106822. private _lightMesh;
  106823. private _material;
  106824. private cachedPosition;
  106825. private cachedForward;
  106826. /**
  106827. * Creates a LightGizmo
  106828. * @param gizmoLayer The utility layer the gizmo will be added to
  106829. */
  106830. constructor(gizmoLayer?: UtilityLayerRenderer);
  106831. private _light;
  106832. /**
  106833. * The light that the gizmo is attached to
  106834. */
  106835. light: Nullable<Light>;
  106836. /**
  106837. * @hidden
  106838. * Updates the gizmo to match the attached mesh's position/rotation
  106839. */
  106840. protected _update(): void;
  106841. private static _Scale;
  106842. /**
  106843. * Creates the lines for a light mesh
  106844. */
  106845. private static _createLightLines;
  106846. /**
  106847. * Disposes of the light gizmo
  106848. */
  106849. dispose(): void;
  106850. private static _CreateHemisphericLightMesh;
  106851. private static _CreatePointLightMesh;
  106852. private static _CreateSpotLightMesh;
  106853. private static _CreateDirectionalLightMesh;
  106854. }
  106855. }
  106856. declare module BABYLON {
  106857. /** @hidden */
  106858. export var backgroundFragmentDeclaration: {
  106859. name: string;
  106860. shader: string;
  106861. };
  106862. }
  106863. declare module BABYLON {
  106864. /** @hidden */
  106865. export var backgroundUboDeclaration: {
  106866. name: string;
  106867. shader: string;
  106868. };
  106869. }
  106870. declare module BABYLON {
  106871. /** @hidden */
  106872. export var backgroundPixelShader: {
  106873. name: string;
  106874. shader: string;
  106875. };
  106876. }
  106877. declare module BABYLON {
  106878. /** @hidden */
  106879. export var backgroundVertexDeclaration: {
  106880. name: string;
  106881. shader: string;
  106882. };
  106883. }
  106884. declare module BABYLON {
  106885. /** @hidden */
  106886. export var backgroundVertexShader: {
  106887. name: string;
  106888. shader: string;
  106889. };
  106890. }
  106891. declare module BABYLON {
  106892. /**
  106893. * Background material used to create an efficient environement around your scene.
  106894. */
  106895. export class BackgroundMaterial extends PushMaterial {
  106896. /**
  106897. * Standard reflectance value at parallel view angle.
  106898. */
  106899. static StandardReflectance0: number;
  106900. /**
  106901. * Standard reflectance value at grazing angle.
  106902. */
  106903. static StandardReflectance90: number;
  106904. protected _primaryColor: Color3;
  106905. /**
  106906. * Key light Color (multiply against the environement texture)
  106907. */
  106908. primaryColor: Color3;
  106909. protected __perceptualColor: Nullable<Color3>;
  106910. /**
  106911. * Experimental Internal Use Only.
  106912. *
  106913. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  106914. * This acts as a helper to set the primary color to a more "human friendly" value.
  106915. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  106916. * output color as close as possible from the chosen value.
  106917. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  106918. * part of lighting setup.)
  106919. */
  106920. _perceptualColor: Nullable<Color3>;
  106921. protected _primaryColorShadowLevel: float;
  106922. /**
  106923. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  106924. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  106925. */
  106926. primaryColorShadowLevel: float;
  106927. protected _primaryColorHighlightLevel: float;
  106928. /**
  106929. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  106930. * The primary color is used at the level chosen to define what the white area would look.
  106931. */
  106932. primaryColorHighlightLevel: float;
  106933. protected _reflectionTexture: Nullable<BaseTexture>;
  106934. /**
  106935. * Reflection Texture used in the material.
  106936. * Should be author in a specific way for the best result (refer to the documentation).
  106937. */
  106938. reflectionTexture: Nullable<BaseTexture>;
  106939. protected _reflectionBlur: float;
  106940. /**
  106941. * Reflection Texture level of blur.
  106942. *
  106943. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  106944. * texture twice.
  106945. */
  106946. reflectionBlur: float;
  106947. protected _diffuseTexture: Nullable<BaseTexture>;
  106948. /**
  106949. * Diffuse Texture used in the material.
  106950. * Should be author in a specific way for the best result (refer to the documentation).
  106951. */
  106952. diffuseTexture: Nullable<BaseTexture>;
  106953. protected _shadowLights: Nullable<IShadowLight[]>;
  106954. /**
  106955. * Specify the list of lights casting shadow on the material.
  106956. * All scene shadow lights will be included if null.
  106957. */
  106958. shadowLights: Nullable<IShadowLight[]>;
  106959. protected _shadowLevel: float;
  106960. /**
  106961. * Helps adjusting the shadow to a softer level if required.
  106962. * 0 means black shadows and 1 means no shadows.
  106963. */
  106964. shadowLevel: float;
  106965. protected _sceneCenter: Vector3;
  106966. /**
  106967. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  106968. * It is usually zero but might be interesting to modify according to your setup.
  106969. */
  106970. sceneCenter: Vector3;
  106971. protected _opacityFresnel: boolean;
  106972. /**
  106973. * This helps specifying that the material is falling off to the sky box at grazing angle.
  106974. * This helps ensuring a nice transition when the camera goes under the ground.
  106975. */
  106976. opacityFresnel: boolean;
  106977. protected _reflectionFresnel: boolean;
  106978. /**
  106979. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  106980. * This helps adding a mirror texture on the ground.
  106981. */
  106982. reflectionFresnel: boolean;
  106983. protected _reflectionFalloffDistance: number;
  106984. /**
  106985. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  106986. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  106987. */
  106988. reflectionFalloffDistance: number;
  106989. protected _reflectionAmount: number;
  106990. /**
  106991. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  106992. */
  106993. reflectionAmount: number;
  106994. protected _reflectionReflectance0: number;
  106995. /**
  106996. * This specifies the weight of the reflection at grazing angle.
  106997. */
  106998. reflectionReflectance0: number;
  106999. protected _reflectionReflectance90: number;
  107000. /**
  107001. * This specifies the weight of the reflection at a perpendicular point of view.
  107002. */
  107003. reflectionReflectance90: number;
  107004. /**
  107005. * Sets the reflection reflectance fresnel values according to the default standard
  107006. * empirically know to work well :-)
  107007. */
  107008. reflectionStandardFresnelWeight: number;
  107009. protected _useRGBColor: boolean;
  107010. /**
  107011. * Helps to directly use the maps channels instead of their level.
  107012. */
  107013. useRGBColor: boolean;
  107014. protected _enableNoise: boolean;
  107015. /**
  107016. * This helps reducing the banding effect that could occur on the background.
  107017. */
  107018. enableNoise: boolean;
  107019. /**
  107020. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  107021. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  107022. * Recommended to be keep at 1.0 except for special cases.
  107023. */
  107024. fovMultiplier: number;
  107025. private _fovMultiplier;
  107026. /**
  107027. * Enable the FOV adjustment feature controlled by fovMultiplier.
  107028. */
  107029. useEquirectangularFOV: boolean;
  107030. private _maxSimultaneousLights;
  107031. /**
  107032. * Number of Simultaneous lights allowed on the material.
  107033. */
  107034. maxSimultaneousLights: int;
  107035. /**
  107036. * Default configuration related to image processing available in the Background Material.
  107037. */
  107038. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107039. /**
  107040. * Keep track of the image processing observer to allow dispose and replace.
  107041. */
  107042. private _imageProcessingObserver;
  107043. /**
  107044. * Attaches a new image processing configuration to the PBR Material.
  107045. * @param configuration (if null the scene configuration will be use)
  107046. */
  107047. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107048. /**
  107049. * Gets the image processing configuration used either in this material.
  107050. */
  107051. /**
  107052. * Sets the Default image processing configuration used either in the this material.
  107053. *
  107054. * If sets to null, the scene one is in use.
  107055. */
  107056. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  107057. /**
  107058. * Gets wether the color curves effect is enabled.
  107059. */
  107060. /**
  107061. * Sets wether the color curves effect is enabled.
  107062. */
  107063. cameraColorCurvesEnabled: boolean;
  107064. /**
  107065. * Gets wether the color grading effect is enabled.
  107066. */
  107067. /**
  107068. * Gets wether the color grading effect is enabled.
  107069. */
  107070. cameraColorGradingEnabled: boolean;
  107071. /**
  107072. * Gets wether tonemapping is enabled or not.
  107073. */
  107074. /**
  107075. * Sets wether tonemapping is enabled or not
  107076. */
  107077. cameraToneMappingEnabled: boolean;
  107078. /**
  107079. * The camera exposure used on this material.
  107080. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107081. * This corresponds to a photographic exposure.
  107082. */
  107083. /**
  107084. * The camera exposure used on this material.
  107085. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107086. * This corresponds to a photographic exposure.
  107087. */
  107088. cameraExposure: float;
  107089. /**
  107090. * Gets The camera contrast used on this material.
  107091. */
  107092. /**
  107093. * Sets The camera contrast used on this material.
  107094. */
  107095. cameraContrast: float;
  107096. /**
  107097. * Gets the Color Grading 2D Lookup Texture.
  107098. */
  107099. /**
  107100. * Sets the Color Grading 2D Lookup Texture.
  107101. */
  107102. cameraColorGradingTexture: Nullable<BaseTexture>;
  107103. /**
  107104. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107105. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107106. * 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;
  107107. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107108. */
  107109. /**
  107110. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107111. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107112. * 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;
  107113. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107114. */
  107115. cameraColorCurves: Nullable<ColorCurves>;
  107116. /**
  107117. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  107118. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  107119. */
  107120. switchToBGR: boolean;
  107121. private _renderTargets;
  107122. private _reflectionControls;
  107123. private _white;
  107124. private _primaryShadowColor;
  107125. private _primaryHighlightColor;
  107126. /**
  107127. * Instantiates a Background Material in the given scene
  107128. * @param name The friendly name of the material
  107129. * @param scene The scene to add the material to
  107130. */
  107131. constructor(name: string, scene: Scene);
  107132. /**
  107133. * Gets a boolean indicating that current material needs to register RTT
  107134. */
  107135. readonly hasRenderTargetTextures: boolean;
  107136. /**
  107137. * The entire material has been created in order to prevent overdraw.
  107138. * @returns false
  107139. */
  107140. needAlphaTesting(): boolean;
  107141. /**
  107142. * The entire material has been created in order to prevent overdraw.
  107143. * @returns true if blending is enable
  107144. */
  107145. needAlphaBlending(): boolean;
  107146. /**
  107147. * Checks wether the material is ready to be rendered for a given mesh.
  107148. * @param mesh The mesh to render
  107149. * @param subMesh The submesh to check against
  107150. * @param useInstances Specify wether or not the material is used with instances
  107151. * @returns true if all the dependencies are ready (Textures, Effects...)
  107152. */
  107153. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107154. /**
  107155. * Compute the primary color according to the chosen perceptual color.
  107156. */
  107157. private _computePrimaryColorFromPerceptualColor;
  107158. /**
  107159. * Compute the highlights and shadow colors according to their chosen levels.
  107160. */
  107161. private _computePrimaryColors;
  107162. /**
  107163. * Build the uniform buffer used in the material.
  107164. */
  107165. buildUniformLayout(): void;
  107166. /**
  107167. * Unbind the material.
  107168. */
  107169. unbind(): void;
  107170. /**
  107171. * Bind only the world matrix to the material.
  107172. * @param world The world matrix to bind.
  107173. */
  107174. bindOnlyWorldMatrix(world: Matrix): void;
  107175. /**
  107176. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  107177. * @param world The world matrix to bind.
  107178. * @param subMesh The submesh to bind for.
  107179. */
  107180. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107181. /**
  107182. * Dispose the material.
  107183. * @param forceDisposeEffect Force disposal of the associated effect.
  107184. * @param forceDisposeTextures Force disposal of the associated textures.
  107185. */
  107186. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107187. /**
  107188. * Clones the material.
  107189. * @param name The cloned name.
  107190. * @returns The cloned material.
  107191. */
  107192. clone(name: string): BackgroundMaterial;
  107193. /**
  107194. * Serializes the current material to its JSON representation.
  107195. * @returns The JSON representation.
  107196. */
  107197. serialize(): any;
  107198. /**
  107199. * Gets the class name of the material
  107200. * @returns "BackgroundMaterial"
  107201. */
  107202. getClassName(): string;
  107203. /**
  107204. * Parse a JSON input to create back a background material.
  107205. * @param source The JSON data to parse
  107206. * @param scene The scene to create the parsed material in
  107207. * @param rootUrl The root url of the assets the material depends upon
  107208. * @returns the instantiated BackgroundMaterial.
  107209. */
  107210. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  107211. }
  107212. }
  107213. declare module BABYLON {
  107214. /**
  107215. * Represents the different options available during the creation of
  107216. * a Environment helper.
  107217. *
  107218. * This can control the default ground, skybox and image processing setup of your scene.
  107219. */
  107220. export interface IEnvironmentHelperOptions {
  107221. /**
  107222. * Specifies wether or not to create a ground.
  107223. * True by default.
  107224. */
  107225. createGround: boolean;
  107226. /**
  107227. * Specifies the ground size.
  107228. * 15 by default.
  107229. */
  107230. groundSize: number;
  107231. /**
  107232. * The texture used on the ground for the main color.
  107233. * Comes from the BabylonJS CDN by default.
  107234. *
  107235. * Remarks: Can be either a texture or a url.
  107236. */
  107237. groundTexture: string | BaseTexture;
  107238. /**
  107239. * The color mixed in the ground texture by default.
  107240. * BabylonJS clearColor by default.
  107241. */
  107242. groundColor: Color3;
  107243. /**
  107244. * Specifies the ground opacity.
  107245. * 1 by default.
  107246. */
  107247. groundOpacity: number;
  107248. /**
  107249. * Enables the ground to receive shadows.
  107250. * True by default.
  107251. */
  107252. enableGroundShadow: boolean;
  107253. /**
  107254. * Helps preventing the shadow to be fully black on the ground.
  107255. * 0.5 by default.
  107256. */
  107257. groundShadowLevel: number;
  107258. /**
  107259. * Creates a mirror texture attach to the ground.
  107260. * false by default.
  107261. */
  107262. enableGroundMirror: boolean;
  107263. /**
  107264. * Specifies the ground mirror size ratio.
  107265. * 0.3 by default as the default kernel is 64.
  107266. */
  107267. groundMirrorSizeRatio: number;
  107268. /**
  107269. * Specifies the ground mirror blur kernel size.
  107270. * 64 by default.
  107271. */
  107272. groundMirrorBlurKernel: number;
  107273. /**
  107274. * Specifies the ground mirror visibility amount.
  107275. * 1 by default
  107276. */
  107277. groundMirrorAmount: number;
  107278. /**
  107279. * Specifies the ground mirror reflectance weight.
  107280. * This uses the standard weight of the background material to setup the fresnel effect
  107281. * of the mirror.
  107282. * 1 by default.
  107283. */
  107284. groundMirrorFresnelWeight: number;
  107285. /**
  107286. * Specifies the ground mirror Falloff distance.
  107287. * This can helps reducing the size of the reflection.
  107288. * 0 by Default.
  107289. */
  107290. groundMirrorFallOffDistance: number;
  107291. /**
  107292. * Specifies the ground mirror texture type.
  107293. * Unsigned Int by Default.
  107294. */
  107295. groundMirrorTextureType: number;
  107296. /**
  107297. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  107298. * the shown objects.
  107299. */
  107300. groundYBias: number;
  107301. /**
  107302. * Specifies wether or not to create a skybox.
  107303. * True by default.
  107304. */
  107305. createSkybox: boolean;
  107306. /**
  107307. * Specifies the skybox size.
  107308. * 20 by default.
  107309. */
  107310. skyboxSize: number;
  107311. /**
  107312. * The texture used on the skybox for the main color.
  107313. * Comes from the BabylonJS CDN by default.
  107314. *
  107315. * Remarks: Can be either a texture or a url.
  107316. */
  107317. skyboxTexture: string | BaseTexture;
  107318. /**
  107319. * The color mixed in the skybox texture by default.
  107320. * BabylonJS clearColor by default.
  107321. */
  107322. skyboxColor: Color3;
  107323. /**
  107324. * The background rotation around the Y axis of the scene.
  107325. * This helps aligning the key lights of your scene with the background.
  107326. * 0 by default.
  107327. */
  107328. backgroundYRotation: number;
  107329. /**
  107330. * Compute automatically the size of the elements to best fit with the scene.
  107331. */
  107332. sizeAuto: boolean;
  107333. /**
  107334. * Default position of the rootMesh if autoSize is not true.
  107335. */
  107336. rootPosition: Vector3;
  107337. /**
  107338. * Sets up the image processing in the scene.
  107339. * true by default.
  107340. */
  107341. setupImageProcessing: boolean;
  107342. /**
  107343. * The texture used as your environment texture in the scene.
  107344. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  107345. *
  107346. * Remarks: Can be either a texture or a url.
  107347. */
  107348. environmentTexture: string | BaseTexture;
  107349. /**
  107350. * The value of the exposure to apply to the scene.
  107351. * 0.6 by default if setupImageProcessing is true.
  107352. */
  107353. cameraExposure: number;
  107354. /**
  107355. * The value of the contrast to apply to the scene.
  107356. * 1.6 by default if setupImageProcessing is true.
  107357. */
  107358. cameraContrast: number;
  107359. /**
  107360. * Specifies wether or not tonemapping should be enabled in the scene.
  107361. * true by default if setupImageProcessing is true.
  107362. */
  107363. toneMappingEnabled: boolean;
  107364. }
  107365. /**
  107366. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  107367. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  107368. * It also helps with the default setup of your imageProcessing configuration.
  107369. */
  107370. export class EnvironmentHelper {
  107371. /**
  107372. * Default ground texture URL.
  107373. */
  107374. private static _groundTextureCDNUrl;
  107375. /**
  107376. * Default skybox texture URL.
  107377. */
  107378. private static _skyboxTextureCDNUrl;
  107379. /**
  107380. * Default environment texture URL.
  107381. */
  107382. private static _environmentTextureCDNUrl;
  107383. /**
  107384. * Creates the default options for the helper.
  107385. */
  107386. private static _getDefaultOptions;
  107387. private _rootMesh;
  107388. /**
  107389. * Gets the root mesh created by the helper.
  107390. */
  107391. readonly rootMesh: Mesh;
  107392. private _skybox;
  107393. /**
  107394. * Gets the skybox created by the helper.
  107395. */
  107396. readonly skybox: Nullable<Mesh>;
  107397. private _skyboxTexture;
  107398. /**
  107399. * Gets the skybox texture created by the helper.
  107400. */
  107401. readonly skyboxTexture: Nullable<BaseTexture>;
  107402. private _skyboxMaterial;
  107403. /**
  107404. * Gets the skybox material created by the helper.
  107405. */
  107406. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  107407. private _ground;
  107408. /**
  107409. * Gets the ground mesh created by the helper.
  107410. */
  107411. readonly ground: Nullable<Mesh>;
  107412. private _groundTexture;
  107413. /**
  107414. * Gets the ground texture created by the helper.
  107415. */
  107416. readonly groundTexture: Nullable<BaseTexture>;
  107417. private _groundMirror;
  107418. /**
  107419. * Gets the ground mirror created by the helper.
  107420. */
  107421. readonly groundMirror: Nullable<MirrorTexture>;
  107422. /**
  107423. * Gets the ground mirror render list to helps pushing the meshes
  107424. * you wish in the ground reflection.
  107425. */
  107426. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  107427. private _groundMaterial;
  107428. /**
  107429. * Gets the ground material created by the helper.
  107430. */
  107431. readonly groundMaterial: Nullable<BackgroundMaterial>;
  107432. /**
  107433. * Stores the creation options.
  107434. */
  107435. private readonly _scene;
  107436. private _options;
  107437. /**
  107438. * This observable will be notified with any error during the creation of the environment,
  107439. * mainly texture creation errors.
  107440. */
  107441. onErrorObservable: Observable<{
  107442. message?: string;
  107443. exception?: any;
  107444. }>;
  107445. /**
  107446. * constructor
  107447. * @param options Defines the options we want to customize the helper
  107448. * @param scene The scene to add the material to
  107449. */
  107450. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  107451. /**
  107452. * Updates the background according to the new options
  107453. * @param options
  107454. */
  107455. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  107456. /**
  107457. * Sets the primary color of all the available elements.
  107458. * @param color the main color to affect to the ground and the background
  107459. */
  107460. setMainColor(color: Color3): void;
  107461. /**
  107462. * Setup the image processing according to the specified options.
  107463. */
  107464. private _setupImageProcessing;
  107465. /**
  107466. * Setup the environment texture according to the specified options.
  107467. */
  107468. private _setupEnvironmentTexture;
  107469. /**
  107470. * Setup the background according to the specified options.
  107471. */
  107472. private _setupBackground;
  107473. /**
  107474. * Get the scene sizes according to the setup.
  107475. */
  107476. private _getSceneSize;
  107477. /**
  107478. * Setup the ground according to the specified options.
  107479. */
  107480. private _setupGround;
  107481. /**
  107482. * Setup the ground material according to the specified options.
  107483. */
  107484. private _setupGroundMaterial;
  107485. /**
  107486. * Setup the ground diffuse texture according to the specified options.
  107487. */
  107488. private _setupGroundDiffuseTexture;
  107489. /**
  107490. * Setup the ground mirror texture according to the specified options.
  107491. */
  107492. private _setupGroundMirrorTexture;
  107493. /**
  107494. * Setup the ground to receive the mirror texture.
  107495. */
  107496. private _setupMirrorInGroundMaterial;
  107497. /**
  107498. * Setup the skybox according to the specified options.
  107499. */
  107500. private _setupSkybox;
  107501. /**
  107502. * Setup the skybox material according to the specified options.
  107503. */
  107504. private _setupSkyboxMaterial;
  107505. /**
  107506. * Setup the skybox reflection texture according to the specified options.
  107507. */
  107508. private _setupSkyboxReflectionTexture;
  107509. private _errorHandler;
  107510. /**
  107511. * Dispose all the elements created by the Helper.
  107512. */
  107513. dispose(): void;
  107514. }
  107515. }
  107516. declare module BABYLON {
  107517. /**
  107518. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  107519. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  107520. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  107521. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  107522. */
  107523. export class PhotoDome extends TransformNode {
  107524. /**
  107525. * Define the image as a Monoscopic panoramic 360 image.
  107526. */
  107527. static readonly MODE_MONOSCOPIC: number;
  107528. /**
  107529. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  107530. */
  107531. static readonly MODE_TOPBOTTOM: number;
  107532. /**
  107533. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  107534. */
  107535. static readonly MODE_SIDEBYSIDE: number;
  107536. private _useDirectMapping;
  107537. /**
  107538. * The texture being displayed on the sphere
  107539. */
  107540. protected _photoTexture: Texture;
  107541. /**
  107542. * Gets or sets the texture being displayed on the sphere
  107543. */
  107544. photoTexture: Texture;
  107545. /**
  107546. * Observable raised when an error occured while loading the 360 image
  107547. */
  107548. onLoadErrorObservable: Observable<string>;
  107549. /**
  107550. * The skybox material
  107551. */
  107552. protected _material: BackgroundMaterial;
  107553. /**
  107554. * The surface used for the skybox
  107555. */
  107556. protected _mesh: Mesh;
  107557. /**
  107558. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  107559. * Also see the options.resolution property.
  107560. */
  107561. fovMultiplier: number;
  107562. private _imageMode;
  107563. /**
  107564. * Gets or set the current video mode for the video. It can be:
  107565. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  107566. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  107567. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  107568. */
  107569. imageMode: number;
  107570. /**
  107571. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  107572. * @param name Element's name, child elements will append suffixes for their own names.
  107573. * @param urlsOfPhoto defines the url of the photo to display
  107574. * @param options defines an object containing optional or exposed sub element properties
  107575. * @param onError defines a callback called when an error occured while loading the texture
  107576. */
  107577. constructor(name: string, urlOfPhoto: string, options: {
  107578. resolution?: number;
  107579. size?: number;
  107580. useDirectMapping?: boolean;
  107581. faceForward?: boolean;
  107582. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  107583. private _onBeforeCameraRenderObserver;
  107584. private _changeImageMode;
  107585. /**
  107586. * Releases resources associated with this node.
  107587. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107588. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107589. */
  107590. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107591. }
  107592. }
  107593. declare module BABYLON {
  107594. /** @hidden */
  107595. export var rgbdDecodePixelShader: {
  107596. name: string;
  107597. shader: string;
  107598. };
  107599. }
  107600. declare module BABYLON {
  107601. /**
  107602. * Class used to host texture specific utilities
  107603. */
  107604. export class BRDFTextureTools {
  107605. /**
  107606. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  107607. * @param texture the texture to expand.
  107608. */
  107609. private static _ExpandDefaultBRDFTexture;
  107610. /**
  107611. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  107612. * @param scene defines the hosting scene
  107613. * @returns the environment BRDF texture
  107614. */
  107615. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  107616. private static _environmentBRDFBase64Texture;
  107617. }
  107618. }
  107619. declare module BABYLON {
  107620. /**
  107621. * @hidden
  107622. */
  107623. export interface IMaterialClearCoatDefines {
  107624. CLEARCOAT: boolean;
  107625. CLEARCOAT_DEFAULTIOR: boolean;
  107626. CLEARCOAT_TEXTURE: boolean;
  107627. CLEARCOAT_TEXTUREDIRECTUV: number;
  107628. CLEARCOAT_BUMP: boolean;
  107629. CLEARCOAT_BUMPDIRECTUV: number;
  107630. CLEARCOAT_TINT: boolean;
  107631. CLEARCOAT_TINT_TEXTURE: boolean;
  107632. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107633. /** @hidden */
  107634. _areTexturesDirty: boolean;
  107635. }
  107636. /**
  107637. * Define the code related to the clear coat parameters of the pbr material.
  107638. */
  107639. export class PBRClearCoatConfiguration {
  107640. /**
  107641. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107642. * The default fits with a polyurethane material.
  107643. */
  107644. private static readonly _DefaultIndexOfRefraction;
  107645. private _isEnabled;
  107646. /**
  107647. * Defines if the clear coat is enabled in the material.
  107648. */
  107649. isEnabled: boolean;
  107650. /**
  107651. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  107652. */
  107653. intensity: number;
  107654. /**
  107655. * Defines the clear coat layer roughness.
  107656. */
  107657. roughness: number;
  107658. private _indexOfRefraction;
  107659. /**
  107660. * Defines the index of refraction of the clear coat.
  107661. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107662. * The default fits with a polyurethane material.
  107663. * Changing the default value is more performance intensive.
  107664. */
  107665. indexOfRefraction: number;
  107666. private _texture;
  107667. /**
  107668. * Stores the clear coat values in a texture.
  107669. */
  107670. texture: Nullable<BaseTexture>;
  107671. private _bumpTexture;
  107672. /**
  107673. * Define the clear coat specific bump texture.
  107674. */
  107675. bumpTexture: Nullable<BaseTexture>;
  107676. private _isTintEnabled;
  107677. /**
  107678. * Defines if the clear coat tint is enabled in the material.
  107679. */
  107680. isTintEnabled: boolean;
  107681. /**
  107682. * Defines the clear coat tint of the material.
  107683. * This is only use if tint is enabled
  107684. */
  107685. tintColor: Color3;
  107686. /**
  107687. * Defines the distance at which the tint color should be found in the
  107688. * clear coat media.
  107689. * This is only use if tint is enabled
  107690. */
  107691. tintColorAtDistance: number;
  107692. /**
  107693. * Defines the clear coat layer thickness.
  107694. * This is only use if tint is enabled
  107695. */
  107696. tintThickness: number;
  107697. private _tintTexture;
  107698. /**
  107699. * Stores the clear tint values in a texture.
  107700. * rgb is tint
  107701. * a is a thickness factor
  107702. */
  107703. tintTexture: Nullable<BaseTexture>;
  107704. /** @hidden */
  107705. private _internalMarkAllSubMeshesAsTexturesDirty;
  107706. /** @hidden */
  107707. _markAllSubMeshesAsTexturesDirty(): void;
  107708. /**
  107709. * Instantiate a new istance of clear coat configuration.
  107710. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107711. */
  107712. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107713. /**
  107714. * Gets wehter the submesh is ready to be used or not.
  107715. * @param defines the list of "defines" to update.
  107716. * @param scene defines the scene the material belongs to.
  107717. * @param engine defines the engine the material belongs to.
  107718. * @param disableBumpMap defines wether the material disables bump or not.
  107719. * @returns - boolean indicating that the submesh is ready or not.
  107720. */
  107721. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  107722. /**
  107723. * Checks to see if a texture is used in the material.
  107724. * @param defines the list of "defines" to update.
  107725. * @param scene defines the scene to the material belongs to.
  107726. */
  107727. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  107728. /**
  107729. * Binds the material data.
  107730. * @param uniformBuffer defines the Uniform buffer to fill in.
  107731. * @param scene defines the scene the material belongs to.
  107732. * @param engine defines the engine the material belongs to.
  107733. * @param disableBumpMap defines wether the material disables bump or not.
  107734. * @param isFrozen defines wether the material is frozen or not.
  107735. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107736. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107737. */
  107738. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  107739. /**
  107740. * Checks to see if a texture is used in the material.
  107741. * @param texture - Base texture to use.
  107742. * @returns - Boolean specifying if a texture is used in the material.
  107743. */
  107744. hasTexture(texture: BaseTexture): boolean;
  107745. /**
  107746. * Returns an array of the actively used textures.
  107747. * @param activeTextures Array of BaseTextures
  107748. */
  107749. getActiveTextures(activeTextures: BaseTexture[]): void;
  107750. /**
  107751. * Returns the animatable textures.
  107752. * @param animatables Array of animatable textures.
  107753. */
  107754. getAnimatables(animatables: IAnimatable[]): void;
  107755. /**
  107756. * Disposes the resources of the material.
  107757. * @param forceDisposeTextures - Forces the disposal of all textures.
  107758. */
  107759. dispose(forceDisposeTextures?: boolean): void;
  107760. /**
  107761. * Get the current class name of the texture useful for serialization or dynamic coding.
  107762. * @returns "PBRClearCoatConfiguration"
  107763. */
  107764. getClassName(): string;
  107765. /**
  107766. * Add fallbacks to the effect fallbacks list.
  107767. * @param defines defines the Base texture to use.
  107768. * @param fallbacks defines the current fallback list.
  107769. * @param currentRank defines the current fallback rank.
  107770. * @returns the new fallback rank.
  107771. */
  107772. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107773. /**
  107774. * Add the required uniforms to the current list.
  107775. * @param uniforms defines the current uniform list.
  107776. */
  107777. static AddUniforms(uniforms: string[]): void;
  107778. /**
  107779. * Add the required samplers to the current list.
  107780. * @param samplers defines the current sampler list.
  107781. */
  107782. static AddSamplers(samplers: string[]): void;
  107783. /**
  107784. * Add the required uniforms to the current buffer.
  107785. * @param uniformBuffer defines the current uniform buffer.
  107786. */
  107787. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107788. /**
  107789. * Makes a duplicate of the current configuration into another one.
  107790. * @param clearCoatConfiguration define the config where to copy the info
  107791. */
  107792. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  107793. /**
  107794. * Serializes this clear coat configuration.
  107795. * @returns - An object with the serialized config.
  107796. */
  107797. serialize(): any;
  107798. /**
  107799. * Parses a anisotropy Configuration from a serialized object.
  107800. * @param source - Serialized object.
  107801. * @param scene Defines the scene we are parsing for
  107802. * @param rootUrl Defines the rootUrl to load from
  107803. */
  107804. parse(source: any, scene: Scene, rootUrl: string): void;
  107805. }
  107806. }
  107807. declare module BABYLON {
  107808. /**
  107809. * @hidden
  107810. */
  107811. export interface IMaterialAnisotropicDefines {
  107812. ANISOTROPIC: boolean;
  107813. ANISOTROPIC_TEXTURE: boolean;
  107814. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107815. MAINUV1: boolean;
  107816. _areTexturesDirty: boolean;
  107817. _needUVs: boolean;
  107818. }
  107819. /**
  107820. * Define the code related to the anisotropic parameters of the pbr material.
  107821. */
  107822. export class PBRAnisotropicConfiguration {
  107823. private _isEnabled;
  107824. /**
  107825. * Defines if the anisotropy is enabled in the material.
  107826. */
  107827. isEnabled: boolean;
  107828. /**
  107829. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  107830. */
  107831. intensity: number;
  107832. /**
  107833. * Defines if the effect is along the tangents, bitangents or in between.
  107834. * By default, the effect is "strectching" the highlights along the tangents.
  107835. */
  107836. direction: Vector2;
  107837. private _texture;
  107838. /**
  107839. * Stores the anisotropy values in a texture.
  107840. * rg is direction (like normal from -1 to 1)
  107841. * b is a intensity
  107842. */
  107843. texture: Nullable<BaseTexture>;
  107844. /** @hidden */
  107845. private _internalMarkAllSubMeshesAsTexturesDirty;
  107846. /** @hidden */
  107847. _markAllSubMeshesAsTexturesDirty(): void;
  107848. /**
  107849. * Instantiate a new istance of anisotropy configuration.
  107850. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107851. */
  107852. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107853. /**
  107854. * Specifies that the submesh is ready to be used.
  107855. * @param defines the list of "defines" to update.
  107856. * @param scene defines the scene the material belongs to.
  107857. * @returns - boolean indicating that the submesh is ready or not.
  107858. */
  107859. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  107860. /**
  107861. * Checks to see if a texture is used in the material.
  107862. * @param defines the list of "defines" to update.
  107863. * @param mesh the mesh we are preparing the defines for.
  107864. * @param scene defines the scene the material belongs to.
  107865. */
  107866. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  107867. /**
  107868. * Binds the material data.
  107869. * @param uniformBuffer defines the Uniform buffer to fill in.
  107870. * @param scene defines the scene the material belongs to.
  107871. * @param isFrozen defines wether the material is frozen or not.
  107872. */
  107873. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107874. /**
  107875. * Checks to see if a texture is used in the material.
  107876. * @param texture - Base texture to use.
  107877. * @returns - Boolean specifying if a texture is used in the material.
  107878. */
  107879. hasTexture(texture: BaseTexture): boolean;
  107880. /**
  107881. * Returns an array of the actively used textures.
  107882. * @param activeTextures Array of BaseTextures
  107883. */
  107884. getActiveTextures(activeTextures: BaseTexture[]): void;
  107885. /**
  107886. * Returns the animatable textures.
  107887. * @param animatables Array of animatable textures.
  107888. */
  107889. getAnimatables(animatables: IAnimatable[]): void;
  107890. /**
  107891. * Disposes the resources of the material.
  107892. * @param forceDisposeTextures - Forces the disposal of all textures.
  107893. */
  107894. dispose(forceDisposeTextures?: boolean): void;
  107895. /**
  107896. * Get the current class name of the texture useful for serialization or dynamic coding.
  107897. * @returns "PBRAnisotropicConfiguration"
  107898. */
  107899. getClassName(): string;
  107900. /**
  107901. * Add fallbacks to the effect fallbacks list.
  107902. * @param defines defines the Base texture to use.
  107903. * @param fallbacks defines the current fallback list.
  107904. * @param currentRank defines the current fallback rank.
  107905. * @returns the new fallback rank.
  107906. */
  107907. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107908. /**
  107909. * Add the required uniforms to the current list.
  107910. * @param uniforms defines the current uniform list.
  107911. */
  107912. static AddUniforms(uniforms: string[]): void;
  107913. /**
  107914. * Add the required uniforms to the current buffer.
  107915. * @param uniformBuffer defines the current uniform buffer.
  107916. */
  107917. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107918. /**
  107919. * Add the required samplers to the current list.
  107920. * @param samplers defines the current sampler list.
  107921. */
  107922. static AddSamplers(samplers: string[]): void;
  107923. /**
  107924. * Makes a duplicate of the current configuration into another one.
  107925. * @param anisotropicConfiguration define the config where to copy the info
  107926. */
  107927. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  107928. /**
  107929. * Serializes this anisotropy configuration.
  107930. * @returns - An object with the serialized config.
  107931. */
  107932. serialize(): any;
  107933. /**
  107934. * Parses a anisotropy Configuration from a serialized object.
  107935. * @param source - Serialized object.
  107936. * @param scene Defines the scene we are parsing for
  107937. * @param rootUrl Defines the rootUrl to load from
  107938. */
  107939. parse(source: any, scene: Scene, rootUrl: string): void;
  107940. }
  107941. }
  107942. declare module BABYLON {
  107943. /**
  107944. * @hidden
  107945. */
  107946. export interface IMaterialBRDFDefines {
  107947. BRDF_V_HEIGHT_CORRELATED: boolean;
  107948. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107949. SPHERICAL_HARMONICS: boolean;
  107950. /** @hidden */
  107951. _areMiscDirty: boolean;
  107952. }
  107953. /**
  107954. * Define the code related to the BRDF parameters of the pbr material.
  107955. */
  107956. export class PBRBRDFConfiguration {
  107957. /**
  107958. * Default value used for the energy conservation.
  107959. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107960. */
  107961. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  107962. /**
  107963. * Default value used for the Smith Visibility Height Correlated mode.
  107964. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107965. */
  107966. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  107967. /**
  107968. * Default value used for the IBL diffuse part.
  107969. * This can help switching back to the polynomials mode globally which is a tiny bit
  107970. * less GPU intensive at the drawback of a lower quality.
  107971. */
  107972. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  107973. private _useEnergyConservation;
  107974. /**
  107975. * Defines if the material uses energy conservation.
  107976. */
  107977. useEnergyConservation: boolean;
  107978. private _useSmithVisibilityHeightCorrelated;
  107979. /**
  107980. * LEGACY Mode set to false
  107981. * Defines if the material uses height smith correlated visibility term.
  107982. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  107983. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  107984. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  107985. * Not relying on height correlated will also disable energy conservation.
  107986. */
  107987. useSmithVisibilityHeightCorrelated: boolean;
  107988. private _useSphericalHarmonics;
  107989. /**
  107990. * LEGACY Mode set to false
  107991. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  107992. * diffuse part of the IBL.
  107993. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  107994. * to the ground truth.
  107995. */
  107996. useSphericalHarmonics: boolean;
  107997. /** @hidden */
  107998. private _internalMarkAllSubMeshesAsMiscDirty;
  107999. /** @hidden */
  108000. _markAllSubMeshesAsMiscDirty(): void;
  108001. /**
  108002. * Instantiate a new istance of clear coat configuration.
  108003. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  108004. */
  108005. constructor(markAllSubMeshesAsMiscDirty: () => void);
  108006. /**
  108007. * Checks to see if a texture is used in the material.
  108008. * @param defines the list of "defines" to update.
  108009. */
  108010. prepareDefines(defines: IMaterialBRDFDefines): void;
  108011. /**
  108012. * Get the current class name of the texture useful for serialization or dynamic coding.
  108013. * @returns "PBRClearCoatConfiguration"
  108014. */
  108015. getClassName(): string;
  108016. /**
  108017. * Makes a duplicate of the current configuration into another one.
  108018. * @param brdfConfiguration define the config where to copy the info
  108019. */
  108020. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  108021. /**
  108022. * Serializes this BRDF configuration.
  108023. * @returns - An object with the serialized config.
  108024. */
  108025. serialize(): any;
  108026. /**
  108027. * Parses a anisotropy Configuration from a serialized object.
  108028. * @param source - Serialized object.
  108029. * @param scene Defines the scene we are parsing for
  108030. * @param rootUrl Defines the rootUrl to load from
  108031. */
  108032. parse(source: any, scene: Scene, rootUrl: string): void;
  108033. }
  108034. }
  108035. declare module BABYLON {
  108036. /**
  108037. * @hidden
  108038. */
  108039. export interface IMaterialSheenDefines {
  108040. SHEEN: boolean;
  108041. SHEEN_TEXTURE: boolean;
  108042. SHEEN_TEXTUREDIRECTUV: number;
  108043. SHEEN_LINKWITHALBEDO: boolean;
  108044. /** @hidden */
  108045. _areTexturesDirty: boolean;
  108046. }
  108047. /**
  108048. * Define the code related to the Sheen parameters of the pbr material.
  108049. */
  108050. export class PBRSheenConfiguration {
  108051. private _isEnabled;
  108052. /**
  108053. * Defines if the material uses sheen.
  108054. */
  108055. isEnabled: boolean;
  108056. private _linkSheenWithAlbedo;
  108057. /**
  108058. * Defines if the sheen is linked to the sheen color.
  108059. */
  108060. linkSheenWithAlbedo: boolean;
  108061. /**
  108062. * Defines the sheen intensity.
  108063. */
  108064. intensity: number;
  108065. /**
  108066. * Defines the sheen color.
  108067. */
  108068. color: Color3;
  108069. private _texture;
  108070. /**
  108071. * Stores the sheen tint values in a texture.
  108072. * rgb is tint
  108073. * a is a intensity
  108074. */
  108075. texture: Nullable<BaseTexture>;
  108076. /** @hidden */
  108077. private _internalMarkAllSubMeshesAsTexturesDirty;
  108078. /** @hidden */
  108079. _markAllSubMeshesAsTexturesDirty(): void;
  108080. /**
  108081. * Instantiate a new istance of clear coat configuration.
  108082. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108083. */
  108084. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108085. /**
  108086. * Specifies that the submesh is ready to be used.
  108087. * @param defines the list of "defines" to update.
  108088. * @param scene defines the scene the material belongs to.
  108089. * @returns - boolean indicating that the submesh is ready or not.
  108090. */
  108091. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  108092. /**
  108093. * Checks to see if a texture is used in the material.
  108094. * @param defines the list of "defines" to update.
  108095. * @param scene defines the scene the material belongs to.
  108096. */
  108097. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  108098. /**
  108099. * Binds the material data.
  108100. * @param uniformBuffer defines the Uniform buffer to fill in.
  108101. * @param scene defines the scene the material belongs to.
  108102. * @param isFrozen defines wether the material is frozen or not.
  108103. */
  108104. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  108105. /**
  108106. * Checks to see if a texture is used in the material.
  108107. * @param texture - Base texture to use.
  108108. * @returns - Boolean specifying if a texture is used in the material.
  108109. */
  108110. hasTexture(texture: BaseTexture): boolean;
  108111. /**
  108112. * Returns an array of the actively used textures.
  108113. * @param activeTextures Array of BaseTextures
  108114. */
  108115. getActiveTextures(activeTextures: BaseTexture[]): void;
  108116. /**
  108117. * Returns the animatable textures.
  108118. * @param animatables Array of animatable textures.
  108119. */
  108120. getAnimatables(animatables: IAnimatable[]): void;
  108121. /**
  108122. * Disposes the resources of the material.
  108123. * @param forceDisposeTextures - Forces the disposal of all textures.
  108124. */
  108125. dispose(forceDisposeTextures?: boolean): void;
  108126. /**
  108127. * Get the current class name of the texture useful for serialization or dynamic coding.
  108128. * @returns "PBRSheenConfiguration"
  108129. */
  108130. getClassName(): string;
  108131. /**
  108132. * Add fallbacks to the effect fallbacks list.
  108133. * @param defines defines the Base texture to use.
  108134. * @param fallbacks defines the current fallback list.
  108135. * @param currentRank defines the current fallback rank.
  108136. * @returns the new fallback rank.
  108137. */
  108138. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  108139. /**
  108140. * Add the required uniforms to the current list.
  108141. * @param uniforms defines the current uniform list.
  108142. */
  108143. static AddUniforms(uniforms: string[]): void;
  108144. /**
  108145. * Add the required uniforms to the current buffer.
  108146. * @param uniformBuffer defines the current uniform buffer.
  108147. */
  108148. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108149. /**
  108150. * Add the required samplers to the current list.
  108151. * @param samplers defines the current sampler list.
  108152. */
  108153. static AddSamplers(samplers: string[]): void;
  108154. /**
  108155. * Makes a duplicate of the current configuration into another one.
  108156. * @param sheenConfiguration define the config where to copy the info
  108157. */
  108158. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  108159. /**
  108160. * Serializes this BRDF configuration.
  108161. * @returns - An object with the serialized config.
  108162. */
  108163. serialize(): any;
  108164. /**
  108165. * Parses a anisotropy Configuration from a serialized object.
  108166. * @param source - Serialized object.
  108167. * @param scene Defines the scene we are parsing for
  108168. * @param rootUrl Defines the rootUrl to load from
  108169. */
  108170. parse(source: any, scene: Scene, rootUrl: string): void;
  108171. }
  108172. }
  108173. declare module BABYLON {
  108174. /**
  108175. * @hidden
  108176. */
  108177. export interface IMaterialSubSurfaceDefines {
  108178. SUBSURFACE: boolean;
  108179. SS_REFRACTION: boolean;
  108180. SS_TRANSLUCENCY: boolean;
  108181. SS_SCATERRING: boolean;
  108182. SS_THICKNESSANDMASK_TEXTURE: boolean;
  108183. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  108184. SS_REFRACTIONMAP_3D: boolean;
  108185. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  108186. SS_LODINREFRACTIONALPHA: boolean;
  108187. SS_GAMMAREFRACTION: boolean;
  108188. SS_RGBDREFRACTION: boolean;
  108189. SS_LINEARSPECULARREFRACTION: boolean;
  108190. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  108191. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  108192. /** @hidden */
  108193. _areTexturesDirty: boolean;
  108194. }
  108195. /**
  108196. * Define the code related to the sub surface parameters of the pbr material.
  108197. */
  108198. export class PBRSubSurfaceConfiguration {
  108199. private _isRefractionEnabled;
  108200. /**
  108201. * Defines if the refraction is enabled in the material.
  108202. */
  108203. isRefractionEnabled: boolean;
  108204. private _isTranslucencyEnabled;
  108205. /**
  108206. * Defines if the translucency is enabled in the material.
  108207. */
  108208. isTranslucencyEnabled: boolean;
  108209. private _isScatteringEnabled;
  108210. /**
  108211. * Defines the refraction intensity of the material.
  108212. * The refraction when enabled replaces the Diffuse part of the material.
  108213. * The intensity helps transitionning between diffuse and refraction.
  108214. */
  108215. refractionIntensity: number;
  108216. /**
  108217. * Defines the translucency intensity of the material.
  108218. * When translucency has been enabled, this defines how much of the "translucency"
  108219. * is addded to the diffuse part of the material.
  108220. */
  108221. translucencyIntensity: number;
  108222. /**
  108223. * Defines the scattering intensity of the material.
  108224. * When scattering has been enabled, this defines how much of the "scattered light"
  108225. * is addded to the diffuse part of the material.
  108226. */
  108227. scatteringIntensity: number;
  108228. private _thicknessTexture;
  108229. /**
  108230. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  108231. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  108232. * 0 would mean minimumThickness
  108233. * 1 would mean maximumThickness
  108234. * The other channels might be use as a mask to vary the different effects intensity.
  108235. */
  108236. thicknessTexture: Nullable<BaseTexture>;
  108237. private _refractionTexture;
  108238. /**
  108239. * Defines the texture to use for refraction.
  108240. */
  108241. refractionTexture: Nullable<BaseTexture>;
  108242. private _indexOfRefraction;
  108243. /**
  108244. * Defines the index of refraction used in the material.
  108245. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  108246. */
  108247. indexOfRefraction: number;
  108248. private _invertRefractionY;
  108249. /**
  108250. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  108251. */
  108252. invertRefractionY: boolean;
  108253. private _linkRefractionWithTransparency;
  108254. /**
  108255. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  108256. * Materials half opaque for instance using refraction could benefit from this control.
  108257. */
  108258. linkRefractionWithTransparency: boolean;
  108259. /**
  108260. * Defines the minimum thickness stored in the thickness map.
  108261. * If no thickness map is defined, this value will be used to simulate thickness.
  108262. */
  108263. minimumThickness: number;
  108264. /**
  108265. * Defines the maximum thickness stored in the thickness map.
  108266. */
  108267. maximumThickness: number;
  108268. /**
  108269. * Defines the volume tint of the material.
  108270. * This is used for both translucency and scattering.
  108271. */
  108272. tintColor: Color3;
  108273. /**
  108274. * Defines the distance at which the tint color should be found in the media.
  108275. * This is used for refraction only.
  108276. */
  108277. tintColorAtDistance: number;
  108278. /**
  108279. * Defines how far each channel transmit through the media.
  108280. * It is defined as a color to simplify it selection.
  108281. */
  108282. diffusionDistance: Color3;
  108283. private _useMaskFromThicknessTexture;
  108284. /**
  108285. * Stores the intensity of the different subsurface effects in the thickness texture.
  108286. * * the green channel is the translucency intensity.
  108287. * * the blue channel is the scattering intensity.
  108288. * * the alpha channel is the refraction intensity.
  108289. */
  108290. useMaskFromThicknessTexture: boolean;
  108291. /** @hidden */
  108292. private _internalMarkAllSubMeshesAsTexturesDirty;
  108293. /** @hidden */
  108294. _markAllSubMeshesAsTexturesDirty(): void;
  108295. /**
  108296. * Instantiate a new istance of sub surface configuration.
  108297. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108298. */
  108299. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108300. /**
  108301. * Gets wehter the submesh is ready to be used or not.
  108302. * @param defines the list of "defines" to update.
  108303. * @param scene defines the scene the material belongs to.
  108304. * @returns - boolean indicating that the submesh is ready or not.
  108305. */
  108306. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  108307. /**
  108308. * Checks to see if a texture is used in the material.
  108309. * @param defines the list of "defines" to update.
  108310. * @param scene defines the scene to the material belongs to.
  108311. */
  108312. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  108313. /**
  108314. * Binds the material data.
  108315. * @param uniformBuffer defines the Uniform buffer to fill in.
  108316. * @param scene defines the scene the material belongs to.
  108317. * @param engine defines the engine the material belongs to.
  108318. * @param isFrozen defines wether the material is frozen or not.
  108319. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  108320. */
  108321. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  108322. /**
  108323. * Unbinds the material from the mesh.
  108324. * @param activeEffect defines the effect that should be unbound from.
  108325. * @returns true if unbound, otherwise false
  108326. */
  108327. unbind(activeEffect: Effect): boolean;
  108328. /**
  108329. * Returns the texture used for refraction or null if none is used.
  108330. * @param scene defines the scene the material belongs to.
  108331. * @returns - Refraction texture if present. If no refraction texture and refraction
  108332. * is linked with transparency, returns environment texture. Otherwise, returns null.
  108333. */
  108334. private _getRefractionTexture;
  108335. /**
  108336. * Returns true if alpha blending should be disabled.
  108337. */
  108338. readonly disableAlphaBlending: boolean;
  108339. /**
  108340. * Fills the list of render target textures.
  108341. * @param renderTargets the list of render targets to update
  108342. */
  108343. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  108344. /**
  108345. * Checks to see if a texture is used in the material.
  108346. * @param texture - Base texture to use.
  108347. * @returns - Boolean specifying if a texture is used in the material.
  108348. */
  108349. hasTexture(texture: BaseTexture): boolean;
  108350. /**
  108351. * Gets a boolean indicating that current material needs to register RTT
  108352. * @returns true if this uses a render target otherwise false.
  108353. */
  108354. hasRenderTargetTextures(): boolean;
  108355. /**
  108356. * Returns an array of the actively used textures.
  108357. * @param activeTextures Array of BaseTextures
  108358. */
  108359. getActiveTextures(activeTextures: BaseTexture[]): void;
  108360. /**
  108361. * Returns the animatable textures.
  108362. * @param animatables Array of animatable textures.
  108363. */
  108364. getAnimatables(animatables: IAnimatable[]): void;
  108365. /**
  108366. * Disposes the resources of the material.
  108367. * @param forceDisposeTextures - Forces the disposal of all textures.
  108368. */
  108369. dispose(forceDisposeTextures?: boolean): void;
  108370. /**
  108371. * Get the current class name of the texture useful for serialization or dynamic coding.
  108372. * @returns "PBRSubSurfaceConfiguration"
  108373. */
  108374. getClassName(): string;
  108375. /**
  108376. * Add fallbacks to the effect fallbacks list.
  108377. * @param defines defines the Base texture to use.
  108378. * @param fallbacks defines the current fallback list.
  108379. * @param currentRank defines the current fallback rank.
  108380. * @returns the new fallback rank.
  108381. */
  108382. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  108383. /**
  108384. * Add the required uniforms to the current list.
  108385. * @param uniforms defines the current uniform list.
  108386. */
  108387. static AddUniforms(uniforms: string[]): void;
  108388. /**
  108389. * Add the required samplers to the current list.
  108390. * @param samplers defines the current sampler list.
  108391. */
  108392. static AddSamplers(samplers: string[]): void;
  108393. /**
  108394. * Add the required uniforms to the current buffer.
  108395. * @param uniformBuffer defines the current uniform buffer.
  108396. */
  108397. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108398. /**
  108399. * Makes a duplicate of the current configuration into another one.
  108400. * @param configuration define the config where to copy the info
  108401. */
  108402. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  108403. /**
  108404. * Serializes this Sub Surface configuration.
  108405. * @returns - An object with the serialized config.
  108406. */
  108407. serialize(): any;
  108408. /**
  108409. * Parses a anisotropy Configuration from a serialized object.
  108410. * @param source - Serialized object.
  108411. * @param scene Defines the scene we are parsing for
  108412. * @param rootUrl Defines the rootUrl to load from
  108413. */
  108414. parse(source: any, scene: Scene, rootUrl: string): void;
  108415. }
  108416. }
  108417. declare module BABYLON {
  108418. /** @hidden */
  108419. export var pbrFragmentDeclaration: {
  108420. name: string;
  108421. shader: string;
  108422. };
  108423. }
  108424. declare module BABYLON {
  108425. /** @hidden */
  108426. export var pbrUboDeclaration: {
  108427. name: string;
  108428. shader: string;
  108429. };
  108430. }
  108431. declare module BABYLON {
  108432. /** @hidden */
  108433. export var pbrFragmentExtraDeclaration: {
  108434. name: string;
  108435. shader: string;
  108436. };
  108437. }
  108438. declare module BABYLON {
  108439. /** @hidden */
  108440. export var pbrFragmentSamplersDeclaration: {
  108441. name: string;
  108442. shader: string;
  108443. };
  108444. }
  108445. declare module BABYLON {
  108446. /** @hidden */
  108447. export var pbrHelperFunctions: {
  108448. name: string;
  108449. shader: string;
  108450. };
  108451. }
  108452. declare module BABYLON {
  108453. /** @hidden */
  108454. export var harmonicsFunctions: {
  108455. name: string;
  108456. shader: string;
  108457. };
  108458. }
  108459. declare module BABYLON {
  108460. /** @hidden */
  108461. export var pbrDirectLightingSetupFunctions: {
  108462. name: string;
  108463. shader: string;
  108464. };
  108465. }
  108466. declare module BABYLON {
  108467. /** @hidden */
  108468. export var pbrDirectLightingFalloffFunctions: {
  108469. name: string;
  108470. shader: string;
  108471. };
  108472. }
  108473. declare module BABYLON {
  108474. /** @hidden */
  108475. export var pbrBRDFFunctions: {
  108476. name: string;
  108477. shader: string;
  108478. };
  108479. }
  108480. declare module BABYLON {
  108481. /** @hidden */
  108482. export var pbrDirectLightingFunctions: {
  108483. name: string;
  108484. shader: string;
  108485. };
  108486. }
  108487. declare module BABYLON {
  108488. /** @hidden */
  108489. export var pbrIBLFunctions: {
  108490. name: string;
  108491. shader: string;
  108492. };
  108493. }
  108494. declare module BABYLON {
  108495. /** @hidden */
  108496. export var pbrDebug: {
  108497. name: string;
  108498. shader: string;
  108499. };
  108500. }
  108501. declare module BABYLON {
  108502. /** @hidden */
  108503. export var pbrPixelShader: {
  108504. name: string;
  108505. shader: string;
  108506. };
  108507. }
  108508. declare module BABYLON {
  108509. /** @hidden */
  108510. export var pbrVertexDeclaration: {
  108511. name: string;
  108512. shader: string;
  108513. };
  108514. }
  108515. declare module BABYLON {
  108516. /** @hidden */
  108517. export var pbrVertexShader: {
  108518. name: string;
  108519. shader: string;
  108520. };
  108521. }
  108522. declare module BABYLON {
  108523. /**
  108524. * Manages the defines for the PBR Material.
  108525. * @hidden
  108526. */
  108527. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  108528. PBR: boolean;
  108529. MAINUV1: boolean;
  108530. MAINUV2: boolean;
  108531. UV1: boolean;
  108532. UV2: boolean;
  108533. ALBEDO: boolean;
  108534. ALBEDODIRECTUV: number;
  108535. VERTEXCOLOR: boolean;
  108536. AMBIENT: boolean;
  108537. AMBIENTDIRECTUV: number;
  108538. AMBIENTINGRAYSCALE: boolean;
  108539. OPACITY: boolean;
  108540. VERTEXALPHA: boolean;
  108541. OPACITYDIRECTUV: number;
  108542. OPACITYRGB: boolean;
  108543. ALPHATEST: boolean;
  108544. DEPTHPREPASS: boolean;
  108545. ALPHABLEND: boolean;
  108546. ALPHAFROMALBEDO: boolean;
  108547. ALPHATESTVALUE: string;
  108548. SPECULAROVERALPHA: boolean;
  108549. RADIANCEOVERALPHA: boolean;
  108550. ALPHAFRESNEL: boolean;
  108551. LINEARALPHAFRESNEL: boolean;
  108552. PREMULTIPLYALPHA: boolean;
  108553. EMISSIVE: boolean;
  108554. EMISSIVEDIRECTUV: number;
  108555. REFLECTIVITY: boolean;
  108556. REFLECTIVITYDIRECTUV: number;
  108557. SPECULARTERM: boolean;
  108558. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  108559. MICROSURFACEAUTOMATIC: boolean;
  108560. LODBASEDMICROSFURACE: boolean;
  108561. MICROSURFACEMAP: boolean;
  108562. MICROSURFACEMAPDIRECTUV: number;
  108563. METALLICWORKFLOW: boolean;
  108564. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  108565. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  108566. METALLNESSSTOREINMETALMAPBLUE: boolean;
  108567. AOSTOREINMETALMAPRED: boolean;
  108568. ENVIRONMENTBRDF: boolean;
  108569. ENVIRONMENTBRDF_RGBD: boolean;
  108570. NORMAL: boolean;
  108571. TANGENT: boolean;
  108572. BUMP: boolean;
  108573. BUMPDIRECTUV: number;
  108574. OBJECTSPACE_NORMALMAP: boolean;
  108575. PARALLAX: boolean;
  108576. PARALLAXOCCLUSION: boolean;
  108577. NORMALXYSCALE: boolean;
  108578. LIGHTMAP: boolean;
  108579. LIGHTMAPDIRECTUV: number;
  108580. USELIGHTMAPASSHADOWMAP: boolean;
  108581. GAMMALIGHTMAP: boolean;
  108582. REFLECTION: boolean;
  108583. REFLECTIONMAP_3D: boolean;
  108584. REFLECTIONMAP_SPHERICAL: boolean;
  108585. REFLECTIONMAP_PLANAR: boolean;
  108586. REFLECTIONMAP_CUBIC: boolean;
  108587. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108588. REFLECTIONMAP_PROJECTION: boolean;
  108589. REFLECTIONMAP_SKYBOX: boolean;
  108590. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  108591. REFLECTIONMAP_EXPLICIT: boolean;
  108592. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108593. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108594. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108595. INVERTCUBICMAP: boolean;
  108596. USESPHERICALFROMREFLECTIONMAP: boolean;
  108597. USEIRRADIANCEMAP: boolean;
  108598. SPHERICAL_HARMONICS: boolean;
  108599. USESPHERICALINVERTEX: boolean;
  108600. REFLECTIONMAP_OPPOSITEZ: boolean;
  108601. LODINREFLECTIONALPHA: boolean;
  108602. GAMMAREFLECTION: boolean;
  108603. RGBDREFLECTION: boolean;
  108604. LINEARSPECULARREFLECTION: boolean;
  108605. RADIANCEOCCLUSION: boolean;
  108606. HORIZONOCCLUSION: boolean;
  108607. INSTANCES: boolean;
  108608. NUM_BONE_INFLUENCERS: number;
  108609. BonesPerMesh: number;
  108610. BONETEXTURE: boolean;
  108611. NONUNIFORMSCALING: boolean;
  108612. MORPHTARGETS: boolean;
  108613. MORPHTARGETS_NORMAL: boolean;
  108614. MORPHTARGETS_TANGENT: boolean;
  108615. MORPHTARGETS_UV: boolean;
  108616. NUM_MORPH_INFLUENCERS: number;
  108617. IMAGEPROCESSING: boolean;
  108618. VIGNETTE: boolean;
  108619. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108620. VIGNETTEBLENDMODEOPAQUE: boolean;
  108621. TONEMAPPING: boolean;
  108622. TONEMAPPING_ACES: boolean;
  108623. CONTRAST: boolean;
  108624. COLORCURVES: boolean;
  108625. COLORGRADING: boolean;
  108626. COLORGRADING3D: boolean;
  108627. SAMPLER3DGREENDEPTH: boolean;
  108628. SAMPLER3DBGRMAP: boolean;
  108629. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108630. EXPOSURE: boolean;
  108631. MULTIVIEW: boolean;
  108632. USEPHYSICALLIGHTFALLOFF: boolean;
  108633. USEGLTFLIGHTFALLOFF: boolean;
  108634. TWOSIDEDLIGHTING: boolean;
  108635. SHADOWFLOAT: boolean;
  108636. CLIPPLANE: boolean;
  108637. CLIPPLANE2: boolean;
  108638. CLIPPLANE3: boolean;
  108639. CLIPPLANE4: boolean;
  108640. POINTSIZE: boolean;
  108641. FOG: boolean;
  108642. LOGARITHMICDEPTH: boolean;
  108643. FORCENORMALFORWARD: boolean;
  108644. SPECULARAA: boolean;
  108645. CLEARCOAT: boolean;
  108646. CLEARCOAT_DEFAULTIOR: boolean;
  108647. CLEARCOAT_TEXTURE: boolean;
  108648. CLEARCOAT_TEXTUREDIRECTUV: number;
  108649. CLEARCOAT_BUMP: boolean;
  108650. CLEARCOAT_BUMPDIRECTUV: number;
  108651. CLEARCOAT_TINT: boolean;
  108652. CLEARCOAT_TINT_TEXTURE: boolean;
  108653. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  108654. ANISOTROPIC: boolean;
  108655. ANISOTROPIC_TEXTURE: boolean;
  108656. ANISOTROPIC_TEXTUREDIRECTUV: number;
  108657. BRDF_V_HEIGHT_CORRELATED: boolean;
  108658. MS_BRDF_ENERGY_CONSERVATION: boolean;
  108659. SHEEN: boolean;
  108660. SHEEN_TEXTURE: boolean;
  108661. SHEEN_TEXTUREDIRECTUV: number;
  108662. SHEEN_LINKWITHALBEDO: boolean;
  108663. SUBSURFACE: boolean;
  108664. SS_REFRACTION: boolean;
  108665. SS_TRANSLUCENCY: boolean;
  108666. SS_SCATERRING: boolean;
  108667. SS_THICKNESSANDMASK_TEXTURE: boolean;
  108668. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  108669. SS_REFRACTIONMAP_3D: boolean;
  108670. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  108671. SS_LODINREFRACTIONALPHA: boolean;
  108672. SS_GAMMAREFRACTION: boolean;
  108673. SS_RGBDREFRACTION: boolean;
  108674. SS_LINEARSPECULARREFRACTION: boolean;
  108675. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  108676. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  108677. UNLIT: boolean;
  108678. DEBUGMODE: number;
  108679. /**
  108680. * Initializes the PBR Material defines.
  108681. */
  108682. constructor();
  108683. /**
  108684. * Resets the PBR Material defines.
  108685. */
  108686. reset(): void;
  108687. }
  108688. /**
  108689. * The Physically based material base class of BJS.
  108690. *
  108691. * This offers the main features of a standard PBR material.
  108692. * For more information, please refer to the documentation :
  108693. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108694. */
  108695. export abstract class PBRBaseMaterial extends PushMaterial {
  108696. /**
  108697. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108698. */
  108699. static readonly PBRMATERIAL_OPAQUE: number;
  108700. /**
  108701. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108702. */
  108703. static readonly PBRMATERIAL_ALPHATEST: number;
  108704. /**
  108705. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108706. */
  108707. static readonly PBRMATERIAL_ALPHABLEND: number;
  108708. /**
  108709. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108710. * They are also discarded below the alpha cutoff threshold to improve performances.
  108711. */
  108712. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108713. /**
  108714. * Defines the default value of how much AO map is occluding the analytical lights
  108715. * (point spot...).
  108716. */
  108717. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108718. /**
  108719. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  108720. */
  108721. static readonly LIGHTFALLOFF_PHYSICAL: number;
  108722. /**
  108723. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  108724. * to enhance interoperability with other engines.
  108725. */
  108726. static readonly LIGHTFALLOFF_GLTF: number;
  108727. /**
  108728. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  108729. * to enhance interoperability with other materials.
  108730. */
  108731. static readonly LIGHTFALLOFF_STANDARD: number;
  108732. /**
  108733. * Intensity of the direct lights e.g. the four lights available in your scene.
  108734. * This impacts both the direct diffuse and specular highlights.
  108735. */
  108736. protected _directIntensity: number;
  108737. /**
  108738. * Intensity of the emissive part of the material.
  108739. * This helps controlling the emissive effect without modifying the emissive color.
  108740. */
  108741. protected _emissiveIntensity: number;
  108742. /**
  108743. * Intensity of the environment e.g. how much the environment will light the object
  108744. * either through harmonics for rough material or through the refelction for shiny ones.
  108745. */
  108746. protected _environmentIntensity: number;
  108747. /**
  108748. * This is a special control allowing the reduction of the specular highlights coming from the
  108749. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108750. */
  108751. protected _specularIntensity: number;
  108752. /**
  108753. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  108754. */
  108755. private _lightingInfos;
  108756. /**
  108757. * Debug Control allowing disabling the bump map on this material.
  108758. */
  108759. protected _disableBumpMap: boolean;
  108760. /**
  108761. * AKA Diffuse Texture in standard nomenclature.
  108762. */
  108763. protected _albedoTexture: Nullable<BaseTexture>;
  108764. /**
  108765. * AKA Occlusion Texture in other nomenclature.
  108766. */
  108767. protected _ambientTexture: Nullable<BaseTexture>;
  108768. /**
  108769. * AKA Occlusion Texture Intensity in other nomenclature.
  108770. */
  108771. protected _ambientTextureStrength: number;
  108772. /**
  108773. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108774. * 1 means it completely occludes it
  108775. * 0 mean it has no impact
  108776. */
  108777. protected _ambientTextureImpactOnAnalyticalLights: number;
  108778. /**
  108779. * Stores the alpha values in a texture.
  108780. */
  108781. protected _opacityTexture: Nullable<BaseTexture>;
  108782. /**
  108783. * Stores the reflection values in a texture.
  108784. */
  108785. protected _reflectionTexture: Nullable<BaseTexture>;
  108786. /**
  108787. * Stores the emissive values in a texture.
  108788. */
  108789. protected _emissiveTexture: Nullable<BaseTexture>;
  108790. /**
  108791. * AKA Specular texture in other nomenclature.
  108792. */
  108793. protected _reflectivityTexture: Nullable<BaseTexture>;
  108794. /**
  108795. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108796. */
  108797. protected _metallicTexture: Nullable<BaseTexture>;
  108798. /**
  108799. * Specifies the metallic scalar of the metallic/roughness workflow.
  108800. * Can also be used to scale the metalness values of the metallic texture.
  108801. */
  108802. protected _metallic: Nullable<number>;
  108803. /**
  108804. * Specifies the roughness scalar of the metallic/roughness workflow.
  108805. * Can also be used to scale the roughness values of the metallic texture.
  108806. */
  108807. protected _roughness: Nullable<number>;
  108808. /**
  108809. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108810. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108811. */
  108812. protected _microSurfaceTexture: Nullable<BaseTexture>;
  108813. /**
  108814. * Stores surface normal data used to displace a mesh in a texture.
  108815. */
  108816. protected _bumpTexture: Nullable<BaseTexture>;
  108817. /**
  108818. * Stores the pre-calculated light information of a mesh in a texture.
  108819. */
  108820. protected _lightmapTexture: Nullable<BaseTexture>;
  108821. /**
  108822. * The color of a material in ambient lighting.
  108823. */
  108824. protected _ambientColor: Color3;
  108825. /**
  108826. * AKA Diffuse Color in other nomenclature.
  108827. */
  108828. protected _albedoColor: Color3;
  108829. /**
  108830. * AKA Specular Color in other nomenclature.
  108831. */
  108832. protected _reflectivityColor: Color3;
  108833. /**
  108834. * The color applied when light is reflected from a material.
  108835. */
  108836. protected _reflectionColor: Color3;
  108837. /**
  108838. * The color applied when light is emitted from a material.
  108839. */
  108840. protected _emissiveColor: Color3;
  108841. /**
  108842. * AKA Glossiness in other nomenclature.
  108843. */
  108844. protected _microSurface: number;
  108845. /**
  108846. * Specifies that the material will use the light map as a show map.
  108847. */
  108848. protected _useLightmapAsShadowmap: boolean;
  108849. /**
  108850. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108851. * makes the reflect vector face the model (under horizon).
  108852. */
  108853. protected _useHorizonOcclusion: boolean;
  108854. /**
  108855. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108856. * too much the area relying on ambient texture to define their ambient occlusion.
  108857. */
  108858. protected _useRadianceOcclusion: boolean;
  108859. /**
  108860. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108861. */
  108862. protected _useAlphaFromAlbedoTexture: boolean;
  108863. /**
  108864. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  108865. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108866. */
  108867. protected _useSpecularOverAlpha: boolean;
  108868. /**
  108869. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108870. */
  108871. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108872. /**
  108873. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108874. */
  108875. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  108876. /**
  108877. * Specifies if the metallic texture contains the roughness information in its green channel.
  108878. */
  108879. protected _useRoughnessFromMetallicTextureGreen: boolean;
  108880. /**
  108881. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108882. */
  108883. protected _useMetallnessFromMetallicTextureBlue: boolean;
  108884. /**
  108885. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108886. */
  108887. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  108888. /**
  108889. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108890. */
  108891. protected _useAmbientInGrayScale: boolean;
  108892. /**
  108893. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108894. * The material will try to infer what glossiness each pixel should be.
  108895. */
  108896. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  108897. /**
  108898. * Defines the falloff type used in this material.
  108899. * It by default is Physical.
  108900. */
  108901. protected _lightFalloff: number;
  108902. /**
  108903. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108904. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108905. */
  108906. protected _useRadianceOverAlpha: boolean;
  108907. /**
  108908. * Allows using an object space normal map (instead of tangent space).
  108909. */
  108910. protected _useObjectSpaceNormalMap: boolean;
  108911. /**
  108912. * Allows using the bump map in parallax mode.
  108913. */
  108914. protected _useParallax: boolean;
  108915. /**
  108916. * Allows using the bump map in parallax occlusion mode.
  108917. */
  108918. protected _useParallaxOcclusion: boolean;
  108919. /**
  108920. * Controls the scale bias of the parallax mode.
  108921. */
  108922. protected _parallaxScaleBias: number;
  108923. /**
  108924. * If sets to true, disables all the lights affecting the material.
  108925. */
  108926. protected _disableLighting: boolean;
  108927. /**
  108928. * Number of Simultaneous lights allowed on the material.
  108929. */
  108930. protected _maxSimultaneousLights: number;
  108931. /**
  108932. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  108933. */
  108934. protected _invertNormalMapX: boolean;
  108935. /**
  108936. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  108937. */
  108938. protected _invertNormalMapY: boolean;
  108939. /**
  108940. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108941. */
  108942. protected _twoSidedLighting: boolean;
  108943. /**
  108944. * Defines the alpha limits in alpha test mode.
  108945. */
  108946. protected _alphaCutOff: number;
  108947. /**
  108948. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108949. */
  108950. protected _forceAlphaTest: boolean;
  108951. /**
  108952. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108953. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108954. */
  108955. protected _useAlphaFresnel: boolean;
  108956. /**
  108957. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108958. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108959. */
  108960. protected _useLinearAlphaFresnel: boolean;
  108961. /**
  108962. * The transparency mode of the material.
  108963. */
  108964. protected _transparencyMode: Nullable<number>;
  108965. /**
  108966. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  108967. * from cos thetav and roughness:
  108968. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  108969. */
  108970. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  108971. /**
  108972. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108973. */
  108974. protected _forceIrradianceInFragment: boolean;
  108975. /**
  108976. * Force normal to face away from face.
  108977. */
  108978. protected _forceNormalForward: boolean;
  108979. /**
  108980. * Enables specular anti aliasing in the PBR shader.
  108981. * It will both interacts on the Geometry for analytical and IBL lighting.
  108982. * It also prefilter the roughness map based on the bump values.
  108983. */
  108984. protected _enableSpecularAntiAliasing: boolean;
  108985. /**
  108986. * Default configuration related to image processing available in the PBR Material.
  108987. */
  108988. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108989. /**
  108990. * Keep track of the image processing observer to allow dispose and replace.
  108991. */
  108992. private _imageProcessingObserver;
  108993. /**
  108994. * Attaches a new image processing configuration to the PBR Material.
  108995. * @param configuration
  108996. */
  108997. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108998. /**
  108999. * Stores the available render targets.
  109000. */
  109001. private _renderTargets;
  109002. /**
  109003. * Sets the global ambient color for the material used in lighting calculations.
  109004. */
  109005. private _globalAmbientColor;
  109006. /**
  109007. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  109008. */
  109009. private _useLogarithmicDepth;
  109010. /**
  109011. * If set to true, no lighting calculations will be applied.
  109012. */
  109013. private _unlit;
  109014. private _debugMode;
  109015. /**
  109016. * @hidden
  109017. * This is reserved for the inspector.
  109018. * Defines the material debug mode.
  109019. * It helps seeing only some components of the material while troubleshooting.
  109020. */
  109021. debugMode: number;
  109022. /**
  109023. * @hidden
  109024. * This is reserved for the inspector.
  109025. * Specify from where on screen the debug mode should start.
  109026. * The value goes from -1 (full screen) to 1 (not visible)
  109027. * It helps with side by side comparison against the final render
  109028. * This defaults to -1
  109029. */
  109030. private debugLimit;
  109031. /**
  109032. * @hidden
  109033. * This is reserved for the inspector.
  109034. * As the default viewing range might not be enough (if the ambient is really small for instance)
  109035. * You can use the factor to better multiply the final value.
  109036. */
  109037. private debugFactor;
  109038. /**
  109039. * Defines the clear coat layer parameters for the material.
  109040. */
  109041. readonly clearCoat: PBRClearCoatConfiguration;
  109042. /**
  109043. * Defines the anisotropic parameters for the material.
  109044. */
  109045. readonly anisotropy: PBRAnisotropicConfiguration;
  109046. /**
  109047. * Defines the BRDF parameters for the material.
  109048. */
  109049. readonly brdf: PBRBRDFConfiguration;
  109050. /**
  109051. * Defines the Sheen parameters for the material.
  109052. */
  109053. readonly sheen: PBRSheenConfiguration;
  109054. /**
  109055. * Defines the SubSurface parameters for the material.
  109056. */
  109057. readonly subSurface: PBRSubSurfaceConfiguration;
  109058. /**
  109059. * Custom callback helping to override the default shader used in the material.
  109060. */
  109061. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  109062. /**
  109063. * Instantiates a new PBRMaterial instance.
  109064. *
  109065. * @param name The material name
  109066. * @param scene The scene the material will be use in.
  109067. */
  109068. constructor(name: string, scene: Scene);
  109069. /**
  109070. * Gets a boolean indicating that current material needs to register RTT
  109071. */
  109072. readonly hasRenderTargetTextures: boolean;
  109073. /**
  109074. * Gets the name of the material class.
  109075. */
  109076. getClassName(): string;
  109077. /**
  109078. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  109079. */
  109080. /**
  109081. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  109082. */
  109083. useLogarithmicDepth: boolean;
  109084. /**
  109085. * Gets the current transparency mode.
  109086. */
  109087. /**
  109088. * Sets the transparency mode of the material.
  109089. *
  109090. * | Value | Type | Description |
  109091. * | ----- | ----------------------------------- | ----------- |
  109092. * | 0 | OPAQUE | |
  109093. * | 1 | ALPHATEST | |
  109094. * | 2 | ALPHABLEND | |
  109095. * | 3 | ALPHATESTANDBLEND | |
  109096. *
  109097. */
  109098. transparencyMode: Nullable<number>;
  109099. /**
  109100. * Returns true if alpha blending should be disabled.
  109101. */
  109102. private readonly _disableAlphaBlending;
  109103. /**
  109104. * Specifies whether or not this material should be rendered in alpha blend mode.
  109105. */
  109106. needAlphaBlending(): boolean;
  109107. /**
  109108. * Specifies if the mesh will require alpha blending.
  109109. * @param mesh - BJS mesh.
  109110. */
  109111. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  109112. /**
  109113. * Specifies whether or not this material should be rendered in alpha test mode.
  109114. */
  109115. needAlphaTesting(): boolean;
  109116. /**
  109117. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  109118. */
  109119. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  109120. /**
  109121. * Gets the texture used for the alpha test.
  109122. */
  109123. getAlphaTestTexture(): Nullable<BaseTexture>;
  109124. /**
  109125. * Specifies that the submesh is ready to be used.
  109126. * @param mesh - BJS mesh.
  109127. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  109128. * @param useInstances - Specifies that instances should be used.
  109129. * @returns - boolean indicating that the submesh is ready or not.
  109130. */
  109131. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109132. /**
  109133. * Specifies if the material uses metallic roughness workflow.
  109134. * @returns boolean specifiying if the material uses metallic roughness workflow.
  109135. */
  109136. isMetallicWorkflow(): boolean;
  109137. private _prepareEffect;
  109138. private _prepareDefines;
  109139. /**
  109140. * Force shader compilation
  109141. */
  109142. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  109143. clipPlane: boolean;
  109144. }>): void;
  109145. /**
  109146. * Initializes the uniform buffer layout for the shader.
  109147. */
  109148. buildUniformLayout(): void;
  109149. /**
  109150. * Unbinds the material from the mesh
  109151. */
  109152. unbind(): void;
  109153. /**
  109154. * Binds the submesh data.
  109155. * @param world - The world matrix.
  109156. * @param mesh - The BJS mesh.
  109157. * @param subMesh - A submesh of the BJS mesh.
  109158. */
  109159. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109160. /**
  109161. * Returns the animatable textures.
  109162. * @returns - Array of animatable textures.
  109163. */
  109164. getAnimatables(): IAnimatable[];
  109165. /**
  109166. * Returns the texture used for reflections.
  109167. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  109168. */
  109169. private _getReflectionTexture;
  109170. /**
  109171. * Returns an array of the actively used textures.
  109172. * @returns - Array of BaseTextures
  109173. */
  109174. getActiveTextures(): BaseTexture[];
  109175. /**
  109176. * Checks to see if a texture is used in the material.
  109177. * @param texture - Base texture to use.
  109178. * @returns - Boolean specifying if a texture is used in the material.
  109179. */
  109180. hasTexture(texture: BaseTexture): boolean;
  109181. /**
  109182. * Disposes the resources of the material.
  109183. * @param forceDisposeEffect - Forces the disposal of effects.
  109184. * @param forceDisposeTextures - Forces the disposal of all textures.
  109185. */
  109186. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109187. }
  109188. }
  109189. declare module BABYLON {
  109190. /**
  109191. * The Physically based material of BJS.
  109192. *
  109193. * This offers the main features of a standard PBR material.
  109194. * For more information, please refer to the documentation :
  109195. * https://doc.babylonjs.com/how_to/physically_based_rendering
  109196. */
  109197. export class PBRMaterial extends PBRBaseMaterial {
  109198. /**
  109199. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  109200. */
  109201. static readonly PBRMATERIAL_OPAQUE: number;
  109202. /**
  109203. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  109204. */
  109205. static readonly PBRMATERIAL_ALPHATEST: number;
  109206. /**
  109207. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109208. */
  109209. static readonly PBRMATERIAL_ALPHABLEND: number;
  109210. /**
  109211. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109212. * They are also discarded below the alpha cutoff threshold to improve performances.
  109213. */
  109214. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  109215. /**
  109216. * Defines the default value of how much AO map is occluding the analytical lights
  109217. * (point spot...).
  109218. */
  109219. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  109220. /**
  109221. * Intensity of the direct lights e.g. the four lights available in your scene.
  109222. * This impacts both the direct diffuse and specular highlights.
  109223. */
  109224. directIntensity: number;
  109225. /**
  109226. * Intensity of the emissive part of the material.
  109227. * This helps controlling the emissive effect without modifying the emissive color.
  109228. */
  109229. emissiveIntensity: number;
  109230. /**
  109231. * Intensity of the environment e.g. how much the environment will light the object
  109232. * either through harmonics for rough material or through the refelction for shiny ones.
  109233. */
  109234. environmentIntensity: number;
  109235. /**
  109236. * This is a special control allowing the reduction of the specular highlights coming from the
  109237. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  109238. */
  109239. specularIntensity: number;
  109240. /**
  109241. * Debug Control allowing disabling the bump map on this material.
  109242. */
  109243. disableBumpMap: boolean;
  109244. /**
  109245. * AKA Diffuse Texture in standard nomenclature.
  109246. */
  109247. albedoTexture: BaseTexture;
  109248. /**
  109249. * AKA Occlusion Texture in other nomenclature.
  109250. */
  109251. ambientTexture: BaseTexture;
  109252. /**
  109253. * AKA Occlusion Texture Intensity in other nomenclature.
  109254. */
  109255. ambientTextureStrength: number;
  109256. /**
  109257. * Defines how much the AO map is occluding the analytical lights (point spot...).
  109258. * 1 means it completely occludes it
  109259. * 0 mean it has no impact
  109260. */
  109261. ambientTextureImpactOnAnalyticalLights: number;
  109262. /**
  109263. * Stores the alpha values in a texture.
  109264. */
  109265. opacityTexture: BaseTexture;
  109266. /**
  109267. * Stores the reflection values in a texture.
  109268. */
  109269. reflectionTexture: Nullable<BaseTexture>;
  109270. /**
  109271. * Stores the emissive values in a texture.
  109272. */
  109273. emissiveTexture: BaseTexture;
  109274. /**
  109275. * AKA Specular texture in other nomenclature.
  109276. */
  109277. reflectivityTexture: BaseTexture;
  109278. /**
  109279. * Used to switch from specular/glossiness to metallic/roughness workflow.
  109280. */
  109281. metallicTexture: BaseTexture;
  109282. /**
  109283. * Specifies the metallic scalar of the metallic/roughness workflow.
  109284. * Can also be used to scale the metalness values of the metallic texture.
  109285. */
  109286. metallic: Nullable<number>;
  109287. /**
  109288. * Specifies the roughness scalar of the metallic/roughness workflow.
  109289. * Can also be used to scale the roughness values of the metallic texture.
  109290. */
  109291. roughness: Nullable<number>;
  109292. /**
  109293. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  109294. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  109295. */
  109296. microSurfaceTexture: BaseTexture;
  109297. /**
  109298. * Stores surface normal data used to displace a mesh in a texture.
  109299. */
  109300. bumpTexture: BaseTexture;
  109301. /**
  109302. * Stores the pre-calculated light information of a mesh in a texture.
  109303. */
  109304. lightmapTexture: BaseTexture;
  109305. /**
  109306. * Stores the refracted light information in a texture.
  109307. */
  109308. refractionTexture: Nullable<BaseTexture>;
  109309. /**
  109310. * The color of a material in ambient lighting.
  109311. */
  109312. ambientColor: Color3;
  109313. /**
  109314. * AKA Diffuse Color in other nomenclature.
  109315. */
  109316. albedoColor: Color3;
  109317. /**
  109318. * AKA Specular Color in other nomenclature.
  109319. */
  109320. reflectivityColor: Color3;
  109321. /**
  109322. * The color reflected from the material.
  109323. */
  109324. reflectionColor: Color3;
  109325. /**
  109326. * The color emitted from the material.
  109327. */
  109328. emissiveColor: Color3;
  109329. /**
  109330. * AKA Glossiness in other nomenclature.
  109331. */
  109332. microSurface: number;
  109333. /**
  109334. * source material index of refraction (IOR)' / 'destination material IOR.
  109335. */
  109336. indexOfRefraction: number;
  109337. /**
  109338. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  109339. */
  109340. invertRefractionY: boolean;
  109341. /**
  109342. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  109343. * Materials half opaque for instance using refraction could benefit from this control.
  109344. */
  109345. linkRefractionWithTransparency: boolean;
  109346. /**
  109347. * If true, the light map contains occlusion information instead of lighting info.
  109348. */
  109349. useLightmapAsShadowmap: boolean;
  109350. /**
  109351. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  109352. */
  109353. useAlphaFromAlbedoTexture: boolean;
  109354. /**
  109355. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  109356. */
  109357. forceAlphaTest: boolean;
  109358. /**
  109359. * Defines the alpha limits in alpha test mode.
  109360. */
  109361. alphaCutOff: number;
  109362. /**
  109363. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109364. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109365. */
  109366. useSpecularOverAlpha: boolean;
  109367. /**
  109368. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  109369. */
  109370. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  109371. /**
  109372. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  109373. */
  109374. useRoughnessFromMetallicTextureAlpha: boolean;
  109375. /**
  109376. * Specifies if the metallic texture contains the roughness information in its green channel.
  109377. */
  109378. useRoughnessFromMetallicTextureGreen: boolean;
  109379. /**
  109380. * Specifies if the metallic texture contains the metallness information in its blue channel.
  109381. */
  109382. useMetallnessFromMetallicTextureBlue: boolean;
  109383. /**
  109384. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  109385. */
  109386. useAmbientOcclusionFromMetallicTextureRed: boolean;
  109387. /**
  109388. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  109389. */
  109390. useAmbientInGrayScale: boolean;
  109391. /**
  109392. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  109393. * The material will try to infer what glossiness each pixel should be.
  109394. */
  109395. useAutoMicroSurfaceFromReflectivityMap: boolean;
  109396. /**
  109397. * BJS is using an harcoded light falloff based on a manually sets up range.
  109398. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  109399. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  109400. */
  109401. /**
  109402. * BJS is using an harcoded light falloff based on a manually sets up range.
  109403. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  109404. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  109405. */
  109406. usePhysicalLightFalloff: boolean;
  109407. /**
  109408. * In order to support the falloff compatibility with gltf, a special mode has been added
  109409. * to reproduce the gltf light falloff.
  109410. */
  109411. /**
  109412. * In order to support the falloff compatibility with gltf, a special mode has been added
  109413. * to reproduce the gltf light falloff.
  109414. */
  109415. useGLTFLightFalloff: boolean;
  109416. /**
  109417. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109418. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109419. */
  109420. useRadianceOverAlpha: boolean;
  109421. /**
  109422. * Allows using an object space normal map (instead of tangent space).
  109423. */
  109424. useObjectSpaceNormalMap: boolean;
  109425. /**
  109426. * Allows using the bump map in parallax mode.
  109427. */
  109428. useParallax: boolean;
  109429. /**
  109430. * Allows using the bump map in parallax occlusion mode.
  109431. */
  109432. useParallaxOcclusion: boolean;
  109433. /**
  109434. * Controls the scale bias of the parallax mode.
  109435. */
  109436. parallaxScaleBias: number;
  109437. /**
  109438. * If sets to true, disables all the lights affecting the material.
  109439. */
  109440. disableLighting: boolean;
  109441. /**
  109442. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  109443. */
  109444. forceIrradianceInFragment: boolean;
  109445. /**
  109446. * Number of Simultaneous lights allowed on the material.
  109447. */
  109448. maxSimultaneousLights: number;
  109449. /**
  109450. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109451. */
  109452. invertNormalMapX: boolean;
  109453. /**
  109454. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109455. */
  109456. invertNormalMapY: boolean;
  109457. /**
  109458. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109459. */
  109460. twoSidedLighting: boolean;
  109461. /**
  109462. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109463. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  109464. */
  109465. useAlphaFresnel: boolean;
  109466. /**
  109467. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109468. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  109469. */
  109470. useLinearAlphaFresnel: boolean;
  109471. /**
  109472. * Let user defines the brdf lookup texture used for IBL.
  109473. * A default 8bit version is embedded but you could point at :
  109474. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  109475. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  109476. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  109477. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  109478. */
  109479. environmentBRDFTexture: Nullable<BaseTexture>;
  109480. /**
  109481. * Force normal to face away from face.
  109482. */
  109483. forceNormalForward: boolean;
  109484. /**
  109485. * Enables specular anti aliasing in the PBR shader.
  109486. * It will both interacts on the Geometry for analytical and IBL lighting.
  109487. * It also prefilter the roughness map based on the bump values.
  109488. */
  109489. enableSpecularAntiAliasing: boolean;
  109490. /**
  109491. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  109492. * makes the reflect vector face the model (under horizon).
  109493. */
  109494. useHorizonOcclusion: boolean;
  109495. /**
  109496. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  109497. * too much the area relying on ambient texture to define their ambient occlusion.
  109498. */
  109499. useRadianceOcclusion: boolean;
  109500. /**
  109501. * If set to true, no lighting calculations will be applied.
  109502. */
  109503. unlit: boolean;
  109504. /**
  109505. * Gets the image processing configuration used either in this material.
  109506. */
  109507. /**
  109508. * Sets the Default image processing configuration used either in the this material.
  109509. *
  109510. * If sets to null, the scene one is in use.
  109511. */
  109512. imageProcessingConfiguration: ImageProcessingConfiguration;
  109513. /**
  109514. * Gets wether the color curves effect is enabled.
  109515. */
  109516. /**
  109517. * Sets wether the color curves effect is enabled.
  109518. */
  109519. cameraColorCurvesEnabled: boolean;
  109520. /**
  109521. * Gets wether the color grading effect is enabled.
  109522. */
  109523. /**
  109524. * Gets wether the color grading effect is enabled.
  109525. */
  109526. cameraColorGradingEnabled: boolean;
  109527. /**
  109528. * Gets wether tonemapping is enabled or not.
  109529. */
  109530. /**
  109531. * Sets wether tonemapping is enabled or not
  109532. */
  109533. cameraToneMappingEnabled: boolean;
  109534. /**
  109535. * The camera exposure used on this material.
  109536. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109537. * This corresponds to a photographic exposure.
  109538. */
  109539. /**
  109540. * The camera exposure used on this material.
  109541. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109542. * This corresponds to a photographic exposure.
  109543. */
  109544. cameraExposure: number;
  109545. /**
  109546. * Gets The camera contrast used on this material.
  109547. */
  109548. /**
  109549. * Sets The camera contrast used on this material.
  109550. */
  109551. cameraContrast: number;
  109552. /**
  109553. * Gets the Color Grading 2D Lookup Texture.
  109554. */
  109555. /**
  109556. * Sets the Color Grading 2D Lookup Texture.
  109557. */
  109558. cameraColorGradingTexture: Nullable<BaseTexture>;
  109559. /**
  109560. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109561. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109562. * 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;
  109563. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109564. */
  109565. /**
  109566. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109567. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109568. * 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;
  109569. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109570. */
  109571. cameraColorCurves: Nullable<ColorCurves>;
  109572. /**
  109573. * Instantiates a new PBRMaterial instance.
  109574. *
  109575. * @param name The material name
  109576. * @param scene The scene the material will be use in.
  109577. */
  109578. constructor(name: string, scene: Scene);
  109579. /**
  109580. * Returns the name of this material class.
  109581. */
  109582. getClassName(): string;
  109583. /**
  109584. * Makes a duplicate of the current material.
  109585. * @param name - name to use for the new material.
  109586. */
  109587. clone(name: string): PBRMaterial;
  109588. /**
  109589. * Serializes this PBR Material.
  109590. * @returns - An object with the serialized material.
  109591. */
  109592. serialize(): any;
  109593. /**
  109594. * Parses a PBR Material from a serialized object.
  109595. * @param source - Serialized object.
  109596. * @param scene - BJS scene instance.
  109597. * @param rootUrl - url for the scene object
  109598. * @returns - PBRMaterial
  109599. */
  109600. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  109601. }
  109602. }
  109603. declare module BABYLON {
  109604. /**
  109605. * Direct draw surface info
  109606. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  109607. */
  109608. export interface DDSInfo {
  109609. /**
  109610. * Width of the texture
  109611. */
  109612. width: number;
  109613. /**
  109614. * Width of the texture
  109615. */
  109616. height: number;
  109617. /**
  109618. * Number of Mipmaps for the texture
  109619. * @see https://en.wikipedia.org/wiki/Mipmap
  109620. */
  109621. mipmapCount: number;
  109622. /**
  109623. * If the textures format is a known fourCC format
  109624. * @see https://www.fourcc.org/
  109625. */
  109626. isFourCC: boolean;
  109627. /**
  109628. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  109629. */
  109630. isRGB: boolean;
  109631. /**
  109632. * If the texture is a lumincance format
  109633. */
  109634. isLuminance: boolean;
  109635. /**
  109636. * If this is a cube texture
  109637. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  109638. */
  109639. isCube: boolean;
  109640. /**
  109641. * If the texture is a compressed format eg. FOURCC_DXT1
  109642. */
  109643. isCompressed: boolean;
  109644. /**
  109645. * The dxgiFormat of the texture
  109646. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  109647. */
  109648. dxgiFormat: number;
  109649. /**
  109650. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  109651. */
  109652. textureType: number;
  109653. /**
  109654. * Sphericle polynomial created for the dds texture
  109655. */
  109656. sphericalPolynomial?: SphericalPolynomial;
  109657. }
  109658. /**
  109659. * Class used to provide DDS decompression tools
  109660. */
  109661. export class DDSTools {
  109662. /**
  109663. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  109664. */
  109665. static StoreLODInAlphaChannel: boolean;
  109666. /**
  109667. * Gets DDS information from an array buffer
  109668. * @param arrayBuffer defines the array buffer to read data from
  109669. * @returns the DDS information
  109670. */
  109671. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  109672. private static _FloatView;
  109673. private static _Int32View;
  109674. private static _ToHalfFloat;
  109675. private static _FromHalfFloat;
  109676. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  109677. private static _GetHalfFloatRGBAArrayBuffer;
  109678. private static _GetFloatRGBAArrayBuffer;
  109679. private static _GetFloatAsUIntRGBAArrayBuffer;
  109680. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  109681. private static _GetRGBAArrayBuffer;
  109682. private static _ExtractLongWordOrder;
  109683. private static _GetRGBArrayBuffer;
  109684. private static _GetLuminanceArrayBuffer;
  109685. /**
  109686. * Uploads DDS Levels to a Babylon Texture
  109687. * @hidden
  109688. */
  109689. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  109690. }
  109691. interface Engine {
  109692. /**
  109693. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  109694. * @param rootUrl defines the url where the file to load is located
  109695. * @param scene defines the current scene
  109696. * @param lodScale defines scale to apply to the mip map selection
  109697. * @param lodOffset defines offset to apply to the mip map selection
  109698. * @param onLoad defines an optional callback raised when the texture is loaded
  109699. * @param onError defines an optional callback raised if there is an issue to load the texture
  109700. * @param format defines the format of the data
  109701. * @param forcedExtension defines the extension to use to pick the right loader
  109702. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  109703. * @returns the cube texture as an InternalTexture
  109704. */
  109705. 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;
  109706. }
  109707. }
  109708. declare module BABYLON {
  109709. /**
  109710. * Implementation of the DDS Texture Loader.
  109711. * @hidden
  109712. */
  109713. export class _DDSTextureLoader implements IInternalTextureLoader {
  109714. /**
  109715. * Defines wether the loader supports cascade loading the different faces.
  109716. */
  109717. readonly supportCascades: boolean;
  109718. /**
  109719. * This returns if the loader support the current file information.
  109720. * @param extension defines the file extension of the file being loaded
  109721. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109722. * @param fallback defines the fallback internal texture if any
  109723. * @param isBase64 defines whether the texture is encoded as a base64
  109724. * @param isBuffer defines whether the texture data are stored as a buffer
  109725. * @returns true if the loader can load the specified file
  109726. */
  109727. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109728. /**
  109729. * Transform the url before loading if required.
  109730. * @param rootUrl the url of the texture
  109731. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109732. * @returns the transformed texture
  109733. */
  109734. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109735. /**
  109736. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109737. * @param rootUrl the url of the texture
  109738. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109739. * @returns the fallback texture
  109740. */
  109741. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109742. /**
  109743. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109744. * @param data contains the texture data
  109745. * @param texture defines the BabylonJS internal texture
  109746. * @param createPolynomials will be true if polynomials have been requested
  109747. * @param onLoad defines the callback to trigger once the texture is ready
  109748. * @param onError defines the callback to trigger in case of error
  109749. */
  109750. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109751. /**
  109752. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109753. * @param data contains the texture data
  109754. * @param texture defines the BabylonJS internal texture
  109755. * @param callback defines the method to call once ready to upload
  109756. */
  109757. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109758. }
  109759. }
  109760. declare module BABYLON {
  109761. /** @hidden */
  109762. export var rgbdEncodePixelShader: {
  109763. name: string;
  109764. shader: string;
  109765. };
  109766. }
  109767. declare module BABYLON {
  109768. /**
  109769. * Raw texture data and descriptor sufficient for WebGL texture upload
  109770. */
  109771. export interface EnvironmentTextureInfo {
  109772. /**
  109773. * Version of the environment map
  109774. */
  109775. version: number;
  109776. /**
  109777. * Width of image
  109778. */
  109779. width: number;
  109780. /**
  109781. * Irradiance information stored in the file.
  109782. */
  109783. irradiance: any;
  109784. /**
  109785. * Specular information stored in the file.
  109786. */
  109787. specular: any;
  109788. }
  109789. /**
  109790. * Sets of helpers addressing the serialization and deserialization of environment texture
  109791. * stored in a BabylonJS env file.
  109792. * Those files are usually stored as .env files.
  109793. */
  109794. export class EnvironmentTextureTools {
  109795. /**
  109796. * Magic number identifying the env file.
  109797. */
  109798. private static _MagicBytes;
  109799. /**
  109800. * Gets the environment info from an env file.
  109801. * @param data The array buffer containing the .env bytes.
  109802. * @returns the environment file info (the json header) if successfully parsed.
  109803. */
  109804. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109805. /**
  109806. * Creates an environment texture from a loaded cube texture.
  109807. * @param texture defines the cube texture to convert in env file
  109808. * @return a promise containing the environment data if succesfull.
  109809. */
  109810. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109811. /**
  109812. * Creates a JSON representation of the spherical data.
  109813. * @param texture defines the texture containing the polynomials
  109814. * @return the JSON representation of the spherical info
  109815. */
  109816. private static _CreateEnvTextureIrradiance;
  109817. /**
  109818. * Uploads the texture info contained in the env file to the GPU.
  109819. * @param texture defines the internal texture to upload to
  109820. * @param arrayBuffer defines the buffer cotaining the data to load
  109821. * @param info defines the texture info retrieved through the GetEnvInfo method
  109822. * @returns a promise
  109823. */
  109824. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109825. /**
  109826. * Uploads the levels of image data to the GPU.
  109827. * @param texture defines the internal texture to upload to
  109828. * @param imageData defines the array buffer views of image data [mipmap][face]
  109829. * @returns a promise
  109830. */
  109831. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109832. /**
  109833. * Uploads spherical polynomials information to the texture.
  109834. * @param texture defines the texture we are trying to upload the information to
  109835. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109836. */
  109837. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109838. /** @hidden */
  109839. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109840. }
  109841. }
  109842. declare module BABYLON {
  109843. /**
  109844. * Implementation of the ENV Texture Loader.
  109845. * @hidden
  109846. */
  109847. export class _ENVTextureLoader implements IInternalTextureLoader {
  109848. /**
  109849. * Defines wether the loader supports cascade loading the different faces.
  109850. */
  109851. readonly supportCascades: boolean;
  109852. /**
  109853. * This returns if the loader support the current file information.
  109854. * @param extension defines the file extension of the file being loaded
  109855. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109856. * @param fallback defines the fallback internal texture if any
  109857. * @param isBase64 defines whether the texture is encoded as a base64
  109858. * @param isBuffer defines whether the texture data are stored as a buffer
  109859. * @returns true if the loader can load the specified file
  109860. */
  109861. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109862. /**
  109863. * Transform the url before loading if required.
  109864. * @param rootUrl the url of the texture
  109865. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109866. * @returns the transformed texture
  109867. */
  109868. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109869. /**
  109870. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109871. * @param rootUrl the url of the texture
  109872. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109873. * @returns the fallback texture
  109874. */
  109875. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109876. /**
  109877. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109878. * @param data contains the texture data
  109879. * @param texture defines the BabylonJS internal texture
  109880. * @param createPolynomials will be true if polynomials have been requested
  109881. * @param onLoad defines the callback to trigger once the texture is ready
  109882. * @param onError defines the callback to trigger in case of error
  109883. */
  109884. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109885. /**
  109886. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109887. * @param data contains the texture data
  109888. * @param texture defines the BabylonJS internal texture
  109889. * @param callback defines the method to call once ready to upload
  109890. */
  109891. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109892. }
  109893. }
  109894. declare module BABYLON {
  109895. /**
  109896. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  109897. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  109898. */
  109899. export class KhronosTextureContainer {
  109900. /** contents of the KTX container file */
  109901. arrayBuffer: any;
  109902. private static HEADER_LEN;
  109903. private static COMPRESSED_2D;
  109904. private static COMPRESSED_3D;
  109905. private static TEX_2D;
  109906. private static TEX_3D;
  109907. /**
  109908. * Gets the openGL type
  109909. */
  109910. glType: number;
  109911. /**
  109912. * Gets the openGL type size
  109913. */
  109914. glTypeSize: number;
  109915. /**
  109916. * Gets the openGL format
  109917. */
  109918. glFormat: number;
  109919. /**
  109920. * Gets the openGL internal format
  109921. */
  109922. glInternalFormat: number;
  109923. /**
  109924. * Gets the base internal format
  109925. */
  109926. glBaseInternalFormat: number;
  109927. /**
  109928. * Gets image width in pixel
  109929. */
  109930. pixelWidth: number;
  109931. /**
  109932. * Gets image height in pixel
  109933. */
  109934. pixelHeight: number;
  109935. /**
  109936. * Gets image depth in pixels
  109937. */
  109938. pixelDepth: number;
  109939. /**
  109940. * Gets the number of array elements
  109941. */
  109942. numberOfArrayElements: number;
  109943. /**
  109944. * Gets the number of faces
  109945. */
  109946. numberOfFaces: number;
  109947. /**
  109948. * Gets the number of mipmap levels
  109949. */
  109950. numberOfMipmapLevels: number;
  109951. /**
  109952. * Gets the bytes of key value data
  109953. */
  109954. bytesOfKeyValueData: number;
  109955. /**
  109956. * Gets the load type
  109957. */
  109958. loadType: number;
  109959. /**
  109960. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  109961. */
  109962. isInvalid: boolean;
  109963. /**
  109964. * Creates a new KhronosTextureContainer
  109965. * @param arrayBuffer contents of the KTX container file
  109966. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  109967. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  109968. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  109969. */
  109970. constructor(
  109971. /** contents of the KTX container file */
  109972. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  109973. /**
  109974. * Uploads KTX content to a Babylon Texture.
  109975. * It is assumed that the texture has already been created & is currently bound
  109976. * @hidden
  109977. */
  109978. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  109979. private _upload2DCompressedLevels;
  109980. }
  109981. }
  109982. declare module BABYLON {
  109983. /**
  109984. * Implementation of the KTX Texture Loader.
  109985. * @hidden
  109986. */
  109987. export class _KTXTextureLoader implements IInternalTextureLoader {
  109988. /**
  109989. * Defines wether the loader supports cascade loading the different faces.
  109990. */
  109991. readonly supportCascades: boolean;
  109992. /**
  109993. * This returns if the loader support the current file information.
  109994. * @param extension defines the file extension of the file being loaded
  109995. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109996. * @param fallback defines the fallback internal texture if any
  109997. * @param isBase64 defines whether the texture is encoded as a base64
  109998. * @param isBuffer defines whether the texture data are stored as a buffer
  109999. * @returns true if the loader can load the specified file
  110000. */
  110001. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  110002. /**
  110003. * Transform the url before loading if required.
  110004. * @param rootUrl the url of the texture
  110005. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110006. * @returns the transformed texture
  110007. */
  110008. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  110009. /**
  110010. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  110011. * @param rootUrl the url of the texture
  110012. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110013. * @returns the fallback texture
  110014. */
  110015. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  110016. /**
  110017. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  110018. * @param data contains the texture data
  110019. * @param texture defines the BabylonJS internal texture
  110020. * @param createPolynomials will be true if polynomials have been requested
  110021. * @param onLoad defines the callback to trigger once the texture is ready
  110022. * @param onError defines the callback to trigger in case of error
  110023. */
  110024. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  110025. /**
  110026. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  110027. * @param data contains the texture data
  110028. * @param texture defines the BabylonJS internal texture
  110029. * @param callback defines the method to call once ready to upload
  110030. */
  110031. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  110032. }
  110033. }
  110034. declare module BABYLON {
  110035. /**
  110036. * Options for the default xr helper
  110037. */
  110038. export class WebXRDefaultExperienceOptions {
  110039. /**
  110040. * Floor meshes that should be used for teleporting
  110041. */
  110042. floorMeshes: Array<AbstractMesh>;
  110043. }
  110044. /**
  110045. * Default experience which provides a similar setup to the previous webVRExperience
  110046. */
  110047. export class WebXRDefaultExperience {
  110048. /**
  110049. * Base experience
  110050. */
  110051. baseExperience: WebXRExperienceHelper;
  110052. /**
  110053. * Input experience extension
  110054. */
  110055. input: WebXRInput;
  110056. /**
  110057. * Loads the controller models
  110058. */
  110059. controllerModelLoader: WebXRControllerModelLoader;
  110060. /**
  110061. * Enables laser pointer and selection
  110062. */
  110063. pointerSelection: WebXRControllerPointerSelection;
  110064. /**
  110065. * Enables teleportation
  110066. */
  110067. teleportation: WebXRControllerTeleportation;
  110068. /**
  110069. * Enables ui for enetering/exiting xr
  110070. */
  110071. enterExitUI: WebXREnterExitUI;
  110072. /**
  110073. * Default output canvas xr should render to
  110074. */
  110075. outputCanvas: WebXRManagedOutputCanvas;
  110076. /**
  110077. * Creates the default xr experience
  110078. * @param scene scene
  110079. * @param options options for basic configuration
  110080. * @returns resulting WebXRDefaultExperience
  110081. */
  110082. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  110083. private constructor();
  110084. /**
  110085. * DIsposes of the experience helper
  110086. */
  110087. dispose(): void;
  110088. }
  110089. }
  110090. declare module BABYLON {
  110091. /** @hidden */
  110092. export var _forceSceneHelpersToBundle: boolean;
  110093. interface Scene {
  110094. /**
  110095. * Creates a default light for the scene.
  110096. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  110097. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  110098. */
  110099. createDefaultLight(replace?: boolean): void;
  110100. /**
  110101. * Creates a default camera for the scene.
  110102. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  110103. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  110104. * @param replace has default false, when true replaces the active camera in the scene
  110105. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  110106. */
  110107. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  110108. /**
  110109. * Creates a default camera and a default light.
  110110. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  110111. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  110112. * @param replace has the default false, when true replaces the active camera/light in the scene
  110113. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  110114. */
  110115. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  110116. /**
  110117. * Creates a new sky box
  110118. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  110119. * @param environmentTexture defines the texture to use as environment texture
  110120. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  110121. * @param scale defines the overall scale of the skybox
  110122. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  110123. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  110124. * @returns a new mesh holding the sky box
  110125. */
  110126. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  110127. /**
  110128. * Creates a new environment
  110129. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  110130. * @param options defines the options you can use to configure the environment
  110131. * @returns the new EnvironmentHelper
  110132. */
  110133. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  110134. /**
  110135. * Creates a new VREXperienceHelper
  110136. * @see http://doc.babylonjs.com/how_to/webvr_helper
  110137. * @param webVROptions defines the options used to create the new VREXperienceHelper
  110138. * @returns a new VREXperienceHelper
  110139. */
  110140. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  110141. /**
  110142. * Creates a new WebXRDefaultExperience
  110143. * @see http://doc.babylonjs.com/how_to/webxr
  110144. * @param options experience options
  110145. * @returns a promise for a new WebXRDefaultExperience
  110146. */
  110147. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  110148. }
  110149. }
  110150. declare module BABYLON {
  110151. /**
  110152. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  110153. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  110154. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  110155. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  110156. */
  110157. export class VideoDome extends TransformNode {
  110158. /**
  110159. * Define the video source as a Monoscopic panoramic 360 video.
  110160. */
  110161. static readonly MODE_MONOSCOPIC: number;
  110162. /**
  110163. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  110164. */
  110165. static readonly MODE_TOPBOTTOM: number;
  110166. /**
  110167. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  110168. */
  110169. static readonly MODE_SIDEBYSIDE: number;
  110170. private _useDirectMapping;
  110171. /**
  110172. * The video texture being displayed on the sphere
  110173. */
  110174. protected _videoTexture: VideoTexture;
  110175. /**
  110176. * Gets the video texture being displayed on the sphere
  110177. */
  110178. readonly videoTexture: VideoTexture;
  110179. /**
  110180. * The skybox material
  110181. */
  110182. protected _material: BackgroundMaterial;
  110183. /**
  110184. * The surface used for the skybox
  110185. */
  110186. protected _mesh: Mesh;
  110187. /**
  110188. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  110189. * Also see the options.resolution property.
  110190. */
  110191. fovMultiplier: number;
  110192. private _videoMode;
  110193. /**
  110194. * Gets or set the current video mode for the video. It can be:
  110195. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  110196. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  110197. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  110198. */
  110199. videoMode: number;
  110200. /**
  110201. * Oberserver used in Stereoscopic VR Mode.
  110202. */
  110203. private _onBeforeCameraRenderObserver;
  110204. /**
  110205. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  110206. * @param name Element's name, child elements will append suffixes for their own names.
  110207. * @param urlsOrVideo defines the url(s) or the video element to use
  110208. * @param options An object containing optional or exposed sub element properties
  110209. */
  110210. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  110211. resolution?: number;
  110212. clickToPlay?: boolean;
  110213. autoPlay?: boolean;
  110214. loop?: boolean;
  110215. size?: number;
  110216. poster?: string;
  110217. faceForward?: boolean;
  110218. useDirectMapping?: boolean;
  110219. }, scene: Scene);
  110220. private _changeVideoMode;
  110221. /**
  110222. * Releases resources associated with this node.
  110223. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110224. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110225. */
  110226. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110227. }
  110228. }
  110229. declare module BABYLON {
  110230. /**
  110231. * This class can be used to get instrumentation data from a Babylon engine
  110232. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  110233. */
  110234. export class EngineInstrumentation implements IDisposable {
  110235. /**
  110236. * Define the instrumented engine.
  110237. */
  110238. engine: Engine;
  110239. private _captureGPUFrameTime;
  110240. private _gpuFrameTimeToken;
  110241. private _gpuFrameTime;
  110242. private _captureShaderCompilationTime;
  110243. private _shaderCompilationTime;
  110244. private _onBeginFrameObserver;
  110245. private _onEndFrameObserver;
  110246. private _onBeforeShaderCompilationObserver;
  110247. private _onAfterShaderCompilationObserver;
  110248. /**
  110249. * Gets the perf counter used for GPU frame time
  110250. */
  110251. readonly gpuFrameTimeCounter: PerfCounter;
  110252. /**
  110253. * Gets the GPU frame time capture status
  110254. */
  110255. /**
  110256. * Enable or disable the GPU frame time capture
  110257. */
  110258. captureGPUFrameTime: boolean;
  110259. /**
  110260. * Gets the perf counter used for shader compilation time
  110261. */
  110262. readonly shaderCompilationTimeCounter: PerfCounter;
  110263. /**
  110264. * Gets the shader compilation time capture status
  110265. */
  110266. /**
  110267. * Enable or disable the shader compilation time capture
  110268. */
  110269. captureShaderCompilationTime: boolean;
  110270. /**
  110271. * Instantiates a new engine instrumentation.
  110272. * This class can be used to get instrumentation data from a Babylon engine
  110273. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  110274. * @param engine Defines the engine to instrument
  110275. */
  110276. constructor(
  110277. /**
  110278. * Define the instrumented engine.
  110279. */
  110280. engine: Engine);
  110281. /**
  110282. * Dispose and release associated resources.
  110283. */
  110284. dispose(): void;
  110285. }
  110286. }
  110287. declare module BABYLON {
  110288. /**
  110289. * This class can be used to get instrumentation data from a Babylon engine
  110290. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  110291. */
  110292. export class SceneInstrumentation implements IDisposable {
  110293. /**
  110294. * Defines the scene to instrument
  110295. */
  110296. scene: Scene;
  110297. private _captureActiveMeshesEvaluationTime;
  110298. private _activeMeshesEvaluationTime;
  110299. private _captureRenderTargetsRenderTime;
  110300. private _renderTargetsRenderTime;
  110301. private _captureFrameTime;
  110302. private _frameTime;
  110303. private _captureRenderTime;
  110304. private _renderTime;
  110305. private _captureInterFrameTime;
  110306. private _interFrameTime;
  110307. private _captureParticlesRenderTime;
  110308. private _particlesRenderTime;
  110309. private _captureSpritesRenderTime;
  110310. private _spritesRenderTime;
  110311. private _capturePhysicsTime;
  110312. private _physicsTime;
  110313. private _captureAnimationsTime;
  110314. private _animationsTime;
  110315. private _captureCameraRenderTime;
  110316. private _cameraRenderTime;
  110317. private _onBeforeActiveMeshesEvaluationObserver;
  110318. private _onAfterActiveMeshesEvaluationObserver;
  110319. private _onBeforeRenderTargetsRenderObserver;
  110320. private _onAfterRenderTargetsRenderObserver;
  110321. private _onAfterRenderObserver;
  110322. private _onBeforeDrawPhaseObserver;
  110323. private _onAfterDrawPhaseObserver;
  110324. private _onBeforeAnimationsObserver;
  110325. private _onBeforeParticlesRenderingObserver;
  110326. private _onAfterParticlesRenderingObserver;
  110327. private _onBeforeSpritesRenderingObserver;
  110328. private _onAfterSpritesRenderingObserver;
  110329. private _onBeforePhysicsObserver;
  110330. private _onAfterPhysicsObserver;
  110331. private _onAfterAnimationsObserver;
  110332. private _onBeforeCameraRenderObserver;
  110333. private _onAfterCameraRenderObserver;
  110334. /**
  110335. * Gets the perf counter used for active meshes evaluation time
  110336. */
  110337. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  110338. /**
  110339. * Gets the active meshes evaluation time capture status
  110340. */
  110341. /**
  110342. * Enable or disable the active meshes evaluation time capture
  110343. */
  110344. captureActiveMeshesEvaluationTime: boolean;
  110345. /**
  110346. * Gets the perf counter used for render targets render time
  110347. */
  110348. readonly renderTargetsRenderTimeCounter: PerfCounter;
  110349. /**
  110350. * Gets the render targets render time capture status
  110351. */
  110352. /**
  110353. * Enable or disable the render targets render time capture
  110354. */
  110355. captureRenderTargetsRenderTime: boolean;
  110356. /**
  110357. * Gets the perf counter used for particles render time
  110358. */
  110359. readonly particlesRenderTimeCounter: PerfCounter;
  110360. /**
  110361. * Gets the particles render time capture status
  110362. */
  110363. /**
  110364. * Enable or disable the particles render time capture
  110365. */
  110366. captureParticlesRenderTime: boolean;
  110367. /**
  110368. * Gets the perf counter used for sprites render time
  110369. */
  110370. readonly spritesRenderTimeCounter: PerfCounter;
  110371. /**
  110372. * Gets the sprites render time capture status
  110373. */
  110374. /**
  110375. * Enable or disable the sprites render time capture
  110376. */
  110377. captureSpritesRenderTime: boolean;
  110378. /**
  110379. * Gets the perf counter used for physics time
  110380. */
  110381. readonly physicsTimeCounter: PerfCounter;
  110382. /**
  110383. * Gets the physics time capture status
  110384. */
  110385. /**
  110386. * Enable or disable the physics time capture
  110387. */
  110388. capturePhysicsTime: boolean;
  110389. /**
  110390. * Gets the perf counter used for animations time
  110391. */
  110392. readonly animationsTimeCounter: PerfCounter;
  110393. /**
  110394. * Gets the animations time capture status
  110395. */
  110396. /**
  110397. * Enable or disable the animations time capture
  110398. */
  110399. captureAnimationsTime: boolean;
  110400. /**
  110401. * Gets the perf counter used for frame time capture
  110402. */
  110403. readonly frameTimeCounter: PerfCounter;
  110404. /**
  110405. * Gets the frame time capture status
  110406. */
  110407. /**
  110408. * Enable or disable the frame time capture
  110409. */
  110410. captureFrameTime: boolean;
  110411. /**
  110412. * Gets the perf counter used for inter-frames time capture
  110413. */
  110414. readonly interFrameTimeCounter: PerfCounter;
  110415. /**
  110416. * Gets the inter-frames time capture status
  110417. */
  110418. /**
  110419. * Enable or disable the inter-frames time capture
  110420. */
  110421. captureInterFrameTime: boolean;
  110422. /**
  110423. * Gets the perf counter used for render time capture
  110424. */
  110425. readonly renderTimeCounter: PerfCounter;
  110426. /**
  110427. * Gets the render time capture status
  110428. */
  110429. /**
  110430. * Enable or disable the render time capture
  110431. */
  110432. captureRenderTime: boolean;
  110433. /**
  110434. * Gets the perf counter used for camera render time capture
  110435. */
  110436. readonly cameraRenderTimeCounter: PerfCounter;
  110437. /**
  110438. * Gets the camera render time capture status
  110439. */
  110440. /**
  110441. * Enable or disable the camera render time capture
  110442. */
  110443. captureCameraRenderTime: boolean;
  110444. /**
  110445. * Gets the perf counter used for draw calls
  110446. */
  110447. readonly drawCallsCounter: PerfCounter;
  110448. /**
  110449. * Instantiates a new scene instrumentation.
  110450. * This class can be used to get instrumentation data from a Babylon engine
  110451. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  110452. * @param scene Defines the scene to instrument
  110453. */
  110454. constructor(
  110455. /**
  110456. * Defines the scene to instrument
  110457. */
  110458. scene: Scene);
  110459. /**
  110460. * Dispose and release associated resources.
  110461. */
  110462. dispose(): void;
  110463. }
  110464. }
  110465. declare module BABYLON {
  110466. /** @hidden */
  110467. export var glowMapGenerationPixelShader: {
  110468. name: string;
  110469. shader: string;
  110470. };
  110471. }
  110472. declare module BABYLON {
  110473. /** @hidden */
  110474. export var glowMapGenerationVertexShader: {
  110475. name: string;
  110476. shader: string;
  110477. };
  110478. }
  110479. declare module BABYLON {
  110480. /**
  110481. * Effect layer options. This helps customizing the behaviour
  110482. * of the effect layer.
  110483. */
  110484. export interface IEffectLayerOptions {
  110485. /**
  110486. * Multiplication factor apply to the canvas size to compute the render target size
  110487. * used to generated the objects (the smaller the faster).
  110488. */
  110489. mainTextureRatio: number;
  110490. /**
  110491. * Enforces a fixed size texture to ensure effect stability across devices.
  110492. */
  110493. mainTextureFixedSize?: number;
  110494. /**
  110495. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  110496. */
  110497. alphaBlendingMode: number;
  110498. /**
  110499. * The camera attached to the layer.
  110500. */
  110501. camera: Nullable<Camera>;
  110502. /**
  110503. * The rendering group to draw the layer in.
  110504. */
  110505. renderingGroupId: number;
  110506. }
  110507. /**
  110508. * The effect layer Helps adding post process effect blended with the main pass.
  110509. *
  110510. * This can be for instance use to generate glow or higlight effects on the scene.
  110511. *
  110512. * The effect layer class can not be used directly and is intented to inherited from to be
  110513. * customized per effects.
  110514. */
  110515. export abstract class EffectLayer {
  110516. private _vertexBuffers;
  110517. private _indexBuffer;
  110518. private _cachedDefines;
  110519. private _effectLayerMapGenerationEffect;
  110520. private _effectLayerOptions;
  110521. private _mergeEffect;
  110522. protected _scene: Scene;
  110523. protected _engine: Engine;
  110524. protected _maxSize: number;
  110525. protected _mainTextureDesiredSize: ISize;
  110526. protected _mainTexture: RenderTargetTexture;
  110527. protected _shouldRender: boolean;
  110528. protected _postProcesses: PostProcess[];
  110529. protected _textures: BaseTexture[];
  110530. protected _emissiveTextureAndColor: {
  110531. texture: Nullable<BaseTexture>;
  110532. color: Color4;
  110533. };
  110534. /**
  110535. * The name of the layer
  110536. */
  110537. name: string;
  110538. /**
  110539. * The clear color of the texture used to generate the glow map.
  110540. */
  110541. neutralColor: Color4;
  110542. /**
  110543. * Specifies wether the highlight layer is enabled or not.
  110544. */
  110545. isEnabled: boolean;
  110546. /**
  110547. * Gets the camera attached to the layer.
  110548. */
  110549. readonly camera: Nullable<Camera>;
  110550. /**
  110551. * Gets the rendering group id the layer should render in.
  110552. */
  110553. renderingGroupId: number;
  110554. /**
  110555. * An event triggered when the effect layer has been disposed.
  110556. */
  110557. onDisposeObservable: Observable<EffectLayer>;
  110558. /**
  110559. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  110560. */
  110561. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  110562. /**
  110563. * An event triggered when the generated texture is being merged in the scene.
  110564. */
  110565. onBeforeComposeObservable: Observable<EffectLayer>;
  110566. /**
  110567. * An event triggered when the generated texture has been merged in the scene.
  110568. */
  110569. onAfterComposeObservable: Observable<EffectLayer>;
  110570. /**
  110571. * An event triggered when the efffect layer changes its size.
  110572. */
  110573. onSizeChangedObservable: Observable<EffectLayer>;
  110574. /** @hidden */
  110575. static _SceneComponentInitialization: (scene: Scene) => void;
  110576. /**
  110577. * Instantiates a new effect Layer and references it in the scene.
  110578. * @param name The name of the layer
  110579. * @param scene The scene to use the layer in
  110580. */
  110581. constructor(
  110582. /** The Friendly of the effect in the scene */
  110583. name: string, scene: Scene);
  110584. /**
  110585. * Get the effect name of the layer.
  110586. * @return The effect name
  110587. */
  110588. abstract getEffectName(): string;
  110589. /**
  110590. * Checks for the readiness of the element composing the layer.
  110591. * @param subMesh the mesh to check for
  110592. * @param useInstances specify wether or not to use instances to render the mesh
  110593. * @return true if ready otherwise, false
  110594. */
  110595. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110596. /**
  110597. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110598. * @returns true if the effect requires stencil during the main canvas render pass.
  110599. */
  110600. abstract needStencil(): boolean;
  110601. /**
  110602. * Create the merge effect. This is the shader use to blit the information back
  110603. * to the main canvas at the end of the scene rendering.
  110604. * @returns The effect containing the shader used to merge the effect on the main canvas
  110605. */
  110606. protected abstract _createMergeEffect(): Effect;
  110607. /**
  110608. * Creates the render target textures and post processes used in the effect layer.
  110609. */
  110610. protected abstract _createTextureAndPostProcesses(): void;
  110611. /**
  110612. * Implementation specific of rendering the generating effect on the main canvas.
  110613. * @param effect The effect used to render through
  110614. */
  110615. protected abstract _internalRender(effect: Effect): void;
  110616. /**
  110617. * Sets the required values for both the emissive texture and and the main color.
  110618. */
  110619. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110620. /**
  110621. * Free any resources and references associated to a mesh.
  110622. * Internal use
  110623. * @param mesh The mesh to free.
  110624. */
  110625. abstract _disposeMesh(mesh: Mesh): void;
  110626. /**
  110627. * Serializes this layer (Glow or Highlight for example)
  110628. * @returns a serialized layer object
  110629. */
  110630. abstract serialize?(): any;
  110631. /**
  110632. * Initializes the effect layer with the required options.
  110633. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  110634. */
  110635. protected _init(options: Partial<IEffectLayerOptions>): void;
  110636. /**
  110637. * Generates the index buffer of the full screen quad blending to the main canvas.
  110638. */
  110639. private _generateIndexBuffer;
  110640. /**
  110641. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  110642. */
  110643. private _generateVertexBuffer;
  110644. /**
  110645. * Sets the main texture desired size which is the closest power of two
  110646. * of the engine canvas size.
  110647. */
  110648. private _setMainTextureSize;
  110649. /**
  110650. * Creates the main texture for the effect layer.
  110651. */
  110652. protected _createMainTexture(): void;
  110653. /**
  110654. * Adds specific effects defines.
  110655. * @param defines The defines to add specifics to.
  110656. */
  110657. protected _addCustomEffectDefines(defines: string[]): void;
  110658. /**
  110659. * Checks for the readiness of the element composing the layer.
  110660. * @param subMesh the mesh to check for
  110661. * @param useInstances specify wether or not to use instances to render the mesh
  110662. * @param emissiveTexture the associated emissive texture used to generate the glow
  110663. * @return true if ready otherwise, false
  110664. */
  110665. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  110666. /**
  110667. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  110668. */
  110669. render(): void;
  110670. /**
  110671. * Determine if a given mesh will be used in the current effect.
  110672. * @param mesh mesh to test
  110673. * @returns true if the mesh will be used
  110674. */
  110675. hasMesh(mesh: AbstractMesh): boolean;
  110676. /**
  110677. * Returns true if the layer contains information to display, otherwise false.
  110678. * @returns true if the glow layer should be rendered
  110679. */
  110680. shouldRender(): boolean;
  110681. /**
  110682. * Returns true if the mesh should render, otherwise false.
  110683. * @param mesh The mesh to render
  110684. * @returns true if it should render otherwise false
  110685. */
  110686. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  110687. /**
  110688. * Returns true if the mesh can be rendered, otherwise false.
  110689. * @param mesh The mesh to render
  110690. * @param material The material used on the mesh
  110691. * @returns true if it can be rendered otherwise false
  110692. */
  110693. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110694. /**
  110695. * Returns true if the mesh should render, otherwise false.
  110696. * @param mesh The mesh to render
  110697. * @returns true if it should render otherwise false
  110698. */
  110699. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  110700. /**
  110701. * Renders the submesh passed in parameter to the generation map.
  110702. */
  110703. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  110704. /**
  110705. * Rebuild the required buffers.
  110706. * @hidden Internal use only.
  110707. */
  110708. _rebuild(): void;
  110709. /**
  110710. * Dispose only the render target textures and post process.
  110711. */
  110712. private _disposeTextureAndPostProcesses;
  110713. /**
  110714. * Dispose the highlight layer and free resources.
  110715. */
  110716. dispose(): void;
  110717. /**
  110718. * Gets the class name of the effect layer
  110719. * @returns the string with the class name of the effect layer
  110720. */
  110721. getClassName(): string;
  110722. /**
  110723. * Creates an effect layer from parsed effect layer data
  110724. * @param parsedEffectLayer defines effect layer data
  110725. * @param scene defines the current scene
  110726. * @param rootUrl defines the root URL containing the effect layer information
  110727. * @returns a parsed effect Layer
  110728. */
  110729. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  110730. }
  110731. }
  110732. declare module BABYLON {
  110733. interface AbstractScene {
  110734. /**
  110735. * The list of effect layers (highlights/glow) added to the scene
  110736. * @see http://doc.babylonjs.com/how_to/highlight_layer
  110737. * @see http://doc.babylonjs.com/how_to/glow_layer
  110738. */
  110739. effectLayers: Array<EffectLayer>;
  110740. /**
  110741. * Removes the given effect layer from this scene.
  110742. * @param toRemove defines the effect layer to remove
  110743. * @returns the index of the removed effect layer
  110744. */
  110745. removeEffectLayer(toRemove: EffectLayer): number;
  110746. /**
  110747. * Adds the given effect layer to this scene
  110748. * @param newEffectLayer defines the effect layer to add
  110749. */
  110750. addEffectLayer(newEffectLayer: EffectLayer): void;
  110751. }
  110752. /**
  110753. * Defines the layer scene component responsible to manage any effect layers
  110754. * in a given scene.
  110755. */
  110756. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  110757. /**
  110758. * The component name helpfull to identify the component in the list of scene components.
  110759. */
  110760. readonly name: string;
  110761. /**
  110762. * The scene the component belongs to.
  110763. */
  110764. scene: Scene;
  110765. private _engine;
  110766. private _renderEffects;
  110767. private _needStencil;
  110768. private _previousStencilState;
  110769. /**
  110770. * Creates a new instance of the component for the given scene
  110771. * @param scene Defines the scene to register the component in
  110772. */
  110773. constructor(scene: Scene);
  110774. /**
  110775. * Registers the component in a given scene
  110776. */
  110777. register(): void;
  110778. /**
  110779. * Rebuilds the elements related to this component in case of
  110780. * context lost for instance.
  110781. */
  110782. rebuild(): void;
  110783. /**
  110784. * Serializes the component data to the specified json object
  110785. * @param serializationObject The object to serialize to
  110786. */
  110787. serialize(serializationObject: any): void;
  110788. /**
  110789. * Adds all the elements from the container to the scene
  110790. * @param container the container holding the elements
  110791. */
  110792. addFromContainer(container: AbstractScene): void;
  110793. /**
  110794. * Removes all the elements in the container from the scene
  110795. * @param container contains the elements to remove
  110796. * @param dispose if the removed element should be disposed (default: false)
  110797. */
  110798. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110799. /**
  110800. * Disposes the component and the associated ressources.
  110801. */
  110802. dispose(): void;
  110803. private _isReadyForMesh;
  110804. private _renderMainTexture;
  110805. private _setStencil;
  110806. private _setStencilBack;
  110807. private _draw;
  110808. private _drawCamera;
  110809. private _drawRenderingGroup;
  110810. }
  110811. }
  110812. declare module BABYLON {
  110813. /** @hidden */
  110814. export var glowMapMergePixelShader: {
  110815. name: string;
  110816. shader: string;
  110817. };
  110818. }
  110819. declare module BABYLON {
  110820. /** @hidden */
  110821. export var glowMapMergeVertexShader: {
  110822. name: string;
  110823. shader: string;
  110824. };
  110825. }
  110826. declare module BABYLON {
  110827. interface AbstractScene {
  110828. /**
  110829. * Return a the first highlight layer of the scene with a given name.
  110830. * @param name The name of the highlight layer to look for.
  110831. * @return The highlight layer if found otherwise null.
  110832. */
  110833. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  110834. }
  110835. /**
  110836. * Glow layer options. This helps customizing the behaviour
  110837. * of the glow layer.
  110838. */
  110839. export interface IGlowLayerOptions {
  110840. /**
  110841. * Multiplication factor apply to the canvas size to compute the render target size
  110842. * used to generated the glowing objects (the smaller the faster).
  110843. */
  110844. mainTextureRatio: number;
  110845. /**
  110846. * Enforces a fixed size texture to ensure resize independant blur.
  110847. */
  110848. mainTextureFixedSize?: number;
  110849. /**
  110850. * How big is the kernel of the blur texture.
  110851. */
  110852. blurKernelSize: number;
  110853. /**
  110854. * The camera attached to the layer.
  110855. */
  110856. camera: Nullable<Camera>;
  110857. /**
  110858. * Enable MSAA by chosing the number of samples.
  110859. */
  110860. mainTextureSamples?: number;
  110861. /**
  110862. * The rendering group to draw the layer in.
  110863. */
  110864. renderingGroupId: number;
  110865. }
  110866. /**
  110867. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  110868. *
  110869. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110870. * glowy meshes to your scene.
  110871. *
  110872. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  110873. */
  110874. export class GlowLayer extends EffectLayer {
  110875. /**
  110876. * Effect Name of the layer.
  110877. */
  110878. static readonly EffectName: string;
  110879. /**
  110880. * The default blur kernel size used for the glow.
  110881. */
  110882. static DefaultBlurKernelSize: number;
  110883. /**
  110884. * The default texture size ratio used for the glow.
  110885. */
  110886. static DefaultTextureRatio: number;
  110887. /**
  110888. * Sets the kernel size of the blur.
  110889. */
  110890. /**
  110891. * Gets the kernel size of the blur.
  110892. */
  110893. blurKernelSize: number;
  110894. /**
  110895. * Sets the glow intensity.
  110896. */
  110897. /**
  110898. * Gets the glow intensity.
  110899. */
  110900. intensity: number;
  110901. private _options;
  110902. private _intensity;
  110903. private _horizontalBlurPostprocess1;
  110904. private _verticalBlurPostprocess1;
  110905. private _horizontalBlurPostprocess2;
  110906. private _verticalBlurPostprocess2;
  110907. private _blurTexture1;
  110908. private _blurTexture2;
  110909. private _postProcesses1;
  110910. private _postProcesses2;
  110911. private _includedOnlyMeshes;
  110912. private _excludedMeshes;
  110913. /**
  110914. * Callback used to let the user override the color selection on a per mesh basis
  110915. */
  110916. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  110917. /**
  110918. * Callback used to let the user override the texture selection on a per mesh basis
  110919. */
  110920. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  110921. /**
  110922. * Instantiates a new glow Layer and references it to the scene.
  110923. * @param name The name of the layer
  110924. * @param scene The scene to use the layer in
  110925. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  110926. */
  110927. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  110928. /**
  110929. * Get the effect name of the layer.
  110930. * @return The effect name
  110931. */
  110932. getEffectName(): string;
  110933. /**
  110934. * Create the merge effect. This is the shader use to blit the information back
  110935. * to the main canvas at the end of the scene rendering.
  110936. */
  110937. protected _createMergeEffect(): Effect;
  110938. /**
  110939. * Creates the render target textures and post processes used in the glow layer.
  110940. */
  110941. protected _createTextureAndPostProcesses(): void;
  110942. /**
  110943. * Checks for the readiness of the element composing the layer.
  110944. * @param subMesh the mesh to check for
  110945. * @param useInstances specify wether or not to use instances to render the mesh
  110946. * @param emissiveTexture the associated emissive texture used to generate the glow
  110947. * @return true if ready otherwise, false
  110948. */
  110949. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110950. /**
  110951. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110952. */
  110953. needStencil(): boolean;
  110954. /**
  110955. * Returns true if the mesh can be rendered, otherwise false.
  110956. * @param mesh The mesh to render
  110957. * @param material The material used on the mesh
  110958. * @returns true if it can be rendered otherwise false
  110959. */
  110960. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110961. /**
  110962. * Implementation specific of rendering the generating effect on the main canvas.
  110963. * @param effect The effect used to render through
  110964. */
  110965. protected _internalRender(effect: Effect): void;
  110966. /**
  110967. * Sets the required values for both the emissive texture and and the main color.
  110968. */
  110969. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110970. /**
  110971. * Returns true if the mesh should render, otherwise false.
  110972. * @param mesh The mesh to render
  110973. * @returns true if it should render otherwise false
  110974. */
  110975. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110976. /**
  110977. * Adds specific effects defines.
  110978. * @param defines The defines to add specifics to.
  110979. */
  110980. protected _addCustomEffectDefines(defines: string[]): void;
  110981. /**
  110982. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  110983. * @param mesh The mesh to exclude from the glow layer
  110984. */
  110985. addExcludedMesh(mesh: Mesh): void;
  110986. /**
  110987. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  110988. * @param mesh The mesh to remove
  110989. */
  110990. removeExcludedMesh(mesh: Mesh): void;
  110991. /**
  110992. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  110993. * @param mesh The mesh to include in the glow layer
  110994. */
  110995. addIncludedOnlyMesh(mesh: Mesh): void;
  110996. /**
  110997. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  110998. * @param mesh The mesh to remove
  110999. */
  111000. removeIncludedOnlyMesh(mesh: Mesh): void;
  111001. /**
  111002. * Determine if a given mesh will be used in the glow layer
  111003. * @param mesh The mesh to test
  111004. * @returns true if the mesh will be highlighted by the current glow layer
  111005. */
  111006. hasMesh(mesh: AbstractMesh): boolean;
  111007. /**
  111008. * Free any resources and references associated to a mesh.
  111009. * Internal use
  111010. * @param mesh The mesh to free.
  111011. * @hidden
  111012. */
  111013. _disposeMesh(mesh: Mesh): void;
  111014. /**
  111015. * Gets the class name of the effect layer
  111016. * @returns the string with the class name of the effect layer
  111017. */
  111018. getClassName(): string;
  111019. /**
  111020. * Serializes this glow layer
  111021. * @returns a serialized glow layer object
  111022. */
  111023. serialize(): any;
  111024. /**
  111025. * Creates a Glow Layer from parsed glow layer data
  111026. * @param parsedGlowLayer defines glow layer data
  111027. * @param scene defines the current scene
  111028. * @param rootUrl defines the root URL containing the glow layer information
  111029. * @returns a parsed Glow Layer
  111030. */
  111031. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  111032. }
  111033. }
  111034. declare module BABYLON {
  111035. /** @hidden */
  111036. export var glowBlurPostProcessPixelShader: {
  111037. name: string;
  111038. shader: string;
  111039. };
  111040. }
  111041. declare module BABYLON {
  111042. interface AbstractScene {
  111043. /**
  111044. * Return a the first highlight layer of the scene with a given name.
  111045. * @param name The name of the highlight layer to look for.
  111046. * @return The highlight layer if found otherwise null.
  111047. */
  111048. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  111049. }
  111050. /**
  111051. * Highlight layer options. This helps customizing the behaviour
  111052. * of the highlight layer.
  111053. */
  111054. export interface IHighlightLayerOptions {
  111055. /**
  111056. * Multiplication factor apply to the canvas size to compute the render target size
  111057. * used to generated the glowing objects (the smaller the faster).
  111058. */
  111059. mainTextureRatio: number;
  111060. /**
  111061. * Enforces a fixed size texture to ensure resize independant blur.
  111062. */
  111063. mainTextureFixedSize?: number;
  111064. /**
  111065. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  111066. * of the picture to blur (the smaller the faster).
  111067. */
  111068. blurTextureSizeRatio: number;
  111069. /**
  111070. * How big in texel of the blur texture is the vertical blur.
  111071. */
  111072. blurVerticalSize: number;
  111073. /**
  111074. * How big in texel of the blur texture is the horizontal blur.
  111075. */
  111076. blurHorizontalSize: number;
  111077. /**
  111078. * Alpha blending mode used to apply the blur. Default is combine.
  111079. */
  111080. alphaBlendingMode: number;
  111081. /**
  111082. * The camera attached to the layer.
  111083. */
  111084. camera: Nullable<Camera>;
  111085. /**
  111086. * Should we display highlight as a solid stroke?
  111087. */
  111088. isStroke?: boolean;
  111089. /**
  111090. * The rendering group to draw the layer in.
  111091. */
  111092. renderingGroupId: number;
  111093. }
  111094. /**
  111095. * The highlight layer Helps adding a glow effect around a mesh.
  111096. *
  111097. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  111098. * glowy meshes to your scene.
  111099. *
  111100. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  111101. */
  111102. export class HighlightLayer extends EffectLayer {
  111103. name: string;
  111104. /**
  111105. * Effect Name of the highlight layer.
  111106. */
  111107. static readonly EffectName: string;
  111108. /**
  111109. * The neutral color used during the preparation of the glow effect.
  111110. * This is black by default as the blend operation is a blend operation.
  111111. */
  111112. static NeutralColor: Color4;
  111113. /**
  111114. * Stencil value used for glowing meshes.
  111115. */
  111116. static GlowingMeshStencilReference: number;
  111117. /**
  111118. * Stencil value used for the other meshes in the scene.
  111119. */
  111120. static NormalMeshStencilReference: number;
  111121. /**
  111122. * Specifies whether or not the inner glow is ACTIVE in the layer.
  111123. */
  111124. innerGlow: boolean;
  111125. /**
  111126. * Specifies whether or not the outer glow is ACTIVE in the layer.
  111127. */
  111128. outerGlow: boolean;
  111129. /**
  111130. * Specifies the horizontal size of the blur.
  111131. */
  111132. /**
  111133. * Gets the horizontal size of the blur.
  111134. */
  111135. blurHorizontalSize: number;
  111136. /**
  111137. * Specifies the vertical size of the blur.
  111138. */
  111139. /**
  111140. * Gets the vertical size of the blur.
  111141. */
  111142. blurVerticalSize: number;
  111143. /**
  111144. * An event triggered when the highlight layer is being blurred.
  111145. */
  111146. onBeforeBlurObservable: Observable<HighlightLayer>;
  111147. /**
  111148. * An event triggered when the highlight layer has been blurred.
  111149. */
  111150. onAfterBlurObservable: Observable<HighlightLayer>;
  111151. private _instanceGlowingMeshStencilReference;
  111152. private _options;
  111153. private _downSamplePostprocess;
  111154. private _horizontalBlurPostprocess;
  111155. private _verticalBlurPostprocess;
  111156. private _blurTexture;
  111157. private _meshes;
  111158. private _excludedMeshes;
  111159. /**
  111160. * Instantiates a new highlight Layer and references it to the scene..
  111161. * @param name The name of the layer
  111162. * @param scene The scene to use the layer in
  111163. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  111164. */
  111165. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  111166. /**
  111167. * Get the effect name of the layer.
  111168. * @return The effect name
  111169. */
  111170. getEffectName(): string;
  111171. /**
  111172. * Create the merge effect. This is the shader use to blit the information back
  111173. * to the main canvas at the end of the scene rendering.
  111174. */
  111175. protected _createMergeEffect(): Effect;
  111176. /**
  111177. * Creates the render target textures and post processes used in the highlight layer.
  111178. */
  111179. protected _createTextureAndPostProcesses(): void;
  111180. /**
  111181. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  111182. */
  111183. needStencil(): boolean;
  111184. /**
  111185. * Checks for the readiness of the element composing the layer.
  111186. * @param subMesh the mesh to check for
  111187. * @param useInstances specify wether or not to use instances to render the mesh
  111188. * @param emissiveTexture the associated emissive texture used to generate the glow
  111189. * @return true if ready otherwise, false
  111190. */
  111191. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111192. /**
  111193. * Implementation specific of rendering the generating effect on the main canvas.
  111194. * @param effect The effect used to render through
  111195. */
  111196. protected _internalRender(effect: Effect): void;
  111197. /**
  111198. * Returns true if the layer contains information to display, otherwise false.
  111199. */
  111200. shouldRender(): boolean;
  111201. /**
  111202. * Returns true if the mesh should render, otherwise false.
  111203. * @param mesh The mesh to render
  111204. * @returns true if it should render otherwise false
  111205. */
  111206. protected _shouldRenderMesh(mesh: Mesh): boolean;
  111207. /**
  111208. * Sets the required values for both the emissive texture and and the main color.
  111209. */
  111210. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  111211. /**
  111212. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  111213. * @param mesh The mesh to exclude from the highlight layer
  111214. */
  111215. addExcludedMesh(mesh: Mesh): void;
  111216. /**
  111217. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  111218. * @param mesh The mesh to highlight
  111219. */
  111220. removeExcludedMesh(mesh: Mesh): void;
  111221. /**
  111222. * Determine if a given mesh will be highlighted by the current HighlightLayer
  111223. * @param mesh mesh to test
  111224. * @returns true if the mesh will be highlighted by the current HighlightLayer
  111225. */
  111226. hasMesh(mesh: AbstractMesh): boolean;
  111227. /**
  111228. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  111229. * @param mesh The mesh to highlight
  111230. * @param color The color of the highlight
  111231. * @param glowEmissiveOnly Extract the glow from the emissive texture
  111232. */
  111233. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  111234. /**
  111235. * Remove a mesh from the highlight layer in order to make it stop glowing.
  111236. * @param mesh The mesh to highlight
  111237. */
  111238. removeMesh(mesh: Mesh): void;
  111239. /**
  111240. * Force the stencil to the normal expected value for none glowing parts
  111241. */
  111242. private _defaultStencilReference;
  111243. /**
  111244. * Free any resources and references associated to a mesh.
  111245. * Internal use
  111246. * @param mesh The mesh to free.
  111247. * @hidden
  111248. */
  111249. _disposeMesh(mesh: Mesh): void;
  111250. /**
  111251. * Dispose the highlight layer and free resources.
  111252. */
  111253. dispose(): void;
  111254. /**
  111255. * Gets the class name of the effect layer
  111256. * @returns the string with the class name of the effect layer
  111257. */
  111258. getClassName(): string;
  111259. /**
  111260. * Serializes this Highlight layer
  111261. * @returns a serialized Highlight layer object
  111262. */
  111263. serialize(): any;
  111264. /**
  111265. * Creates a Highlight layer from parsed Highlight layer data
  111266. * @param parsedHightlightLayer defines the Highlight layer data
  111267. * @param scene defines the current scene
  111268. * @param rootUrl defines the root URL containing the Highlight layer information
  111269. * @returns a parsed Highlight layer
  111270. */
  111271. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  111272. }
  111273. }
  111274. declare module BABYLON {
  111275. interface AbstractScene {
  111276. /**
  111277. * The list of layers (background and foreground) of the scene
  111278. */
  111279. layers: Array<Layer>;
  111280. }
  111281. /**
  111282. * Defines the layer scene component responsible to manage any layers
  111283. * in a given scene.
  111284. */
  111285. export class LayerSceneComponent implements ISceneComponent {
  111286. /**
  111287. * The component name helpfull to identify the component in the list of scene components.
  111288. */
  111289. readonly name: string;
  111290. /**
  111291. * The scene the component belongs to.
  111292. */
  111293. scene: Scene;
  111294. private _engine;
  111295. /**
  111296. * Creates a new instance of the component for the given scene
  111297. * @param scene Defines the scene to register the component in
  111298. */
  111299. constructor(scene: Scene);
  111300. /**
  111301. * Registers the component in a given scene
  111302. */
  111303. register(): void;
  111304. /**
  111305. * Rebuilds the elements related to this component in case of
  111306. * context lost for instance.
  111307. */
  111308. rebuild(): void;
  111309. /**
  111310. * Disposes the component and the associated ressources.
  111311. */
  111312. dispose(): void;
  111313. private _draw;
  111314. private _drawCameraPredicate;
  111315. private _drawCameraBackground;
  111316. private _drawCameraForeground;
  111317. private _drawRenderTargetPredicate;
  111318. private _drawRenderTargetBackground;
  111319. private _drawRenderTargetForeground;
  111320. /**
  111321. * Adds all the elements from the container to the scene
  111322. * @param container the container holding the elements
  111323. */
  111324. addFromContainer(container: AbstractScene): void;
  111325. /**
  111326. * Removes all the elements in the container from the scene
  111327. * @param container contains the elements to remove
  111328. * @param dispose if the removed element should be disposed (default: false)
  111329. */
  111330. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111331. }
  111332. }
  111333. declare module BABYLON {
  111334. /** @hidden */
  111335. export var layerPixelShader: {
  111336. name: string;
  111337. shader: string;
  111338. };
  111339. }
  111340. declare module BABYLON {
  111341. /** @hidden */
  111342. export var layerVertexShader: {
  111343. name: string;
  111344. shader: string;
  111345. };
  111346. }
  111347. declare module BABYLON {
  111348. /**
  111349. * This represents a full screen 2d layer.
  111350. * This can be useful to display a picture in the background of your scene for instance.
  111351. * @see https://www.babylonjs-playground.com/#08A2BS#1
  111352. */
  111353. export class Layer {
  111354. /**
  111355. * Define the name of the layer.
  111356. */
  111357. name: string;
  111358. /**
  111359. * Define the texture the layer should display.
  111360. */
  111361. texture: Nullable<Texture>;
  111362. /**
  111363. * Is the layer in background or foreground.
  111364. */
  111365. isBackground: boolean;
  111366. /**
  111367. * Define the color of the layer (instead of texture).
  111368. */
  111369. color: Color4;
  111370. /**
  111371. * Define the scale of the layer in order to zoom in out of the texture.
  111372. */
  111373. scale: Vector2;
  111374. /**
  111375. * Define an offset for the layer in order to shift the texture.
  111376. */
  111377. offset: Vector2;
  111378. /**
  111379. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  111380. */
  111381. alphaBlendingMode: number;
  111382. /**
  111383. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  111384. * Alpha test will not mix with the background color in case of transparency.
  111385. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  111386. */
  111387. alphaTest: boolean;
  111388. /**
  111389. * Define a mask to restrict the layer to only some of the scene cameras.
  111390. */
  111391. layerMask: number;
  111392. /**
  111393. * Define the list of render target the layer is visible into.
  111394. */
  111395. renderTargetTextures: RenderTargetTexture[];
  111396. /**
  111397. * Define if the layer is only used in renderTarget or if it also
  111398. * renders in the main frame buffer of the canvas.
  111399. */
  111400. renderOnlyInRenderTargetTextures: boolean;
  111401. private _scene;
  111402. private _vertexBuffers;
  111403. private _indexBuffer;
  111404. private _effect;
  111405. private _alphaTestEffect;
  111406. /**
  111407. * An event triggered when the layer is disposed.
  111408. */
  111409. onDisposeObservable: Observable<Layer>;
  111410. private _onDisposeObserver;
  111411. /**
  111412. * Back compatibility with callback before the onDisposeObservable existed.
  111413. * The set callback will be triggered when the layer has been disposed.
  111414. */
  111415. onDispose: () => void;
  111416. /**
  111417. * An event triggered before rendering the scene
  111418. */
  111419. onBeforeRenderObservable: Observable<Layer>;
  111420. private _onBeforeRenderObserver;
  111421. /**
  111422. * Back compatibility with callback before the onBeforeRenderObservable existed.
  111423. * The set callback will be triggered just before rendering the layer.
  111424. */
  111425. onBeforeRender: () => void;
  111426. /**
  111427. * An event triggered after rendering the scene
  111428. */
  111429. onAfterRenderObservable: Observable<Layer>;
  111430. private _onAfterRenderObserver;
  111431. /**
  111432. * Back compatibility with callback before the onAfterRenderObservable existed.
  111433. * The set callback will be triggered just after rendering the layer.
  111434. */
  111435. onAfterRender: () => void;
  111436. /**
  111437. * Instantiates a new layer.
  111438. * This represents a full screen 2d layer.
  111439. * This can be useful to display a picture in the background of your scene for instance.
  111440. * @see https://www.babylonjs-playground.com/#08A2BS#1
  111441. * @param name Define the name of the layer in the scene
  111442. * @param imgUrl Define the url of the texture to display in the layer
  111443. * @param scene Define the scene the layer belongs to
  111444. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  111445. * @param color Defines a color for the layer
  111446. */
  111447. constructor(
  111448. /**
  111449. * Define the name of the layer.
  111450. */
  111451. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  111452. private _createIndexBuffer;
  111453. /** @hidden */
  111454. _rebuild(): void;
  111455. /**
  111456. * Renders the layer in the scene.
  111457. */
  111458. render(): void;
  111459. /**
  111460. * Disposes and releases the associated ressources.
  111461. */
  111462. dispose(): void;
  111463. }
  111464. }
  111465. declare module BABYLON {
  111466. /** @hidden */
  111467. export var lensFlarePixelShader: {
  111468. name: string;
  111469. shader: string;
  111470. };
  111471. }
  111472. declare module BABYLON {
  111473. /** @hidden */
  111474. export var lensFlareVertexShader: {
  111475. name: string;
  111476. shader: string;
  111477. };
  111478. }
  111479. declare module BABYLON {
  111480. /**
  111481. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  111482. * It is usually composed of several `lensFlare`.
  111483. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111484. */
  111485. export class LensFlareSystem {
  111486. /**
  111487. * Define the name of the lens flare system
  111488. */
  111489. name: string;
  111490. /**
  111491. * List of lens flares used in this system.
  111492. */
  111493. lensFlares: LensFlare[];
  111494. /**
  111495. * Define a limit from the border the lens flare can be visible.
  111496. */
  111497. borderLimit: number;
  111498. /**
  111499. * Define a viewport border we do not want to see the lens flare in.
  111500. */
  111501. viewportBorder: number;
  111502. /**
  111503. * Define a predicate which could limit the list of meshes able to occlude the effect.
  111504. */
  111505. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  111506. /**
  111507. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  111508. */
  111509. layerMask: number;
  111510. /**
  111511. * Define the id of the lens flare system in the scene.
  111512. * (equal to name by default)
  111513. */
  111514. id: string;
  111515. private _scene;
  111516. private _emitter;
  111517. private _vertexBuffers;
  111518. private _indexBuffer;
  111519. private _effect;
  111520. private _positionX;
  111521. private _positionY;
  111522. private _isEnabled;
  111523. /** @hidden */
  111524. static _SceneComponentInitialization: (scene: Scene) => void;
  111525. /**
  111526. * Instantiates a lens flare system.
  111527. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  111528. * It is usually composed of several `lensFlare`.
  111529. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111530. * @param name Define the name of the lens flare system in the scene
  111531. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  111532. * @param scene Define the scene the lens flare system belongs to
  111533. */
  111534. constructor(
  111535. /**
  111536. * Define the name of the lens flare system
  111537. */
  111538. name: string, emitter: any, scene: Scene);
  111539. /**
  111540. * Define if the lens flare system is enabled.
  111541. */
  111542. isEnabled: boolean;
  111543. /**
  111544. * Get the scene the effects belongs to.
  111545. * @returns the scene holding the lens flare system
  111546. */
  111547. getScene(): Scene;
  111548. /**
  111549. * Get the emitter of the lens flare system.
  111550. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  111551. * @returns the emitter of the lens flare system
  111552. */
  111553. getEmitter(): any;
  111554. /**
  111555. * Set the emitter of the lens flare system.
  111556. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  111557. * @param newEmitter Define the new emitter of the system
  111558. */
  111559. setEmitter(newEmitter: any): void;
  111560. /**
  111561. * Get the lens flare system emitter position.
  111562. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  111563. * @returns the position
  111564. */
  111565. getEmitterPosition(): Vector3;
  111566. /**
  111567. * @hidden
  111568. */
  111569. computeEffectivePosition(globalViewport: Viewport): boolean;
  111570. /** @hidden */
  111571. _isVisible(): boolean;
  111572. /**
  111573. * @hidden
  111574. */
  111575. render(): boolean;
  111576. /**
  111577. * Dispose and release the lens flare with its associated resources.
  111578. */
  111579. dispose(): void;
  111580. /**
  111581. * Parse a lens flare system from a JSON repressentation
  111582. * @param parsedLensFlareSystem Define the JSON to parse
  111583. * @param scene Define the scene the parsed system should be instantiated in
  111584. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  111585. * @returns the parsed system
  111586. */
  111587. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  111588. /**
  111589. * Serialize the current Lens Flare System into a JSON representation.
  111590. * @returns the serialized JSON
  111591. */
  111592. serialize(): any;
  111593. }
  111594. }
  111595. declare module BABYLON {
  111596. /**
  111597. * This represents one of the lens effect in a `lensFlareSystem`.
  111598. * It controls one of the indiviual texture used in the effect.
  111599. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111600. */
  111601. export class LensFlare {
  111602. /**
  111603. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  111604. */
  111605. size: number;
  111606. /**
  111607. * 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.
  111608. */
  111609. position: number;
  111610. /**
  111611. * Define the lens color.
  111612. */
  111613. color: Color3;
  111614. /**
  111615. * Define the lens texture.
  111616. */
  111617. texture: Nullable<Texture>;
  111618. /**
  111619. * Define the alpha mode to render this particular lens.
  111620. */
  111621. alphaMode: number;
  111622. private _system;
  111623. /**
  111624. * Creates a new Lens Flare.
  111625. * This represents one of the lens effect in a `lensFlareSystem`.
  111626. * It controls one of the indiviual texture used in the effect.
  111627. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111628. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  111629. * @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.
  111630. * @param color Define the lens color
  111631. * @param imgUrl Define the lens texture url
  111632. * @param system Define the `lensFlareSystem` this flare is part of
  111633. * @returns The newly created Lens Flare
  111634. */
  111635. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  111636. /**
  111637. * Instantiates a new Lens Flare.
  111638. * This represents one of the lens effect in a `lensFlareSystem`.
  111639. * It controls one of the indiviual texture used in the effect.
  111640. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111641. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  111642. * @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.
  111643. * @param color Define the lens color
  111644. * @param imgUrl Define the lens texture url
  111645. * @param system Define the `lensFlareSystem` this flare is part of
  111646. */
  111647. constructor(
  111648. /**
  111649. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  111650. */
  111651. size: number,
  111652. /**
  111653. * 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.
  111654. */
  111655. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  111656. /**
  111657. * Dispose and release the lens flare with its associated resources.
  111658. */
  111659. dispose(): void;
  111660. }
  111661. }
  111662. declare module BABYLON {
  111663. interface AbstractScene {
  111664. /**
  111665. * The list of lens flare system added to the scene
  111666. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111667. */
  111668. lensFlareSystems: Array<LensFlareSystem>;
  111669. /**
  111670. * Removes the given lens flare system from this scene.
  111671. * @param toRemove The lens flare system to remove
  111672. * @returns The index of the removed lens flare system
  111673. */
  111674. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  111675. /**
  111676. * Adds the given lens flare system to this scene
  111677. * @param newLensFlareSystem The lens flare system to add
  111678. */
  111679. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  111680. /**
  111681. * Gets a lens flare system using its name
  111682. * @param name defines the name to look for
  111683. * @returns the lens flare system or null if not found
  111684. */
  111685. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  111686. /**
  111687. * Gets a lens flare system using its id
  111688. * @param id defines the id to look for
  111689. * @returns the lens flare system or null if not found
  111690. */
  111691. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  111692. }
  111693. /**
  111694. * Defines the lens flare scene component responsible to manage any lens flares
  111695. * in a given scene.
  111696. */
  111697. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  111698. /**
  111699. * The component name helpfull to identify the component in the list of scene components.
  111700. */
  111701. readonly name: string;
  111702. /**
  111703. * The scene the component belongs to.
  111704. */
  111705. scene: Scene;
  111706. /**
  111707. * Creates a new instance of the component for the given scene
  111708. * @param scene Defines the scene to register the component in
  111709. */
  111710. constructor(scene: Scene);
  111711. /**
  111712. * Registers the component in a given scene
  111713. */
  111714. register(): void;
  111715. /**
  111716. * Rebuilds the elements related to this component in case of
  111717. * context lost for instance.
  111718. */
  111719. rebuild(): void;
  111720. /**
  111721. * Adds all the elements from the container to the scene
  111722. * @param container the container holding the elements
  111723. */
  111724. addFromContainer(container: AbstractScene): void;
  111725. /**
  111726. * Removes all the elements in the container from the scene
  111727. * @param container contains the elements to remove
  111728. * @param dispose if the removed element should be disposed (default: false)
  111729. */
  111730. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111731. /**
  111732. * Serializes the component data to the specified json object
  111733. * @param serializationObject The object to serialize to
  111734. */
  111735. serialize(serializationObject: any): void;
  111736. /**
  111737. * Disposes the component and the associated ressources.
  111738. */
  111739. dispose(): void;
  111740. private _draw;
  111741. }
  111742. }
  111743. declare module BABYLON {
  111744. /**
  111745. * Defines the shadow generator component responsible to manage any shadow generators
  111746. * in a given scene.
  111747. */
  111748. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  111749. /**
  111750. * The component name helpfull to identify the component in the list of scene components.
  111751. */
  111752. readonly name: string;
  111753. /**
  111754. * The scene the component belongs to.
  111755. */
  111756. scene: Scene;
  111757. /**
  111758. * Creates a new instance of the component for the given scene
  111759. * @param scene Defines the scene to register the component in
  111760. */
  111761. constructor(scene: Scene);
  111762. /**
  111763. * Registers the component in a given scene
  111764. */
  111765. register(): void;
  111766. /**
  111767. * Rebuilds the elements related to this component in case of
  111768. * context lost for instance.
  111769. */
  111770. rebuild(): void;
  111771. /**
  111772. * Serializes the component data to the specified json object
  111773. * @param serializationObject The object to serialize to
  111774. */
  111775. serialize(serializationObject: any): void;
  111776. /**
  111777. * Adds all the elements from the container to the scene
  111778. * @param container the container holding the elements
  111779. */
  111780. addFromContainer(container: AbstractScene): void;
  111781. /**
  111782. * Removes all the elements in the container from the scene
  111783. * @param container contains the elements to remove
  111784. * @param dispose if the removed element should be disposed (default: false)
  111785. */
  111786. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111787. /**
  111788. * Rebuilds the elements related to this component in case of
  111789. * context lost for instance.
  111790. */
  111791. dispose(): void;
  111792. private _gatherRenderTargets;
  111793. }
  111794. }
  111795. declare module BABYLON {
  111796. /**
  111797. * A point light is a light defined by an unique point in world space.
  111798. * The light is emitted in every direction from this point.
  111799. * A good example of a point light is a standard light bulb.
  111800. * Documentation: https://doc.babylonjs.com/babylon101/lights
  111801. */
  111802. export class PointLight extends ShadowLight {
  111803. private _shadowAngle;
  111804. /**
  111805. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111806. * This specifies what angle the shadow will use to be created.
  111807. *
  111808. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111809. */
  111810. /**
  111811. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111812. * This specifies what angle the shadow will use to be created.
  111813. *
  111814. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111815. */
  111816. shadowAngle: number;
  111817. /**
  111818. * Gets the direction if it has been set.
  111819. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111820. */
  111821. /**
  111822. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111823. */
  111824. direction: Vector3;
  111825. /**
  111826. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  111827. * A PointLight emits the light in every direction.
  111828. * It can cast shadows.
  111829. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  111830. * ```javascript
  111831. * var pointLight = new PointLight("pl", camera.position, scene);
  111832. * ```
  111833. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111834. * @param name The light friendly name
  111835. * @param position The position of the point light in the scene
  111836. * @param scene The scene the lights belongs to
  111837. */
  111838. constructor(name: string, position: Vector3, scene: Scene);
  111839. /**
  111840. * Returns the string "PointLight"
  111841. * @returns the class name
  111842. */
  111843. getClassName(): string;
  111844. /**
  111845. * Returns the integer 0.
  111846. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111847. */
  111848. getTypeID(): number;
  111849. /**
  111850. * Specifies wether or not the shadowmap should be a cube texture.
  111851. * @returns true if the shadowmap needs to be a cube texture.
  111852. */
  111853. needCube(): boolean;
  111854. /**
  111855. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  111856. * @param faceIndex The index of the face we are computed the direction to generate shadow
  111857. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  111858. */
  111859. getShadowDirection(faceIndex?: number): Vector3;
  111860. /**
  111861. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  111862. * - fov = PI / 2
  111863. * - aspect ratio : 1.0
  111864. * - z-near and far equal to the active camera minZ and maxZ.
  111865. * Returns the PointLight.
  111866. */
  111867. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111868. protected _buildUniformLayout(): void;
  111869. /**
  111870. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  111871. * @param effect The effect to update
  111872. * @param lightIndex The index of the light in the effect to update
  111873. * @returns The point light
  111874. */
  111875. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  111876. /**
  111877. * Prepares the list of defines specific to the light type.
  111878. * @param defines the list of defines
  111879. * @param lightIndex defines the index of the light for the effect
  111880. */
  111881. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111882. }
  111883. }
  111884. declare module BABYLON {
  111885. /**
  111886. * Header information of HDR texture files.
  111887. */
  111888. export interface HDRInfo {
  111889. /**
  111890. * The height of the texture in pixels.
  111891. */
  111892. height: number;
  111893. /**
  111894. * The width of the texture in pixels.
  111895. */
  111896. width: number;
  111897. /**
  111898. * The index of the beginning of the data in the binary file.
  111899. */
  111900. dataPosition: number;
  111901. }
  111902. /**
  111903. * This groups tools to convert HDR texture to native colors array.
  111904. */
  111905. export class HDRTools {
  111906. private static Ldexp;
  111907. private static Rgbe2float;
  111908. private static readStringLine;
  111909. /**
  111910. * Reads header information from an RGBE texture stored in a native array.
  111911. * More information on this format are available here:
  111912. * https://en.wikipedia.org/wiki/RGBE_image_format
  111913. *
  111914. * @param uint8array The binary file stored in native array.
  111915. * @return The header information.
  111916. */
  111917. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  111918. /**
  111919. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  111920. * This RGBE texture needs to store the information as a panorama.
  111921. *
  111922. * More information on this format are available here:
  111923. * https://en.wikipedia.org/wiki/RGBE_image_format
  111924. *
  111925. * @param buffer The binary file stored in an array buffer.
  111926. * @param size The expected size of the extracted cubemap.
  111927. * @return The Cube Map information.
  111928. */
  111929. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  111930. /**
  111931. * Returns the pixels data extracted from an RGBE texture.
  111932. * This pixels will be stored left to right up to down in the R G B order in one array.
  111933. *
  111934. * More information on this format are available here:
  111935. * https://en.wikipedia.org/wiki/RGBE_image_format
  111936. *
  111937. * @param uint8array The binary file stored in an array buffer.
  111938. * @param hdrInfo The header information of the file.
  111939. * @return The pixels data in RGB right to left up to down order.
  111940. */
  111941. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  111942. private static RGBE_ReadPixels_RLE;
  111943. }
  111944. }
  111945. declare module BABYLON {
  111946. /**
  111947. * This represents a texture coming from an HDR input.
  111948. *
  111949. * The only supported format is currently panorama picture stored in RGBE format.
  111950. * Example of such files can be found on HDRLib: http://hdrlib.com/
  111951. */
  111952. export class HDRCubeTexture extends BaseTexture {
  111953. private static _facesMapping;
  111954. private _generateHarmonics;
  111955. private _noMipmap;
  111956. private _textureMatrix;
  111957. private _size;
  111958. private _onLoad;
  111959. private _onError;
  111960. /**
  111961. * The texture URL.
  111962. */
  111963. url: string;
  111964. /**
  111965. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  111966. */
  111967. coordinatesMode: number;
  111968. protected _isBlocking: boolean;
  111969. /**
  111970. * Sets wether or not the texture is blocking during loading.
  111971. */
  111972. /**
  111973. * Gets wether or not the texture is blocking during loading.
  111974. */
  111975. isBlocking: boolean;
  111976. protected _rotationY: number;
  111977. /**
  111978. * Sets texture matrix rotation angle around Y axis in radians.
  111979. */
  111980. /**
  111981. * Gets texture matrix rotation angle around Y axis radians.
  111982. */
  111983. rotationY: number;
  111984. /**
  111985. * Gets or sets the center of the bounding box associated with the cube texture
  111986. * It must define where the camera used to render the texture was set
  111987. */
  111988. boundingBoxPosition: Vector3;
  111989. private _boundingBoxSize;
  111990. /**
  111991. * Gets or sets the size of the bounding box associated with the cube texture
  111992. * When defined, the cubemap will switch to local mode
  111993. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  111994. * @example https://www.babylonjs-playground.com/#RNASML
  111995. */
  111996. boundingBoxSize: Vector3;
  111997. /**
  111998. * Instantiates an HDRTexture from the following parameters.
  111999. *
  112000. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  112001. * @param scene The scene the texture will be used in
  112002. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  112003. * @param noMipmap Forces to not generate the mipmap if true
  112004. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  112005. * @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)
  112006. * @param reserved Reserved flag for internal use.
  112007. */
  112008. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  112009. /**
  112010. * Get the current class name of the texture useful for serialization or dynamic coding.
  112011. * @returns "HDRCubeTexture"
  112012. */
  112013. getClassName(): string;
  112014. /**
  112015. * Occurs when the file is raw .hdr file.
  112016. */
  112017. private loadTexture;
  112018. clone(): HDRCubeTexture;
  112019. delayLoad(): void;
  112020. /**
  112021. * Get the texture reflection matrix used to rotate/transform the reflection.
  112022. * @returns the reflection matrix
  112023. */
  112024. getReflectionTextureMatrix(): Matrix;
  112025. /**
  112026. * Set the texture reflection matrix used to rotate/transform the reflection.
  112027. * @param value Define the reflection matrix to set
  112028. */
  112029. setReflectionTextureMatrix(value: Matrix): void;
  112030. /**
  112031. * Parses a JSON representation of an HDR Texture in order to create the texture
  112032. * @param parsedTexture Define the JSON representation
  112033. * @param scene Define the scene the texture should be created in
  112034. * @param rootUrl Define the root url in case we need to load relative dependencies
  112035. * @returns the newly created texture after parsing
  112036. */
  112037. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  112038. serialize(): any;
  112039. }
  112040. }
  112041. declare module BABYLON {
  112042. /**
  112043. * Class used to control physics engine
  112044. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  112045. */
  112046. export class PhysicsEngine implements IPhysicsEngine {
  112047. private _physicsPlugin;
  112048. /**
  112049. * Global value used to control the smallest number supported by the simulation
  112050. */
  112051. static Epsilon: number;
  112052. private _impostors;
  112053. private _joints;
  112054. /**
  112055. * Gets the gravity vector used by the simulation
  112056. */
  112057. gravity: Vector3;
  112058. /**
  112059. * Factory used to create the default physics plugin.
  112060. * @returns The default physics plugin
  112061. */
  112062. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  112063. /**
  112064. * Creates a new Physics Engine
  112065. * @param gravity defines the gravity vector used by the simulation
  112066. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  112067. */
  112068. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  112069. /**
  112070. * Sets the gravity vector used by the simulation
  112071. * @param gravity defines the gravity vector to use
  112072. */
  112073. setGravity(gravity: Vector3): void;
  112074. /**
  112075. * Set the time step of the physics engine.
  112076. * Default is 1/60.
  112077. * To slow it down, enter 1/600 for example.
  112078. * To speed it up, 1/30
  112079. * @param newTimeStep defines the new timestep to apply to this world.
  112080. */
  112081. setTimeStep(newTimeStep?: number): void;
  112082. /**
  112083. * Get the time step of the physics engine.
  112084. * @returns the current time step
  112085. */
  112086. getTimeStep(): number;
  112087. /**
  112088. * Release all resources
  112089. */
  112090. dispose(): void;
  112091. /**
  112092. * Gets the name of the current physics plugin
  112093. * @returns the name of the plugin
  112094. */
  112095. getPhysicsPluginName(): string;
  112096. /**
  112097. * Adding a new impostor for the impostor tracking.
  112098. * This will be done by the impostor itself.
  112099. * @param impostor the impostor to add
  112100. */
  112101. addImpostor(impostor: PhysicsImpostor): void;
  112102. /**
  112103. * Remove an impostor from the engine.
  112104. * This impostor and its mesh will not longer be updated by the physics engine.
  112105. * @param impostor the impostor to remove
  112106. */
  112107. removeImpostor(impostor: PhysicsImpostor): void;
  112108. /**
  112109. * Add a joint to the physics engine
  112110. * @param mainImpostor defines the main impostor to which the joint is added.
  112111. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  112112. * @param joint defines the joint that will connect both impostors.
  112113. */
  112114. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112115. /**
  112116. * Removes a joint from the simulation
  112117. * @param mainImpostor defines the impostor used with the joint
  112118. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  112119. * @param joint defines the joint to remove
  112120. */
  112121. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112122. /**
  112123. * Called by the scene. No need to call it.
  112124. * @param delta defines the timespam between frames
  112125. */
  112126. _step(delta: number): void;
  112127. /**
  112128. * Gets the current plugin used to run the simulation
  112129. * @returns current plugin
  112130. */
  112131. getPhysicsPlugin(): IPhysicsEnginePlugin;
  112132. /**
  112133. * Gets the list of physic impostors
  112134. * @returns an array of PhysicsImpostor
  112135. */
  112136. getImpostors(): Array<PhysicsImpostor>;
  112137. /**
  112138. * Gets the impostor for a physics enabled object
  112139. * @param object defines the object impersonated by the impostor
  112140. * @returns the PhysicsImpostor or null if not found
  112141. */
  112142. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  112143. /**
  112144. * Gets the impostor for a physics body object
  112145. * @param body defines physics body used by the impostor
  112146. * @returns the PhysicsImpostor or null if not found
  112147. */
  112148. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  112149. /**
  112150. * Does a raycast in the physics world
  112151. * @param from when should the ray start?
  112152. * @param to when should the ray end?
  112153. * @returns PhysicsRaycastResult
  112154. */
  112155. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112156. }
  112157. }
  112158. declare module BABYLON {
  112159. /** @hidden */
  112160. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  112161. private _useDeltaForWorldStep;
  112162. world: any;
  112163. name: string;
  112164. private _physicsMaterials;
  112165. private _fixedTimeStep;
  112166. private _cannonRaycastResult;
  112167. private _raycastResult;
  112168. private _physicsBodysToRemoveAfterStep;
  112169. BJSCANNON: any;
  112170. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  112171. setGravity(gravity: Vector3): void;
  112172. setTimeStep(timeStep: number): void;
  112173. getTimeStep(): number;
  112174. executeStep(delta: number): void;
  112175. private _removeMarkedPhysicsBodiesFromWorld;
  112176. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112177. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112178. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112179. private _processChildMeshes;
  112180. removePhysicsBody(impostor: PhysicsImpostor): void;
  112181. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112182. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112183. private _addMaterial;
  112184. private _checkWithEpsilon;
  112185. private _createShape;
  112186. private _createHeightmap;
  112187. private _minus90X;
  112188. private _plus90X;
  112189. private _tmpPosition;
  112190. private _tmpDeltaPosition;
  112191. private _tmpUnityRotation;
  112192. private _updatePhysicsBodyTransformation;
  112193. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112194. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112195. isSupported(): boolean;
  112196. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112197. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112198. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112199. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112200. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112201. getBodyMass(impostor: PhysicsImpostor): number;
  112202. getBodyFriction(impostor: PhysicsImpostor): number;
  112203. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112204. getBodyRestitution(impostor: PhysicsImpostor): number;
  112205. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112206. sleepBody(impostor: PhysicsImpostor): void;
  112207. wakeUpBody(impostor: PhysicsImpostor): void;
  112208. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  112209. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  112210. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  112211. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112212. getRadius(impostor: PhysicsImpostor): number;
  112213. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112214. dispose(): void;
  112215. private _extendNamespace;
  112216. /**
  112217. * Does a raycast in the physics world
  112218. * @param from when should the ray start?
  112219. * @param to when should the ray end?
  112220. * @returns PhysicsRaycastResult
  112221. */
  112222. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112223. }
  112224. }
  112225. declare module BABYLON {
  112226. /** @hidden */
  112227. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  112228. world: any;
  112229. name: string;
  112230. BJSOIMO: any;
  112231. private _raycastResult;
  112232. constructor(iterations?: number, oimoInjection?: any);
  112233. setGravity(gravity: Vector3): void;
  112234. setTimeStep(timeStep: number): void;
  112235. getTimeStep(): number;
  112236. private _tmpImpostorsArray;
  112237. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112238. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112239. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112240. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112241. private _tmpPositionVector;
  112242. removePhysicsBody(impostor: PhysicsImpostor): void;
  112243. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112244. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112245. isSupported(): boolean;
  112246. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112247. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112248. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112249. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112250. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112251. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112252. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112253. getBodyMass(impostor: PhysicsImpostor): number;
  112254. getBodyFriction(impostor: PhysicsImpostor): number;
  112255. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112256. getBodyRestitution(impostor: PhysicsImpostor): number;
  112257. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112258. sleepBody(impostor: PhysicsImpostor): void;
  112259. wakeUpBody(impostor: PhysicsImpostor): void;
  112260. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112261. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  112262. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112263. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112264. getRadius(impostor: PhysicsImpostor): number;
  112265. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112266. dispose(): void;
  112267. /**
  112268. * Does a raycast in the physics world
  112269. * @param from when should the ray start?
  112270. * @param to when should the ray end?
  112271. * @returns PhysicsRaycastResult
  112272. */
  112273. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112274. }
  112275. }
  112276. declare module BABYLON {
  112277. /**
  112278. * Class containing static functions to help procedurally build meshes
  112279. */
  112280. export class RibbonBuilder {
  112281. /**
  112282. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  112283. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  112284. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  112285. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  112286. * * 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
  112287. * * 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
  112288. * * 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
  112289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112290. * * 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
  112291. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  112292. * * 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
  112293. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  112294. * * 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
  112295. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  112296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112297. * @param name defines the name of the mesh
  112298. * @param options defines the options used to create the mesh
  112299. * @param scene defines the hosting scene
  112300. * @returns the ribbon mesh
  112301. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  112302. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112303. */
  112304. static CreateRibbon(name: string, options: {
  112305. pathArray: Vector3[][];
  112306. closeArray?: boolean;
  112307. closePath?: boolean;
  112308. offset?: number;
  112309. updatable?: boolean;
  112310. sideOrientation?: number;
  112311. frontUVs?: Vector4;
  112312. backUVs?: Vector4;
  112313. instance?: Mesh;
  112314. invertUV?: boolean;
  112315. uvs?: Vector2[];
  112316. colors?: Color4[];
  112317. }, scene?: Nullable<Scene>): Mesh;
  112318. }
  112319. }
  112320. declare module BABYLON {
  112321. /**
  112322. * Class containing static functions to help procedurally build meshes
  112323. */
  112324. export class ShapeBuilder {
  112325. /**
  112326. * 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.
  112327. * * 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.
  112328. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  112329. * * 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.
  112330. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  112331. * * 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
  112332. * * 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
  112333. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  112334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112335. * * 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
  112336. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  112337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112338. * @param name defines the name of the mesh
  112339. * @param options defines the options used to create the mesh
  112340. * @param scene defines the hosting scene
  112341. * @returns the extruded shape mesh
  112342. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112343. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  112344. */
  112345. static ExtrudeShape(name: string, options: {
  112346. shape: Vector3[];
  112347. path: Vector3[];
  112348. scale?: number;
  112349. rotation?: number;
  112350. cap?: number;
  112351. updatable?: boolean;
  112352. sideOrientation?: number;
  112353. frontUVs?: Vector4;
  112354. backUVs?: Vector4;
  112355. instance?: Mesh;
  112356. invertUV?: boolean;
  112357. }, scene?: Nullable<Scene>): Mesh;
  112358. /**
  112359. * Creates an custom extruded shape mesh.
  112360. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  112361. * * 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.
  112362. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  112363. * * 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
  112364. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  112365. * * 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
  112366. * * It must returns a float value that will be the scale value applied to the shape on each path point
  112367. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  112368. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  112369. * * 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
  112370. * * 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
  112371. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  112372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112373. * * 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
  112374. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  112375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112376. * @param name defines the name of the mesh
  112377. * @param options defines the options used to create the mesh
  112378. * @param scene defines the hosting scene
  112379. * @returns the custom extruded shape mesh
  112380. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  112381. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112382. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  112383. */
  112384. static ExtrudeShapeCustom(name: string, options: {
  112385. shape: Vector3[];
  112386. path: Vector3[];
  112387. scaleFunction?: any;
  112388. rotationFunction?: any;
  112389. ribbonCloseArray?: boolean;
  112390. ribbonClosePath?: boolean;
  112391. cap?: number;
  112392. updatable?: boolean;
  112393. sideOrientation?: number;
  112394. frontUVs?: Vector4;
  112395. backUVs?: Vector4;
  112396. instance?: Mesh;
  112397. invertUV?: boolean;
  112398. }, scene?: Nullable<Scene>): Mesh;
  112399. private static _ExtrudeShapeGeneric;
  112400. }
  112401. }
  112402. declare module BABYLON {
  112403. /**
  112404. * AmmoJS Physics plugin
  112405. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112406. * @see https://github.com/kripken/ammo.js/
  112407. */
  112408. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  112409. private _useDeltaForWorldStep;
  112410. /**
  112411. * Reference to the Ammo library
  112412. */
  112413. bjsAMMO: any;
  112414. /**
  112415. * Created ammoJS world which physics bodies are added to
  112416. */
  112417. world: any;
  112418. /**
  112419. * Name of the plugin
  112420. */
  112421. name: string;
  112422. private _timeStep;
  112423. private _fixedTimeStep;
  112424. private _maxSteps;
  112425. private _tmpQuaternion;
  112426. private _tmpAmmoTransform;
  112427. private _tmpAmmoQuaternion;
  112428. private _tmpAmmoConcreteContactResultCallback;
  112429. private _collisionConfiguration;
  112430. private _dispatcher;
  112431. private _overlappingPairCache;
  112432. private _solver;
  112433. private _softBodySolver;
  112434. private _tmpAmmoVectorA;
  112435. private _tmpAmmoVectorB;
  112436. private _tmpAmmoVectorC;
  112437. private _tmpAmmoVectorD;
  112438. private _tmpContactCallbackResult;
  112439. private _tmpAmmoVectorRCA;
  112440. private _tmpAmmoVectorRCB;
  112441. private _raycastResult;
  112442. private static readonly DISABLE_COLLISION_FLAG;
  112443. private static readonly KINEMATIC_FLAG;
  112444. private static readonly DISABLE_DEACTIVATION_FLAG;
  112445. /**
  112446. * Initializes the ammoJS plugin
  112447. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  112448. * @param ammoInjection can be used to inject your own ammo reference
  112449. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  112450. */
  112451. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  112452. /**
  112453. * Sets the gravity of the physics world (m/(s^2))
  112454. * @param gravity Gravity to set
  112455. */
  112456. setGravity(gravity: Vector3): void;
  112457. /**
  112458. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  112459. * @param timeStep timestep to use in seconds
  112460. */
  112461. setTimeStep(timeStep: number): void;
  112462. /**
  112463. * 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)
  112464. * @param fixedTimeStep fixedTimeStep to use in seconds
  112465. */
  112466. setFixedTimeStep(fixedTimeStep: number): void;
  112467. /**
  112468. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  112469. * @param maxSteps the maximum number of steps by the physics engine per frame
  112470. */
  112471. setMaxSteps(maxSteps: number): void;
  112472. /**
  112473. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  112474. * @returns the current timestep in seconds
  112475. */
  112476. getTimeStep(): number;
  112477. private _isImpostorInContact;
  112478. private _isImpostorPairInContact;
  112479. private _stepSimulation;
  112480. /**
  112481. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  112482. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  112483. * After the step the babylon meshes are set to the position of the physics imposters
  112484. * @param delta amount of time to step forward
  112485. * @param impostors array of imposters to update before/after the step
  112486. */
  112487. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112488. /**
  112489. * Update babylon mesh to match physics world object
  112490. * @param impostor imposter to match
  112491. */
  112492. private _afterSoftStep;
  112493. /**
  112494. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112495. * @param impostor imposter to match
  112496. */
  112497. private _ropeStep;
  112498. /**
  112499. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112500. * @param impostor imposter to match
  112501. */
  112502. private _softbodyOrClothStep;
  112503. private _tmpVector;
  112504. private _tmpMatrix;
  112505. /**
  112506. * Applies an impulse on the imposter
  112507. * @param impostor imposter to apply impulse to
  112508. * @param force amount of force to be applied to the imposter
  112509. * @param contactPoint the location to apply the impulse on the imposter
  112510. */
  112511. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112512. /**
  112513. * Applies a force on the imposter
  112514. * @param impostor imposter to apply force
  112515. * @param force amount of force to be applied to the imposter
  112516. * @param contactPoint the location to apply the force on the imposter
  112517. */
  112518. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112519. /**
  112520. * Creates a physics body using the plugin
  112521. * @param impostor the imposter to create the physics body on
  112522. */
  112523. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112524. /**
  112525. * Removes the physics body from the imposter and disposes of the body's memory
  112526. * @param impostor imposter to remove the physics body from
  112527. */
  112528. removePhysicsBody(impostor: PhysicsImpostor): void;
  112529. /**
  112530. * Generates a joint
  112531. * @param impostorJoint the imposter joint to create the joint with
  112532. */
  112533. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112534. /**
  112535. * Removes a joint
  112536. * @param impostorJoint the imposter joint to remove the joint from
  112537. */
  112538. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112539. private _addMeshVerts;
  112540. /**
  112541. * Initialise the soft body vertices to match its object's (mesh) vertices
  112542. * Softbody vertices (nodes) are in world space and to match this
  112543. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  112544. * @param impostor to create the softbody for
  112545. */
  112546. private _softVertexData;
  112547. /**
  112548. * Create an impostor's soft body
  112549. * @param impostor to create the softbody for
  112550. */
  112551. private _createSoftbody;
  112552. /**
  112553. * Create cloth for an impostor
  112554. * @param impostor to create the softbody for
  112555. */
  112556. private _createCloth;
  112557. /**
  112558. * Create rope for an impostor
  112559. * @param impostor to create the softbody for
  112560. */
  112561. private _createRope;
  112562. private _addHullVerts;
  112563. private _createShape;
  112564. /**
  112565. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  112566. * @param impostor imposter containing the physics body and babylon object
  112567. */
  112568. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112569. /**
  112570. * Sets the babylon object's position/rotation from the physics body's position/rotation
  112571. * @param impostor imposter containing the physics body and babylon object
  112572. * @param newPosition new position
  112573. * @param newRotation new rotation
  112574. */
  112575. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112576. /**
  112577. * If this plugin is supported
  112578. * @returns true if its supported
  112579. */
  112580. isSupported(): boolean;
  112581. /**
  112582. * Sets the linear velocity of the physics body
  112583. * @param impostor imposter to set the velocity on
  112584. * @param velocity velocity to set
  112585. */
  112586. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112587. /**
  112588. * Sets the angular velocity of the physics body
  112589. * @param impostor imposter to set the velocity on
  112590. * @param velocity velocity to set
  112591. */
  112592. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112593. /**
  112594. * gets the linear velocity
  112595. * @param impostor imposter to get linear velocity from
  112596. * @returns linear velocity
  112597. */
  112598. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112599. /**
  112600. * gets the angular velocity
  112601. * @param impostor imposter to get angular velocity from
  112602. * @returns angular velocity
  112603. */
  112604. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112605. /**
  112606. * Sets the mass of physics body
  112607. * @param impostor imposter to set the mass on
  112608. * @param mass mass to set
  112609. */
  112610. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112611. /**
  112612. * Gets the mass of the physics body
  112613. * @param impostor imposter to get the mass from
  112614. * @returns mass
  112615. */
  112616. getBodyMass(impostor: PhysicsImpostor): number;
  112617. /**
  112618. * Gets friction of the impostor
  112619. * @param impostor impostor to get friction from
  112620. * @returns friction value
  112621. */
  112622. getBodyFriction(impostor: PhysicsImpostor): number;
  112623. /**
  112624. * Sets friction of the impostor
  112625. * @param impostor impostor to set friction on
  112626. * @param friction friction value
  112627. */
  112628. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112629. /**
  112630. * Gets restitution of the impostor
  112631. * @param impostor impostor to get restitution from
  112632. * @returns restitution value
  112633. */
  112634. getBodyRestitution(impostor: PhysicsImpostor): number;
  112635. /**
  112636. * Sets resitution of the impostor
  112637. * @param impostor impostor to set resitution on
  112638. * @param restitution resitution value
  112639. */
  112640. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112641. /**
  112642. * Gets pressure inside the impostor
  112643. * @param impostor impostor to get pressure from
  112644. * @returns pressure value
  112645. */
  112646. getBodyPressure(impostor: PhysicsImpostor): number;
  112647. /**
  112648. * Sets pressure inside a soft body impostor
  112649. * Cloth and rope must remain 0 pressure
  112650. * @param impostor impostor to set pressure on
  112651. * @param pressure pressure value
  112652. */
  112653. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  112654. /**
  112655. * Gets stiffness of the impostor
  112656. * @param impostor impostor to get stiffness from
  112657. * @returns pressure value
  112658. */
  112659. getBodyStiffness(impostor: PhysicsImpostor): number;
  112660. /**
  112661. * Sets stiffness of the impostor
  112662. * @param impostor impostor to set stiffness on
  112663. * @param stiffness stiffness value from 0 to 1
  112664. */
  112665. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  112666. /**
  112667. * Gets velocityIterations of the impostor
  112668. * @param impostor impostor to get velocity iterations from
  112669. * @returns velocityIterations value
  112670. */
  112671. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  112672. /**
  112673. * Sets velocityIterations of the impostor
  112674. * @param impostor impostor to set velocity iterations on
  112675. * @param velocityIterations velocityIterations value
  112676. */
  112677. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  112678. /**
  112679. * Gets positionIterations of the impostor
  112680. * @param impostor impostor to get position iterations from
  112681. * @returns positionIterations value
  112682. */
  112683. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  112684. /**
  112685. * Sets positionIterations of the impostor
  112686. * @param impostor impostor to set position on
  112687. * @param positionIterations positionIterations value
  112688. */
  112689. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  112690. /**
  112691. * Append an anchor to a cloth object
  112692. * @param impostor is the cloth impostor to add anchor to
  112693. * @param otherImpostor is the rigid impostor to anchor to
  112694. * @param width ratio across width from 0 to 1
  112695. * @param height ratio up height from 0 to 1
  112696. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  112697. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112698. */
  112699. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112700. /**
  112701. * Append an hook to a rope object
  112702. * @param impostor is the rope impostor to add hook to
  112703. * @param otherImpostor is the rigid impostor to hook to
  112704. * @param length ratio along the rope from 0 to 1
  112705. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  112706. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112707. */
  112708. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112709. /**
  112710. * Sleeps the physics body and stops it from being active
  112711. * @param impostor impostor to sleep
  112712. */
  112713. sleepBody(impostor: PhysicsImpostor): void;
  112714. /**
  112715. * Activates the physics body
  112716. * @param impostor impostor to activate
  112717. */
  112718. wakeUpBody(impostor: PhysicsImpostor): void;
  112719. /**
  112720. * Updates the distance parameters of the joint
  112721. * @param joint joint to update
  112722. * @param maxDistance maximum distance of the joint
  112723. * @param minDistance minimum distance of the joint
  112724. */
  112725. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112726. /**
  112727. * Sets a motor on the joint
  112728. * @param joint joint to set motor on
  112729. * @param speed speed of the motor
  112730. * @param maxForce maximum force of the motor
  112731. * @param motorIndex index of the motor
  112732. */
  112733. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  112734. /**
  112735. * Sets the motors limit
  112736. * @param joint joint to set limit on
  112737. * @param upperLimit upper limit
  112738. * @param lowerLimit lower limit
  112739. */
  112740. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  112741. /**
  112742. * Syncs the position and rotation of a mesh with the impostor
  112743. * @param mesh mesh to sync
  112744. * @param impostor impostor to update the mesh with
  112745. */
  112746. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112747. /**
  112748. * Gets the radius of the impostor
  112749. * @param impostor impostor to get radius from
  112750. * @returns the radius
  112751. */
  112752. getRadius(impostor: PhysicsImpostor): number;
  112753. /**
  112754. * Gets the box size of the impostor
  112755. * @param impostor impostor to get box size from
  112756. * @param result the resulting box size
  112757. */
  112758. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112759. /**
  112760. * Disposes of the impostor
  112761. */
  112762. dispose(): void;
  112763. /**
  112764. * Does a raycast in the physics world
  112765. * @param from when should the ray start?
  112766. * @param to when should the ray end?
  112767. * @returns PhysicsRaycastResult
  112768. */
  112769. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112770. }
  112771. }
  112772. declare module BABYLON {
  112773. interface AbstractScene {
  112774. /**
  112775. * The list of reflection probes added to the scene
  112776. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112777. */
  112778. reflectionProbes: Array<ReflectionProbe>;
  112779. /**
  112780. * Removes the given reflection probe from this scene.
  112781. * @param toRemove The reflection probe to remove
  112782. * @returns The index of the removed reflection probe
  112783. */
  112784. removeReflectionProbe(toRemove: ReflectionProbe): number;
  112785. /**
  112786. * Adds the given reflection probe to this scene.
  112787. * @param newReflectionProbe The reflection probe to add
  112788. */
  112789. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  112790. }
  112791. /**
  112792. * Class used to generate realtime reflection / refraction cube textures
  112793. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112794. */
  112795. export class ReflectionProbe {
  112796. /** defines the name of the probe */
  112797. name: string;
  112798. private _scene;
  112799. private _renderTargetTexture;
  112800. private _projectionMatrix;
  112801. private _viewMatrix;
  112802. private _target;
  112803. private _add;
  112804. private _attachedMesh;
  112805. private _invertYAxis;
  112806. /** Gets or sets probe position (center of the cube map) */
  112807. position: Vector3;
  112808. /**
  112809. * Creates a new reflection probe
  112810. * @param name defines the name of the probe
  112811. * @param size defines the texture resolution (for each face)
  112812. * @param scene defines the hosting scene
  112813. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  112814. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  112815. */
  112816. constructor(
  112817. /** defines the name of the probe */
  112818. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  112819. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  112820. samples: number;
  112821. /** Gets or sets the refresh rate to use (on every frame by default) */
  112822. refreshRate: number;
  112823. /**
  112824. * Gets the hosting scene
  112825. * @returns a Scene
  112826. */
  112827. getScene(): Scene;
  112828. /** Gets the internal CubeTexture used to render to */
  112829. readonly cubeTexture: RenderTargetTexture;
  112830. /** Gets the list of meshes to render */
  112831. readonly renderList: Nullable<AbstractMesh[]>;
  112832. /**
  112833. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  112834. * @param mesh defines the mesh to attach to
  112835. */
  112836. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112837. /**
  112838. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  112839. * @param renderingGroupId The rendering group id corresponding to its index
  112840. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  112841. */
  112842. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  112843. /**
  112844. * Clean all associated resources
  112845. */
  112846. dispose(): void;
  112847. /**
  112848. * Converts the reflection probe information to a readable string for debug purpose.
  112849. * @param fullDetails Supports for multiple levels of logging within scene loading
  112850. * @returns the human readable reflection probe info
  112851. */
  112852. toString(fullDetails?: boolean): string;
  112853. /**
  112854. * Get the class name of the relfection probe.
  112855. * @returns "ReflectionProbe"
  112856. */
  112857. getClassName(): string;
  112858. /**
  112859. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  112860. * @returns The JSON representation of the texture
  112861. */
  112862. serialize(): any;
  112863. /**
  112864. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  112865. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  112866. * @param scene Define the scene the parsed reflection probe should be instantiated in
  112867. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  112868. * @returns The parsed reflection probe if successful
  112869. */
  112870. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  112871. }
  112872. }
  112873. declare module BABYLON {
  112874. /** @hidden */
  112875. export var _BabylonLoaderRegistered: boolean;
  112876. }
  112877. declare module BABYLON {
  112878. /**
  112879. * The Physically based simple base material of BJS.
  112880. *
  112881. * This enables better naming and convention enforcements on top of the pbrMaterial.
  112882. * It is used as the base class for both the specGloss and metalRough conventions.
  112883. */
  112884. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  112885. /**
  112886. * Number of Simultaneous lights allowed on the material.
  112887. */
  112888. maxSimultaneousLights: number;
  112889. /**
  112890. * If sets to true, disables all the lights affecting the material.
  112891. */
  112892. disableLighting: boolean;
  112893. /**
  112894. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  112895. */
  112896. environmentTexture: BaseTexture;
  112897. /**
  112898. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  112899. */
  112900. invertNormalMapX: boolean;
  112901. /**
  112902. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  112903. */
  112904. invertNormalMapY: boolean;
  112905. /**
  112906. * Normal map used in the model.
  112907. */
  112908. normalTexture: BaseTexture;
  112909. /**
  112910. * Emissivie color used to self-illuminate the model.
  112911. */
  112912. emissiveColor: Color3;
  112913. /**
  112914. * Emissivie texture used to self-illuminate the model.
  112915. */
  112916. emissiveTexture: BaseTexture;
  112917. /**
  112918. * Occlusion Channel Strenght.
  112919. */
  112920. occlusionStrength: number;
  112921. /**
  112922. * Occlusion Texture of the material (adding extra occlusion effects).
  112923. */
  112924. occlusionTexture: BaseTexture;
  112925. /**
  112926. * Defines the alpha limits in alpha test mode.
  112927. */
  112928. alphaCutOff: number;
  112929. /**
  112930. * Gets the current double sided mode.
  112931. */
  112932. /**
  112933. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  112934. */
  112935. doubleSided: boolean;
  112936. /**
  112937. * Stores the pre-calculated light information of a mesh in a texture.
  112938. */
  112939. lightmapTexture: BaseTexture;
  112940. /**
  112941. * If true, the light map contains occlusion information instead of lighting info.
  112942. */
  112943. useLightmapAsShadowmap: boolean;
  112944. /**
  112945. * Instantiates a new PBRMaterial instance.
  112946. *
  112947. * @param name The material name
  112948. * @param scene The scene the material will be use in.
  112949. */
  112950. constructor(name: string, scene: Scene);
  112951. getClassName(): string;
  112952. }
  112953. }
  112954. declare module BABYLON {
  112955. /**
  112956. * The PBR material of BJS following the metal roughness convention.
  112957. *
  112958. * This fits to the PBR convention in the GLTF definition:
  112959. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  112960. */
  112961. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  112962. /**
  112963. * The base color has two different interpretations depending on the value of metalness.
  112964. * When the material is a metal, the base color is the specific measured reflectance value
  112965. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  112966. * of the material.
  112967. */
  112968. baseColor: Color3;
  112969. /**
  112970. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  112971. * well as opacity information in the alpha channel.
  112972. */
  112973. baseTexture: BaseTexture;
  112974. /**
  112975. * Specifies the metallic scalar value of the material.
  112976. * Can also be used to scale the metalness values of the metallic texture.
  112977. */
  112978. metallic: number;
  112979. /**
  112980. * Specifies the roughness scalar value of the material.
  112981. * Can also be used to scale the roughness values of the metallic texture.
  112982. */
  112983. roughness: number;
  112984. /**
  112985. * Texture containing both the metallic value in the B channel and the
  112986. * roughness value in the G channel to keep better precision.
  112987. */
  112988. metallicRoughnessTexture: BaseTexture;
  112989. /**
  112990. * Instantiates a new PBRMetalRoughnessMaterial instance.
  112991. *
  112992. * @param name The material name
  112993. * @param scene The scene the material will be use in.
  112994. */
  112995. constructor(name: string, scene: Scene);
  112996. /**
  112997. * Return the currrent class name of the material.
  112998. */
  112999. getClassName(): string;
  113000. /**
  113001. * Makes a duplicate of the current material.
  113002. * @param name - name to use for the new material.
  113003. */
  113004. clone(name: string): PBRMetallicRoughnessMaterial;
  113005. /**
  113006. * Serialize the material to a parsable JSON object.
  113007. */
  113008. serialize(): any;
  113009. /**
  113010. * Parses a JSON object correponding to the serialize function.
  113011. */
  113012. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  113013. }
  113014. }
  113015. declare module BABYLON {
  113016. /**
  113017. * The PBR material of BJS following the specular glossiness convention.
  113018. *
  113019. * This fits to the PBR convention in the GLTF definition:
  113020. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  113021. */
  113022. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  113023. /**
  113024. * Specifies the diffuse color of the material.
  113025. */
  113026. diffuseColor: Color3;
  113027. /**
  113028. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  113029. * channel.
  113030. */
  113031. diffuseTexture: BaseTexture;
  113032. /**
  113033. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  113034. */
  113035. specularColor: Color3;
  113036. /**
  113037. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  113038. */
  113039. glossiness: number;
  113040. /**
  113041. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  113042. */
  113043. specularGlossinessTexture: BaseTexture;
  113044. /**
  113045. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  113046. *
  113047. * @param name The material name
  113048. * @param scene The scene the material will be use in.
  113049. */
  113050. constructor(name: string, scene: Scene);
  113051. /**
  113052. * Return the currrent class name of the material.
  113053. */
  113054. getClassName(): string;
  113055. /**
  113056. * Makes a duplicate of the current material.
  113057. * @param name - name to use for the new material.
  113058. */
  113059. clone(name: string): PBRSpecularGlossinessMaterial;
  113060. /**
  113061. * Serialize the material to a parsable JSON object.
  113062. */
  113063. serialize(): any;
  113064. /**
  113065. * Parses a JSON object correponding to the serialize function.
  113066. */
  113067. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  113068. }
  113069. }
  113070. declare module BABYLON {
  113071. /**
  113072. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  113073. * It can help converting any input color in a desired output one. This can then be used to create effects
  113074. * from sepia, black and white to sixties or futuristic rendering...
  113075. *
  113076. * The only supported format is currently 3dl.
  113077. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  113078. */
  113079. export class ColorGradingTexture extends BaseTexture {
  113080. /**
  113081. * The current texture matrix. (will always be identity in color grading texture)
  113082. */
  113083. private _textureMatrix;
  113084. /**
  113085. * The texture URL.
  113086. */
  113087. url: string;
  113088. /**
  113089. * Empty line regex stored for GC.
  113090. */
  113091. private static _noneEmptyLineRegex;
  113092. private _engine;
  113093. /**
  113094. * Instantiates a ColorGradingTexture from the following parameters.
  113095. *
  113096. * @param url The location of the color gradind data (currently only supporting 3dl)
  113097. * @param scene The scene the texture will be used in
  113098. */
  113099. constructor(url: string, scene: Scene);
  113100. /**
  113101. * Returns the texture matrix used in most of the material.
  113102. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  113103. */
  113104. getTextureMatrix(): Matrix;
  113105. /**
  113106. * Occurs when the file being loaded is a .3dl LUT file.
  113107. */
  113108. private load3dlTexture;
  113109. /**
  113110. * Starts the loading process of the texture.
  113111. */
  113112. private loadTexture;
  113113. /**
  113114. * Clones the color gradind texture.
  113115. */
  113116. clone(): ColorGradingTexture;
  113117. /**
  113118. * Called during delayed load for textures.
  113119. */
  113120. delayLoad(): void;
  113121. /**
  113122. * Parses a color grading texture serialized by Babylon.
  113123. * @param parsedTexture The texture information being parsedTexture
  113124. * @param scene The scene to load the texture in
  113125. * @param rootUrl The root url of the data assets to load
  113126. * @return A color gradind texture
  113127. */
  113128. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  113129. /**
  113130. * Serializes the LUT texture to json format.
  113131. */
  113132. serialize(): any;
  113133. }
  113134. }
  113135. declare module BABYLON {
  113136. /**
  113137. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  113138. */
  113139. export class EquiRectangularCubeTexture extends BaseTexture {
  113140. /** The six faces of the cube. */
  113141. private static _FacesMapping;
  113142. private _noMipmap;
  113143. private _onLoad;
  113144. private _onError;
  113145. /** The size of the cubemap. */
  113146. private _size;
  113147. /** The buffer of the image. */
  113148. private _buffer;
  113149. /** The width of the input image. */
  113150. private _width;
  113151. /** The height of the input image. */
  113152. private _height;
  113153. /** The URL to the image. */
  113154. url: string;
  113155. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  113156. coordinatesMode: number;
  113157. /**
  113158. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  113159. * @param url The location of the image
  113160. * @param scene The scene the texture will be used in
  113161. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  113162. * @param noMipmap Forces to not generate the mipmap if true
  113163. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  113164. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  113165. * @param onLoad — defines a callback called when texture is loaded
  113166. * @param onError — defines a callback called if there is an error
  113167. */
  113168. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  113169. /**
  113170. * Load the image data, by putting the image on a canvas and extracting its buffer.
  113171. */
  113172. private loadImage;
  113173. /**
  113174. * Convert the image buffer into a cubemap and create a CubeTexture.
  113175. */
  113176. private loadTexture;
  113177. /**
  113178. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  113179. * @param buffer The ArrayBuffer that should be converted.
  113180. * @returns The buffer as Float32Array.
  113181. */
  113182. private getFloat32ArrayFromArrayBuffer;
  113183. /**
  113184. * Get the current class name of the texture useful for serialization or dynamic coding.
  113185. * @returns "EquiRectangularCubeTexture"
  113186. */
  113187. getClassName(): string;
  113188. /**
  113189. * Create a clone of the current EquiRectangularCubeTexture and return it.
  113190. * @returns A clone of the current EquiRectangularCubeTexture.
  113191. */
  113192. clone(): EquiRectangularCubeTexture;
  113193. }
  113194. }
  113195. declare module BABYLON {
  113196. /**
  113197. * Based on jsTGALoader - Javascript loader for TGA file
  113198. * By Vincent Thibault
  113199. * @see http://blog.robrowser.com/javascript-tga-loader.html
  113200. */
  113201. export class TGATools {
  113202. private static _TYPE_INDEXED;
  113203. private static _TYPE_RGB;
  113204. private static _TYPE_GREY;
  113205. private static _TYPE_RLE_INDEXED;
  113206. private static _TYPE_RLE_RGB;
  113207. private static _TYPE_RLE_GREY;
  113208. private static _ORIGIN_MASK;
  113209. private static _ORIGIN_SHIFT;
  113210. private static _ORIGIN_BL;
  113211. private static _ORIGIN_BR;
  113212. private static _ORIGIN_UL;
  113213. private static _ORIGIN_UR;
  113214. /**
  113215. * Gets the header of a TGA file
  113216. * @param data defines the TGA data
  113217. * @returns the header
  113218. */
  113219. static GetTGAHeader(data: Uint8Array): any;
  113220. /**
  113221. * Uploads TGA content to a Babylon Texture
  113222. * @hidden
  113223. */
  113224. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  113225. /** @hidden */
  113226. 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;
  113227. /** @hidden */
  113228. 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;
  113229. /** @hidden */
  113230. 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;
  113231. /** @hidden */
  113232. 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;
  113233. /** @hidden */
  113234. 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;
  113235. /** @hidden */
  113236. 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;
  113237. }
  113238. }
  113239. declare module BABYLON {
  113240. /**
  113241. * Implementation of the TGA Texture Loader.
  113242. * @hidden
  113243. */
  113244. export class _TGATextureLoader implements IInternalTextureLoader {
  113245. /**
  113246. * Defines wether the loader supports cascade loading the different faces.
  113247. */
  113248. readonly supportCascades: boolean;
  113249. /**
  113250. * This returns if the loader support the current file information.
  113251. * @param extension defines the file extension of the file being loaded
  113252. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113253. * @param fallback defines the fallback internal texture if any
  113254. * @param isBase64 defines whether the texture is encoded as a base64
  113255. * @param isBuffer defines whether the texture data are stored as a buffer
  113256. * @returns true if the loader can load the specified file
  113257. */
  113258. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113259. /**
  113260. * Transform the url before loading if required.
  113261. * @param rootUrl the url of the texture
  113262. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113263. * @returns the transformed texture
  113264. */
  113265. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113266. /**
  113267. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113268. * @param rootUrl the url of the texture
  113269. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113270. * @returns the fallback texture
  113271. */
  113272. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113273. /**
  113274. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113275. * @param data contains the texture data
  113276. * @param texture defines the BabylonJS internal texture
  113277. * @param createPolynomials will be true if polynomials have been requested
  113278. * @param onLoad defines the callback to trigger once the texture is ready
  113279. * @param onError defines the callback to trigger in case of error
  113280. */
  113281. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113282. /**
  113283. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113284. * @param data contains the texture data
  113285. * @param texture defines the BabylonJS internal texture
  113286. * @param callback defines the method to call once ready to upload
  113287. */
  113288. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113289. }
  113290. }
  113291. declare module BABYLON {
  113292. /**
  113293. * Info about the .basis files
  113294. */
  113295. class BasisFileInfo {
  113296. /**
  113297. * If the file has alpha
  113298. */
  113299. hasAlpha: boolean;
  113300. /**
  113301. * Info about each image of the basis file
  113302. */
  113303. images: Array<{
  113304. levels: Array<{
  113305. width: number;
  113306. height: number;
  113307. transcodedPixels: ArrayBufferView;
  113308. }>;
  113309. }>;
  113310. }
  113311. /**
  113312. * Result of transcoding a basis file
  113313. */
  113314. class TranscodeResult {
  113315. /**
  113316. * Info about the .basis file
  113317. */
  113318. fileInfo: BasisFileInfo;
  113319. /**
  113320. * Format to use when loading the file
  113321. */
  113322. format: number;
  113323. }
  113324. /**
  113325. * Configuration options for the Basis transcoder
  113326. */
  113327. export class BasisTranscodeConfiguration {
  113328. /**
  113329. * Supported compression formats used to determine the supported output format of the transcoder
  113330. */
  113331. supportedCompressionFormats?: {
  113332. /**
  113333. * etc1 compression format
  113334. */
  113335. etc1?: boolean;
  113336. /**
  113337. * s3tc compression format
  113338. */
  113339. s3tc?: boolean;
  113340. /**
  113341. * pvrtc compression format
  113342. */
  113343. pvrtc?: boolean;
  113344. /**
  113345. * etc2 compression format
  113346. */
  113347. etc2?: boolean;
  113348. };
  113349. /**
  113350. * If mipmap levels should be loaded for transcoded images (Default: true)
  113351. */
  113352. loadMipmapLevels?: boolean;
  113353. /**
  113354. * Index of a single image to load (Default: all images)
  113355. */
  113356. loadSingleImage?: number;
  113357. }
  113358. /**
  113359. * Used to load .Basis files
  113360. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  113361. */
  113362. export class BasisTools {
  113363. private static _IgnoreSupportedFormats;
  113364. /**
  113365. * URL to use when loading the basis transcoder
  113366. */
  113367. static JSModuleURL: string;
  113368. /**
  113369. * URL to use when loading the wasm module for the transcoder
  113370. */
  113371. static WasmModuleURL: string;
  113372. /**
  113373. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  113374. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  113375. * @returns internal format corresponding to the Basis format
  113376. */
  113377. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  113378. private static _WorkerPromise;
  113379. private static _Worker;
  113380. private static _actionId;
  113381. private static _CreateWorkerAsync;
  113382. /**
  113383. * Transcodes a loaded image file to compressed pixel data
  113384. * @param imageData image data to transcode
  113385. * @param config configuration options for the transcoding
  113386. * @returns a promise resulting in the transcoded image
  113387. */
  113388. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  113389. /**
  113390. * Loads a texture from the transcode result
  113391. * @param texture texture load to
  113392. * @param transcodeResult the result of transcoding the basis file to load from
  113393. */
  113394. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  113395. }
  113396. }
  113397. declare module BABYLON {
  113398. /**
  113399. * Loader for .basis file format
  113400. */
  113401. export class _BasisTextureLoader implements IInternalTextureLoader {
  113402. /**
  113403. * Defines whether the loader supports cascade loading the different faces.
  113404. */
  113405. readonly supportCascades: boolean;
  113406. /**
  113407. * This returns if the loader support the current file information.
  113408. * @param extension defines the file extension of the file being loaded
  113409. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113410. * @param fallback defines the fallback internal texture if any
  113411. * @param isBase64 defines whether the texture is encoded as a base64
  113412. * @param isBuffer defines whether the texture data are stored as a buffer
  113413. * @returns true if the loader can load the specified file
  113414. */
  113415. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113416. /**
  113417. * Transform the url before loading if required.
  113418. * @param rootUrl the url of the texture
  113419. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113420. * @returns the transformed texture
  113421. */
  113422. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113423. /**
  113424. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113425. * @param rootUrl the url of the texture
  113426. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113427. * @returns the fallback texture
  113428. */
  113429. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113430. /**
  113431. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  113432. * @param data contains the texture data
  113433. * @param texture defines the BabylonJS internal texture
  113434. * @param createPolynomials will be true if polynomials have been requested
  113435. * @param onLoad defines the callback to trigger once the texture is ready
  113436. * @param onError defines the callback to trigger in case of error
  113437. */
  113438. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113439. /**
  113440. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113441. * @param data contains the texture data
  113442. * @param texture defines the BabylonJS internal texture
  113443. * @param callback defines the method to call once ready to upload
  113444. */
  113445. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113446. }
  113447. }
  113448. declare module BABYLON {
  113449. /**
  113450. * 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.
  113451. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  113452. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  113453. */
  113454. export class CustomProceduralTexture extends ProceduralTexture {
  113455. private _animate;
  113456. private _time;
  113457. private _config;
  113458. private _texturePath;
  113459. /**
  113460. * Instantiates a new Custom Procedural Texture.
  113461. * 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.
  113462. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  113463. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  113464. * @param name Define the name of the texture
  113465. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  113466. * @param size Define the size of the texture to create
  113467. * @param scene Define the scene the texture belongs to
  113468. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  113469. * @param generateMipMaps Define if the texture should creates mip maps or not
  113470. */
  113471. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  113472. private _loadJson;
  113473. /**
  113474. * Is the texture ready to be used ? (rendered at least once)
  113475. * @returns true if ready, otherwise, false.
  113476. */
  113477. isReady(): boolean;
  113478. /**
  113479. * Render the texture to its associated render target.
  113480. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  113481. */
  113482. render(useCameraPostProcess?: boolean): void;
  113483. /**
  113484. * Update the list of dependant textures samplers in the shader.
  113485. */
  113486. updateTextures(): void;
  113487. /**
  113488. * Update the uniform values of the procedural texture in the shader.
  113489. */
  113490. updateShaderUniforms(): void;
  113491. /**
  113492. * Define if the texture animates or not.
  113493. */
  113494. animate: boolean;
  113495. }
  113496. }
  113497. declare module BABYLON {
  113498. /** @hidden */
  113499. export var noisePixelShader: {
  113500. name: string;
  113501. shader: string;
  113502. };
  113503. }
  113504. declare module BABYLON {
  113505. /**
  113506. * Class used to generate noise procedural textures
  113507. */
  113508. export class NoiseProceduralTexture extends ProceduralTexture {
  113509. private _time;
  113510. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  113511. brightness: number;
  113512. /** Defines the number of octaves to process */
  113513. octaves: number;
  113514. /** Defines the level of persistence (0.8 by default) */
  113515. persistence: number;
  113516. /** Gets or sets animation speed factor (default is 1) */
  113517. animationSpeedFactor: number;
  113518. /**
  113519. * Creates a new NoiseProceduralTexture
  113520. * @param name defines the name fo the texture
  113521. * @param size defines the size of the texture (default is 256)
  113522. * @param scene defines the hosting scene
  113523. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  113524. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  113525. */
  113526. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  113527. private _updateShaderUniforms;
  113528. protected _getDefines(): string;
  113529. /** Generate the current state of the procedural texture */
  113530. render(useCameraPostProcess?: boolean): void;
  113531. /**
  113532. * Serializes this noise procedural texture
  113533. * @returns a serialized noise procedural texture object
  113534. */
  113535. serialize(): any;
  113536. /**
  113537. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  113538. * @param parsedTexture defines parsed texture data
  113539. * @param scene defines the current scene
  113540. * @param rootUrl defines the root URL containing noise procedural texture information
  113541. * @returns a parsed NoiseProceduralTexture
  113542. */
  113543. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  113544. }
  113545. }
  113546. declare module BABYLON {
  113547. /**
  113548. * Raw cube texture where the raw buffers are passed in
  113549. */
  113550. export class RawCubeTexture extends CubeTexture {
  113551. /**
  113552. * Creates a cube texture where the raw buffers are passed in.
  113553. * @param scene defines the scene the texture is attached to
  113554. * @param data defines the array of data to use to create each face
  113555. * @param size defines the size of the textures
  113556. * @param format defines the format of the data
  113557. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  113558. * @param generateMipMaps defines if the engine should generate the mip levels
  113559. * @param invertY defines if data must be stored with Y axis inverted
  113560. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  113561. * @param compression defines the compression used (null by default)
  113562. */
  113563. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  113564. /**
  113565. * Updates the raw cube texture.
  113566. * @param data defines the data to store
  113567. * @param format defines the data format
  113568. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  113569. * @param invertY defines if data must be stored with Y axis inverted
  113570. * @param compression defines the compression used (null by default)
  113571. * @param level defines which level of the texture to update
  113572. */
  113573. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  113574. /**
  113575. * Updates a raw cube texture with RGBD encoded data.
  113576. * @param data defines the array of data [mipmap][face] to use to create each face
  113577. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  113578. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  113579. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  113580. * @returns a promsie that resolves when the operation is complete
  113581. */
  113582. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  113583. /**
  113584. * Clones the raw cube texture.
  113585. * @return a new cube texture
  113586. */
  113587. clone(): CubeTexture;
  113588. /** @hidden */
  113589. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  113590. }
  113591. }
  113592. declare module BABYLON {
  113593. /**
  113594. * Class used to store 3D textures containing user data
  113595. */
  113596. export class RawTexture3D extends Texture {
  113597. /** Gets or sets the texture format to use */
  113598. format: number;
  113599. private _engine;
  113600. /**
  113601. * Create a new RawTexture3D
  113602. * @param data defines the data of the texture
  113603. * @param width defines the width of the texture
  113604. * @param height defines the height of the texture
  113605. * @param depth defines the depth of the texture
  113606. * @param format defines the texture format to use
  113607. * @param scene defines the hosting scene
  113608. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  113609. * @param invertY defines if texture must be stored with Y axis inverted
  113610. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  113611. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  113612. */
  113613. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  113614. /** Gets or sets the texture format to use */
  113615. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  113616. /**
  113617. * Update the texture with new data
  113618. * @param data defines the data to store in the texture
  113619. */
  113620. update(data: ArrayBufferView): void;
  113621. }
  113622. }
  113623. declare module BABYLON {
  113624. /**
  113625. * Creates a refraction texture used by refraction channel of the standard material.
  113626. * It is like a mirror but to see through a material.
  113627. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113628. */
  113629. export class RefractionTexture extends RenderTargetTexture {
  113630. /**
  113631. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  113632. * 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.
  113633. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113634. */
  113635. refractionPlane: Plane;
  113636. /**
  113637. * Define how deep under the surface we should see.
  113638. */
  113639. depth: number;
  113640. /**
  113641. * Creates a refraction texture used by refraction channel of the standard material.
  113642. * It is like a mirror but to see through a material.
  113643. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113644. * @param name Define the texture name
  113645. * @param size Define the size of the underlying texture
  113646. * @param scene Define the scene the refraction belongs to
  113647. * @param generateMipMaps Define if we need to generate mips level for the refraction
  113648. */
  113649. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  113650. /**
  113651. * Clone the refraction texture.
  113652. * @returns the cloned texture
  113653. */
  113654. clone(): RefractionTexture;
  113655. /**
  113656. * Serialize the texture to a JSON representation you could use in Parse later on
  113657. * @returns the serialized JSON representation
  113658. */
  113659. serialize(): any;
  113660. }
  113661. }
  113662. declare module BABYLON {
  113663. /**
  113664. * Defines the options related to the creation of an HtmlElementTexture
  113665. */
  113666. export interface IHtmlElementTextureOptions {
  113667. /**
  113668. * Defines wether mip maps should be created or not.
  113669. */
  113670. generateMipMaps?: boolean;
  113671. /**
  113672. * Defines the sampling mode of the texture.
  113673. */
  113674. samplingMode?: number;
  113675. /**
  113676. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  113677. */
  113678. engine: Nullable<Engine>;
  113679. /**
  113680. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  113681. */
  113682. scene: Nullable<Scene>;
  113683. }
  113684. /**
  113685. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  113686. * To be as efficient as possible depending on your constraints nothing aside the first upload
  113687. * is automatically managed.
  113688. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  113689. * in your application.
  113690. *
  113691. * As the update is not automatic, you need to call them manually.
  113692. */
  113693. export class HtmlElementTexture extends BaseTexture {
  113694. /**
  113695. * The texture URL.
  113696. */
  113697. element: HTMLVideoElement | HTMLCanvasElement;
  113698. private static readonly DefaultOptions;
  113699. private _textureMatrix;
  113700. private _engine;
  113701. private _isVideo;
  113702. private _generateMipMaps;
  113703. private _samplingMode;
  113704. /**
  113705. * Instantiates a HtmlElementTexture from the following parameters.
  113706. *
  113707. * @param name Defines the name of the texture
  113708. * @param element Defines the video or canvas the texture is filled with
  113709. * @param options Defines the other none mandatory texture creation options
  113710. */
  113711. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  113712. private _createInternalTexture;
  113713. /**
  113714. * Returns the texture matrix used in most of the material.
  113715. */
  113716. getTextureMatrix(): Matrix;
  113717. /**
  113718. * Updates the content of the texture.
  113719. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  113720. */
  113721. update(invertY?: Nullable<boolean>): void;
  113722. }
  113723. }
  113724. declare module BABYLON {
  113725. /**
  113726. * Enum used to define the target of a block
  113727. */
  113728. export enum NodeMaterialBlockTargets {
  113729. /** Vertex shader */
  113730. Vertex = 1,
  113731. /** Fragment shader */
  113732. Fragment = 2,
  113733. /** Neutral */
  113734. Neutral = 4,
  113735. /** Vertex and Fragment */
  113736. VertexAndFragment = 3
  113737. }
  113738. }
  113739. declare module BABYLON {
  113740. /**
  113741. * Defines the kind of connection point for node based material
  113742. */
  113743. export enum NodeMaterialBlockConnectionPointTypes {
  113744. /** Float */
  113745. Float = 1,
  113746. /** Int */
  113747. Int = 2,
  113748. /** Vector2 */
  113749. Vector2 = 4,
  113750. /** Vector3 */
  113751. Vector3 = 8,
  113752. /** Vector4 */
  113753. Vector4 = 16,
  113754. /** Color3 */
  113755. Color3 = 32,
  113756. /** Color4 */
  113757. Color4 = 64,
  113758. /** Matrix */
  113759. Matrix = 128,
  113760. /** Vector3 or Color3 */
  113761. Vector3OrColor3 = 40,
  113762. /** Vector3 or Vector4 */
  113763. Vector3OrVector4 = 24,
  113764. /** Vector4 or Color4 */
  113765. Vector4OrColor4 = 80,
  113766. /** Color3 or Color4 */
  113767. Color3OrColor4 = 96,
  113768. /** Vector2 or Color3 or Color4 */
  113769. Vector2OrColor3OrColor4 = 100,
  113770. /** Vector3 or Color3 or Color4 or Vector4 */
  113771. Vector3OrColor3OrVector4OrColor4 = 120,
  113772. /** Vector2 or Vector3 or Color3 or Color4 or Vector4 */
  113773. Vector2OrVector3OrColor3OrVector4OrColor4 = 124,
  113774. /** Detect type based on connection */
  113775. AutoDetect = 1024,
  113776. /** Output type that will be defined by input type */
  113777. BasedOnInput = 2048
  113778. }
  113779. }
  113780. declare module BABYLON {
  113781. /**
  113782. * Root class for all node material optimizers
  113783. */
  113784. export class NodeMaterialOptimizer {
  113785. /**
  113786. * Function used to optimize a NodeMaterial graph
  113787. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  113788. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  113789. */
  113790. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  113791. }
  113792. }
  113793. declare module BABYLON {
  113794. /**
  113795. * Block used to transform a vector4 with a matrix
  113796. */
  113797. export class Vector4TransformBlock extends NodeMaterialBlock {
  113798. /**
  113799. * Defines the value to use to complement Vector3 to transform it to a Vector4
  113800. */
  113801. complementW: number;
  113802. /**
  113803. * Creates a new Vector4TransformBlock
  113804. * @param name defines the block name
  113805. */
  113806. constructor(name: string);
  113807. /**
  113808. * Gets the current class name
  113809. * @returns the class name
  113810. */
  113811. getClassName(): string;
  113812. /**
  113813. * Gets the vector input
  113814. */
  113815. readonly vector: NodeMaterialConnectionPoint;
  113816. /**
  113817. * Gets the output component
  113818. */
  113819. readonly output: NodeMaterialConnectionPoint;
  113820. /**
  113821. * Gets the matrix transform input
  113822. */
  113823. readonly transform: NodeMaterialConnectionPoint;
  113824. protected _buildBlock(state: NodeMaterialBuildState): this;
  113825. }
  113826. }
  113827. declare module BABYLON {
  113828. /**
  113829. * Block used to output the vertex position
  113830. */
  113831. export class VertexOutputBlock extends NodeMaterialBlock {
  113832. /**
  113833. * Creates a new VertexOutputBlock
  113834. * @param name defines the block name
  113835. */
  113836. constructor(name: string);
  113837. /**
  113838. * Gets the current class name
  113839. * @returns the class name
  113840. */
  113841. getClassName(): string;
  113842. /**
  113843. * Gets the vector input component
  113844. */
  113845. readonly vector: NodeMaterialConnectionPoint;
  113846. protected _buildBlock(state: NodeMaterialBuildState): this;
  113847. }
  113848. }
  113849. declare module BABYLON {
  113850. /**
  113851. * Block used to output the final color
  113852. */
  113853. export class FragmentOutputBlock extends NodeMaterialBlock {
  113854. /**
  113855. * Gets or sets a boolean indicating if this block will output an alpha value
  113856. */
  113857. alphaBlendingEnabled: boolean;
  113858. /**
  113859. * Create a new FragmentOutputBlock
  113860. * @param name defines the block name
  113861. */
  113862. constructor(name: string);
  113863. /**
  113864. * Gets the current class name
  113865. * @returns the class name
  113866. */
  113867. getClassName(): string;
  113868. /**
  113869. * Gets the color input component
  113870. */
  113871. readonly color: NodeMaterialConnectionPoint;
  113872. protected _buildBlock(state: NodeMaterialBuildState): this;
  113873. }
  113874. }
  113875. declare module BABYLON {
  113876. /**
  113877. * Interface used to configure the node material editor
  113878. */
  113879. export interface INodeMaterialEditorOptions {
  113880. /** Define the URl to load node editor script */
  113881. editorURL?: string;
  113882. }
  113883. /** @hidden */
  113884. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  113885. /** BONES */
  113886. NUM_BONE_INFLUENCERS: number;
  113887. BonesPerMesh: number;
  113888. BONETEXTURE: boolean;
  113889. /** MORPH TARGETS */
  113890. MORPHTARGETS: boolean;
  113891. MORPHTARGETS_NORMAL: boolean;
  113892. MORPHTARGETS_TANGENT: boolean;
  113893. MORPHTARGETS_UV: boolean;
  113894. NUM_MORPH_INFLUENCERS: number;
  113895. /** IMAGE PROCESSING */
  113896. IMAGEPROCESSING: boolean;
  113897. VIGNETTE: boolean;
  113898. VIGNETTEBLENDMODEMULTIPLY: boolean;
  113899. VIGNETTEBLENDMODEOPAQUE: boolean;
  113900. TONEMAPPING: boolean;
  113901. TONEMAPPING_ACES: boolean;
  113902. CONTRAST: boolean;
  113903. EXPOSURE: boolean;
  113904. COLORCURVES: boolean;
  113905. COLORGRADING: boolean;
  113906. COLORGRADING3D: boolean;
  113907. SAMPLER3DGREENDEPTH: boolean;
  113908. SAMPLER3DBGRMAP: boolean;
  113909. IMAGEPROCESSINGPOSTPROCESS: boolean;
  113910. constructor();
  113911. setValue(name: string, value: boolean): void;
  113912. }
  113913. /**
  113914. * Class used to configure NodeMaterial
  113915. */
  113916. export interface INodeMaterialOptions {
  113917. /**
  113918. * Defines if blocks should emit comments
  113919. */
  113920. emitComments: boolean;
  113921. }
  113922. /**
  113923. * Class used to create a node based material built by assembling shader blocks
  113924. */
  113925. export class NodeMaterial extends PushMaterial {
  113926. private _options;
  113927. private _vertexCompilationState;
  113928. private _fragmentCompilationState;
  113929. private _sharedData;
  113930. private _buildId;
  113931. private _buildWasSuccessful;
  113932. private _cachedWorldViewMatrix;
  113933. private _cachedWorldViewProjectionMatrix;
  113934. private _optimizers;
  113935. /** Define the URl to load node editor script */
  113936. static EditorURL: string;
  113937. private BJSNODEMATERIALEDITOR;
  113938. /** Get the inspector from bundle or global */
  113939. private _getGlobalNodeMaterialEditor;
  113940. /**
  113941. * Defines the maximum number of lights that can be used in the material
  113942. */
  113943. maxSimultaneousLights: number;
  113944. /**
  113945. * Observable raised when the material is built
  113946. */
  113947. onBuildObservable: Observable<NodeMaterial>;
  113948. /**
  113949. * Gets or sets the root nodes of the material vertex shader
  113950. */
  113951. _vertexOutputNodes: NodeMaterialBlock[];
  113952. /**
  113953. * Gets or sets the root nodes of the material fragment (pixel) shader
  113954. */
  113955. _fragmentOutputNodes: NodeMaterialBlock[];
  113956. /** Gets or sets options to control the node material overall behavior */
  113957. options: INodeMaterialOptions;
  113958. /**
  113959. * Default configuration related to image processing available in the standard Material.
  113960. */
  113961. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113962. /**
  113963. * Gets the image processing configuration used either in this material.
  113964. */
  113965. /**
  113966. * Sets the Default image processing configuration used either in the this material.
  113967. *
  113968. * If sets to null, the scene one is in use.
  113969. */
  113970. imageProcessingConfiguration: ImageProcessingConfiguration;
  113971. /**
  113972. * Create a new node based material
  113973. * @param name defines the material name
  113974. * @param scene defines the hosting scene
  113975. * @param options defines creation option
  113976. */
  113977. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  113978. /**
  113979. * Gets the current class name of the material e.g. "NodeMaterial"
  113980. * @returns the class name
  113981. */
  113982. getClassName(): string;
  113983. /**
  113984. * Keep track of the image processing observer to allow dispose and replace.
  113985. */
  113986. private _imageProcessingObserver;
  113987. /**
  113988. * Attaches a new image processing configuration to the Standard Material.
  113989. * @param configuration
  113990. */
  113991. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113992. /**
  113993. * Adds a new optimizer to the list of optimizers
  113994. * @param optimizer defines the optimizers to add
  113995. * @returns the current material
  113996. */
  113997. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  113998. /**
  113999. * Remove an optimizer from the list of optimizers
  114000. * @param optimizer defines the optimizers to remove
  114001. * @returns the current material
  114002. */
  114003. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  114004. /**
  114005. * Add a new block to the list of output nodes
  114006. * @param node defines the node to add
  114007. * @returns the current material
  114008. */
  114009. addOutputNode(node: NodeMaterialBlock): this;
  114010. /**
  114011. * Remove a block from the list of root nodes
  114012. * @param node defines the node to remove
  114013. * @returns the current material
  114014. */
  114015. removeOutputNode(node: NodeMaterialBlock): this;
  114016. private _addVertexOutputNode;
  114017. private _removeVertexOutputNode;
  114018. private _addFragmentOutputNode;
  114019. private _removeFragmentOutputNode;
  114020. /**
  114021. * Specifies if the material will require alpha blending
  114022. * @returns a boolean specifying if alpha blending is needed
  114023. */
  114024. needAlphaBlending(): boolean;
  114025. /**
  114026. * Specifies if this material should be rendered in alpha test mode
  114027. * @returns a boolean specifying if an alpha test is needed.
  114028. */
  114029. needAlphaTesting(): boolean;
  114030. private _initializeBlock;
  114031. private _resetDualBlocks;
  114032. /**
  114033. * Build the material and generates the inner effect
  114034. * @param verbose defines if the build should log activity
  114035. */
  114036. build(verbose?: boolean): void;
  114037. /**
  114038. * Runs an otpimization phase to try to improve the shader code
  114039. */
  114040. optimize(): void;
  114041. private _prepareDefinesForAttributes;
  114042. /**
  114043. * Get if the submesh is ready to be used and all its information available.
  114044. * Child classes can use it to update shaders
  114045. * @param mesh defines the mesh to check
  114046. * @param subMesh defines which submesh to check
  114047. * @param useInstances specifies that instances should be used
  114048. * @returns a boolean indicating that the submesh is ready or not
  114049. */
  114050. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114051. /**
  114052. * Binds the world matrix to the material
  114053. * @param world defines the world transformation matrix
  114054. */
  114055. bindOnlyWorldMatrix(world: Matrix): void;
  114056. /**
  114057. * Binds the submesh to this material by preparing the effect and shader to draw
  114058. * @param world defines the world transformation matrix
  114059. * @param mesh defines the mesh containing the submesh
  114060. * @param subMesh defines the submesh to bind the material to
  114061. */
  114062. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114063. /**
  114064. * Gets the active textures from the material
  114065. * @returns an array of textures
  114066. */
  114067. getActiveTextures(): BaseTexture[];
  114068. /**
  114069. * Specifies if the material uses a texture
  114070. * @param texture defines the texture to check against the material
  114071. * @returns a boolean specifying if the material uses the texture
  114072. */
  114073. hasTexture(texture: BaseTexture): boolean;
  114074. /**
  114075. * Disposes the material
  114076. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  114077. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  114078. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  114079. */
  114080. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  114081. /** Creates the node editor window. */
  114082. private _createNodeEditor;
  114083. /**
  114084. * Launch the node material editor
  114085. * @param config Define the configuration of the editor
  114086. * @return a promise fulfilled when the node editor is visible
  114087. */
  114088. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  114089. /**
  114090. * Clear the current material
  114091. */
  114092. clear(): void;
  114093. /**
  114094. * Clear the current material and set it to a default state
  114095. */
  114096. setToDefault(): void;
  114097. }
  114098. }
  114099. declare module BABYLON {
  114100. /**
  114101. * Block used to read a texture from a sampler
  114102. */
  114103. export class TextureBlock extends NodeMaterialBlock {
  114104. private _defineName;
  114105. private _samplerName;
  114106. private _transformedUVName;
  114107. private _textureTransformName;
  114108. private _textureInfoName;
  114109. private _mainUVName;
  114110. private _mainUVDefineName;
  114111. /**
  114112. * Gets or sets the texture associated with the node
  114113. */
  114114. texture: Nullable<BaseTexture>;
  114115. /**
  114116. * Create a new TextureBlock
  114117. * @param name defines the block name
  114118. */
  114119. constructor(name: string);
  114120. /**
  114121. * Gets the current class name
  114122. * @returns the class name
  114123. */
  114124. getClassName(): string;
  114125. /**
  114126. * Gets the uv input component
  114127. */
  114128. readonly uv: NodeMaterialConnectionPoint;
  114129. /**
  114130. * Gets the output component
  114131. */
  114132. readonly output: NodeMaterialConnectionPoint;
  114133. autoConfigure(): void;
  114134. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114135. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114136. isReady(): boolean;
  114137. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114138. private _injectVertexCode;
  114139. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  114140. }
  114141. }
  114142. declare module BABYLON {
  114143. /**
  114144. * Class used to store shared data between 2 NodeMaterialBuildState
  114145. */
  114146. export class NodeMaterialBuildStateSharedData {
  114147. /**
  114148. * Gets the list of emitted varyings
  114149. */
  114150. varyings: string[];
  114151. /**
  114152. * Gets the varying declaration string
  114153. */
  114154. varyingDeclaration: string;
  114155. /**
  114156. * Input blocks
  114157. */
  114158. inputBlocks: InputBlock[];
  114159. /**
  114160. * Input blocks
  114161. */
  114162. textureBlocks: TextureBlock[];
  114163. /**
  114164. * Bindable blocks (Blocks that need to set data to the effect)
  114165. */
  114166. bindableBlocks: NodeMaterialBlock[];
  114167. /**
  114168. * List of blocks that can provide a compilation fallback
  114169. */
  114170. blocksWithFallbacks: NodeMaterialBlock[];
  114171. /**
  114172. * List of blocks that can provide a define update
  114173. */
  114174. blocksWithDefines: NodeMaterialBlock[];
  114175. /**
  114176. * List of blocks that can provide a repeatable content
  114177. */
  114178. repeatableContentBlocks: NodeMaterialBlock[];
  114179. /**
  114180. * List of blocks that can provide a dynamic list of uniforms
  114181. */
  114182. dynamicUniformBlocks: NodeMaterialBlock[];
  114183. /**
  114184. * List of blocks that can block the isReady function for the material
  114185. */
  114186. blockingBlocks: NodeMaterialBlock[];
  114187. /**
  114188. * Build Id used to avoid multiple recompilations
  114189. */
  114190. buildId: number;
  114191. /** List of emitted variables */
  114192. variableNames: {
  114193. [key: string]: number;
  114194. };
  114195. /** List of emitted defines */
  114196. defineNames: {
  114197. [key: string]: number;
  114198. };
  114199. /** Should emit comments? */
  114200. emitComments: boolean;
  114201. /** Emit build activity */
  114202. verbose: boolean;
  114203. /**
  114204. * Gets the compilation hints emitted at compilation time
  114205. */
  114206. hints: {
  114207. needWorldViewMatrix: boolean;
  114208. needWorldViewProjectionMatrix: boolean;
  114209. needAlphaBlending: boolean;
  114210. needAlphaTesting: boolean;
  114211. };
  114212. /**
  114213. * List of compilation checks
  114214. */
  114215. checks: {
  114216. emitVertex: boolean;
  114217. emitFragment: boolean;
  114218. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  114219. };
  114220. /** Creates a new shared data */
  114221. constructor();
  114222. /**
  114223. * Emits console errors and exceptions if there is a failing check
  114224. */
  114225. emitErrors(): void;
  114226. }
  114227. }
  114228. declare module BABYLON {
  114229. /**
  114230. * Class used to store node based material build state
  114231. */
  114232. export class NodeMaterialBuildState {
  114233. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  114234. supportUniformBuffers: boolean;
  114235. /**
  114236. * Gets the list of emitted attributes
  114237. */
  114238. attributes: string[];
  114239. /**
  114240. * Gets the list of emitted uniforms
  114241. */
  114242. uniforms: string[];
  114243. /**
  114244. * Gets the list of emitted uniform buffers
  114245. */
  114246. uniformBuffers: string[];
  114247. /**
  114248. * Gets the list of emitted samplers
  114249. */
  114250. samplers: string[];
  114251. /**
  114252. * Gets the list of emitted functions
  114253. */
  114254. functions: {
  114255. [key: string]: string;
  114256. };
  114257. /**
  114258. * Gets the target of the compilation state
  114259. */
  114260. target: NodeMaterialBlockTargets;
  114261. /**
  114262. * Gets the list of emitted counters
  114263. */
  114264. counters: {
  114265. [key: string]: number;
  114266. };
  114267. /**
  114268. * Shared data between multiple NodeMaterialBuildState instances
  114269. */
  114270. sharedData: NodeMaterialBuildStateSharedData;
  114271. /** @hidden */
  114272. _vertexState: NodeMaterialBuildState;
  114273. /** @hidden */
  114274. _attributeDeclaration: string;
  114275. /** @hidden */
  114276. _uniformDeclaration: string;
  114277. /** @hidden */
  114278. _samplerDeclaration: string;
  114279. /** @hidden */
  114280. _varyingTransfer: string;
  114281. private _repeatableContentAnchorIndex;
  114282. /** @hidden */
  114283. _builtCompilationString: string;
  114284. /**
  114285. * Gets the emitted compilation strings
  114286. */
  114287. compilationString: string;
  114288. /**
  114289. * Finalize the compilation strings
  114290. * @param state defines the current compilation state
  114291. */
  114292. finalize(state: NodeMaterialBuildState): void;
  114293. /** @hidden */
  114294. readonly _repeatableContentAnchor: string;
  114295. /** @hidden */
  114296. _getFreeVariableName(prefix: string): string;
  114297. /** @hidden */
  114298. _getFreeDefineName(prefix: string): string;
  114299. /** @hidden */
  114300. _excludeVariableName(name: string): void;
  114301. /** @hidden */
  114302. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  114303. /** @hidden */
  114304. _emitFunction(name: string, code: string, comments: string): void;
  114305. /** @hidden */
  114306. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  114307. replaceStrings?: {
  114308. search: RegExp;
  114309. replace: string;
  114310. }[];
  114311. repeatKey?: string;
  114312. }): string;
  114313. /** @hidden */
  114314. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  114315. repeatKey?: string;
  114316. removeAttributes?: boolean;
  114317. removeUniforms?: boolean;
  114318. removeVaryings?: boolean;
  114319. removeIfDef?: boolean;
  114320. replaceStrings?: {
  114321. search: RegExp;
  114322. replace: string;
  114323. }[];
  114324. }, storeKey?: string): void;
  114325. /** @hidden */
  114326. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  114327. /** @hidden */
  114328. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  114329. }
  114330. }
  114331. declare module BABYLON {
  114332. /**
  114333. * Defines a block that can be used inside a node based material
  114334. */
  114335. export class NodeMaterialBlock {
  114336. private _buildId;
  114337. private _buildTarget;
  114338. private _target;
  114339. private _isFinalMerger;
  114340. private _isInput;
  114341. /** @hidden */
  114342. _inputs: NodeMaterialConnectionPoint[];
  114343. /** @hidden */
  114344. _outputs: NodeMaterialConnectionPoint[];
  114345. /**
  114346. * Gets or sets the name of the block
  114347. */
  114348. name: string;
  114349. /**
  114350. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  114351. */
  114352. readonly isFinalMerger: boolean;
  114353. /**
  114354. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  114355. */
  114356. readonly isInput: boolean;
  114357. /**
  114358. * Gets or sets the build Id
  114359. */
  114360. buildId: number;
  114361. /**
  114362. * Gets or sets the target of the block
  114363. */
  114364. target: NodeMaterialBlockTargets;
  114365. /**
  114366. * Gets the list of input points
  114367. */
  114368. readonly inputs: NodeMaterialConnectionPoint[];
  114369. /** Gets the list of output points */
  114370. readonly outputs: NodeMaterialConnectionPoint[];
  114371. /**
  114372. * Find an input by its name
  114373. * @param name defines the name of the input to look for
  114374. * @returns the input or null if not found
  114375. */
  114376. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  114377. /**
  114378. * Find an output by its name
  114379. * @param name defines the name of the outputto look for
  114380. * @returns the output or null if not found
  114381. */
  114382. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  114383. /**
  114384. * Creates a new NodeMaterialBlock
  114385. * @param name defines the block name
  114386. * @param target defines the target of that block (Vertex by default)
  114387. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  114388. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  114389. */
  114390. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  114391. /**
  114392. * Initialize the block and prepare the context for build
  114393. * @param state defines the state that will be used for the build
  114394. */
  114395. initialize(state: NodeMaterialBuildState): void;
  114396. /**
  114397. * Bind data to effect. Will only be called for blocks with isBindable === true
  114398. * @param effect defines the effect to bind data to
  114399. * @param nodeMaterial defines the hosting NodeMaterial
  114400. * @param mesh defines the mesh that will be rendered
  114401. */
  114402. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114403. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  114404. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  114405. protected _writeFloat(value: number): string;
  114406. /**
  114407. * Gets the current class name e.g. "NodeMaterialBlock"
  114408. * @returns the class name
  114409. */
  114410. getClassName(): string;
  114411. /**
  114412. * Register a new input. Must be called inside a block constructor
  114413. * @param name defines the connection point name
  114414. * @param type defines the connection point type
  114415. * @param isOptional defines a boolean indicating that this input can be omitted
  114416. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  114417. * @returns the current block
  114418. */
  114419. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  114420. /**
  114421. * Register a new output. Must be called inside a block constructor
  114422. * @param name defines the connection point name
  114423. * @param type defines the connection point type
  114424. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  114425. * @returns the current block
  114426. */
  114427. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  114428. /**
  114429. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  114430. * @param forOutput defines an optional connection point to check compatibility with
  114431. * @returns the first available input or null
  114432. */
  114433. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  114434. /**
  114435. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  114436. * @param forBlock defines an optional block to check compatibility with
  114437. * @returns the first available input or null
  114438. */
  114439. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  114440. /**
  114441. * Connect current block with another block
  114442. * @param other defines the block to connect with
  114443. * @param options define the various options to help pick the right connections
  114444. * @returns the current block
  114445. */
  114446. connectTo(other: NodeMaterialBlock, options?: {
  114447. input?: string;
  114448. output?: string;
  114449. outputSwizzle?: string;
  114450. }): this | undefined;
  114451. protected _buildBlock(state: NodeMaterialBuildState): void;
  114452. /**
  114453. * Add uniforms, samplers and uniform buffers at compilation time
  114454. * @param state defines the state to update
  114455. * @param nodeMaterial defines the node material requesting the update
  114456. * @param defines defines the material defines to update
  114457. */
  114458. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114459. /**
  114460. * Add potential fallbacks if shader compilation fails
  114461. * @param mesh defines the mesh to be rendered
  114462. * @param fallbacks defines the current prioritized list of fallbacks
  114463. */
  114464. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  114465. /**
  114466. * Update defines for shader compilation
  114467. * @param mesh defines the mesh to be rendered
  114468. * @param nodeMaterial defines the node material requesting the update
  114469. * @param defines defines the material defines to update
  114470. * @param useInstances specifies that instances should be used
  114471. */
  114472. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114473. /**
  114474. * Initialize defines for shader compilation
  114475. * @param mesh defines the mesh to be rendered
  114476. * @param nodeMaterial defines the node material requesting the update
  114477. * @param defines defines the material defines to be prepared
  114478. * @param useInstances specifies that instances should be used
  114479. */
  114480. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114481. /**
  114482. * Lets the block try to connect some inputs automatically
  114483. */
  114484. autoConfigure(): void;
  114485. /**
  114486. * Function called when a block is declared as repeatable content generator
  114487. * @param vertexShaderState defines the current compilation state for the vertex shader
  114488. * @param fragmentShaderState defines the current compilation state for the fragment shader
  114489. * @param mesh defines the mesh to be rendered
  114490. * @param defines defines the material defines to update
  114491. */
  114492. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  114493. /**
  114494. * Checks if the block is ready
  114495. * @param mesh defines the mesh to be rendered
  114496. * @param nodeMaterial defines the node material requesting the update
  114497. * @param defines defines the material defines to update
  114498. * @param useInstances specifies that instances should be used
  114499. * @returns true if the block is ready
  114500. */
  114501. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  114502. private _processBuild;
  114503. /**
  114504. * Compile the current node and generate the shader code
  114505. * @param state defines the current compilation state (uniforms, samplers, current string)
  114506. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  114507. * @returns true if already built
  114508. */
  114509. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  114510. }
  114511. }
  114512. declare module BABYLON {
  114513. /**
  114514. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  114515. */
  114516. export enum NodeMaterialBlockConnectionPointMode {
  114517. /** Value is an uniform */
  114518. Uniform = 0,
  114519. /** Value is a mesh attribute */
  114520. Attribute = 1,
  114521. /** Value is a varying between vertex and fragment shaders */
  114522. Varying = 2,
  114523. /** Mode is undefined */
  114524. Undefined = 3
  114525. }
  114526. }
  114527. declare module BABYLON {
  114528. /**
  114529. * Enum used to define well known values e.g. values automatically provided by the system
  114530. */
  114531. export enum NodeMaterialWellKnownValues {
  114532. /** World */
  114533. World = 1,
  114534. /** View */
  114535. View = 2,
  114536. /** Projection */
  114537. Projection = 3,
  114538. /** ViewProjection */
  114539. ViewProjection = 4,
  114540. /** WorldView */
  114541. WorldView = 5,
  114542. /** WorldViewProjection */
  114543. WorldViewProjection = 6,
  114544. /** CameraPosition */
  114545. CameraPosition = 7,
  114546. /** Fog Color */
  114547. FogColor = 8
  114548. }
  114549. }
  114550. declare module BABYLON {
  114551. /**
  114552. * Block used to expose an input value
  114553. */
  114554. export class InputBlock extends NodeMaterialBlock {
  114555. private _mode;
  114556. private _associatedVariableName;
  114557. private _storedValue;
  114558. private _valueCallback;
  114559. private _type;
  114560. /** @hidden */
  114561. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  114562. /**
  114563. * Gets or sets the connection point type (default is float)
  114564. */
  114565. readonly type: NodeMaterialBlockConnectionPointTypes;
  114566. /**
  114567. * Creates a new InputBlock
  114568. * @param name defines the block name
  114569. * @param target defines the target of that block (Vertex by default)
  114570. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  114571. */
  114572. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  114573. /**
  114574. * Gets the output component
  114575. */
  114576. readonly output: NodeMaterialConnectionPoint;
  114577. /**
  114578. * Set the source of this connection point to a vertex attribute
  114579. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  114580. * @returns the current connection point
  114581. */
  114582. setAsAttribute(attributeName?: string): InputBlock;
  114583. /**
  114584. * Set the source of this connection point to a well known value
  114585. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  114586. * @returns the current connection point
  114587. */
  114588. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  114589. /**
  114590. * Gets or sets the value of that point.
  114591. * Please note that this value will be ignored if valueCallback is defined
  114592. */
  114593. value: any;
  114594. /**
  114595. * Gets or sets a callback used to get the value of that point.
  114596. * Please note that setting this value will force the connection point to ignore the value property
  114597. */
  114598. valueCallback: () => any;
  114599. /**
  114600. * Gets or sets the associated variable name in the shader
  114601. */
  114602. associatedVariableName: string;
  114603. /**
  114604. * Gets a boolean indicating that this connection point not defined yet
  114605. */
  114606. readonly isUndefined: boolean;
  114607. /**
  114608. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  114609. * In this case the connection point name must be the name of the uniform to use.
  114610. * Can only be set on inputs
  114611. */
  114612. isUniform: boolean;
  114613. /**
  114614. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  114615. * In this case the connection point name must be the name of the attribute to use
  114616. * Can only be set on inputs
  114617. */
  114618. isAttribute: boolean;
  114619. /**
  114620. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  114621. * Can only be set on exit points
  114622. */
  114623. isVarying: boolean;
  114624. /**
  114625. * Gets a boolean indicating that the current connection point is a well known value
  114626. */
  114627. readonly isWellKnownValue: boolean;
  114628. /**
  114629. * Gets or sets the current well known value or null if not defined as well know value
  114630. */
  114631. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  114632. /**
  114633. * Gets the current class name
  114634. * @returns the class name
  114635. */
  114636. getClassName(): string;
  114637. private _emitDefine;
  114638. /**
  114639. * Set the input block to its default value (based on its type)
  114640. */
  114641. setDefaultValue(): void;
  114642. private _emit;
  114643. /** @hidden */
  114644. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  114645. /** @hidden */
  114646. _transmit(effect: Effect, scene: Scene): void;
  114647. protected _buildBlock(state: NodeMaterialBuildState): void;
  114648. }
  114649. }
  114650. declare module BABYLON {
  114651. /**
  114652. * Defines a connection point for a block
  114653. */
  114654. export class NodeMaterialConnectionPoint {
  114655. /** @hidden */
  114656. _ownerBlock: NodeMaterialBlock;
  114657. /** @hidden */
  114658. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  114659. private _endpoints;
  114660. private _associatedVariableName;
  114661. /** @hidden */
  114662. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  114663. private _type;
  114664. /** @hidden */
  114665. _enforceAssociatedVariableName: boolean;
  114666. /**
  114667. * Gets or sets the associated variable name in the shader
  114668. */
  114669. associatedVariableName: string;
  114670. /**
  114671. * Gets or sets the connection point type (default is float)
  114672. */
  114673. type: NodeMaterialBlockConnectionPointTypes;
  114674. /**
  114675. * Gets or sets the connection point name
  114676. */
  114677. name: string;
  114678. /**
  114679. * Gets or sets the swizzle to apply to this connection point when reading or writing
  114680. */
  114681. swizzle: string;
  114682. /**
  114683. * Gets or sets a boolean indicating that this connection point can be omitted
  114684. */
  114685. isOptional: boolean;
  114686. /**
  114687. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  114688. */
  114689. define: string;
  114690. /** Gets or sets the target of that connection point */
  114691. target: NodeMaterialBlockTargets;
  114692. /**
  114693. * Gets a boolean indicating that the current point is connected
  114694. */
  114695. readonly isConnected: boolean;
  114696. /**
  114697. * Gets a boolean indicating that the current point is connected to an input block
  114698. */
  114699. readonly isConnectedToInput: boolean;
  114700. /**
  114701. * Gets a the connected input block (if any)
  114702. */
  114703. readonly connectInputBlock: Nullable<InputBlock>;
  114704. /** Get the other side of the connection (if any) */
  114705. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  114706. /** Get the block that owns this connection point */
  114707. readonly ownerBlock: NodeMaterialBlock;
  114708. /** Get the block connected on the other side of this connection (if any) */
  114709. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  114710. /** Get the block connected on the endpoints of this connection (if any) */
  114711. readonly connectedBlocks: Array<NodeMaterialBlock>;
  114712. /** Gets the list of connected endpoints */
  114713. readonly endpoints: NodeMaterialConnectionPoint[];
  114714. /**
  114715. * Creates a new connection point
  114716. * @param name defines the connection point name
  114717. * @param ownerBlock defines the block hosting this connection point
  114718. */
  114719. constructor(name: string, ownerBlock: NodeMaterialBlock);
  114720. /**
  114721. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  114722. * @returns the class name
  114723. */
  114724. getClassName(): string;
  114725. private _getTypeLength;
  114726. /**
  114727. * Gets an boolean indicating if the current point can be connected to another point
  114728. * @param connectionPoint defines the other connection point
  114729. * @returns true if the connection is possible
  114730. */
  114731. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  114732. /**
  114733. * Connect this point to another connection point
  114734. * @param connectionPoint defines the other connection point
  114735. * @returns the current connection point
  114736. */
  114737. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  114738. /**
  114739. * Disconnect this point from one of his endpoint
  114740. * @param endpoint defines the other connection point
  114741. * @returns the current connection point
  114742. */
  114743. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  114744. }
  114745. }
  114746. declare module BABYLON {
  114747. /**
  114748. * Block used to add support for vertex skinning (bones)
  114749. */
  114750. export class BonesBlock extends NodeMaterialBlock {
  114751. /**
  114752. * Creates a new BonesBlock
  114753. * @param name defines the block name
  114754. */
  114755. constructor(name: string);
  114756. /**
  114757. * Initialize the block and prepare the context for build
  114758. * @param state defines the state that will be used for the build
  114759. */
  114760. initialize(state: NodeMaterialBuildState): void;
  114761. /**
  114762. * Gets the current class name
  114763. * @returns the class name
  114764. */
  114765. getClassName(): string;
  114766. /**
  114767. * Gets the matrix indices input component
  114768. */
  114769. readonly matricesIndices: NodeMaterialConnectionPoint;
  114770. /**
  114771. * Gets the matrix weights input component
  114772. */
  114773. readonly matricesWeights: NodeMaterialConnectionPoint;
  114774. /**
  114775. * Gets the extra matrix indices input component
  114776. */
  114777. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  114778. /**
  114779. * Gets the extra matrix weights input component
  114780. */
  114781. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  114782. /**
  114783. * Gets the world input component
  114784. */
  114785. readonly world: NodeMaterialConnectionPoint;
  114786. /**
  114787. * Gets the output component
  114788. */
  114789. readonly output: NodeMaterialConnectionPoint;
  114790. autoConfigure(): void;
  114791. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  114792. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114793. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114794. protected _buildBlock(state: NodeMaterialBuildState): this;
  114795. }
  114796. }
  114797. declare module BABYLON {
  114798. /**
  114799. * Block used to add support for instances
  114800. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114801. */
  114802. export class InstancesBlock extends NodeMaterialBlock {
  114803. /**
  114804. * Creates a new InstancesBlock
  114805. * @param name defines the block name
  114806. */
  114807. constructor(name: string);
  114808. /**
  114809. * Gets the current class name
  114810. * @returns the class name
  114811. */
  114812. getClassName(): string;
  114813. /**
  114814. * Gets the first world row input component
  114815. */
  114816. readonly world0: NodeMaterialConnectionPoint;
  114817. /**
  114818. * Gets the second world row input component
  114819. */
  114820. readonly world1: NodeMaterialConnectionPoint;
  114821. /**
  114822. * Gets the third world row input component
  114823. */
  114824. readonly world2: NodeMaterialConnectionPoint;
  114825. /**
  114826. * Gets the forth world row input component
  114827. */
  114828. readonly world3: NodeMaterialConnectionPoint;
  114829. /**
  114830. * Gets the world input component
  114831. */
  114832. readonly world: NodeMaterialConnectionPoint;
  114833. /**
  114834. * Gets the output component
  114835. */
  114836. readonly output: NodeMaterialConnectionPoint;
  114837. autoConfigure(): void;
  114838. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114839. protected _buildBlock(state: NodeMaterialBuildState): this;
  114840. }
  114841. }
  114842. declare module BABYLON {
  114843. /**
  114844. * Block used to add morph targets support to vertex shader
  114845. */
  114846. export class MorphTargetsBlock extends NodeMaterialBlock {
  114847. private _repeatableContentAnchor;
  114848. private _repeatebleContentGenerated;
  114849. /**
  114850. * Create a new MorphTargetsBlock
  114851. * @param name defines the block name
  114852. */
  114853. constructor(name: string);
  114854. /**
  114855. * Gets the current class name
  114856. * @returns the class name
  114857. */
  114858. getClassName(): string;
  114859. /**
  114860. * Gets the position input component
  114861. */
  114862. readonly position: NodeMaterialConnectionPoint;
  114863. /**
  114864. * Gets the normal input component
  114865. */
  114866. readonly normal: NodeMaterialConnectionPoint;
  114867. /**
  114868. * Gets the tangent input component
  114869. */
  114870. readonly tangent: NodeMaterialConnectionPoint;
  114871. /**
  114872. * Gets the tangent input component
  114873. */
  114874. readonly uv: NodeMaterialConnectionPoint;
  114875. /**
  114876. * Gets the position output component
  114877. */
  114878. readonly positionOutput: NodeMaterialConnectionPoint;
  114879. /**
  114880. * Gets the normal output component
  114881. */
  114882. readonly normalOutput: NodeMaterialConnectionPoint;
  114883. /**
  114884. * Gets the tangent output component
  114885. */
  114886. readonly tangentOutput: NodeMaterialConnectionPoint;
  114887. /**
  114888. * Gets the tangent output component
  114889. */
  114890. readonly uvOutput: NodeMaterialConnectionPoint;
  114891. initialize(state: NodeMaterialBuildState): void;
  114892. autoConfigure(): void;
  114893. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114894. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114895. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  114896. protected _buildBlock(state: NodeMaterialBuildState): this;
  114897. }
  114898. }
  114899. declare module BABYLON {
  114900. /**
  114901. * Block used to add an alpha test in the fragment shader
  114902. */
  114903. export class AlphaTestBlock extends NodeMaterialBlock {
  114904. /**
  114905. * Gets or sets the alpha value where alpha testing happens
  114906. */
  114907. alphaCutOff: number;
  114908. /**
  114909. * Create a new AlphaTestBlock
  114910. * @param name defines the block name
  114911. */
  114912. constructor(name: string);
  114913. /**
  114914. * Gets the current class name
  114915. * @returns the class name
  114916. */
  114917. getClassName(): string;
  114918. /**
  114919. * Gets the color input component
  114920. */
  114921. readonly color: NodeMaterialConnectionPoint;
  114922. protected _buildBlock(state: NodeMaterialBuildState): this;
  114923. }
  114924. }
  114925. declare module BABYLON {
  114926. /**
  114927. * Block used to create a Color4 out of 4 inputs (one for each component)
  114928. */
  114929. export class RGBAMergerBlock extends NodeMaterialBlock {
  114930. /**
  114931. * Create a new RGBAMergerBlock
  114932. * @param name defines the block name
  114933. */
  114934. constructor(name: string);
  114935. /**
  114936. * Gets the current class name
  114937. * @returns the class name
  114938. */
  114939. getClassName(): string;
  114940. /**
  114941. * Gets the R input component
  114942. */
  114943. readonly r: NodeMaterialConnectionPoint;
  114944. /**
  114945. * Gets the G input component
  114946. */
  114947. readonly g: NodeMaterialConnectionPoint;
  114948. /**
  114949. * Gets the B input component
  114950. */
  114951. readonly b: NodeMaterialConnectionPoint;
  114952. /**
  114953. * Gets the RGB input component
  114954. */
  114955. readonly rgb: NodeMaterialConnectionPoint;
  114956. /**
  114957. * Gets the R input component
  114958. */
  114959. readonly a: NodeMaterialConnectionPoint;
  114960. /**
  114961. * Gets the output component
  114962. */
  114963. readonly output: NodeMaterialConnectionPoint;
  114964. protected _buildBlock(state: NodeMaterialBuildState): this;
  114965. }
  114966. }
  114967. declare module BABYLON {
  114968. /**
  114969. * Block used to create a Color3 out of 3 inputs (one for each component)
  114970. */
  114971. export class RGBMergerBlock extends NodeMaterialBlock {
  114972. /**
  114973. * Create a new RGBMergerBlock
  114974. * @param name defines the block name
  114975. */
  114976. constructor(name: string);
  114977. /**
  114978. * Gets the current class name
  114979. * @returns the class name
  114980. */
  114981. getClassName(): string;
  114982. /**
  114983. * Gets the R component input
  114984. */
  114985. readonly r: NodeMaterialConnectionPoint;
  114986. /**
  114987. * Gets the G component input
  114988. */
  114989. readonly g: NodeMaterialConnectionPoint;
  114990. /**
  114991. * Gets the B component input
  114992. */
  114993. readonly b: NodeMaterialConnectionPoint;
  114994. /**
  114995. * Gets the output component
  114996. */
  114997. readonly output: NodeMaterialConnectionPoint;
  114998. protected _buildBlock(state: NodeMaterialBuildState): this;
  114999. }
  115000. }
  115001. declare module BABYLON {
  115002. /**
  115003. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  115004. */
  115005. export class RGBASplitterBlock extends NodeMaterialBlock {
  115006. /**
  115007. * Create a new RGBASplitterBlock
  115008. * @param name defines the block name
  115009. */
  115010. constructor(name: string);
  115011. /**
  115012. * Gets the current class name
  115013. * @returns the class name
  115014. */
  115015. getClassName(): string;
  115016. /**
  115017. * Gets the input component
  115018. */
  115019. readonly input: NodeMaterialConnectionPoint;
  115020. protected _buildBlock(state: NodeMaterialBuildState): this;
  115021. }
  115022. }
  115023. declare module BABYLON {
  115024. /**
  115025. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  115026. */
  115027. export class RGBSplitterBlock extends NodeMaterialBlock {
  115028. /**
  115029. * Create a new RGBSplitterBlock
  115030. * @param name defines the block name
  115031. */
  115032. constructor(name: string);
  115033. /**
  115034. * Gets the current class name
  115035. * @returns the class name
  115036. */
  115037. getClassName(): string;
  115038. /**
  115039. * Gets the input component
  115040. */
  115041. readonly input: NodeMaterialConnectionPoint;
  115042. protected _buildBlock(state: NodeMaterialBuildState): this;
  115043. }
  115044. }
  115045. declare module BABYLON {
  115046. /**
  115047. * Block used to add image processing support to fragment shader
  115048. */
  115049. export class ImageProcessingBlock extends NodeMaterialBlock {
  115050. /**
  115051. * Create a new ImageProcessingBlock
  115052. * @param name defines the block name
  115053. */
  115054. constructor(name: string);
  115055. /**
  115056. * Gets the current class name
  115057. * @returns the class name
  115058. */
  115059. getClassName(): string;
  115060. /**
  115061. * Gets the color input component
  115062. */
  115063. readonly color: NodeMaterialConnectionPoint;
  115064. /**
  115065. * Gets the output component
  115066. */
  115067. readonly output: NodeMaterialConnectionPoint;
  115068. /**
  115069. * Initialize the block and prepare the context for build
  115070. * @param state defines the state that will be used for the build
  115071. */
  115072. initialize(state: NodeMaterialBuildState): void;
  115073. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  115074. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115075. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115076. protected _buildBlock(state: NodeMaterialBuildState): this;
  115077. }
  115078. }
  115079. declare module BABYLON {
  115080. /**
  115081. * Block used to add support for scene fog
  115082. */
  115083. export class FogBlock extends NodeMaterialBlock {
  115084. private _fogDistanceName;
  115085. private _fogParameters;
  115086. /**
  115087. * Create a new FogBlock
  115088. * @param name defines the block name
  115089. */
  115090. constructor(name: string);
  115091. /**
  115092. * Gets the current class name
  115093. * @returns the class name
  115094. */
  115095. getClassName(): string;
  115096. /**
  115097. * Gets the world position input component
  115098. */
  115099. readonly worldPosition: NodeMaterialConnectionPoint;
  115100. /**
  115101. * Gets the view input component
  115102. */
  115103. readonly view: NodeMaterialConnectionPoint;
  115104. /**
  115105. * Gets the color input component
  115106. */
  115107. readonly color: NodeMaterialConnectionPoint;
  115108. /**
  115109. * Gets the fog color input component
  115110. */
  115111. readonly fogColor: NodeMaterialConnectionPoint;
  115112. /**
  115113. * Gets the output component
  115114. */
  115115. readonly output: NodeMaterialConnectionPoint;
  115116. autoConfigure(): void;
  115117. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115118. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115119. protected _buildBlock(state: NodeMaterialBuildState): this;
  115120. }
  115121. }
  115122. declare module BABYLON {
  115123. /**
  115124. * Block used to add light in the fragment shader
  115125. */
  115126. export class LightBlock extends NodeMaterialBlock {
  115127. private _lightId;
  115128. /**
  115129. * Gets or sets the light associated with this block
  115130. */
  115131. light: Nullable<Light>;
  115132. /**
  115133. * Create a new LightBlock
  115134. * @param name defines the block name
  115135. */
  115136. constructor(name: string);
  115137. /**
  115138. * Gets the current class name
  115139. * @returns the class name
  115140. */
  115141. getClassName(): string;
  115142. /**
  115143. * Gets the world position input component
  115144. */
  115145. readonly worldPosition: NodeMaterialConnectionPoint;
  115146. /**
  115147. * Gets the world normal input component
  115148. */
  115149. readonly worldNormal: NodeMaterialConnectionPoint;
  115150. /**
  115151. * Gets the camera (or eye) position component
  115152. */
  115153. readonly cameraPosition: NodeMaterialConnectionPoint;
  115154. /**
  115155. * Gets the diffuse output component
  115156. */
  115157. readonly diffuseOutput: NodeMaterialConnectionPoint;
  115158. /**
  115159. * Gets the specular output component
  115160. */
  115161. readonly specularOutput: NodeMaterialConnectionPoint;
  115162. autoConfigure(): void;
  115163. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115164. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115165. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115166. private _injectVertexCode;
  115167. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  115168. }
  115169. }
  115170. declare module BABYLON {
  115171. /**
  115172. * Block used to multiply 2 values
  115173. */
  115174. export class MultiplyBlock extends NodeMaterialBlock {
  115175. /**
  115176. * Creates a new MultiplyBlock
  115177. * @param name defines the block name
  115178. */
  115179. constructor(name: string);
  115180. /**
  115181. * Gets the current class name
  115182. * @returns the class name
  115183. */
  115184. getClassName(): string;
  115185. /**
  115186. * Gets the left operand input component
  115187. */
  115188. readonly left: NodeMaterialConnectionPoint;
  115189. /**
  115190. * Gets the right operand input component
  115191. */
  115192. readonly right: NodeMaterialConnectionPoint;
  115193. /**
  115194. * Gets the output component
  115195. */
  115196. readonly output: NodeMaterialConnectionPoint;
  115197. protected _buildBlock(state: NodeMaterialBuildState): this;
  115198. }
  115199. }
  115200. declare module BABYLON {
  115201. /**
  115202. * Block used to add 2 vector4
  115203. */
  115204. export class AddBlock extends NodeMaterialBlock {
  115205. /**
  115206. * Creates a new AddBlock
  115207. * @param name defines the block name
  115208. */
  115209. constructor(name: string);
  115210. /**
  115211. * Gets the current class name
  115212. * @returns the class name
  115213. */
  115214. getClassName(): string;
  115215. /**
  115216. * Gets the left operand input component
  115217. */
  115218. readonly left: NodeMaterialConnectionPoint;
  115219. /**
  115220. * Gets the right operand input component
  115221. */
  115222. readonly right: NodeMaterialConnectionPoint;
  115223. /**
  115224. * Gets the output component
  115225. */
  115226. readonly output: NodeMaterialConnectionPoint;
  115227. protected _buildBlock(state: NodeMaterialBuildState): this;
  115228. }
  115229. }
  115230. declare module BABYLON {
  115231. /**
  115232. * Block used to clamp a float
  115233. */
  115234. export class ClampBlock extends NodeMaterialBlock {
  115235. /** Gets or sets the minimum range */
  115236. minimum: number;
  115237. /** Gets or sets the maximum range */
  115238. maximum: number;
  115239. /**
  115240. * Creates a new ClampBlock
  115241. * @param name defines the block name
  115242. */
  115243. constructor(name: string);
  115244. /**
  115245. * Gets the current class name
  115246. * @returns the class name
  115247. */
  115248. getClassName(): string;
  115249. /**
  115250. * Gets the value input component
  115251. */
  115252. readonly value: NodeMaterialConnectionPoint;
  115253. /**
  115254. * Gets the output component
  115255. */
  115256. readonly output: NodeMaterialConnectionPoint;
  115257. protected _buildBlock(state: NodeMaterialBuildState): this;
  115258. }
  115259. }
  115260. declare module BABYLON {
  115261. /**
  115262. * Block used to transform a vector2 with a matrix
  115263. */
  115264. export class Vector2TransformBlock extends NodeMaterialBlock {
  115265. /**
  115266. * Defines the value to use to complement Vector2 to transform it to a Vector4
  115267. */
  115268. complementZ: number;
  115269. /**
  115270. * Defines the value to use to complement Vector2 to transform it to a Vector4
  115271. */
  115272. complementW: number;
  115273. /**
  115274. * Creates a new Vector2TransformBlock
  115275. * @param name defines the block name
  115276. */
  115277. constructor(name: string);
  115278. /**
  115279. * Gets the vector input
  115280. */
  115281. readonly vector: NodeMaterialConnectionPoint;
  115282. /**
  115283. * Gets the matrix transform input
  115284. */
  115285. readonly transform: NodeMaterialConnectionPoint;
  115286. /**
  115287. * Gets the output component
  115288. */
  115289. readonly output: NodeMaterialConnectionPoint;
  115290. /**
  115291. * Gets the current class name
  115292. * @returns the class name
  115293. */
  115294. getClassName(): string;
  115295. protected _buildBlock(state: NodeMaterialBuildState): this;
  115296. }
  115297. }
  115298. declare module BABYLON {
  115299. /**
  115300. * Block used to transform a vector3 with a matrix
  115301. */
  115302. export class Vector3TransformBlock extends NodeMaterialBlock {
  115303. /**
  115304. * Defines the value to use to complement Vector3 to transform it to a Vector4
  115305. */
  115306. complement: number;
  115307. /**
  115308. * Creates a new Vector3TransformBlock
  115309. * @param name defines the block name
  115310. */
  115311. constructor(name: string);
  115312. /**
  115313. * Gets the vector input
  115314. */
  115315. readonly vector: NodeMaterialConnectionPoint;
  115316. /**
  115317. * Gets the matrix transform input
  115318. */
  115319. readonly transform: NodeMaterialConnectionPoint;
  115320. /**
  115321. * Gets the output component
  115322. */
  115323. readonly output: NodeMaterialConnectionPoint;
  115324. /**
  115325. * Gets the current class name
  115326. * @returns the class name
  115327. */
  115328. getClassName(): string;
  115329. protected _buildBlock(state: NodeMaterialBuildState): this;
  115330. }
  115331. }
  115332. declare module BABYLON {
  115333. /**
  115334. * Helper class to render one or more effects
  115335. */
  115336. export class EffectRenderer {
  115337. private engine;
  115338. private static _Vertices;
  115339. private static _Indices;
  115340. private _vertexBuffers;
  115341. private _indexBuffer;
  115342. private _ringBufferIndex;
  115343. private _ringScreenBuffer;
  115344. private _getNextFrameBuffer;
  115345. /**
  115346. * Creates an effect renderer
  115347. * @param engine the engine to use for rendering
  115348. */
  115349. constructor(engine: Engine);
  115350. /**
  115351. * renders one or more effects to a specified texture
  115352. * @param effectWrappers list of effects to renderer
  115353. * @param outputTexture texture to draw to, if null it will render to the screen
  115354. */
  115355. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  115356. /**
  115357. * Disposes of the effect renderer
  115358. */
  115359. dispose(): void;
  115360. }
  115361. /**
  115362. * Options to create an EffectWrapper
  115363. */
  115364. interface EffectWrapperCreationOptions {
  115365. /**
  115366. * Engine to use to create the effect
  115367. */
  115368. engine: Engine;
  115369. /**
  115370. * Fragment shader for the effect
  115371. */
  115372. fragmentShader: string;
  115373. /**
  115374. * Attributes to use in the shader
  115375. */
  115376. attributeNames: Array<string>;
  115377. /**
  115378. * Uniforms to use in the shader
  115379. */
  115380. uniformNames: Array<string>;
  115381. /**
  115382. * Texture sampler names to use in the shader
  115383. */
  115384. samplerNames: Array<string>;
  115385. }
  115386. /**
  115387. * Wraps an effect to be used for rendering
  115388. */
  115389. export class EffectWrapper {
  115390. /**
  115391. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  115392. */
  115393. onApplyObservable: Observable<{}>;
  115394. /**
  115395. * The underlying effect
  115396. */
  115397. effect: Effect;
  115398. /**
  115399. * Creates an effect to be renderer
  115400. * @param creationOptions options to create the effect
  115401. */
  115402. constructor(creationOptions: EffectWrapperCreationOptions);
  115403. /**
  115404. * Disposes of the effect wrapper
  115405. */
  115406. dispose(): void;
  115407. }
  115408. }
  115409. declare module BABYLON {
  115410. /**
  115411. * Helper class to push actions to a pool of workers.
  115412. */
  115413. export class WorkerPool implements IDisposable {
  115414. private _workerInfos;
  115415. private _pendingActions;
  115416. /**
  115417. * Constructor
  115418. * @param workers Array of workers to use for actions
  115419. */
  115420. constructor(workers: Array<Worker>);
  115421. /**
  115422. * Terminates all workers and clears any pending actions.
  115423. */
  115424. dispose(): void;
  115425. /**
  115426. * Pushes an action to the worker pool. If all the workers are active, the action will be
  115427. * pended until a worker has completed its action.
  115428. * @param action The action to perform. Call onComplete when the action is complete.
  115429. */
  115430. push(action: (worker: Worker, onComplete: () => void) => void): void;
  115431. private _execute;
  115432. }
  115433. }
  115434. declare module BABYLON {
  115435. /**
  115436. * Configuration for Draco compression
  115437. */
  115438. export interface IDracoCompressionConfiguration {
  115439. /**
  115440. * Configuration for the decoder.
  115441. */
  115442. decoder: {
  115443. /**
  115444. * The url to the WebAssembly module.
  115445. */
  115446. wasmUrl?: string;
  115447. /**
  115448. * The url to the WebAssembly binary.
  115449. */
  115450. wasmBinaryUrl?: string;
  115451. /**
  115452. * The url to the fallback JavaScript module.
  115453. */
  115454. fallbackUrl?: string;
  115455. };
  115456. }
  115457. /**
  115458. * Draco compression (https://google.github.io/draco/)
  115459. *
  115460. * This class wraps the Draco module.
  115461. *
  115462. * **Encoder**
  115463. *
  115464. * The encoder is not currently implemented.
  115465. *
  115466. * **Decoder**
  115467. *
  115468. * 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.
  115469. *
  115470. * To update the configuration, use the following code:
  115471. * ```javascript
  115472. * DracoCompression.Configuration = {
  115473. * decoder: {
  115474. * wasmUrl: "<url to the WebAssembly library>",
  115475. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  115476. * fallbackUrl: "<url to the fallback JavaScript library>",
  115477. * }
  115478. * };
  115479. * ```
  115480. *
  115481. * 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.
  115482. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  115483. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  115484. *
  115485. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  115486. * ```javascript
  115487. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  115488. * ```
  115489. *
  115490. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  115491. */
  115492. export class DracoCompression implements IDisposable {
  115493. private _workerPoolPromise?;
  115494. private _decoderModulePromise?;
  115495. /**
  115496. * The configuration. Defaults to the following urls:
  115497. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  115498. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  115499. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  115500. */
  115501. static Configuration: IDracoCompressionConfiguration;
  115502. /**
  115503. * Returns true if the decoder configuration is available.
  115504. */
  115505. static readonly DecoderAvailable: boolean;
  115506. /**
  115507. * Default number of workers to create when creating the draco compression object.
  115508. */
  115509. static DefaultNumWorkers: number;
  115510. private static GetDefaultNumWorkers;
  115511. private static _Default;
  115512. /**
  115513. * Default instance for the draco compression object.
  115514. */
  115515. static readonly Default: DracoCompression;
  115516. /**
  115517. * Constructor
  115518. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  115519. */
  115520. constructor(numWorkers?: number);
  115521. /**
  115522. * Stop all async operations and release resources.
  115523. */
  115524. dispose(): void;
  115525. /**
  115526. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  115527. * @returns a promise that resolves when ready
  115528. */
  115529. whenReadyAsync(): Promise<void>;
  115530. /**
  115531. * Decode Draco compressed mesh data to vertex data.
  115532. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  115533. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  115534. * @returns A promise that resolves with the decoded vertex data
  115535. */
  115536. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  115537. [kind: string]: number;
  115538. }): Promise<VertexData>;
  115539. }
  115540. }
  115541. declare module BABYLON {
  115542. /**
  115543. * Class for building Constructive Solid Geometry
  115544. */
  115545. export class CSG {
  115546. private polygons;
  115547. /**
  115548. * The world matrix
  115549. */
  115550. matrix: Matrix;
  115551. /**
  115552. * Stores the position
  115553. */
  115554. position: Vector3;
  115555. /**
  115556. * Stores the rotation
  115557. */
  115558. rotation: Vector3;
  115559. /**
  115560. * Stores the rotation quaternion
  115561. */
  115562. rotationQuaternion: Nullable<Quaternion>;
  115563. /**
  115564. * Stores the scaling vector
  115565. */
  115566. scaling: Vector3;
  115567. /**
  115568. * Convert the Mesh to CSG
  115569. * @param mesh The Mesh to convert to CSG
  115570. * @returns A new CSG from the Mesh
  115571. */
  115572. static FromMesh(mesh: Mesh): CSG;
  115573. /**
  115574. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  115575. * @param polygons Polygons used to construct a CSG solid
  115576. */
  115577. private static FromPolygons;
  115578. /**
  115579. * Clones, or makes a deep copy, of the CSG
  115580. * @returns A new CSG
  115581. */
  115582. clone(): CSG;
  115583. /**
  115584. * Unions this CSG with another CSG
  115585. * @param csg The CSG to union against this CSG
  115586. * @returns The unioned CSG
  115587. */
  115588. union(csg: CSG): CSG;
  115589. /**
  115590. * Unions this CSG with another CSG in place
  115591. * @param csg The CSG to union against this CSG
  115592. */
  115593. unionInPlace(csg: CSG): void;
  115594. /**
  115595. * Subtracts this CSG with another CSG
  115596. * @param csg The CSG to subtract against this CSG
  115597. * @returns A new CSG
  115598. */
  115599. subtract(csg: CSG): CSG;
  115600. /**
  115601. * Subtracts this CSG with another CSG in place
  115602. * @param csg The CSG to subtact against this CSG
  115603. */
  115604. subtractInPlace(csg: CSG): void;
  115605. /**
  115606. * Intersect this CSG with another CSG
  115607. * @param csg The CSG to intersect against this CSG
  115608. * @returns A new CSG
  115609. */
  115610. intersect(csg: CSG): CSG;
  115611. /**
  115612. * Intersects this CSG with another CSG in place
  115613. * @param csg The CSG to intersect against this CSG
  115614. */
  115615. intersectInPlace(csg: CSG): void;
  115616. /**
  115617. * Return a new CSG solid with solid and empty space switched. This solid is
  115618. * not modified.
  115619. * @returns A new CSG solid with solid and empty space switched
  115620. */
  115621. inverse(): CSG;
  115622. /**
  115623. * Inverses the CSG in place
  115624. */
  115625. inverseInPlace(): void;
  115626. /**
  115627. * This is used to keep meshes transformations so they can be restored
  115628. * when we build back a Babylon Mesh
  115629. * NB : All CSG operations are performed in world coordinates
  115630. * @param csg The CSG to copy the transform attributes from
  115631. * @returns This CSG
  115632. */
  115633. copyTransformAttributes(csg: CSG): CSG;
  115634. /**
  115635. * Build Raw mesh from CSG
  115636. * Coordinates here are in world space
  115637. * @param name The name of the mesh geometry
  115638. * @param scene The Scene
  115639. * @param keepSubMeshes Specifies if the submeshes should be kept
  115640. * @returns A new Mesh
  115641. */
  115642. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  115643. /**
  115644. * Build Mesh from CSG taking material and transforms into account
  115645. * @param name The name of the Mesh
  115646. * @param material The material of the Mesh
  115647. * @param scene The Scene
  115648. * @param keepSubMeshes Specifies if submeshes should be kept
  115649. * @returns The new Mesh
  115650. */
  115651. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  115652. }
  115653. }
  115654. declare module BABYLON {
  115655. /**
  115656. * Class used to create a trail following a mesh
  115657. */
  115658. export class TrailMesh extends Mesh {
  115659. private _generator;
  115660. private _autoStart;
  115661. private _running;
  115662. private _diameter;
  115663. private _length;
  115664. private _sectionPolygonPointsCount;
  115665. private _sectionVectors;
  115666. private _sectionNormalVectors;
  115667. private _beforeRenderObserver;
  115668. /**
  115669. * @constructor
  115670. * @param name The value used by scene.getMeshByName() to do a lookup.
  115671. * @param generator The mesh to generate a trail.
  115672. * @param scene The scene to add this mesh to.
  115673. * @param diameter Diameter of trailing mesh. Default is 1.
  115674. * @param length Length of trailing mesh. Default is 60.
  115675. * @param autoStart Automatically start trailing mesh. Default true.
  115676. */
  115677. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  115678. /**
  115679. * "TrailMesh"
  115680. * @returns "TrailMesh"
  115681. */
  115682. getClassName(): string;
  115683. private _createMesh;
  115684. /**
  115685. * Start trailing mesh.
  115686. */
  115687. start(): void;
  115688. /**
  115689. * Stop trailing mesh.
  115690. */
  115691. stop(): void;
  115692. /**
  115693. * Update trailing mesh geometry.
  115694. */
  115695. update(): void;
  115696. /**
  115697. * Returns a new TrailMesh object.
  115698. * @param name is a string, the name given to the new mesh
  115699. * @param newGenerator use new generator object for cloned trail mesh
  115700. * @returns a new mesh
  115701. */
  115702. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  115703. /**
  115704. * Serializes this trail mesh
  115705. * @param serializationObject object to write serialization to
  115706. */
  115707. serialize(serializationObject: any): void;
  115708. /**
  115709. * Parses a serialized trail mesh
  115710. * @param parsedMesh the serialized mesh
  115711. * @param scene the scene to create the trail mesh in
  115712. * @returns the created trail mesh
  115713. */
  115714. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  115715. }
  115716. }
  115717. declare module BABYLON {
  115718. /**
  115719. * Class containing static functions to help procedurally build meshes
  115720. */
  115721. export class TiledBoxBuilder {
  115722. /**
  115723. * Creates a box mesh
  115724. * 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)
  115725. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115727. * * 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
  115728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115729. * @param name defines the name of the mesh
  115730. * @param options defines the options used to create the mesh
  115731. * @param scene defines the hosting scene
  115732. * @returns the box mesh
  115733. */
  115734. static CreateTiledBox(name: string, options: {
  115735. pattern?: number;
  115736. width?: number;
  115737. height?: number;
  115738. depth?: number;
  115739. tileSize?: number;
  115740. tileWidth?: number;
  115741. tileHeight?: number;
  115742. alignHorizontal?: number;
  115743. alignVertical?: number;
  115744. faceUV?: Vector4[];
  115745. faceColors?: Color4[];
  115746. sideOrientation?: number;
  115747. updatable?: boolean;
  115748. }, scene?: Nullable<Scene>): Mesh;
  115749. }
  115750. }
  115751. declare module BABYLON {
  115752. /**
  115753. * Class containing static functions to help procedurally build meshes
  115754. */
  115755. export class TorusKnotBuilder {
  115756. /**
  115757. * Creates a torus knot mesh
  115758. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  115759. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  115760. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  115761. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  115762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115763. * * 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
  115764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115765. * @param name defines the name of the mesh
  115766. * @param options defines the options used to create the mesh
  115767. * @param scene defines the hosting scene
  115768. * @returns the torus knot mesh
  115769. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  115770. */
  115771. static CreateTorusKnot(name: string, options: {
  115772. radius?: number;
  115773. tube?: number;
  115774. radialSegments?: number;
  115775. tubularSegments?: number;
  115776. p?: number;
  115777. q?: number;
  115778. updatable?: boolean;
  115779. sideOrientation?: number;
  115780. frontUVs?: Vector4;
  115781. backUVs?: Vector4;
  115782. }, scene: any): Mesh;
  115783. }
  115784. }
  115785. declare module BABYLON {
  115786. /**
  115787. * Polygon
  115788. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  115789. */
  115790. export class Polygon {
  115791. /**
  115792. * Creates a rectangle
  115793. * @param xmin bottom X coord
  115794. * @param ymin bottom Y coord
  115795. * @param xmax top X coord
  115796. * @param ymax top Y coord
  115797. * @returns points that make the resulting rectation
  115798. */
  115799. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  115800. /**
  115801. * Creates a circle
  115802. * @param radius radius of circle
  115803. * @param cx scale in x
  115804. * @param cy scale in y
  115805. * @param numberOfSides number of sides that make up the circle
  115806. * @returns points that make the resulting circle
  115807. */
  115808. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  115809. /**
  115810. * Creates a polygon from input string
  115811. * @param input Input polygon data
  115812. * @returns the parsed points
  115813. */
  115814. static Parse(input: string): Vector2[];
  115815. /**
  115816. * Starts building a polygon from x and y coordinates
  115817. * @param x x coordinate
  115818. * @param y y coordinate
  115819. * @returns the started path2
  115820. */
  115821. static StartingAt(x: number, y: number): Path2;
  115822. }
  115823. /**
  115824. * Builds a polygon
  115825. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  115826. */
  115827. export class PolygonMeshBuilder {
  115828. private _points;
  115829. private _outlinepoints;
  115830. private _holes;
  115831. private _name;
  115832. private _scene;
  115833. private _epoints;
  115834. private _eholes;
  115835. private _addToepoint;
  115836. /**
  115837. * Babylon reference to the earcut plugin.
  115838. */
  115839. bjsEarcut: any;
  115840. /**
  115841. * Creates a PolygonMeshBuilder
  115842. * @param name name of the builder
  115843. * @param contours Path of the polygon
  115844. * @param scene scene to add to when creating the mesh
  115845. * @param earcutInjection can be used to inject your own earcut reference
  115846. */
  115847. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  115848. /**
  115849. * Adds a whole within the polygon
  115850. * @param hole Array of points defining the hole
  115851. * @returns this
  115852. */
  115853. addHole(hole: Vector2[]): PolygonMeshBuilder;
  115854. /**
  115855. * Creates the polygon
  115856. * @param updatable If the mesh should be updatable
  115857. * @param depth The depth of the mesh created
  115858. * @returns the created mesh
  115859. */
  115860. build(updatable?: boolean, depth?: number): Mesh;
  115861. /**
  115862. * Creates the polygon
  115863. * @param depth The depth of the mesh created
  115864. * @returns the created VertexData
  115865. */
  115866. buildVertexData(depth?: number): VertexData;
  115867. /**
  115868. * Adds a side to the polygon
  115869. * @param positions points that make the polygon
  115870. * @param normals normals of the polygon
  115871. * @param uvs uvs of the polygon
  115872. * @param indices indices of the polygon
  115873. * @param bounds bounds of the polygon
  115874. * @param points points of the polygon
  115875. * @param depth depth of the polygon
  115876. * @param flip flip of the polygon
  115877. */
  115878. private addSide;
  115879. }
  115880. }
  115881. declare module BABYLON {
  115882. /**
  115883. * Class containing static functions to help procedurally build meshes
  115884. */
  115885. export class PolygonBuilder {
  115886. /**
  115887. * Creates a polygon mesh
  115888. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  115889. * * 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
  115890. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115892. * * 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)
  115893. * * Remember you can only change the shape positions, not their number when updating a polygon
  115894. * @param name defines the name of the mesh
  115895. * @param options defines the options used to create the mesh
  115896. * @param scene defines the hosting scene
  115897. * @param earcutInjection can be used to inject your own earcut reference
  115898. * @returns the polygon mesh
  115899. */
  115900. static CreatePolygon(name: string, options: {
  115901. shape: Vector3[];
  115902. holes?: Vector3[][];
  115903. depth?: number;
  115904. faceUV?: Vector4[];
  115905. faceColors?: Color4[];
  115906. updatable?: boolean;
  115907. sideOrientation?: number;
  115908. frontUVs?: Vector4;
  115909. backUVs?: Vector4;
  115910. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115911. /**
  115912. * Creates an extruded polygon mesh, with depth in the Y direction.
  115913. * * 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)
  115914. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115915. * @param name defines the name of the mesh
  115916. * @param options defines the options used to create the mesh
  115917. * @param scene defines the hosting scene
  115918. * @param earcutInjection can be used to inject your own earcut reference
  115919. * @returns the polygon mesh
  115920. */
  115921. static ExtrudePolygon(name: string, options: {
  115922. shape: Vector3[];
  115923. holes?: Vector3[][];
  115924. depth?: number;
  115925. faceUV?: Vector4[];
  115926. faceColors?: Color4[];
  115927. updatable?: boolean;
  115928. sideOrientation?: number;
  115929. frontUVs?: Vector4;
  115930. backUVs?: Vector4;
  115931. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115932. }
  115933. }
  115934. declare module BABYLON {
  115935. /**
  115936. * Class containing static functions to help procedurally build meshes
  115937. */
  115938. export class LatheBuilder {
  115939. /**
  115940. * Creates lathe mesh.
  115941. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  115942. * * 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
  115943. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  115944. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  115945. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  115946. * * 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
  115947. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  115948. * * 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
  115949. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115950. * * 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
  115951. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115953. * @param name defines the name of the mesh
  115954. * @param options defines the options used to create the mesh
  115955. * @param scene defines the hosting scene
  115956. * @returns the lathe mesh
  115957. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  115958. */
  115959. static CreateLathe(name: string, options: {
  115960. shape: Vector3[];
  115961. radius?: number;
  115962. tessellation?: number;
  115963. clip?: number;
  115964. arc?: number;
  115965. closed?: boolean;
  115966. updatable?: boolean;
  115967. sideOrientation?: number;
  115968. frontUVs?: Vector4;
  115969. backUVs?: Vector4;
  115970. cap?: number;
  115971. invertUV?: boolean;
  115972. }, scene?: Nullable<Scene>): Mesh;
  115973. }
  115974. }
  115975. declare module BABYLON {
  115976. /**
  115977. * Class containing static functions to help procedurally build meshes
  115978. */
  115979. export class TiledPlaneBuilder {
  115980. /**
  115981. * Creates a tiled plane mesh
  115982. * * The parameter `pattern` will, depending on value, do nothing or
  115983. * * * flip (reflect about central vertical) alternate tiles across and up
  115984. * * * flip every tile on alternate rows
  115985. * * * rotate (180 degs) alternate tiles across and up
  115986. * * * rotate every tile on alternate rows
  115987. * * * flip and rotate alternate tiles across and up
  115988. * * * flip and rotate every tile on alternate rows
  115989. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  115990. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  115991. * * 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
  115992. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115993. * * 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)
  115994. * * 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)
  115995. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115996. * @param name defines the name of the mesh
  115997. * @param options defines the options used to create the mesh
  115998. * @param scene defines the hosting scene
  115999. * @returns the box mesh
  116000. */
  116001. static CreateTiledPlane(name: string, options: {
  116002. pattern?: number;
  116003. tileSize?: number;
  116004. tileWidth?: number;
  116005. tileHeight?: number;
  116006. size?: number;
  116007. width?: number;
  116008. height?: number;
  116009. alignHorizontal?: number;
  116010. alignVertical?: number;
  116011. sideOrientation?: number;
  116012. frontUVs?: Vector4;
  116013. backUVs?: Vector4;
  116014. updatable?: boolean;
  116015. }, scene?: Nullable<Scene>): Mesh;
  116016. }
  116017. }
  116018. declare module BABYLON {
  116019. /**
  116020. * Class containing static functions to help procedurally build meshes
  116021. */
  116022. export class TubeBuilder {
  116023. /**
  116024. * Creates a tube mesh.
  116025. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116026. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  116027. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  116028. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  116029. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  116030. * * 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)
  116031. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  116032. * * 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
  116033. * * 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
  116034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116035. * * 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
  116036. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116038. * @param name defines the name of the mesh
  116039. * @param options defines the options used to create the mesh
  116040. * @param scene defines the hosting scene
  116041. * @returns the tube mesh
  116042. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116043. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  116044. */
  116045. static CreateTube(name: string, options: {
  116046. path: Vector3[];
  116047. radius?: number;
  116048. tessellation?: number;
  116049. radiusFunction?: {
  116050. (i: number, distance: number): number;
  116051. };
  116052. cap?: number;
  116053. arc?: number;
  116054. updatable?: boolean;
  116055. sideOrientation?: number;
  116056. frontUVs?: Vector4;
  116057. backUVs?: Vector4;
  116058. instance?: Mesh;
  116059. invertUV?: boolean;
  116060. }, scene?: Nullable<Scene>): Mesh;
  116061. }
  116062. }
  116063. declare module BABYLON {
  116064. /**
  116065. * Class containing static functions to help procedurally build meshes
  116066. */
  116067. export class IcoSphereBuilder {
  116068. /**
  116069. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  116070. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  116071. * * 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`)
  116072. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  116073. * * 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
  116074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116075. * * 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
  116076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116077. * @param name defines the name of the mesh
  116078. * @param options defines the options used to create the mesh
  116079. * @param scene defines the hosting scene
  116080. * @returns the icosahedron mesh
  116081. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  116082. */
  116083. static CreateIcoSphere(name: string, options: {
  116084. radius?: number;
  116085. radiusX?: number;
  116086. radiusY?: number;
  116087. radiusZ?: number;
  116088. flat?: boolean;
  116089. subdivisions?: number;
  116090. sideOrientation?: number;
  116091. frontUVs?: Vector4;
  116092. backUVs?: Vector4;
  116093. updatable?: boolean;
  116094. }, scene?: Nullable<Scene>): Mesh;
  116095. }
  116096. }
  116097. declare module BABYLON {
  116098. /**
  116099. * Class containing static functions to help procedurally build meshes
  116100. */
  116101. export class DecalBuilder {
  116102. /**
  116103. * Creates a decal mesh.
  116104. * 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
  116105. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  116106. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  116107. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  116108. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  116109. * @param name defines the name of the mesh
  116110. * @param sourceMesh defines the mesh where the decal must be applied
  116111. * @param options defines the options used to create the mesh
  116112. * @param scene defines the hosting scene
  116113. * @returns the decal mesh
  116114. * @see https://doc.babylonjs.com/how_to/decals
  116115. */
  116116. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  116117. position?: Vector3;
  116118. normal?: Vector3;
  116119. size?: Vector3;
  116120. angle?: number;
  116121. }): Mesh;
  116122. }
  116123. }
  116124. declare module BABYLON {
  116125. /**
  116126. * Class containing static functions to help procedurally build meshes
  116127. */
  116128. export class MeshBuilder {
  116129. /**
  116130. * Creates a box mesh
  116131. * * The parameter `size` sets the size (float) of each box side (default 1)
  116132. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  116133. * * 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)
  116134. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  116135. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116136. * * 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
  116137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116138. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  116139. * @param name defines the name of the mesh
  116140. * @param options defines the options used to create the mesh
  116141. * @param scene defines the hosting scene
  116142. * @returns the box mesh
  116143. */
  116144. static CreateBox(name: string, options: {
  116145. size?: number;
  116146. width?: number;
  116147. height?: number;
  116148. depth?: number;
  116149. faceUV?: Vector4[];
  116150. faceColors?: Color4[];
  116151. sideOrientation?: number;
  116152. frontUVs?: Vector4;
  116153. backUVs?: Vector4;
  116154. updatable?: boolean;
  116155. }, scene?: Nullable<Scene>): Mesh;
  116156. /**
  116157. * Creates a tiled box mesh
  116158. * * faceTiles sets the pattern, tile size and number of tiles for a face
  116159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116160. * @param name defines the name of the mesh
  116161. * @param options defines the options used to create the mesh
  116162. * @param scene defines the hosting scene
  116163. * @returns the tiled box mesh
  116164. */
  116165. static CreateTiledBox(name: string, options: {
  116166. pattern?: number;
  116167. size?: number;
  116168. width?: number;
  116169. height?: number;
  116170. depth: number;
  116171. tileSize?: number;
  116172. tileWidth?: number;
  116173. tileHeight?: number;
  116174. faceUV?: Vector4[];
  116175. faceColors?: Color4[];
  116176. alignHorizontal?: number;
  116177. alignVertical?: number;
  116178. sideOrientation?: number;
  116179. updatable?: boolean;
  116180. }, scene?: Nullable<Scene>): Mesh;
  116181. /**
  116182. * Creates a sphere mesh
  116183. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  116184. * * 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`)
  116185. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  116186. * * 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
  116187. * * 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)
  116188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116189. * * 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
  116190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116191. * @param name defines the name of the mesh
  116192. * @param options defines the options used to create the mesh
  116193. * @param scene defines the hosting scene
  116194. * @returns the sphere mesh
  116195. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  116196. */
  116197. static CreateSphere(name: string, options: {
  116198. segments?: number;
  116199. diameter?: number;
  116200. diameterX?: number;
  116201. diameterY?: number;
  116202. diameterZ?: number;
  116203. arc?: number;
  116204. slice?: number;
  116205. sideOrientation?: number;
  116206. frontUVs?: Vector4;
  116207. backUVs?: Vector4;
  116208. updatable?: boolean;
  116209. }, scene?: Nullable<Scene>): Mesh;
  116210. /**
  116211. * Creates a plane polygonal mesh. By default, this is a disc
  116212. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  116213. * * 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
  116214. * * 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
  116215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116216. * * 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
  116217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116218. * @param name defines the name of the mesh
  116219. * @param options defines the options used to create the mesh
  116220. * @param scene defines the hosting scene
  116221. * @returns the plane polygonal mesh
  116222. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  116223. */
  116224. static CreateDisc(name: string, options: {
  116225. radius?: number;
  116226. tessellation?: number;
  116227. arc?: number;
  116228. updatable?: boolean;
  116229. sideOrientation?: number;
  116230. frontUVs?: Vector4;
  116231. backUVs?: Vector4;
  116232. }, scene?: Nullable<Scene>): Mesh;
  116233. /**
  116234. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  116235. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  116236. * * 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`)
  116237. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  116238. * * 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
  116239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116240. * * 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
  116241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116242. * @param name defines the name of the mesh
  116243. * @param options defines the options used to create the mesh
  116244. * @param scene defines the hosting scene
  116245. * @returns the icosahedron mesh
  116246. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  116247. */
  116248. static CreateIcoSphere(name: string, options: {
  116249. radius?: number;
  116250. radiusX?: number;
  116251. radiusY?: number;
  116252. radiusZ?: number;
  116253. flat?: boolean;
  116254. subdivisions?: number;
  116255. sideOrientation?: number;
  116256. frontUVs?: Vector4;
  116257. backUVs?: Vector4;
  116258. updatable?: boolean;
  116259. }, scene?: Nullable<Scene>): Mesh;
  116260. /**
  116261. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116262. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  116263. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  116264. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  116265. * * 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
  116266. * * 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
  116267. * * 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
  116268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116269. * * 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
  116270. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116271. * * 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
  116272. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  116273. * * 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
  116274. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  116275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116276. * @param name defines the name of the mesh
  116277. * @param options defines the options used to create the mesh
  116278. * @param scene defines the hosting scene
  116279. * @returns the ribbon mesh
  116280. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  116281. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116282. */
  116283. static CreateRibbon(name: string, options: {
  116284. pathArray: Vector3[][];
  116285. closeArray?: boolean;
  116286. closePath?: boolean;
  116287. offset?: number;
  116288. updatable?: boolean;
  116289. sideOrientation?: number;
  116290. frontUVs?: Vector4;
  116291. backUVs?: Vector4;
  116292. instance?: Mesh;
  116293. invertUV?: boolean;
  116294. uvs?: Vector2[];
  116295. colors?: Color4[];
  116296. }, scene?: Nullable<Scene>): Mesh;
  116297. /**
  116298. * Creates a cylinder or a cone mesh
  116299. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  116300. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  116301. * * 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.
  116302. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  116303. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  116304. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  116305. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  116306. * * 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).
  116307. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  116308. * * 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).
  116309. * * 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
  116310. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  116311. * * 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
  116312. * * 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.
  116313. * * If `enclose` is false, a ring surface is one element.
  116314. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  116315. * * 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
  116316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116317. * * 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
  116318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116319. * @param name defines the name of the mesh
  116320. * @param options defines the options used to create the mesh
  116321. * @param scene defines the hosting scene
  116322. * @returns the cylinder mesh
  116323. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  116324. */
  116325. static CreateCylinder(name: string, options: {
  116326. height?: number;
  116327. diameterTop?: number;
  116328. diameterBottom?: number;
  116329. diameter?: number;
  116330. tessellation?: number;
  116331. subdivisions?: number;
  116332. arc?: number;
  116333. faceColors?: Color4[];
  116334. faceUV?: Vector4[];
  116335. updatable?: boolean;
  116336. hasRings?: boolean;
  116337. enclose?: boolean;
  116338. cap?: number;
  116339. sideOrientation?: number;
  116340. frontUVs?: Vector4;
  116341. backUVs?: Vector4;
  116342. }, scene?: Nullable<Scene>): Mesh;
  116343. /**
  116344. * Creates a torus mesh
  116345. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  116346. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  116347. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  116348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116349. * * 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
  116350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116351. * @param name defines the name of the mesh
  116352. * @param options defines the options used to create the mesh
  116353. * @param scene defines the hosting scene
  116354. * @returns the torus mesh
  116355. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  116356. */
  116357. static CreateTorus(name: string, options: {
  116358. diameter?: number;
  116359. thickness?: number;
  116360. tessellation?: number;
  116361. updatable?: boolean;
  116362. sideOrientation?: number;
  116363. frontUVs?: Vector4;
  116364. backUVs?: Vector4;
  116365. }, scene?: Nullable<Scene>): Mesh;
  116366. /**
  116367. * Creates a torus knot mesh
  116368. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  116369. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  116370. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  116371. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  116372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116373. * * 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
  116374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116375. * @param name defines the name of the mesh
  116376. * @param options defines the options used to create the mesh
  116377. * @param scene defines the hosting scene
  116378. * @returns the torus knot mesh
  116379. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  116380. */
  116381. static CreateTorusKnot(name: string, options: {
  116382. radius?: number;
  116383. tube?: number;
  116384. radialSegments?: number;
  116385. tubularSegments?: number;
  116386. p?: number;
  116387. q?: number;
  116388. updatable?: boolean;
  116389. sideOrientation?: number;
  116390. frontUVs?: Vector4;
  116391. backUVs?: Vector4;
  116392. }, scene?: Nullable<Scene>): Mesh;
  116393. /**
  116394. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  116395. * * 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
  116396. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  116397. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  116398. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  116399. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  116400. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  116401. * * 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
  116402. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  116403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116404. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  116405. * @param name defines the name of the new line system
  116406. * @param options defines the options used to create the line system
  116407. * @param scene defines the hosting scene
  116408. * @returns a new line system mesh
  116409. */
  116410. static CreateLineSystem(name: string, options: {
  116411. lines: Vector3[][];
  116412. updatable?: boolean;
  116413. instance?: Nullable<LinesMesh>;
  116414. colors?: Nullable<Color4[][]>;
  116415. useVertexAlpha?: boolean;
  116416. }, scene: Nullable<Scene>): LinesMesh;
  116417. /**
  116418. * Creates a line mesh
  116419. * 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
  116420. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116421. * * The parameter `points` is an array successive Vector3
  116422. * * 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
  116423. * * The optional parameter `colors` is an array of successive Color4, one per line point
  116424. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  116425. * * When updating an instance, remember that only point positions can change, not the number of points
  116426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116427. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  116428. * @param name defines the name of the new line system
  116429. * @param options defines the options used to create the line system
  116430. * @param scene defines the hosting scene
  116431. * @returns a new line mesh
  116432. */
  116433. static CreateLines(name: string, options: {
  116434. points: Vector3[];
  116435. updatable?: boolean;
  116436. instance?: Nullable<LinesMesh>;
  116437. colors?: Color4[];
  116438. useVertexAlpha?: boolean;
  116439. }, scene?: Nullable<Scene>): LinesMesh;
  116440. /**
  116441. * Creates a dashed line mesh
  116442. * * 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
  116443. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116444. * * The parameter `points` is an array successive Vector3
  116445. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  116446. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  116447. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  116448. * * 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
  116449. * * When updating an instance, remember that only point positions can change, not the number of points
  116450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116451. * @param name defines the name of the mesh
  116452. * @param options defines the options used to create the mesh
  116453. * @param scene defines the hosting scene
  116454. * @returns the dashed line mesh
  116455. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  116456. */
  116457. static CreateDashedLines(name: string, options: {
  116458. points: Vector3[];
  116459. dashSize?: number;
  116460. gapSize?: number;
  116461. dashNb?: number;
  116462. updatable?: boolean;
  116463. instance?: LinesMesh;
  116464. }, scene?: Nullable<Scene>): LinesMesh;
  116465. /**
  116466. * 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.
  116467. * * 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.
  116468. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116469. * * 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.
  116470. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  116471. * * 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
  116472. * * 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
  116473. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  116474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116475. * * 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
  116476. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  116477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116478. * @param name defines the name of the mesh
  116479. * @param options defines the options used to create the mesh
  116480. * @param scene defines the hosting scene
  116481. * @returns the extruded shape mesh
  116482. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116483. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116484. */
  116485. static ExtrudeShape(name: string, options: {
  116486. shape: Vector3[];
  116487. path: Vector3[];
  116488. scale?: number;
  116489. rotation?: number;
  116490. cap?: number;
  116491. updatable?: boolean;
  116492. sideOrientation?: number;
  116493. frontUVs?: Vector4;
  116494. backUVs?: Vector4;
  116495. instance?: Mesh;
  116496. invertUV?: boolean;
  116497. }, scene?: Nullable<Scene>): Mesh;
  116498. /**
  116499. * Creates an custom extruded shape mesh.
  116500. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  116501. * * 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.
  116502. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116503. * * 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
  116504. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  116505. * * 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
  116506. * * It must returns a float value that will be the scale value applied to the shape on each path point
  116507. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  116508. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  116509. * * 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
  116510. * * 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
  116511. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  116512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116513. * * 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
  116514. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116516. * @param name defines the name of the mesh
  116517. * @param options defines the options used to create the mesh
  116518. * @param scene defines the hosting scene
  116519. * @returns the custom extruded shape mesh
  116520. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  116521. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116522. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116523. */
  116524. static ExtrudeShapeCustom(name: string, options: {
  116525. shape: Vector3[];
  116526. path: Vector3[];
  116527. scaleFunction?: any;
  116528. rotationFunction?: any;
  116529. ribbonCloseArray?: boolean;
  116530. ribbonClosePath?: boolean;
  116531. cap?: number;
  116532. updatable?: boolean;
  116533. sideOrientation?: number;
  116534. frontUVs?: Vector4;
  116535. backUVs?: Vector4;
  116536. instance?: Mesh;
  116537. invertUV?: boolean;
  116538. }, scene?: Nullable<Scene>): Mesh;
  116539. /**
  116540. * Creates lathe mesh.
  116541. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  116542. * * 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
  116543. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  116544. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  116545. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  116546. * * 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
  116547. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  116548. * * 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
  116549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116550. * * 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
  116551. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116553. * @param name defines the name of the mesh
  116554. * @param options defines the options used to create the mesh
  116555. * @param scene defines the hosting scene
  116556. * @returns the lathe mesh
  116557. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  116558. */
  116559. static CreateLathe(name: string, options: {
  116560. shape: Vector3[];
  116561. radius?: number;
  116562. tessellation?: number;
  116563. clip?: number;
  116564. arc?: number;
  116565. closed?: boolean;
  116566. updatable?: boolean;
  116567. sideOrientation?: number;
  116568. frontUVs?: Vector4;
  116569. backUVs?: Vector4;
  116570. cap?: number;
  116571. invertUV?: boolean;
  116572. }, scene?: Nullable<Scene>): Mesh;
  116573. /**
  116574. * Creates a tiled plane mesh
  116575. * * You can set a limited pattern arrangement with the tiles
  116576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116577. * * 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
  116578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116579. * @param name defines the name of the mesh
  116580. * @param options defines the options used to create the mesh
  116581. * @param scene defines the hosting scene
  116582. * @returns the plane mesh
  116583. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  116584. */
  116585. static CreateTiledPlane(name: string, options: {
  116586. pattern?: number;
  116587. tileSize?: number;
  116588. tileWidth?: number;
  116589. tileHeight?: number;
  116590. size?: number;
  116591. width?: number;
  116592. height?: number;
  116593. alignHorizontal?: number;
  116594. alignVertical?: number;
  116595. sideOrientation?: number;
  116596. frontUVs?: Vector4;
  116597. backUVs?: Vector4;
  116598. updatable?: boolean;
  116599. }, scene?: Nullable<Scene>): Mesh;
  116600. /**
  116601. * Creates a plane mesh
  116602. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  116603. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  116604. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  116605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116606. * * 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
  116607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116608. * @param name defines the name of the mesh
  116609. * @param options defines the options used to create the mesh
  116610. * @param scene defines the hosting scene
  116611. * @returns the plane mesh
  116612. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  116613. */
  116614. static CreatePlane(name: string, options: {
  116615. size?: number;
  116616. width?: number;
  116617. height?: number;
  116618. sideOrientation?: number;
  116619. frontUVs?: Vector4;
  116620. backUVs?: Vector4;
  116621. updatable?: boolean;
  116622. sourcePlane?: Plane;
  116623. }, scene?: Nullable<Scene>): Mesh;
  116624. /**
  116625. * Creates a ground mesh
  116626. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  116627. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  116628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116629. * @param name defines the name of the mesh
  116630. * @param options defines the options used to create the mesh
  116631. * @param scene defines the hosting scene
  116632. * @returns the ground mesh
  116633. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  116634. */
  116635. static CreateGround(name: string, options: {
  116636. width?: number;
  116637. height?: number;
  116638. subdivisions?: number;
  116639. subdivisionsX?: number;
  116640. subdivisionsY?: number;
  116641. updatable?: boolean;
  116642. }, scene?: Nullable<Scene>): Mesh;
  116643. /**
  116644. * Creates a tiled ground mesh
  116645. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  116646. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  116647. * * 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
  116648. * * 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
  116649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116650. * @param name defines the name of the mesh
  116651. * @param options defines the options used to create the mesh
  116652. * @param scene defines the hosting scene
  116653. * @returns the tiled ground mesh
  116654. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  116655. */
  116656. static CreateTiledGround(name: string, options: {
  116657. xmin: number;
  116658. zmin: number;
  116659. xmax: number;
  116660. zmax: number;
  116661. subdivisions?: {
  116662. w: number;
  116663. h: number;
  116664. };
  116665. precision?: {
  116666. w: number;
  116667. h: number;
  116668. };
  116669. updatable?: boolean;
  116670. }, scene?: Nullable<Scene>): Mesh;
  116671. /**
  116672. * Creates a ground mesh from a height map
  116673. * * The parameter `url` sets the URL of the height map image resource.
  116674. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  116675. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  116676. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  116677. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  116678. * * 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.
  116679. * * 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).
  116680. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  116681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116682. * @param name defines the name of the mesh
  116683. * @param url defines the url to the height map
  116684. * @param options defines the options used to create the mesh
  116685. * @param scene defines the hosting scene
  116686. * @returns the ground mesh
  116687. * @see https://doc.babylonjs.com/babylon101/height_map
  116688. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  116689. */
  116690. static CreateGroundFromHeightMap(name: string, url: string, options: {
  116691. width?: number;
  116692. height?: number;
  116693. subdivisions?: number;
  116694. minHeight?: number;
  116695. maxHeight?: number;
  116696. colorFilter?: Color3;
  116697. alphaFilter?: number;
  116698. updatable?: boolean;
  116699. onReady?: (mesh: GroundMesh) => void;
  116700. }, scene?: Nullable<Scene>): GroundMesh;
  116701. /**
  116702. * Creates a polygon mesh
  116703. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  116704. * * 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
  116705. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  116706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116707. * * 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)
  116708. * * Remember you can only change the shape positions, not their number when updating a polygon
  116709. * @param name defines the name of the mesh
  116710. * @param options defines the options used to create the mesh
  116711. * @param scene defines the hosting scene
  116712. * @param earcutInjection can be used to inject your own earcut reference
  116713. * @returns the polygon mesh
  116714. */
  116715. static CreatePolygon(name: string, options: {
  116716. shape: Vector3[];
  116717. holes?: Vector3[][];
  116718. depth?: number;
  116719. faceUV?: Vector4[];
  116720. faceColors?: Color4[];
  116721. updatable?: boolean;
  116722. sideOrientation?: number;
  116723. frontUVs?: Vector4;
  116724. backUVs?: Vector4;
  116725. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  116726. /**
  116727. * Creates an extruded polygon mesh, with depth in the Y direction.
  116728. * * 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)
  116729. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  116730. * @param name defines the name of the mesh
  116731. * @param options defines the options used to create the mesh
  116732. * @param scene defines the hosting scene
  116733. * @param earcutInjection can be used to inject your own earcut reference
  116734. * @returns the polygon mesh
  116735. */
  116736. static ExtrudePolygon(name: string, options: {
  116737. shape: Vector3[];
  116738. holes?: Vector3[][];
  116739. depth?: number;
  116740. faceUV?: Vector4[];
  116741. faceColors?: Color4[];
  116742. updatable?: boolean;
  116743. sideOrientation?: number;
  116744. frontUVs?: Vector4;
  116745. backUVs?: Vector4;
  116746. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  116747. /**
  116748. * Creates a tube mesh.
  116749. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116750. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  116751. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  116752. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  116753. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  116754. * * 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)
  116755. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  116756. * * 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
  116757. * * 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
  116758. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116759. * * 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
  116760. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116762. * @param name defines the name of the mesh
  116763. * @param options defines the options used to create the mesh
  116764. * @param scene defines the hosting scene
  116765. * @returns the tube mesh
  116766. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116767. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  116768. */
  116769. static CreateTube(name: string, options: {
  116770. path: Vector3[];
  116771. radius?: number;
  116772. tessellation?: number;
  116773. radiusFunction?: {
  116774. (i: number, distance: number): number;
  116775. };
  116776. cap?: number;
  116777. arc?: number;
  116778. updatable?: boolean;
  116779. sideOrientation?: number;
  116780. frontUVs?: Vector4;
  116781. backUVs?: Vector4;
  116782. instance?: Mesh;
  116783. invertUV?: boolean;
  116784. }, scene?: Nullable<Scene>): Mesh;
  116785. /**
  116786. * Creates a polyhedron mesh
  116787. * * 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
  116788. * * The parameter `size` (positive float, default 1) sets the polygon size
  116789. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  116790. * * 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`
  116791. * * 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
  116792. * * 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)`)
  116793. * * 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
  116794. * * 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
  116795. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116796. * * 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
  116797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116798. * @param name defines the name of the mesh
  116799. * @param options defines the options used to create the mesh
  116800. * @param scene defines the hosting scene
  116801. * @returns the polyhedron mesh
  116802. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  116803. */
  116804. static CreatePolyhedron(name: string, options: {
  116805. type?: number;
  116806. size?: number;
  116807. sizeX?: number;
  116808. sizeY?: number;
  116809. sizeZ?: number;
  116810. custom?: any;
  116811. faceUV?: Vector4[];
  116812. faceColors?: Color4[];
  116813. flat?: boolean;
  116814. updatable?: boolean;
  116815. sideOrientation?: number;
  116816. frontUVs?: Vector4;
  116817. backUVs?: Vector4;
  116818. }, scene?: Nullable<Scene>): Mesh;
  116819. /**
  116820. * Creates a decal mesh.
  116821. * 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
  116822. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  116823. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  116824. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  116825. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  116826. * @param name defines the name of the mesh
  116827. * @param sourceMesh defines the mesh where the decal must be applied
  116828. * @param options defines the options used to create the mesh
  116829. * @param scene defines the hosting scene
  116830. * @returns the decal mesh
  116831. * @see https://doc.babylonjs.com/how_to/decals
  116832. */
  116833. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  116834. position?: Vector3;
  116835. normal?: Vector3;
  116836. size?: Vector3;
  116837. angle?: number;
  116838. }): Mesh;
  116839. }
  116840. }
  116841. declare module BABYLON {
  116842. /**
  116843. * A simplifier interface for future simplification implementations
  116844. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116845. */
  116846. export interface ISimplifier {
  116847. /**
  116848. * Simplification of a given mesh according to the given settings.
  116849. * Since this requires computation, it is assumed that the function runs async.
  116850. * @param settings The settings of the simplification, including quality and distance
  116851. * @param successCallback A callback that will be called after the mesh was simplified.
  116852. * @param errorCallback in case of an error, this callback will be called. optional.
  116853. */
  116854. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  116855. }
  116856. /**
  116857. * Expected simplification settings.
  116858. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  116859. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116860. */
  116861. export interface ISimplificationSettings {
  116862. /**
  116863. * Gets or sets the expected quality
  116864. */
  116865. quality: number;
  116866. /**
  116867. * Gets or sets the distance when this optimized version should be used
  116868. */
  116869. distance: number;
  116870. /**
  116871. * Gets an already optimized mesh
  116872. */
  116873. optimizeMesh?: boolean;
  116874. }
  116875. /**
  116876. * Class used to specify simplification options
  116877. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116878. */
  116879. export class SimplificationSettings implements ISimplificationSettings {
  116880. /** expected quality */
  116881. quality: number;
  116882. /** distance when this optimized version should be used */
  116883. distance: number;
  116884. /** already optimized mesh */
  116885. optimizeMesh?: boolean | undefined;
  116886. /**
  116887. * Creates a SimplificationSettings
  116888. * @param quality expected quality
  116889. * @param distance distance when this optimized version should be used
  116890. * @param optimizeMesh already optimized mesh
  116891. */
  116892. constructor(
  116893. /** expected quality */
  116894. quality: number,
  116895. /** distance when this optimized version should be used */
  116896. distance: number,
  116897. /** already optimized mesh */
  116898. optimizeMesh?: boolean | undefined);
  116899. }
  116900. /**
  116901. * Interface used to define a simplification task
  116902. */
  116903. export interface ISimplificationTask {
  116904. /**
  116905. * Array of settings
  116906. */
  116907. settings: Array<ISimplificationSettings>;
  116908. /**
  116909. * Simplification type
  116910. */
  116911. simplificationType: SimplificationType;
  116912. /**
  116913. * Mesh to simplify
  116914. */
  116915. mesh: Mesh;
  116916. /**
  116917. * Callback called on success
  116918. */
  116919. successCallback?: () => void;
  116920. /**
  116921. * Defines if parallel processing can be used
  116922. */
  116923. parallelProcessing: boolean;
  116924. }
  116925. /**
  116926. * Queue used to order the simplification tasks
  116927. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116928. */
  116929. export class SimplificationQueue {
  116930. private _simplificationArray;
  116931. /**
  116932. * Gets a boolean indicating that the process is still running
  116933. */
  116934. running: boolean;
  116935. /**
  116936. * Creates a new queue
  116937. */
  116938. constructor();
  116939. /**
  116940. * Adds a new simplification task
  116941. * @param task defines a task to add
  116942. */
  116943. addTask(task: ISimplificationTask): void;
  116944. /**
  116945. * Execute next task
  116946. */
  116947. executeNext(): void;
  116948. /**
  116949. * Execute a simplification task
  116950. * @param task defines the task to run
  116951. */
  116952. runSimplification(task: ISimplificationTask): void;
  116953. private getSimplifier;
  116954. }
  116955. /**
  116956. * The implemented types of simplification
  116957. * At the moment only Quadratic Error Decimation is implemented
  116958. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116959. */
  116960. export enum SimplificationType {
  116961. /** Quadratic error decimation */
  116962. QUADRATIC = 0
  116963. }
  116964. }
  116965. declare module BABYLON {
  116966. interface Scene {
  116967. /** @hidden (Backing field) */
  116968. _simplificationQueue: SimplificationQueue;
  116969. /**
  116970. * Gets or sets the simplification queue attached to the scene
  116971. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116972. */
  116973. simplificationQueue: SimplificationQueue;
  116974. }
  116975. interface Mesh {
  116976. /**
  116977. * Simplify the mesh according to the given array of settings.
  116978. * Function will return immediately and will simplify async
  116979. * @param settings a collection of simplification settings
  116980. * @param parallelProcessing should all levels calculate parallel or one after the other
  116981. * @param simplificationType the type of simplification to run
  116982. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  116983. * @returns the current mesh
  116984. */
  116985. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  116986. }
  116987. /**
  116988. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  116989. * created in a scene
  116990. */
  116991. export class SimplicationQueueSceneComponent implements ISceneComponent {
  116992. /**
  116993. * The component name helpfull to identify the component in the list of scene components.
  116994. */
  116995. readonly name: string;
  116996. /**
  116997. * The scene the component belongs to.
  116998. */
  116999. scene: Scene;
  117000. /**
  117001. * Creates a new instance of the component for the given scene
  117002. * @param scene Defines the scene to register the component in
  117003. */
  117004. constructor(scene: Scene);
  117005. /**
  117006. * Registers the component in a given scene
  117007. */
  117008. register(): void;
  117009. /**
  117010. * Rebuilds the elements related to this component in case of
  117011. * context lost for instance.
  117012. */
  117013. rebuild(): void;
  117014. /**
  117015. * Disposes the component and the associated ressources
  117016. */
  117017. dispose(): void;
  117018. private _beforeCameraUpdate;
  117019. }
  117020. }
  117021. declare module BABYLON {
  117022. /**
  117023. * Class used to enable access to IndexedDB
  117024. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  117025. */
  117026. export class Database implements IOfflineProvider {
  117027. private _callbackManifestChecked;
  117028. private _currentSceneUrl;
  117029. private _db;
  117030. private _enableSceneOffline;
  117031. private _enableTexturesOffline;
  117032. private _manifestVersionFound;
  117033. private _mustUpdateRessources;
  117034. private _hasReachedQuota;
  117035. private _isSupported;
  117036. private _idbFactory;
  117037. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  117038. private static IsUASupportingBlobStorage;
  117039. /**
  117040. * Gets a boolean indicating if Database storate is enabled (off by default)
  117041. */
  117042. static IDBStorageEnabled: boolean;
  117043. /**
  117044. * Gets a boolean indicating if scene must be saved in the database
  117045. */
  117046. readonly enableSceneOffline: boolean;
  117047. /**
  117048. * Gets a boolean indicating if textures must be saved in the database
  117049. */
  117050. readonly enableTexturesOffline: boolean;
  117051. /**
  117052. * Creates a new Database
  117053. * @param urlToScene defines the url to load the scene
  117054. * @param callbackManifestChecked defines the callback to use when manifest is checked
  117055. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  117056. */
  117057. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  117058. private static _ParseURL;
  117059. private static _ReturnFullUrlLocation;
  117060. private _checkManifestFile;
  117061. /**
  117062. * Open the database and make it available
  117063. * @param successCallback defines the callback to call on success
  117064. * @param errorCallback defines the callback to call on error
  117065. */
  117066. open(successCallback: () => void, errorCallback: () => void): void;
  117067. /**
  117068. * Loads an image from the database
  117069. * @param url defines the url to load from
  117070. * @param image defines the target DOM image
  117071. */
  117072. loadImage(url: string, image: HTMLImageElement): void;
  117073. private _loadImageFromDBAsync;
  117074. private _saveImageIntoDBAsync;
  117075. private _checkVersionFromDB;
  117076. private _loadVersionFromDBAsync;
  117077. private _saveVersionIntoDBAsync;
  117078. /**
  117079. * Loads a file from database
  117080. * @param url defines the URL to load from
  117081. * @param sceneLoaded defines a callback to call on success
  117082. * @param progressCallBack defines a callback to call when progress changed
  117083. * @param errorCallback defines a callback to call on error
  117084. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  117085. */
  117086. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  117087. private _loadFileAsync;
  117088. private _saveFileAsync;
  117089. /**
  117090. * Validates if xhr data is correct
  117091. * @param xhr defines the request to validate
  117092. * @param dataType defines the expected data type
  117093. * @returns true if data is correct
  117094. */
  117095. private static _ValidateXHRData;
  117096. }
  117097. }
  117098. declare module BABYLON {
  117099. /** @hidden */
  117100. export var gpuUpdateParticlesPixelShader: {
  117101. name: string;
  117102. shader: string;
  117103. };
  117104. }
  117105. declare module BABYLON {
  117106. /** @hidden */
  117107. export var gpuUpdateParticlesVertexShader: {
  117108. name: string;
  117109. shader: string;
  117110. };
  117111. }
  117112. declare module BABYLON {
  117113. /** @hidden */
  117114. export var clipPlaneFragmentDeclaration2: {
  117115. name: string;
  117116. shader: string;
  117117. };
  117118. }
  117119. declare module BABYLON {
  117120. /** @hidden */
  117121. export var gpuRenderParticlesPixelShader: {
  117122. name: string;
  117123. shader: string;
  117124. };
  117125. }
  117126. declare module BABYLON {
  117127. /** @hidden */
  117128. export var clipPlaneVertexDeclaration2: {
  117129. name: string;
  117130. shader: string;
  117131. };
  117132. }
  117133. declare module BABYLON {
  117134. /** @hidden */
  117135. export var gpuRenderParticlesVertexShader: {
  117136. name: string;
  117137. shader: string;
  117138. };
  117139. }
  117140. declare module BABYLON {
  117141. /**
  117142. * This represents a GPU particle system in Babylon
  117143. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  117144. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  117145. */
  117146. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  117147. /**
  117148. * The layer mask we are rendering the particles through.
  117149. */
  117150. layerMask: number;
  117151. private _capacity;
  117152. private _activeCount;
  117153. private _currentActiveCount;
  117154. private _accumulatedCount;
  117155. private _renderEffect;
  117156. private _updateEffect;
  117157. private _buffer0;
  117158. private _buffer1;
  117159. private _spriteBuffer;
  117160. private _updateVAO;
  117161. private _renderVAO;
  117162. private _targetIndex;
  117163. private _sourceBuffer;
  117164. private _targetBuffer;
  117165. private _engine;
  117166. private _currentRenderId;
  117167. private _started;
  117168. private _stopped;
  117169. private _timeDelta;
  117170. private _randomTexture;
  117171. private _randomTexture2;
  117172. private _attributesStrideSize;
  117173. private _updateEffectOptions;
  117174. private _randomTextureSize;
  117175. private _actualFrame;
  117176. private readonly _rawTextureWidth;
  117177. /**
  117178. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  117179. */
  117180. static readonly IsSupported: boolean;
  117181. /**
  117182. * An event triggered when the system is disposed.
  117183. */
  117184. onDisposeObservable: Observable<GPUParticleSystem>;
  117185. /**
  117186. * Gets the maximum number of particles active at the same time.
  117187. * @returns The max number of active particles.
  117188. */
  117189. getCapacity(): number;
  117190. /**
  117191. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  117192. * to override the particles.
  117193. */
  117194. forceDepthWrite: boolean;
  117195. /**
  117196. * Gets or set the number of active particles
  117197. */
  117198. activeParticleCount: number;
  117199. private _preWarmDone;
  117200. /**
  117201. * Is this system ready to be used/rendered
  117202. * @return true if the system is ready
  117203. */
  117204. isReady(): boolean;
  117205. /**
  117206. * Gets if the system has been started. (Note: this will still be true after stop is called)
  117207. * @returns True if it has been started, otherwise false.
  117208. */
  117209. isStarted(): boolean;
  117210. /**
  117211. * Starts the particle system and begins to emit
  117212. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  117213. */
  117214. start(delay?: number): void;
  117215. /**
  117216. * Stops the particle system.
  117217. */
  117218. stop(): void;
  117219. /**
  117220. * Remove all active particles
  117221. */
  117222. reset(): void;
  117223. /**
  117224. * Returns the string "GPUParticleSystem"
  117225. * @returns a string containing the class name
  117226. */
  117227. getClassName(): string;
  117228. private _colorGradientsTexture;
  117229. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  117230. /**
  117231. * Adds a new color gradient
  117232. * @param gradient defines the gradient to use (between 0 and 1)
  117233. * @param color1 defines the color to affect to the specified gradient
  117234. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  117235. * @returns the current particle system
  117236. */
  117237. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  117238. /**
  117239. * Remove a specific color gradient
  117240. * @param gradient defines the gradient to remove
  117241. * @returns the current particle system
  117242. */
  117243. removeColorGradient(gradient: number): GPUParticleSystem;
  117244. private _angularSpeedGradientsTexture;
  117245. private _sizeGradientsTexture;
  117246. private _velocityGradientsTexture;
  117247. private _limitVelocityGradientsTexture;
  117248. private _dragGradientsTexture;
  117249. private _addFactorGradient;
  117250. /**
  117251. * Adds a new size gradient
  117252. * @param gradient defines the gradient to use (between 0 and 1)
  117253. * @param factor defines the size factor to affect to the specified gradient
  117254. * @returns the current particle system
  117255. */
  117256. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  117257. /**
  117258. * Remove a specific size gradient
  117259. * @param gradient defines the gradient to remove
  117260. * @returns the current particle system
  117261. */
  117262. removeSizeGradient(gradient: number): GPUParticleSystem;
  117263. /**
  117264. * Adds a new angular speed gradient
  117265. * @param gradient defines the gradient to use (between 0 and 1)
  117266. * @param factor defines the angular speed to affect to the specified gradient
  117267. * @returns the current particle system
  117268. */
  117269. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  117270. /**
  117271. * Remove a specific angular speed gradient
  117272. * @param gradient defines the gradient to remove
  117273. * @returns the current particle system
  117274. */
  117275. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  117276. /**
  117277. * Adds a new velocity gradient
  117278. * @param gradient defines the gradient to use (between 0 and 1)
  117279. * @param factor defines the velocity to affect to the specified gradient
  117280. * @returns the current particle system
  117281. */
  117282. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  117283. /**
  117284. * Remove a specific velocity gradient
  117285. * @param gradient defines the gradient to remove
  117286. * @returns the current particle system
  117287. */
  117288. removeVelocityGradient(gradient: number): GPUParticleSystem;
  117289. /**
  117290. * Adds a new limit velocity gradient
  117291. * @param gradient defines the gradient to use (between 0 and 1)
  117292. * @param factor defines the limit velocity value to affect to the specified gradient
  117293. * @returns the current particle system
  117294. */
  117295. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  117296. /**
  117297. * Remove a specific limit velocity gradient
  117298. * @param gradient defines the gradient to remove
  117299. * @returns the current particle system
  117300. */
  117301. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  117302. /**
  117303. * Adds a new drag gradient
  117304. * @param gradient defines the gradient to use (between 0 and 1)
  117305. * @param factor defines the drag value to affect to the specified gradient
  117306. * @returns the current particle system
  117307. */
  117308. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  117309. /**
  117310. * Remove a specific drag gradient
  117311. * @param gradient defines the gradient to remove
  117312. * @returns the current particle system
  117313. */
  117314. removeDragGradient(gradient: number): GPUParticleSystem;
  117315. /**
  117316. * Not supported by GPUParticleSystem
  117317. * @param gradient defines the gradient to use (between 0 and 1)
  117318. * @param factor defines the emit rate value to affect to the specified gradient
  117319. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117320. * @returns the current particle system
  117321. */
  117322. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117323. /**
  117324. * Not supported by GPUParticleSystem
  117325. * @param gradient defines the gradient to remove
  117326. * @returns the current particle system
  117327. */
  117328. removeEmitRateGradient(gradient: number): IParticleSystem;
  117329. /**
  117330. * Not supported by GPUParticleSystem
  117331. * @param gradient defines the gradient to use (between 0 and 1)
  117332. * @param factor defines the start size value to affect to the specified gradient
  117333. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117334. * @returns the current particle system
  117335. */
  117336. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117337. /**
  117338. * Not supported by GPUParticleSystem
  117339. * @param gradient defines the gradient to remove
  117340. * @returns the current particle system
  117341. */
  117342. removeStartSizeGradient(gradient: number): IParticleSystem;
  117343. /**
  117344. * Not supported by GPUParticleSystem
  117345. * @param gradient defines the gradient to use (between 0 and 1)
  117346. * @param min defines the color remap minimal range
  117347. * @param max defines the color remap maximal range
  117348. * @returns the current particle system
  117349. */
  117350. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  117351. /**
  117352. * Not supported by GPUParticleSystem
  117353. * @param gradient defines the gradient to remove
  117354. * @returns the current particle system
  117355. */
  117356. removeColorRemapGradient(): IParticleSystem;
  117357. /**
  117358. * Not supported by GPUParticleSystem
  117359. * @param gradient defines the gradient to use (between 0 and 1)
  117360. * @param min defines the alpha remap minimal range
  117361. * @param max defines the alpha remap maximal range
  117362. * @returns the current particle system
  117363. */
  117364. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  117365. /**
  117366. * Not supported by GPUParticleSystem
  117367. * @param gradient defines the gradient to remove
  117368. * @returns the current particle system
  117369. */
  117370. removeAlphaRemapGradient(): IParticleSystem;
  117371. /**
  117372. * Not supported by GPUParticleSystem
  117373. * @param gradient defines the gradient to use (between 0 and 1)
  117374. * @param color defines the color to affect to the specified gradient
  117375. * @returns the current particle system
  117376. */
  117377. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  117378. /**
  117379. * Not supported by GPUParticleSystem
  117380. * @param gradient defines the gradient to remove
  117381. * @returns the current particle system
  117382. */
  117383. removeRampGradient(): IParticleSystem;
  117384. /**
  117385. * Not supported by GPUParticleSystem
  117386. * @returns the list of ramp gradients
  117387. */
  117388. getRampGradients(): Nullable<Array<Color3Gradient>>;
  117389. /**
  117390. * Not supported by GPUParticleSystem
  117391. * Gets or sets a boolean indicating that ramp gradients must be used
  117392. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  117393. */
  117394. useRampGradients: boolean;
  117395. /**
  117396. * Not supported by GPUParticleSystem
  117397. * @param gradient defines the gradient to use (between 0 and 1)
  117398. * @param factor defines the life time factor to affect to the specified gradient
  117399. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117400. * @returns the current particle system
  117401. */
  117402. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117403. /**
  117404. * Not supported by GPUParticleSystem
  117405. * @param gradient defines the gradient to remove
  117406. * @returns the current particle system
  117407. */
  117408. removeLifeTimeGradient(gradient: number): IParticleSystem;
  117409. /**
  117410. * Instantiates a GPU particle system.
  117411. * 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.
  117412. * @param name The name of the particle system
  117413. * @param options The options used to create the system
  117414. * @param scene The scene the particle system belongs to
  117415. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  117416. */
  117417. constructor(name: string, options: Partial<{
  117418. capacity: number;
  117419. randomTextureSize: number;
  117420. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  117421. protected _reset(): void;
  117422. private _createUpdateVAO;
  117423. private _createRenderVAO;
  117424. private _initialize;
  117425. /** @hidden */
  117426. _recreateUpdateEffect(): void;
  117427. /** @hidden */
  117428. _recreateRenderEffect(): void;
  117429. /**
  117430. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  117431. * @param preWarm defines if we are in the pre-warmimg phase
  117432. */
  117433. animate(preWarm?: boolean): void;
  117434. private _createFactorGradientTexture;
  117435. private _createSizeGradientTexture;
  117436. private _createAngularSpeedGradientTexture;
  117437. private _createVelocityGradientTexture;
  117438. private _createLimitVelocityGradientTexture;
  117439. private _createDragGradientTexture;
  117440. private _createColorGradientTexture;
  117441. /**
  117442. * Renders the particle system in its current state
  117443. * @param preWarm defines if the system should only update the particles but not render them
  117444. * @returns the current number of particles
  117445. */
  117446. render(preWarm?: boolean): number;
  117447. /**
  117448. * Rebuilds the particle system
  117449. */
  117450. rebuild(): void;
  117451. private _releaseBuffers;
  117452. private _releaseVAOs;
  117453. /**
  117454. * Disposes the particle system and free the associated resources
  117455. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  117456. */
  117457. dispose(disposeTexture?: boolean): void;
  117458. /**
  117459. * Clones the particle system.
  117460. * @param name The name of the cloned object
  117461. * @param newEmitter The new emitter to use
  117462. * @returns the cloned particle system
  117463. */
  117464. clone(name: string, newEmitter: any): GPUParticleSystem;
  117465. /**
  117466. * Serializes the particle system to a JSON object.
  117467. * @returns the JSON object
  117468. */
  117469. serialize(): any;
  117470. /**
  117471. * Parses a JSON object to create a GPU particle system.
  117472. * @param parsedParticleSystem The JSON object to parse
  117473. * @param scene The scene to create the particle system in
  117474. * @param rootUrl The root url to use to load external dependencies like texture
  117475. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  117476. * @returns the parsed GPU particle system
  117477. */
  117478. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  117479. }
  117480. }
  117481. declare module BABYLON {
  117482. /**
  117483. * Represents a set of particle systems working together to create a specific effect
  117484. */
  117485. export class ParticleSystemSet implements IDisposable {
  117486. private _emitterCreationOptions;
  117487. private _emitterNode;
  117488. /**
  117489. * Gets the particle system list
  117490. */
  117491. systems: IParticleSystem[];
  117492. /**
  117493. * Gets the emitter node used with this set
  117494. */
  117495. readonly emitterNode: Nullable<TransformNode>;
  117496. /**
  117497. * Creates a new emitter mesh as a sphere
  117498. * @param options defines the options used to create the sphere
  117499. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  117500. * @param scene defines the hosting scene
  117501. */
  117502. setEmitterAsSphere(options: {
  117503. diameter: number;
  117504. segments: number;
  117505. color: Color3;
  117506. }, renderingGroupId: number, scene: Scene): void;
  117507. /**
  117508. * Starts all particle systems of the set
  117509. * @param emitter defines an optional mesh to use as emitter for the particle systems
  117510. */
  117511. start(emitter?: AbstractMesh): void;
  117512. /**
  117513. * Release all associated resources
  117514. */
  117515. dispose(): void;
  117516. /**
  117517. * Serialize the set into a JSON compatible object
  117518. * @returns a JSON compatible representation of the set
  117519. */
  117520. serialize(): any;
  117521. /**
  117522. * Parse a new ParticleSystemSet from a serialized source
  117523. * @param data defines a JSON compatible representation of the set
  117524. * @param scene defines the hosting scene
  117525. * @param gpu defines if we want GPU particles or CPU particles
  117526. * @returns a new ParticleSystemSet
  117527. */
  117528. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  117529. }
  117530. }
  117531. declare module BABYLON {
  117532. /**
  117533. * This class is made for on one-liner static method to help creating particle system set.
  117534. */
  117535. export class ParticleHelper {
  117536. /**
  117537. * Gets or sets base Assets URL
  117538. */
  117539. static BaseAssetsUrl: string;
  117540. /**
  117541. * Create a default particle system that you can tweak
  117542. * @param emitter defines the emitter to use
  117543. * @param capacity defines the system capacity (default is 500 particles)
  117544. * @param scene defines the hosting scene
  117545. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  117546. * @returns the new Particle system
  117547. */
  117548. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  117549. /**
  117550. * This is the main static method (one-liner) of this helper to create different particle systems
  117551. * @param type This string represents the type to the particle system to create
  117552. * @param scene The scene where the particle system should live
  117553. * @param gpu If the system will use gpu
  117554. * @returns the ParticleSystemSet created
  117555. */
  117556. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  117557. /**
  117558. * Static function used to export a particle system to a ParticleSystemSet variable.
  117559. * Please note that the emitter shape is not exported
  117560. * @param systems defines the particle systems to export
  117561. * @returns the created particle system set
  117562. */
  117563. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  117564. }
  117565. }
  117566. declare module BABYLON {
  117567. interface Engine {
  117568. /**
  117569. * Create an effect to use with particle systems.
  117570. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  117571. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  117572. * @param uniformsNames defines a list of attribute names
  117573. * @param samplers defines an array of string used to represent textures
  117574. * @param defines defines the string containing the defines to use to compile the shaders
  117575. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  117576. * @param onCompiled defines a function to call when the effect creation is successful
  117577. * @param onError defines a function to call when the effect creation has failed
  117578. * @returns the new Effect
  117579. */
  117580. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  117581. }
  117582. interface Mesh {
  117583. /**
  117584. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  117585. * @returns an array of IParticleSystem
  117586. */
  117587. getEmittedParticleSystems(): IParticleSystem[];
  117588. /**
  117589. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  117590. * @returns an array of IParticleSystem
  117591. */
  117592. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  117593. }
  117594. /**
  117595. * @hidden
  117596. */
  117597. export var _IDoNeedToBeInTheBuild: number;
  117598. }
  117599. declare module BABYLON {
  117600. interface Scene {
  117601. /** @hidden (Backing field) */
  117602. _physicsEngine: Nullable<IPhysicsEngine>;
  117603. /**
  117604. * Gets the current physics engine
  117605. * @returns a IPhysicsEngine or null if none attached
  117606. */
  117607. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  117608. /**
  117609. * Enables physics to the current scene
  117610. * @param gravity defines the scene's gravity for the physics engine
  117611. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  117612. * @return a boolean indicating if the physics engine was initialized
  117613. */
  117614. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  117615. /**
  117616. * Disables and disposes the physics engine associated with the scene
  117617. */
  117618. disablePhysicsEngine(): void;
  117619. /**
  117620. * Gets a boolean indicating if there is an active physics engine
  117621. * @returns a boolean indicating if there is an active physics engine
  117622. */
  117623. isPhysicsEnabled(): boolean;
  117624. /**
  117625. * Deletes a physics compound impostor
  117626. * @param compound defines the compound to delete
  117627. */
  117628. deleteCompoundImpostor(compound: any): void;
  117629. /**
  117630. * An event triggered when physic simulation is about to be run
  117631. */
  117632. onBeforePhysicsObservable: Observable<Scene>;
  117633. /**
  117634. * An event triggered when physic simulation has been done
  117635. */
  117636. onAfterPhysicsObservable: Observable<Scene>;
  117637. }
  117638. interface AbstractMesh {
  117639. /** @hidden */
  117640. _physicsImpostor: Nullable<PhysicsImpostor>;
  117641. /**
  117642. * Gets or sets impostor used for physic simulation
  117643. * @see http://doc.babylonjs.com/features/physics_engine
  117644. */
  117645. physicsImpostor: Nullable<PhysicsImpostor>;
  117646. /**
  117647. * Gets the current physics impostor
  117648. * @see http://doc.babylonjs.com/features/physics_engine
  117649. * @returns a physics impostor or null
  117650. */
  117651. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  117652. /** Apply a physic impulse to the mesh
  117653. * @param force defines the force to apply
  117654. * @param contactPoint defines where to apply the force
  117655. * @returns the current mesh
  117656. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117657. */
  117658. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  117659. /**
  117660. * Creates a physic joint between two meshes
  117661. * @param otherMesh defines the other mesh to use
  117662. * @param pivot1 defines the pivot to use on this mesh
  117663. * @param pivot2 defines the pivot to use on the other mesh
  117664. * @param options defines additional options (can be plugin dependent)
  117665. * @returns the current mesh
  117666. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  117667. */
  117668. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  117669. /** @hidden */
  117670. _disposePhysicsObserver: Nullable<Observer<Node>>;
  117671. }
  117672. /**
  117673. * Defines the physics engine scene component responsible to manage a physics engine
  117674. */
  117675. export class PhysicsEngineSceneComponent implements ISceneComponent {
  117676. /**
  117677. * The component name helpful to identify the component in the list of scene components.
  117678. */
  117679. readonly name: string;
  117680. /**
  117681. * The scene the component belongs to.
  117682. */
  117683. scene: Scene;
  117684. /**
  117685. * Creates a new instance of the component for the given scene
  117686. * @param scene Defines the scene to register the component in
  117687. */
  117688. constructor(scene: Scene);
  117689. /**
  117690. * Registers the component in a given scene
  117691. */
  117692. register(): void;
  117693. /**
  117694. * Rebuilds the elements related to this component in case of
  117695. * context lost for instance.
  117696. */
  117697. rebuild(): void;
  117698. /**
  117699. * Disposes the component and the associated ressources
  117700. */
  117701. dispose(): void;
  117702. }
  117703. }
  117704. declare module BABYLON {
  117705. /**
  117706. * A helper for physics simulations
  117707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117708. */
  117709. export class PhysicsHelper {
  117710. private _scene;
  117711. private _physicsEngine;
  117712. /**
  117713. * Initializes the Physics helper
  117714. * @param scene Babylon.js scene
  117715. */
  117716. constructor(scene: Scene);
  117717. /**
  117718. * Applies a radial explosion impulse
  117719. * @param origin the origin of the explosion
  117720. * @param radiusOrEventOptions the radius or the options of radial explosion
  117721. * @param strength the explosion strength
  117722. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117723. * @returns A physics radial explosion event, or null
  117724. */
  117725. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  117726. /**
  117727. * Applies a radial explosion force
  117728. * @param origin the origin of the explosion
  117729. * @param radiusOrEventOptions the radius or the options of radial explosion
  117730. * @param strength the explosion strength
  117731. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117732. * @returns A physics radial explosion event, or null
  117733. */
  117734. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  117735. /**
  117736. * Creates a gravitational field
  117737. * @param origin the origin of the explosion
  117738. * @param radiusOrEventOptions the radius or the options of radial explosion
  117739. * @param strength the explosion strength
  117740. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117741. * @returns A physics gravitational field event, or null
  117742. */
  117743. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  117744. /**
  117745. * Creates a physics updraft event
  117746. * @param origin the origin of the updraft
  117747. * @param radiusOrEventOptions the radius or the options of the updraft
  117748. * @param strength the strength of the updraft
  117749. * @param height the height of the updraft
  117750. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  117751. * @returns A physics updraft event, or null
  117752. */
  117753. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  117754. /**
  117755. * Creates a physics vortex event
  117756. * @param origin the of the vortex
  117757. * @param radiusOrEventOptions the radius or the options of the vortex
  117758. * @param strength the strength of the vortex
  117759. * @param height the height of the vortex
  117760. * @returns a Physics vortex event, or null
  117761. * A physics vortex event or null
  117762. */
  117763. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  117764. }
  117765. /**
  117766. * Represents a physics radial explosion event
  117767. */
  117768. class PhysicsRadialExplosionEvent {
  117769. private _scene;
  117770. private _options;
  117771. private _sphere;
  117772. private _dataFetched;
  117773. /**
  117774. * Initializes a radial explosioin event
  117775. * @param _scene BabylonJS scene
  117776. * @param _options The options for the vortex event
  117777. */
  117778. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  117779. /**
  117780. * Returns the data related to the radial explosion event (sphere).
  117781. * @returns The radial explosion event data
  117782. */
  117783. getData(): PhysicsRadialExplosionEventData;
  117784. /**
  117785. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  117786. * @param impostor A physics imposter
  117787. * @param origin the origin of the explosion
  117788. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  117789. */
  117790. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  117791. /**
  117792. * Triggers affecterd impostors callbacks
  117793. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  117794. */
  117795. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  117796. /**
  117797. * Disposes the sphere.
  117798. * @param force Specifies if the sphere should be disposed by force
  117799. */
  117800. dispose(force?: boolean): void;
  117801. /*** Helpers ***/
  117802. private _prepareSphere;
  117803. private _intersectsWithSphere;
  117804. }
  117805. /**
  117806. * Represents a gravitational field event
  117807. */
  117808. class PhysicsGravitationalFieldEvent {
  117809. private _physicsHelper;
  117810. private _scene;
  117811. private _origin;
  117812. private _options;
  117813. private _tickCallback;
  117814. private _sphere;
  117815. private _dataFetched;
  117816. /**
  117817. * Initializes the physics gravitational field event
  117818. * @param _physicsHelper A physics helper
  117819. * @param _scene BabylonJS scene
  117820. * @param _origin The origin position of the gravitational field event
  117821. * @param _options The options for the vortex event
  117822. */
  117823. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  117824. /**
  117825. * Returns the data related to the gravitational field event (sphere).
  117826. * @returns A gravitational field event
  117827. */
  117828. getData(): PhysicsGravitationalFieldEventData;
  117829. /**
  117830. * Enables the gravitational field.
  117831. */
  117832. enable(): void;
  117833. /**
  117834. * Disables the gravitational field.
  117835. */
  117836. disable(): void;
  117837. /**
  117838. * Disposes the sphere.
  117839. * @param force The force to dispose from the gravitational field event
  117840. */
  117841. dispose(force?: boolean): void;
  117842. private _tick;
  117843. }
  117844. /**
  117845. * Represents a physics updraft event
  117846. */
  117847. class PhysicsUpdraftEvent {
  117848. private _scene;
  117849. private _origin;
  117850. private _options;
  117851. private _physicsEngine;
  117852. private _originTop;
  117853. private _originDirection;
  117854. private _tickCallback;
  117855. private _cylinder;
  117856. private _cylinderPosition;
  117857. private _dataFetched;
  117858. /**
  117859. * Initializes the physics updraft event
  117860. * @param _scene BabylonJS scene
  117861. * @param _origin The origin position of the updraft
  117862. * @param _options The options for the updraft event
  117863. */
  117864. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  117865. /**
  117866. * Returns the data related to the updraft event (cylinder).
  117867. * @returns A physics updraft event
  117868. */
  117869. getData(): PhysicsUpdraftEventData;
  117870. /**
  117871. * Enables the updraft.
  117872. */
  117873. enable(): void;
  117874. /**
  117875. * Disables the updraft.
  117876. */
  117877. disable(): void;
  117878. /**
  117879. * Disposes the cylinder.
  117880. * @param force Specifies if the updraft should be disposed by force
  117881. */
  117882. dispose(force?: boolean): void;
  117883. private getImpostorHitData;
  117884. private _tick;
  117885. /*** Helpers ***/
  117886. private _prepareCylinder;
  117887. private _intersectsWithCylinder;
  117888. }
  117889. /**
  117890. * Represents a physics vortex event
  117891. */
  117892. class PhysicsVortexEvent {
  117893. private _scene;
  117894. private _origin;
  117895. private _options;
  117896. private _physicsEngine;
  117897. private _originTop;
  117898. private _tickCallback;
  117899. private _cylinder;
  117900. private _cylinderPosition;
  117901. private _dataFetched;
  117902. /**
  117903. * Initializes the physics vortex event
  117904. * @param _scene The BabylonJS scene
  117905. * @param _origin The origin position of the vortex
  117906. * @param _options The options for the vortex event
  117907. */
  117908. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  117909. /**
  117910. * Returns the data related to the vortex event (cylinder).
  117911. * @returns The physics vortex event data
  117912. */
  117913. getData(): PhysicsVortexEventData;
  117914. /**
  117915. * Enables the vortex.
  117916. */
  117917. enable(): void;
  117918. /**
  117919. * Disables the cortex.
  117920. */
  117921. disable(): void;
  117922. /**
  117923. * Disposes the sphere.
  117924. * @param force
  117925. */
  117926. dispose(force?: boolean): void;
  117927. private getImpostorHitData;
  117928. private _tick;
  117929. /*** Helpers ***/
  117930. private _prepareCylinder;
  117931. private _intersectsWithCylinder;
  117932. }
  117933. /**
  117934. * Options fot the radial explosion event
  117935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117936. */
  117937. export class PhysicsRadialExplosionEventOptions {
  117938. /**
  117939. * The radius of the sphere for the radial explosion.
  117940. */
  117941. radius: number;
  117942. /**
  117943. * The strenth of the explosion.
  117944. */
  117945. strength: number;
  117946. /**
  117947. * The strenght of the force in correspondence to the distance of the affected object
  117948. */
  117949. falloff: PhysicsRadialImpulseFalloff;
  117950. /**
  117951. * Sphere options for the radial explosion.
  117952. */
  117953. sphere: {
  117954. segments: number;
  117955. diameter: number;
  117956. };
  117957. /**
  117958. * Sphere options for the radial explosion.
  117959. */
  117960. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  117961. }
  117962. /**
  117963. * Options fot the updraft event
  117964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117965. */
  117966. export class PhysicsUpdraftEventOptions {
  117967. /**
  117968. * The radius of the cylinder for the vortex
  117969. */
  117970. radius: number;
  117971. /**
  117972. * The strenth of the updraft.
  117973. */
  117974. strength: number;
  117975. /**
  117976. * The height of the cylinder for the updraft.
  117977. */
  117978. height: number;
  117979. /**
  117980. * The mode for the the updraft.
  117981. */
  117982. updraftMode: PhysicsUpdraftMode;
  117983. }
  117984. /**
  117985. * Options fot the vortex event
  117986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117987. */
  117988. export class PhysicsVortexEventOptions {
  117989. /**
  117990. * The radius of the cylinder for the vortex
  117991. */
  117992. radius: number;
  117993. /**
  117994. * The strenth of the vortex.
  117995. */
  117996. strength: number;
  117997. /**
  117998. * The height of the cylinder for the vortex.
  117999. */
  118000. height: number;
  118001. /**
  118002. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  118003. */
  118004. centripetalForceThreshold: number;
  118005. /**
  118006. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  118007. */
  118008. centripetalForceMultiplier: number;
  118009. /**
  118010. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  118011. */
  118012. centrifugalForceMultiplier: number;
  118013. /**
  118014. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  118015. */
  118016. updraftForceMultiplier: number;
  118017. }
  118018. /**
  118019. * The strenght of the force in correspondence to the distance of the affected object
  118020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  118021. */
  118022. export enum PhysicsRadialImpulseFalloff {
  118023. /** Defines that impulse is constant in strength across it's whole radius */
  118024. Constant = 0,
  118025. /** Defines that impulse gets weaker if it's further from the origin */
  118026. Linear = 1
  118027. }
  118028. /**
  118029. * The strength of the force in correspondence to the distance of the affected object
  118030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  118031. */
  118032. export enum PhysicsUpdraftMode {
  118033. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  118034. Center = 0,
  118035. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  118036. Perpendicular = 1
  118037. }
  118038. /**
  118039. * Interface for a physics hit data
  118040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  118041. */
  118042. export interface PhysicsHitData {
  118043. /**
  118044. * The force applied at the contact point
  118045. */
  118046. force: Vector3;
  118047. /**
  118048. * The contact point
  118049. */
  118050. contactPoint: Vector3;
  118051. /**
  118052. * The distance from the origin to the contact point
  118053. */
  118054. distanceFromOrigin: number;
  118055. }
  118056. /**
  118057. * Interface for radial explosion event data
  118058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  118059. */
  118060. export interface PhysicsRadialExplosionEventData {
  118061. /**
  118062. * A sphere used for the radial explosion event
  118063. */
  118064. sphere: Mesh;
  118065. }
  118066. /**
  118067. * Interface for gravitational field event data
  118068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  118069. */
  118070. export interface PhysicsGravitationalFieldEventData {
  118071. /**
  118072. * A sphere mesh used for the gravitational field event
  118073. */
  118074. sphere: Mesh;
  118075. }
  118076. /**
  118077. * Interface for updraft event data
  118078. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  118079. */
  118080. export interface PhysicsUpdraftEventData {
  118081. /**
  118082. * A cylinder used for the updraft event
  118083. */
  118084. cylinder: Mesh;
  118085. }
  118086. /**
  118087. * Interface for vortex event data
  118088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  118089. */
  118090. export interface PhysicsVortexEventData {
  118091. /**
  118092. * A cylinder used for the vortex event
  118093. */
  118094. cylinder: Mesh;
  118095. }
  118096. /**
  118097. * Interface for an affected physics impostor
  118098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  118099. */
  118100. export interface PhysicsAffectedImpostorWithData {
  118101. /**
  118102. * The impostor affected by the effect
  118103. */
  118104. impostor: PhysicsImpostor;
  118105. /**
  118106. * The data about the hit/horce from the explosion
  118107. */
  118108. hitData: PhysicsHitData;
  118109. }
  118110. }
  118111. declare module BABYLON {
  118112. /** @hidden */
  118113. export var blackAndWhitePixelShader: {
  118114. name: string;
  118115. shader: string;
  118116. };
  118117. }
  118118. declare module BABYLON {
  118119. /**
  118120. * Post process used to render in black and white
  118121. */
  118122. export class BlackAndWhitePostProcess extends PostProcess {
  118123. /**
  118124. * Linear about to convert he result to black and white (default: 1)
  118125. */
  118126. degree: number;
  118127. /**
  118128. * Creates a black and white post process
  118129. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  118130. * @param name The name of the effect.
  118131. * @param options The required width/height ratio to downsize to before computing the render pass.
  118132. * @param camera The camera to apply the render pass to.
  118133. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118134. * @param engine The engine which the post process will be applied. (default: current engine)
  118135. * @param reusable If the post process can be reused on the same frame. (default: false)
  118136. */
  118137. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118138. }
  118139. }
  118140. declare module BABYLON {
  118141. /**
  118142. * This represents a set of one or more post processes in Babylon.
  118143. * A post process can be used to apply a shader to a texture after it is rendered.
  118144. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118145. */
  118146. export class PostProcessRenderEffect {
  118147. private _postProcesses;
  118148. private _getPostProcesses;
  118149. private _singleInstance;
  118150. private _cameras;
  118151. private _indicesForCamera;
  118152. /**
  118153. * Name of the effect
  118154. * @hidden
  118155. */
  118156. _name: string;
  118157. /**
  118158. * Instantiates a post process render effect.
  118159. * A post process can be used to apply a shader to a texture after it is rendered.
  118160. * @param engine The engine the effect is tied to
  118161. * @param name The name of the effect
  118162. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  118163. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  118164. */
  118165. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  118166. /**
  118167. * Checks if all the post processes in the effect are supported.
  118168. */
  118169. readonly isSupported: boolean;
  118170. /**
  118171. * Updates the current state of the effect
  118172. * @hidden
  118173. */
  118174. _update(): void;
  118175. /**
  118176. * Attaches the effect on cameras
  118177. * @param cameras The camera to attach to.
  118178. * @hidden
  118179. */
  118180. _attachCameras(cameras: Camera): void;
  118181. /**
  118182. * Attaches the effect on cameras
  118183. * @param cameras The camera to attach to.
  118184. * @hidden
  118185. */
  118186. _attachCameras(cameras: Camera[]): void;
  118187. /**
  118188. * Detaches the effect on cameras
  118189. * @param cameras The camera to detatch from.
  118190. * @hidden
  118191. */
  118192. _detachCameras(cameras: Camera): void;
  118193. /**
  118194. * Detatches the effect on cameras
  118195. * @param cameras The camera to detatch from.
  118196. * @hidden
  118197. */
  118198. _detachCameras(cameras: Camera[]): void;
  118199. /**
  118200. * Enables the effect on given cameras
  118201. * @param cameras The camera to enable.
  118202. * @hidden
  118203. */
  118204. _enable(cameras: Camera): void;
  118205. /**
  118206. * Enables the effect on given cameras
  118207. * @param cameras The camera to enable.
  118208. * @hidden
  118209. */
  118210. _enable(cameras: Nullable<Camera[]>): void;
  118211. /**
  118212. * Disables the effect on the given cameras
  118213. * @param cameras The camera to disable.
  118214. * @hidden
  118215. */
  118216. _disable(cameras: Camera): void;
  118217. /**
  118218. * Disables the effect on the given cameras
  118219. * @param cameras The camera to disable.
  118220. * @hidden
  118221. */
  118222. _disable(cameras: Nullable<Camera[]>): void;
  118223. /**
  118224. * Gets a list of the post processes contained in the effect.
  118225. * @param camera The camera to get the post processes on.
  118226. * @returns The list of the post processes in the effect.
  118227. */
  118228. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  118229. }
  118230. }
  118231. declare module BABYLON {
  118232. /** @hidden */
  118233. export var extractHighlightsPixelShader: {
  118234. name: string;
  118235. shader: string;
  118236. };
  118237. }
  118238. declare module BABYLON {
  118239. /**
  118240. * 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.
  118241. */
  118242. export class ExtractHighlightsPostProcess extends PostProcess {
  118243. /**
  118244. * The luminance threshold, pixels below this value will be set to black.
  118245. */
  118246. threshold: number;
  118247. /** @hidden */
  118248. _exposure: number;
  118249. /**
  118250. * Post process which has the input texture to be used when performing highlight extraction
  118251. * @hidden
  118252. */
  118253. _inputPostProcess: Nullable<PostProcess>;
  118254. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118255. }
  118256. }
  118257. declare module BABYLON {
  118258. /** @hidden */
  118259. export var bloomMergePixelShader: {
  118260. name: string;
  118261. shader: string;
  118262. };
  118263. }
  118264. declare module BABYLON {
  118265. /**
  118266. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  118267. */
  118268. export class BloomMergePostProcess extends PostProcess {
  118269. /** Weight of the bloom to be added to the original input. */
  118270. weight: number;
  118271. /**
  118272. * Creates a new instance of @see BloomMergePostProcess
  118273. * @param name The name of the effect.
  118274. * @param originalFromInput Post process which's input will be used for the merge.
  118275. * @param blurred Blurred highlights post process which's output will be used.
  118276. * @param weight Weight of the bloom to be added to the original input.
  118277. * @param options The required width/height ratio to downsize to before computing the render pass.
  118278. * @param camera The camera to apply the render pass to.
  118279. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118280. * @param engine The engine which the post process will be applied. (default: current engine)
  118281. * @param reusable If the post process can be reused on the same frame. (default: false)
  118282. * @param textureType Type of textures used when performing the post process. (default: 0)
  118283. * @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)
  118284. */
  118285. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  118286. /** Weight of the bloom to be added to the original input. */
  118287. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118288. }
  118289. }
  118290. declare module BABYLON {
  118291. /**
  118292. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  118293. */
  118294. export class BloomEffect extends PostProcessRenderEffect {
  118295. private bloomScale;
  118296. /**
  118297. * @hidden Internal
  118298. */
  118299. _effects: Array<PostProcess>;
  118300. /**
  118301. * @hidden Internal
  118302. */
  118303. _downscale: ExtractHighlightsPostProcess;
  118304. private _blurX;
  118305. private _blurY;
  118306. private _merge;
  118307. /**
  118308. * The luminance threshold to find bright areas of the image to bloom.
  118309. */
  118310. threshold: number;
  118311. /**
  118312. * The strength of the bloom.
  118313. */
  118314. weight: number;
  118315. /**
  118316. * Specifies the size of the bloom blur kernel, relative to the final output size
  118317. */
  118318. kernel: number;
  118319. /**
  118320. * Creates a new instance of @see BloomEffect
  118321. * @param scene The scene the effect belongs to.
  118322. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  118323. * @param bloomKernel The size of the kernel to be used when applying the blur.
  118324. * @param bloomWeight The the strength of bloom.
  118325. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  118326. * @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)
  118327. */
  118328. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  118329. /**
  118330. * Disposes each of the internal effects for a given camera.
  118331. * @param camera The camera to dispose the effect on.
  118332. */
  118333. disposeEffects(camera: Camera): void;
  118334. /**
  118335. * @hidden Internal
  118336. */
  118337. _updateEffects(): void;
  118338. /**
  118339. * Internal
  118340. * @returns if all the contained post processes are ready.
  118341. * @hidden
  118342. */
  118343. _isReady(): boolean;
  118344. }
  118345. }
  118346. declare module BABYLON {
  118347. /** @hidden */
  118348. export var chromaticAberrationPixelShader: {
  118349. name: string;
  118350. shader: string;
  118351. };
  118352. }
  118353. declare module BABYLON {
  118354. /**
  118355. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  118356. */
  118357. export class ChromaticAberrationPostProcess extends PostProcess {
  118358. /**
  118359. * The amount of seperation of rgb channels (default: 30)
  118360. */
  118361. aberrationAmount: number;
  118362. /**
  118363. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  118364. */
  118365. radialIntensity: number;
  118366. /**
  118367. * 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))
  118368. */
  118369. direction: Vector2;
  118370. /**
  118371. * 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))
  118372. */
  118373. centerPosition: Vector2;
  118374. /**
  118375. * Creates a new instance ChromaticAberrationPostProcess
  118376. * @param name The name of the effect.
  118377. * @param screenWidth The width of the screen to apply the effect on.
  118378. * @param screenHeight The height of the screen to apply the effect on.
  118379. * @param options The required width/height ratio to downsize to before computing the render pass.
  118380. * @param camera The camera to apply the render pass to.
  118381. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118382. * @param engine The engine which the post process will be applied. (default: current engine)
  118383. * @param reusable If the post process can be reused on the same frame. (default: false)
  118384. * @param textureType Type of textures used when performing the post process. (default: 0)
  118385. * @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)
  118386. */
  118387. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118388. }
  118389. }
  118390. declare module BABYLON {
  118391. /** @hidden */
  118392. export var circleOfConfusionPixelShader: {
  118393. name: string;
  118394. shader: string;
  118395. };
  118396. }
  118397. declare module BABYLON {
  118398. /**
  118399. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  118400. */
  118401. export class CircleOfConfusionPostProcess extends PostProcess {
  118402. /**
  118403. * 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.
  118404. */
  118405. lensSize: number;
  118406. /**
  118407. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  118408. */
  118409. fStop: number;
  118410. /**
  118411. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  118412. */
  118413. focusDistance: number;
  118414. /**
  118415. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  118416. */
  118417. focalLength: number;
  118418. private _depthTexture;
  118419. /**
  118420. * Creates a new instance CircleOfConfusionPostProcess
  118421. * @param name The name of the effect.
  118422. * @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.
  118423. * @param options The required width/height ratio to downsize to before computing the render pass.
  118424. * @param camera The camera to apply the render pass to.
  118425. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118426. * @param engine The engine which the post process will be applied. (default: current engine)
  118427. * @param reusable If the post process can be reused on the same frame. (default: false)
  118428. * @param textureType Type of textures used when performing the post process. (default: 0)
  118429. * @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)
  118430. */
  118431. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118432. /**
  118433. * 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.
  118434. */
  118435. depthTexture: RenderTargetTexture;
  118436. }
  118437. }
  118438. declare module BABYLON {
  118439. /** @hidden */
  118440. export var colorCorrectionPixelShader: {
  118441. name: string;
  118442. shader: string;
  118443. };
  118444. }
  118445. declare module BABYLON {
  118446. /**
  118447. *
  118448. * This post-process allows the modification of rendered colors by using
  118449. * a 'look-up table' (LUT). This effect is also called Color Grading.
  118450. *
  118451. * The object needs to be provided an url to a texture containing the color
  118452. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  118453. * Use an image editing software to tweak the LUT to match your needs.
  118454. *
  118455. * For an example of a color LUT, see here:
  118456. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  118457. * For explanations on color grading, see here:
  118458. * @see http://udn.epicgames.com/Three/ColorGrading.html
  118459. *
  118460. */
  118461. export class ColorCorrectionPostProcess extends PostProcess {
  118462. private _colorTableTexture;
  118463. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118464. }
  118465. }
  118466. declare module BABYLON {
  118467. /** @hidden */
  118468. export var convolutionPixelShader: {
  118469. name: string;
  118470. shader: string;
  118471. };
  118472. }
  118473. declare module BABYLON {
  118474. /**
  118475. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  118476. * input texture to perform effects such as edge detection or sharpening
  118477. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118478. */
  118479. export class ConvolutionPostProcess extends PostProcess {
  118480. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  118481. kernel: number[];
  118482. /**
  118483. * Creates a new instance ConvolutionPostProcess
  118484. * @param name The name of the effect.
  118485. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  118486. * @param options The required width/height ratio to downsize to before computing the render pass.
  118487. * @param camera The camera to apply the render pass to.
  118488. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118489. * @param engine The engine which the post process will be applied. (default: current engine)
  118490. * @param reusable If the post process can be reused on the same frame. (default: false)
  118491. * @param textureType Type of textures used when performing the post process. (default: 0)
  118492. */
  118493. constructor(name: string,
  118494. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  118495. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118496. /**
  118497. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118498. */
  118499. static EdgeDetect0Kernel: number[];
  118500. /**
  118501. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118502. */
  118503. static EdgeDetect1Kernel: number[];
  118504. /**
  118505. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118506. */
  118507. static EdgeDetect2Kernel: number[];
  118508. /**
  118509. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118510. */
  118511. static SharpenKernel: number[];
  118512. /**
  118513. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118514. */
  118515. static EmbossKernel: number[];
  118516. /**
  118517. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118518. */
  118519. static GaussianKernel: number[];
  118520. }
  118521. }
  118522. declare module BABYLON {
  118523. /**
  118524. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  118525. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  118526. * based on samples that have a large difference in distance than the center pixel.
  118527. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  118528. */
  118529. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  118530. direction: Vector2;
  118531. /**
  118532. * Creates a new instance CircleOfConfusionPostProcess
  118533. * @param name The name of the effect.
  118534. * @param scene The scene the effect belongs to.
  118535. * @param direction The direction the blur should be applied.
  118536. * @param kernel The size of the kernel used to blur.
  118537. * @param options The required width/height ratio to downsize to before computing the render pass.
  118538. * @param camera The camera to apply the render pass to.
  118539. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  118540. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  118541. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118542. * @param engine The engine which the post process will be applied. (default: current engine)
  118543. * @param reusable If the post process can be reused on the same frame. (default: false)
  118544. * @param textureType Type of textures used when performing the post process. (default: 0)
  118545. * @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)
  118546. */
  118547. 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);
  118548. }
  118549. }
  118550. declare module BABYLON {
  118551. /** @hidden */
  118552. export var depthOfFieldMergePixelShader: {
  118553. name: string;
  118554. shader: string;
  118555. };
  118556. }
  118557. declare module BABYLON {
  118558. /**
  118559. * Options to be set when merging outputs from the default pipeline.
  118560. */
  118561. export class DepthOfFieldMergePostProcessOptions {
  118562. /**
  118563. * The original image to merge on top of
  118564. */
  118565. originalFromInput: PostProcess;
  118566. /**
  118567. * Parameters to perform the merge of the depth of field effect
  118568. */
  118569. depthOfField?: {
  118570. circleOfConfusion: PostProcess;
  118571. blurSteps: Array<PostProcess>;
  118572. };
  118573. /**
  118574. * Parameters to perform the merge of bloom effect
  118575. */
  118576. bloom?: {
  118577. blurred: PostProcess;
  118578. weight: number;
  118579. };
  118580. }
  118581. /**
  118582. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  118583. */
  118584. export class DepthOfFieldMergePostProcess extends PostProcess {
  118585. private blurSteps;
  118586. /**
  118587. * Creates a new instance of DepthOfFieldMergePostProcess
  118588. * @param name The name of the effect.
  118589. * @param originalFromInput Post process which's input will be used for the merge.
  118590. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  118591. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  118592. * @param options The required width/height ratio to downsize to before computing the render pass.
  118593. * @param camera The camera to apply the render pass to.
  118594. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118595. * @param engine The engine which the post process will be applied. (default: current engine)
  118596. * @param reusable If the post process can be reused on the same frame. (default: false)
  118597. * @param textureType Type of textures used when performing the post process. (default: 0)
  118598. * @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)
  118599. */
  118600. 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);
  118601. /**
  118602. * Updates the effect with the current post process compile time values and recompiles the shader.
  118603. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  118604. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  118605. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  118606. * @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
  118607. * @param onCompiled Called when the shader has been compiled.
  118608. * @param onError Called if there is an error when compiling a shader.
  118609. */
  118610. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  118611. }
  118612. }
  118613. declare module BABYLON {
  118614. /**
  118615. * Specifies the level of max blur that should be applied when using the depth of field effect
  118616. */
  118617. export enum DepthOfFieldEffectBlurLevel {
  118618. /**
  118619. * Subtle blur
  118620. */
  118621. Low = 0,
  118622. /**
  118623. * Medium blur
  118624. */
  118625. Medium = 1,
  118626. /**
  118627. * Large blur
  118628. */
  118629. High = 2
  118630. }
  118631. /**
  118632. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  118633. */
  118634. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  118635. private _circleOfConfusion;
  118636. /**
  118637. * @hidden Internal, blurs from high to low
  118638. */
  118639. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  118640. private _depthOfFieldBlurY;
  118641. private _dofMerge;
  118642. /**
  118643. * @hidden Internal post processes in depth of field effect
  118644. */
  118645. _effects: Array<PostProcess>;
  118646. /**
  118647. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  118648. */
  118649. focalLength: number;
  118650. /**
  118651. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  118652. */
  118653. fStop: number;
  118654. /**
  118655. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  118656. */
  118657. focusDistance: number;
  118658. /**
  118659. * 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.
  118660. */
  118661. lensSize: number;
  118662. /**
  118663. * Creates a new instance DepthOfFieldEffect
  118664. * @param scene The scene the effect belongs to.
  118665. * @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.
  118666. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  118667. * @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)
  118668. */
  118669. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  118670. /**
  118671. * Get the current class name of the current effet
  118672. * @returns "DepthOfFieldEffect"
  118673. */
  118674. getClassName(): string;
  118675. /**
  118676. * 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.
  118677. */
  118678. depthTexture: RenderTargetTexture;
  118679. /**
  118680. * Disposes each of the internal effects for a given camera.
  118681. * @param camera The camera to dispose the effect on.
  118682. */
  118683. disposeEffects(camera: Camera): void;
  118684. /**
  118685. * @hidden Internal
  118686. */
  118687. _updateEffects(): void;
  118688. /**
  118689. * Internal
  118690. * @returns if all the contained post processes are ready.
  118691. * @hidden
  118692. */
  118693. _isReady(): boolean;
  118694. }
  118695. }
  118696. declare module BABYLON {
  118697. /** @hidden */
  118698. export var displayPassPixelShader: {
  118699. name: string;
  118700. shader: string;
  118701. };
  118702. }
  118703. declare module BABYLON {
  118704. /**
  118705. * DisplayPassPostProcess which produces an output the same as it's input
  118706. */
  118707. export class DisplayPassPostProcess extends PostProcess {
  118708. /**
  118709. * Creates the DisplayPassPostProcess
  118710. * @param name The name of the effect.
  118711. * @param options The required width/height ratio to downsize to before computing the render pass.
  118712. * @param camera The camera to apply the render pass to.
  118713. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118714. * @param engine The engine which the post process will be applied. (default: current engine)
  118715. * @param reusable If the post process can be reused on the same frame. (default: false)
  118716. */
  118717. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118718. }
  118719. }
  118720. declare module BABYLON {
  118721. /** @hidden */
  118722. export var filterPixelShader: {
  118723. name: string;
  118724. shader: string;
  118725. };
  118726. }
  118727. declare module BABYLON {
  118728. /**
  118729. * Applies a kernel filter to the image
  118730. */
  118731. export class FilterPostProcess extends PostProcess {
  118732. /** The matrix to be applied to the image */
  118733. kernelMatrix: Matrix;
  118734. /**
  118735. *
  118736. * @param name The name of the effect.
  118737. * @param kernelMatrix The matrix to be applied to the image
  118738. * @param options The required width/height ratio to downsize to before computing the render pass.
  118739. * @param camera The camera to apply the render pass to.
  118740. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118741. * @param engine The engine which the post process will be applied. (default: current engine)
  118742. * @param reusable If the post process can be reused on the same frame. (default: false)
  118743. */
  118744. constructor(name: string,
  118745. /** The matrix to be applied to the image */
  118746. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118747. }
  118748. }
  118749. declare module BABYLON {
  118750. /** @hidden */
  118751. export var fxaaPixelShader: {
  118752. name: string;
  118753. shader: string;
  118754. };
  118755. }
  118756. declare module BABYLON {
  118757. /** @hidden */
  118758. export var fxaaVertexShader: {
  118759. name: string;
  118760. shader: string;
  118761. };
  118762. }
  118763. declare module BABYLON {
  118764. /**
  118765. * Fxaa post process
  118766. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  118767. */
  118768. export class FxaaPostProcess extends PostProcess {
  118769. /** @hidden */
  118770. texelWidth: number;
  118771. /** @hidden */
  118772. texelHeight: number;
  118773. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118774. private _getDefines;
  118775. }
  118776. }
  118777. declare module BABYLON {
  118778. /** @hidden */
  118779. export var grainPixelShader: {
  118780. name: string;
  118781. shader: string;
  118782. };
  118783. }
  118784. declare module BABYLON {
  118785. /**
  118786. * The GrainPostProcess adds noise to the image at mid luminance levels
  118787. */
  118788. export class GrainPostProcess extends PostProcess {
  118789. /**
  118790. * The intensity of the grain added (default: 30)
  118791. */
  118792. intensity: number;
  118793. /**
  118794. * If the grain should be randomized on every frame
  118795. */
  118796. animated: boolean;
  118797. /**
  118798. * Creates a new instance of @see GrainPostProcess
  118799. * @param name The name of the effect.
  118800. * @param options The required width/height ratio to downsize to before computing the render pass.
  118801. * @param camera The camera to apply the render pass to.
  118802. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118803. * @param engine The engine which the post process will be applied. (default: current engine)
  118804. * @param reusable If the post process can be reused on the same frame. (default: false)
  118805. * @param textureType Type of textures used when performing the post process. (default: 0)
  118806. * @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)
  118807. */
  118808. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118809. }
  118810. }
  118811. declare module BABYLON {
  118812. /** @hidden */
  118813. export var highlightsPixelShader: {
  118814. name: string;
  118815. shader: string;
  118816. };
  118817. }
  118818. declare module BABYLON {
  118819. /**
  118820. * Extracts highlights from the image
  118821. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118822. */
  118823. export class HighlightsPostProcess extends PostProcess {
  118824. /**
  118825. * Extracts highlights from the image
  118826. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118827. * @param name The name of the effect.
  118828. * @param options The required width/height ratio to downsize to before computing the render pass.
  118829. * @param camera The camera to apply the render pass to.
  118830. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118831. * @param engine The engine which the post process will be applied. (default: current engine)
  118832. * @param reusable If the post process can be reused on the same frame. (default: false)
  118833. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  118834. */
  118835. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118836. }
  118837. }
  118838. declare module BABYLON {
  118839. /** @hidden */
  118840. export var mrtFragmentDeclaration: {
  118841. name: string;
  118842. shader: string;
  118843. };
  118844. }
  118845. declare module BABYLON {
  118846. /** @hidden */
  118847. export var geometryPixelShader: {
  118848. name: string;
  118849. shader: string;
  118850. };
  118851. }
  118852. declare module BABYLON {
  118853. /** @hidden */
  118854. export var geometryVertexShader: {
  118855. name: string;
  118856. shader: string;
  118857. };
  118858. }
  118859. declare module BABYLON {
  118860. /** @hidden */
  118861. interface ISavedTransformationMatrix {
  118862. world: Matrix;
  118863. viewProjection: Matrix;
  118864. }
  118865. /**
  118866. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  118867. */
  118868. export class GeometryBufferRenderer {
  118869. /**
  118870. * Constant used to retrieve the position texture index in the G-Buffer textures array
  118871. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  118872. */
  118873. static readonly POSITION_TEXTURE_TYPE: number;
  118874. /**
  118875. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  118876. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  118877. */
  118878. static readonly VELOCITY_TEXTURE_TYPE: number;
  118879. /**
  118880. * Dictionary used to store the previous transformation matrices of each rendered mesh
  118881. * in order to compute objects velocities when enableVelocity is set to "true"
  118882. * @hidden
  118883. */
  118884. _previousTransformationMatrices: {
  118885. [index: number]: ISavedTransformationMatrix;
  118886. };
  118887. /**
  118888. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  118889. * in order to compute objects velocities when enableVelocity is set to "true"
  118890. * @hidden
  118891. */
  118892. _previousBonesTransformationMatrices: {
  118893. [index: number]: Float32Array;
  118894. };
  118895. /**
  118896. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  118897. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  118898. */
  118899. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  118900. private _scene;
  118901. private _multiRenderTarget;
  118902. private _ratio;
  118903. private _enablePosition;
  118904. private _enableVelocity;
  118905. private _positionIndex;
  118906. private _velocityIndex;
  118907. protected _effect: Effect;
  118908. protected _cachedDefines: string;
  118909. /**
  118910. * Set the render list (meshes to be rendered) used in the G buffer.
  118911. */
  118912. renderList: Mesh[];
  118913. /**
  118914. * Gets wether or not G buffer are supported by the running hardware.
  118915. * This requires draw buffer supports
  118916. */
  118917. readonly isSupported: boolean;
  118918. /**
  118919. * Returns the index of the given texture type in the G-Buffer textures array
  118920. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  118921. * @returns the index of the given texture type in the G-Buffer textures array
  118922. */
  118923. getTextureIndex(textureType: number): number;
  118924. /**
  118925. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  118926. */
  118927. /**
  118928. * Sets whether or not objects positions are enabled for the G buffer.
  118929. */
  118930. enablePosition: boolean;
  118931. /**
  118932. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  118933. */
  118934. /**
  118935. * Sets wether or not objects velocities are enabled for the G buffer.
  118936. */
  118937. enableVelocity: boolean;
  118938. /**
  118939. * Gets the scene associated with the buffer.
  118940. */
  118941. readonly scene: Scene;
  118942. /**
  118943. * Gets the ratio used by the buffer during its creation.
  118944. * How big is the buffer related to the main canvas.
  118945. */
  118946. readonly ratio: number;
  118947. /** @hidden */
  118948. static _SceneComponentInitialization: (scene: Scene) => void;
  118949. /**
  118950. * Creates a new G Buffer for the scene
  118951. * @param scene The scene the buffer belongs to
  118952. * @param ratio How big is the buffer related to the main canvas.
  118953. */
  118954. constructor(scene: Scene, ratio?: number);
  118955. /**
  118956. * Checks wether everything is ready to render a submesh to the G buffer.
  118957. * @param subMesh the submesh to check readiness for
  118958. * @param useInstances is the mesh drawn using instance or not
  118959. * @returns true if ready otherwise false
  118960. */
  118961. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118962. /**
  118963. * Gets the current underlying G Buffer.
  118964. * @returns the buffer
  118965. */
  118966. getGBuffer(): MultiRenderTarget;
  118967. /**
  118968. * Gets the number of samples used to render the buffer (anti aliasing).
  118969. */
  118970. /**
  118971. * Sets the number of samples used to render the buffer (anti aliasing).
  118972. */
  118973. samples: number;
  118974. /**
  118975. * Disposes the renderer and frees up associated resources.
  118976. */
  118977. dispose(): void;
  118978. protected _createRenderTargets(): void;
  118979. private _copyBonesTransformationMatrices;
  118980. }
  118981. }
  118982. declare module BABYLON {
  118983. interface Scene {
  118984. /** @hidden (Backing field) */
  118985. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118986. /**
  118987. * Gets or Sets the current geometry buffer associated to the scene.
  118988. */
  118989. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118990. /**
  118991. * Enables a GeometryBufferRender and associates it with the scene
  118992. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  118993. * @returns the GeometryBufferRenderer
  118994. */
  118995. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  118996. /**
  118997. * Disables the GeometryBufferRender associated with the scene
  118998. */
  118999. disableGeometryBufferRenderer(): void;
  119000. }
  119001. /**
  119002. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  119003. * in several rendering techniques.
  119004. */
  119005. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  119006. /**
  119007. * The component name helpful to identify the component in the list of scene components.
  119008. */
  119009. readonly name: string;
  119010. /**
  119011. * The scene the component belongs to.
  119012. */
  119013. scene: Scene;
  119014. /**
  119015. * Creates a new instance of the component for the given scene
  119016. * @param scene Defines the scene to register the component in
  119017. */
  119018. constructor(scene: Scene);
  119019. /**
  119020. * Registers the component in a given scene
  119021. */
  119022. register(): void;
  119023. /**
  119024. * Rebuilds the elements related to this component in case of
  119025. * context lost for instance.
  119026. */
  119027. rebuild(): void;
  119028. /**
  119029. * Disposes the component and the associated ressources
  119030. */
  119031. dispose(): void;
  119032. private _gatherRenderTargets;
  119033. }
  119034. }
  119035. declare module BABYLON {
  119036. /** @hidden */
  119037. export var motionBlurPixelShader: {
  119038. name: string;
  119039. shader: string;
  119040. };
  119041. }
  119042. declare module BABYLON {
  119043. /**
  119044. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  119045. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  119046. * As an example, all you have to do is to create the post-process:
  119047. * var mb = new BABYLON.MotionBlurPostProcess(
  119048. * 'mb', // The name of the effect.
  119049. * scene, // The scene containing the objects to blur according to their velocity.
  119050. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  119051. * camera // The camera to apply the render pass to.
  119052. * );
  119053. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  119054. */
  119055. export class MotionBlurPostProcess extends PostProcess {
  119056. /**
  119057. * Defines how much the image is blurred by the movement. Default value is equal to 1
  119058. */
  119059. motionStrength: number;
  119060. /**
  119061. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  119062. */
  119063. /**
  119064. * Sets the number of iterations to be used for motion blur quality
  119065. */
  119066. motionBlurSamples: number;
  119067. private _motionBlurSamples;
  119068. private _geometryBufferRenderer;
  119069. /**
  119070. * Creates a new instance MotionBlurPostProcess
  119071. * @param name The name of the effect.
  119072. * @param scene The scene containing the objects to blur according to their velocity.
  119073. * @param options The required width/height ratio to downsize to before computing the render pass.
  119074. * @param camera The camera to apply the render pass to.
  119075. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119076. * @param engine The engine which the post process will be applied. (default: current engine)
  119077. * @param reusable If the post process can be reused on the same frame. (default: false)
  119078. * @param textureType Type of textures used when performing the post process. (default: 0)
  119079. * @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)
  119080. */
  119081. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  119082. /**
  119083. * Excludes the given skinned mesh from computing bones velocities.
  119084. * 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.
  119085. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  119086. */
  119087. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  119088. /**
  119089. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  119090. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  119091. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  119092. */
  119093. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  119094. /**
  119095. * Disposes the post process.
  119096. * @param camera The camera to dispose the post process on.
  119097. */
  119098. dispose(camera?: Camera): void;
  119099. }
  119100. }
  119101. declare module BABYLON {
  119102. /** @hidden */
  119103. export var refractionPixelShader: {
  119104. name: string;
  119105. shader: string;
  119106. };
  119107. }
  119108. declare module BABYLON {
  119109. /**
  119110. * Post process which applies a refractin texture
  119111. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  119112. */
  119113. export class RefractionPostProcess extends PostProcess {
  119114. /** the base color of the refraction (used to taint the rendering) */
  119115. color: Color3;
  119116. /** simulated refraction depth */
  119117. depth: number;
  119118. /** the coefficient of the base color (0 to remove base color tainting) */
  119119. colorLevel: number;
  119120. private _refTexture;
  119121. private _ownRefractionTexture;
  119122. /**
  119123. * Gets or sets the refraction texture
  119124. * Please note that you are responsible for disposing the texture if you set it manually
  119125. */
  119126. refractionTexture: Texture;
  119127. /**
  119128. * Initializes the RefractionPostProcess
  119129. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  119130. * @param name The name of the effect.
  119131. * @param refractionTextureUrl Url of the refraction texture to use
  119132. * @param color the base color of the refraction (used to taint the rendering)
  119133. * @param depth simulated refraction depth
  119134. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  119135. * @param camera The camera to apply the render pass to.
  119136. * @param options The required width/height ratio to downsize to before computing the render pass.
  119137. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119138. * @param engine The engine which the post process will be applied. (default: current engine)
  119139. * @param reusable If the post process can be reused on the same frame. (default: false)
  119140. */
  119141. constructor(name: string, refractionTextureUrl: string,
  119142. /** the base color of the refraction (used to taint the rendering) */
  119143. color: Color3,
  119144. /** simulated refraction depth */
  119145. depth: number,
  119146. /** the coefficient of the base color (0 to remove base color tainting) */
  119147. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  119148. /**
  119149. * Disposes of the post process
  119150. * @param camera Camera to dispose post process on
  119151. */
  119152. dispose(camera: Camera): void;
  119153. }
  119154. }
  119155. declare module BABYLON {
  119156. /** @hidden */
  119157. export var sharpenPixelShader: {
  119158. name: string;
  119159. shader: string;
  119160. };
  119161. }
  119162. declare module BABYLON {
  119163. /**
  119164. * The SharpenPostProcess applies a sharpen kernel to every pixel
  119165. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  119166. */
  119167. export class SharpenPostProcess extends PostProcess {
  119168. /**
  119169. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  119170. */
  119171. colorAmount: number;
  119172. /**
  119173. * How much sharpness should be applied (default: 0.3)
  119174. */
  119175. edgeAmount: number;
  119176. /**
  119177. * Creates a new instance ConvolutionPostProcess
  119178. * @param name The name of the effect.
  119179. * @param options The required width/height ratio to downsize to before computing the render pass.
  119180. * @param camera The camera to apply the render pass to.
  119181. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119182. * @param engine The engine which the post process will be applied. (default: current engine)
  119183. * @param reusable If the post process can be reused on the same frame. (default: false)
  119184. * @param textureType Type of textures used when performing the post process. (default: 0)
  119185. * @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)
  119186. */
  119187. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  119188. }
  119189. }
  119190. declare module BABYLON {
  119191. /**
  119192. * PostProcessRenderPipeline
  119193. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119194. */
  119195. export class PostProcessRenderPipeline {
  119196. private engine;
  119197. private _renderEffects;
  119198. private _renderEffectsForIsolatedPass;
  119199. /**
  119200. * List of inspectable custom properties (used by the Inspector)
  119201. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  119202. */
  119203. inspectableCustomProperties: IInspectable[];
  119204. /**
  119205. * @hidden
  119206. */
  119207. protected _cameras: Camera[];
  119208. /** @hidden */
  119209. _name: string;
  119210. /**
  119211. * Gets pipeline name
  119212. */
  119213. readonly name: string;
  119214. /**
  119215. * Initializes a PostProcessRenderPipeline
  119216. * @param engine engine to add the pipeline to
  119217. * @param name name of the pipeline
  119218. */
  119219. constructor(engine: Engine, name: string);
  119220. /**
  119221. * Gets the class name
  119222. * @returns "PostProcessRenderPipeline"
  119223. */
  119224. getClassName(): string;
  119225. /**
  119226. * If all the render effects in the pipeline are supported
  119227. */
  119228. readonly isSupported: boolean;
  119229. /**
  119230. * Adds an effect to the pipeline
  119231. * @param renderEffect the effect to add
  119232. */
  119233. addEffect(renderEffect: PostProcessRenderEffect): void;
  119234. /** @hidden */
  119235. _rebuild(): void;
  119236. /** @hidden */
  119237. _enableEffect(renderEffectName: string, cameras: Camera): void;
  119238. /** @hidden */
  119239. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  119240. /** @hidden */
  119241. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  119242. /** @hidden */
  119243. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  119244. /** @hidden */
  119245. _attachCameras(cameras: Camera, unique: boolean): void;
  119246. /** @hidden */
  119247. _attachCameras(cameras: Camera[], unique: boolean): void;
  119248. /** @hidden */
  119249. _detachCameras(cameras: Camera): void;
  119250. /** @hidden */
  119251. _detachCameras(cameras: Nullable<Camera[]>): void;
  119252. /** @hidden */
  119253. _update(): void;
  119254. /** @hidden */
  119255. _reset(): void;
  119256. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  119257. /**
  119258. * Disposes of the pipeline
  119259. */
  119260. dispose(): void;
  119261. }
  119262. }
  119263. declare module BABYLON {
  119264. /**
  119265. * PostProcessRenderPipelineManager class
  119266. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119267. */
  119268. export class PostProcessRenderPipelineManager {
  119269. private _renderPipelines;
  119270. /**
  119271. * Initializes a PostProcessRenderPipelineManager
  119272. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119273. */
  119274. constructor();
  119275. /**
  119276. * Gets the list of supported render pipelines
  119277. */
  119278. readonly supportedPipelines: PostProcessRenderPipeline[];
  119279. /**
  119280. * Adds a pipeline to the manager
  119281. * @param renderPipeline The pipeline to add
  119282. */
  119283. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  119284. /**
  119285. * Attaches a camera to the pipeline
  119286. * @param renderPipelineName The name of the pipeline to attach to
  119287. * @param cameras the camera to attach
  119288. * @param unique if the camera can be attached multiple times to the pipeline
  119289. */
  119290. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  119291. /**
  119292. * Detaches a camera from the pipeline
  119293. * @param renderPipelineName The name of the pipeline to detach from
  119294. * @param cameras the camera to detach
  119295. */
  119296. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  119297. /**
  119298. * Enables an effect by name on a pipeline
  119299. * @param renderPipelineName the name of the pipeline to enable the effect in
  119300. * @param renderEffectName the name of the effect to enable
  119301. * @param cameras the cameras that the effect should be enabled on
  119302. */
  119303. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  119304. /**
  119305. * Disables an effect by name on a pipeline
  119306. * @param renderPipelineName the name of the pipeline to disable the effect in
  119307. * @param renderEffectName the name of the effect to disable
  119308. * @param cameras the cameras that the effect should be disabled on
  119309. */
  119310. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  119311. /**
  119312. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  119313. */
  119314. update(): void;
  119315. /** @hidden */
  119316. _rebuild(): void;
  119317. /**
  119318. * Disposes of the manager and pipelines
  119319. */
  119320. dispose(): void;
  119321. }
  119322. }
  119323. declare module BABYLON {
  119324. interface Scene {
  119325. /** @hidden (Backing field) */
  119326. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  119327. /**
  119328. * Gets the postprocess render pipeline manager
  119329. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119330. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  119331. */
  119332. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  119333. }
  119334. /**
  119335. * Defines the Render Pipeline scene component responsible to rendering pipelines
  119336. */
  119337. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  119338. /**
  119339. * The component name helpfull to identify the component in the list of scene components.
  119340. */
  119341. readonly name: string;
  119342. /**
  119343. * The scene the component belongs to.
  119344. */
  119345. scene: Scene;
  119346. /**
  119347. * Creates a new instance of the component for the given scene
  119348. * @param scene Defines the scene to register the component in
  119349. */
  119350. constructor(scene: Scene);
  119351. /**
  119352. * Registers the component in a given scene
  119353. */
  119354. register(): void;
  119355. /**
  119356. * Rebuilds the elements related to this component in case of
  119357. * context lost for instance.
  119358. */
  119359. rebuild(): void;
  119360. /**
  119361. * Disposes the component and the associated ressources
  119362. */
  119363. dispose(): void;
  119364. private _gatherRenderTargets;
  119365. }
  119366. }
  119367. declare module BABYLON {
  119368. /**
  119369. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  119370. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  119371. */
  119372. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  119373. private _scene;
  119374. private _camerasToBeAttached;
  119375. /**
  119376. * ID of the sharpen post process,
  119377. */
  119378. private readonly SharpenPostProcessId;
  119379. /**
  119380. * @ignore
  119381. * ID of the image processing post process;
  119382. */
  119383. readonly ImageProcessingPostProcessId: string;
  119384. /**
  119385. * @ignore
  119386. * ID of the Fast Approximate Anti-Aliasing post process;
  119387. */
  119388. readonly FxaaPostProcessId: string;
  119389. /**
  119390. * ID of the chromatic aberration post process,
  119391. */
  119392. private readonly ChromaticAberrationPostProcessId;
  119393. /**
  119394. * ID of the grain post process
  119395. */
  119396. private readonly GrainPostProcessId;
  119397. /**
  119398. * Sharpen post process which will apply a sharpen convolution to enhance edges
  119399. */
  119400. sharpen: SharpenPostProcess;
  119401. private _sharpenEffect;
  119402. private bloom;
  119403. /**
  119404. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  119405. */
  119406. depthOfField: DepthOfFieldEffect;
  119407. /**
  119408. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  119409. */
  119410. fxaa: FxaaPostProcess;
  119411. /**
  119412. * Image post processing pass used to perform operations such as tone mapping or color grading.
  119413. */
  119414. imageProcessing: ImageProcessingPostProcess;
  119415. /**
  119416. * Chromatic aberration post process which will shift rgb colors in the image
  119417. */
  119418. chromaticAberration: ChromaticAberrationPostProcess;
  119419. private _chromaticAberrationEffect;
  119420. /**
  119421. * Grain post process which add noise to the image
  119422. */
  119423. grain: GrainPostProcess;
  119424. private _grainEffect;
  119425. /**
  119426. * Glow post process which adds a glow to emissive areas of the image
  119427. */
  119428. private _glowLayer;
  119429. /**
  119430. * Animations which can be used to tweak settings over a period of time
  119431. */
  119432. animations: Animation[];
  119433. private _imageProcessingConfigurationObserver;
  119434. private _sharpenEnabled;
  119435. private _bloomEnabled;
  119436. private _depthOfFieldEnabled;
  119437. private _depthOfFieldBlurLevel;
  119438. private _fxaaEnabled;
  119439. private _imageProcessingEnabled;
  119440. private _defaultPipelineTextureType;
  119441. private _bloomScale;
  119442. private _chromaticAberrationEnabled;
  119443. private _grainEnabled;
  119444. private _buildAllowed;
  119445. /**
  119446. * Gets active scene
  119447. */
  119448. readonly scene: Scene;
  119449. /**
  119450. * Enable or disable the sharpen process from the pipeline
  119451. */
  119452. sharpenEnabled: boolean;
  119453. private _resizeObserver;
  119454. private _hardwareScaleLevel;
  119455. private _bloomKernel;
  119456. /**
  119457. * Specifies the size of the bloom blur kernel, relative to the final output size
  119458. */
  119459. bloomKernel: number;
  119460. /**
  119461. * Specifies the weight of the bloom in the final rendering
  119462. */
  119463. private _bloomWeight;
  119464. /**
  119465. * Specifies the luma threshold for the area that will be blurred by the bloom
  119466. */
  119467. private _bloomThreshold;
  119468. private _hdr;
  119469. /**
  119470. * The strength of the bloom.
  119471. */
  119472. bloomWeight: number;
  119473. /**
  119474. * The strength of the bloom.
  119475. */
  119476. bloomThreshold: number;
  119477. /**
  119478. * The scale of the bloom, lower value will provide better performance.
  119479. */
  119480. bloomScale: number;
  119481. /**
  119482. * Enable or disable the bloom from the pipeline
  119483. */
  119484. bloomEnabled: boolean;
  119485. private _rebuildBloom;
  119486. /**
  119487. * If the depth of field is enabled.
  119488. */
  119489. depthOfFieldEnabled: boolean;
  119490. /**
  119491. * Blur level of the depth of field effect. (Higher blur will effect performance)
  119492. */
  119493. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  119494. /**
  119495. * If the anti aliasing is enabled.
  119496. */
  119497. fxaaEnabled: boolean;
  119498. private _samples;
  119499. /**
  119500. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  119501. */
  119502. samples: number;
  119503. /**
  119504. * If image processing is enabled.
  119505. */
  119506. imageProcessingEnabled: boolean;
  119507. /**
  119508. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  119509. */
  119510. glowLayerEnabled: boolean;
  119511. /**
  119512. * Gets the glow layer (or null if not defined)
  119513. */
  119514. readonly glowLayer: Nullable<GlowLayer>;
  119515. /**
  119516. * Enable or disable the chromaticAberration process from the pipeline
  119517. */
  119518. chromaticAberrationEnabled: boolean;
  119519. /**
  119520. * Enable or disable the grain process from the pipeline
  119521. */
  119522. grainEnabled: boolean;
  119523. /**
  119524. * @constructor
  119525. * @param name - The rendering pipeline name (default: "")
  119526. * @param hdr - If high dynamic range textures should be used (default: true)
  119527. * @param scene - The scene linked to this pipeline (default: the last created scene)
  119528. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  119529. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  119530. */
  119531. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  119532. /**
  119533. * Get the class name
  119534. * @returns "DefaultRenderingPipeline"
  119535. */
  119536. getClassName(): string;
  119537. /**
  119538. * Force the compilation of the entire pipeline.
  119539. */
  119540. prepare(): void;
  119541. private _hasCleared;
  119542. private _prevPostProcess;
  119543. private _prevPrevPostProcess;
  119544. private _setAutoClearAndTextureSharing;
  119545. private _depthOfFieldSceneObserver;
  119546. private _buildPipeline;
  119547. private _disposePostProcesses;
  119548. /**
  119549. * Adds a camera to the pipeline
  119550. * @param camera the camera to be added
  119551. */
  119552. addCamera(camera: Camera): void;
  119553. /**
  119554. * Removes a camera from the pipeline
  119555. * @param camera the camera to remove
  119556. */
  119557. removeCamera(camera: Camera): void;
  119558. /**
  119559. * Dispose of the pipeline and stop all post processes
  119560. */
  119561. dispose(): void;
  119562. /**
  119563. * Serialize the rendering pipeline (Used when exporting)
  119564. * @returns the serialized object
  119565. */
  119566. serialize(): any;
  119567. /**
  119568. * Parse the serialized pipeline
  119569. * @param source Source pipeline.
  119570. * @param scene The scene to load the pipeline to.
  119571. * @param rootUrl The URL of the serialized pipeline.
  119572. * @returns An instantiated pipeline from the serialized object.
  119573. */
  119574. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  119575. }
  119576. }
  119577. declare module BABYLON {
  119578. /** @hidden */
  119579. export var lensHighlightsPixelShader: {
  119580. name: string;
  119581. shader: string;
  119582. };
  119583. }
  119584. declare module BABYLON {
  119585. /** @hidden */
  119586. export var depthOfFieldPixelShader: {
  119587. name: string;
  119588. shader: string;
  119589. };
  119590. }
  119591. declare module BABYLON {
  119592. /**
  119593. * BABYLON.JS Chromatic Aberration GLSL Shader
  119594. * Author: Olivier Guyot
  119595. * Separates very slightly R, G and B colors on the edges of the screen
  119596. * Inspired by Francois Tarlier & Martins Upitis
  119597. */
  119598. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  119599. /**
  119600. * @ignore
  119601. * The chromatic aberration PostProcess id in the pipeline
  119602. */
  119603. LensChromaticAberrationEffect: string;
  119604. /**
  119605. * @ignore
  119606. * The highlights enhancing PostProcess id in the pipeline
  119607. */
  119608. HighlightsEnhancingEffect: string;
  119609. /**
  119610. * @ignore
  119611. * The depth-of-field PostProcess id in the pipeline
  119612. */
  119613. LensDepthOfFieldEffect: string;
  119614. private _scene;
  119615. private _depthTexture;
  119616. private _grainTexture;
  119617. private _chromaticAberrationPostProcess;
  119618. private _highlightsPostProcess;
  119619. private _depthOfFieldPostProcess;
  119620. private _edgeBlur;
  119621. private _grainAmount;
  119622. private _chromaticAberration;
  119623. private _distortion;
  119624. private _highlightsGain;
  119625. private _highlightsThreshold;
  119626. private _dofDistance;
  119627. private _dofAperture;
  119628. private _dofDarken;
  119629. private _dofPentagon;
  119630. private _blurNoise;
  119631. /**
  119632. * @constructor
  119633. *
  119634. * Effect parameters are as follow:
  119635. * {
  119636. * chromatic_aberration: number; // from 0 to x (1 for realism)
  119637. * edge_blur: number; // from 0 to x (1 for realism)
  119638. * distortion: number; // from 0 to x (1 for realism)
  119639. * grain_amount: number; // from 0 to 1
  119640. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  119641. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  119642. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  119643. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  119644. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  119645. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  119646. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  119647. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  119648. * }
  119649. * Note: if an effect parameter is unset, effect is disabled
  119650. *
  119651. * @param name The rendering pipeline name
  119652. * @param parameters - An object containing all parameters (see above)
  119653. * @param scene The scene linked to this pipeline
  119654. * @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)
  119655. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119656. */
  119657. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  119658. /**
  119659. * Get the class name
  119660. * @returns "LensRenderingPipeline"
  119661. */
  119662. getClassName(): string;
  119663. /**
  119664. * Gets associated scene
  119665. */
  119666. readonly scene: Scene;
  119667. /**
  119668. * Gets or sets the edge blur
  119669. */
  119670. edgeBlur: number;
  119671. /**
  119672. * Gets or sets the grain amount
  119673. */
  119674. grainAmount: number;
  119675. /**
  119676. * Gets or sets the chromatic aberration amount
  119677. */
  119678. chromaticAberration: number;
  119679. /**
  119680. * Gets or sets the depth of field aperture
  119681. */
  119682. dofAperture: number;
  119683. /**
  119684. * Gets or sets the edge distortion
  119685. */
  119686. edgeDistortion: number;
  119687. /**
  119688. * Gets or sets the depth of field distortion
  119689. */
  119690. dofDistortion: number;
  119691. /**
  119692. * Gets or sets the darken out of focus amount
  119693. */
  119694. darkenOutOfFocus: number;
  119695. /**
  119696. * Gets or sets a boolean indicating if blur noise is enabled
  119697. */
  119698. blurNoise: boolean;
  119699. /**
  119700. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  119701. */
  119702. pentagonBokeh: boolean;
  119703. /**
  119704. * Gets or sets the highlight grain amount
  119705. */
  119706. highlightsGain: number;
  119707. /**
  119708. * Gets or sets the highlight threshold
  119709. */
  119710. highlightsThreshold: number;
  119711. /**
  119712. * Sets the amount of blur at the edges
  119713. * @param amount blur amount
  119714. */
  119715. setEdgeBlur(amount: number): void;
  119716. /**
  119717. * Sets edge blur to 0
  119718. */
  119719. disableEdgeBlur(): void;
  119720. /**
  119721. * Sets the amout of grain
  119722. * @param amount Amount of grain
  119723. */
  119724. setGrainAmount(amount: number): void;
  119725. /**
  119726. * Set grain amount to 0
  119727. */
  119728. disableGrain(): void;
  119729. /**
  119730. * Sets the chromatic aberration amount
  119731. * @param amount amount of chromatic aberration
  119732. */
  119733. setChromaticAberration(amount: number): void;
  119734. /**
  119735. * Sets chromatic aberration amount to 0
  119736. */
  119737. disableChromaticAberration(): void;
  119738. /**
  119739. * Sets the EdgeDistortion amount
  119740. * @param amount amount of EdgeDistortion
  119741. */
  119742. setEdgeDistortion(amount: number): void;
  119743. /**
  119744. * Sets edge distortion to 0
  119745. */
  119746. disableEdgeDistortion(): void;
  119747. /**
  119748. * Sets the FocusDistance amount
  119749. * @param amount amount of FocusDistance
  119750. */
  119751. setFocusDistance(amount: number): void;
  119752. /**
  119753. * Disables depth of field
  119754. */
  119755. disableDepthOfField(): void;
  119756. /**
  119757. * Sets the Aperture amount
  119758. * @param amount amount of Aperture
  119759. */
  119760. setAperture(amount: number): void;
  119761. /**
  119762. * Sets the DarkenOutOfFocus amount
  119763. * @param amount amount of DarkenOutOfFocus
  119764. */
  119765. setDarkenOutOfFocus(amount: number): void;
  119766. private _pentagonBokehIsEnabled;
  119767. /**
  119768. * Creates a pentagon bokeh effect
  119769. */
  119770. enablePentagonBokeh(): void;
  119771. /**
  119772. * Disables the pentagon bokeh effect
  119773. */
  119774. disablePentagonBokeh(): void;
  119775. /**
  119776. * Enables noise blur
  119777. */
  119778. enableNoiseBlur(): void;
  119779. /**
  119780. * Disables noise blur
  119781. */
  119782. disableNoiseBlur(): void;
  119783. /**
  119784. * Sets the HighlightsGain amount
  119785. * @param amount amount of HighlightsGain
  119786. */
  119787. setHighlightsGain(amount: number): void;
  119788. /**
  119789. * Sets the HighlightsThreshold amount
  119790. * @param amount amount of HighlightsThreshold
  119791. */
  119792. setHighlightsThreshold(amount: number): void;
  119793. /**
  119794. * Disables highlights
  119795. */
  119796. disableHighlights(): void;
  119797. /**
  119798. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  119799. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  119800. */
  119801. dispose(disableDepthRender?: boolean): void;
  119802. private _createChromaticAberrationPostProcess;
  119803. private _createHighlightsPostProcess;
  119804. private _createDepthOfFieldPostProcess;
  119805. private _createGrainTexture;
  119806. }
  119807. }
  119808. declare module BABYLON {
  119809. /** @hidden */
  119810. export var ssao2PixelShader: {
  119811. name: string;
  119812. shader: string;
  119813. };
  119814. }
  119815. declare module BABYLON {
  119816. /** @hidden */
  119817. export var ssaoCombinePixelShader: {
  119818. name: string;
  119819. shader: string;
  119820. };
  119821. }
  119822. declare module BABYLON {
  119823. /**
  119824. * Render pipeline to produce ssao effect
  119825. */
  119826. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  119827. /**
  119828. * @ignore
  119829. * The PassPostProcess id in the pipeline that contains the original scene color
  119830. */
  119831. SSAOOriginalSceneColorEffect: string;
  119832. /**
  119833. * @ignore
  119834. * The SSAO PostProcess id in the pipeline
  119835. */
  119836. SSAORenderEffect: string;
  119837. /**
  119838. * @ignore
  119839. * The horizontal blur PostProcess id in the pipeline
  119840. */
  119841. SSAOBlurHRenderEffect: string;
  119842. /**
  119843. * @ignore
  119844. * The vertical blur PostProcess id in the pipeline
  119845. */
  119846. SSAOBlurVRenderEffect: string;
  119847. /**
  119848. * @ignore
  119849. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119850. */
  119851. SSAOCombineRenderEffect: string;
  119852. /**
  119853. * The output strength of the SSAO post-process. Default value is 1.0.
  119854. */
  119855. totalStrength: number;
  119856. /**
  119857. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  119858. */
  119859. maxZ: number;
  119860. /**
  119861. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  119862. */
  119863. minZAspect: number;
  119864. private _samples;
  119865. /**
  119866. * Number of samples used for the SSAO calculations. Default value is 8
  119867. */
  119868. samples: number;
  119869. private _textureSamples;
  119870. /**
  119871. * Number of samples to use for antialiasing
  119872. */
  119873. textureSamples: number;
  119874. /**
  119875. * Ratio object used for SSAO ratio and blur ratio
  119876. */
  119877. private _ratio;
  119878. /**
  119879. * Dynamically generated sphere sampler.
  119880. */
  119881. private _sampleSphere;
  119882. /**
  119883. * Blur filter offsets
  119884. */
  119885. private _samplerOffsets;
  119886. private _expensiveBlur;
  119887. /**
  119888. * If bilateral blur should be used
  119889. */
  119890. expensiveBlur: boolean;
  119891. /**
  119892. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  119893. */
  119894. radius: number;
  119895. /**
  119896. * The base color of the SSAO post-process
  119897. * The final result is "base + ssao" between [0, 1]
  119898. */
  119899. base: number;
  119900. /**
  119901. * Support test.
  119902. */
  119903. static readonly IsSupported: boolean;
  119904. private _scene;
  119905. private _depthTexture;
  119906. private _normalTexture;
  119907. private _randomTexture;
  119908. private _originalColorPostProcess;
  119909. private _ssaoPostProcess;
  119910. private _blurHPostProcess;
  119911. private _blurVPostProcess;
  119912. private _ssaoCombinePostProcess;
  119913. private _firstUpdate;
  119914. /**
  119915. * Gets active scene
  119916. */
  119917. readonly scene: Scene;
  119918. /**
  119919. * @constructor
  119920. * @param name The rendering pipeline name
  119921. * @param scene The scene linked to this pipeline
  119922. * @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 }
  119923. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119924. */
  119925. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119926. /**
  119927. * Get the class name
  119928. * @returns "SSAO2RenderingPipeline"
  119929. */
  119930. getClassName(): string;
  119931. /**
  119932. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119933. */
  119934. dispose(disableGeometryBufferRenderer?: boolean): void;
  119935. private _createBlurPostProcess;
  119936. /** @hidden */
  119937. _rebuild(): void;
  119938. private _bits;
  119939. private _radicalInverse_VdC;
  119940. private _hammersley;
  119941. private _hemisphereSample_uniform;
  119942. private _generateHemisphere;
  119943. private _createSSAOPostProcess;
  119944. private _createSSAOCombinePostProcess;
  119945. private _createRandomTexture;
  119946. /**
  119947. * Serialize the rendering pipeline (Used when exporting)
  119948. * @returns the serialized object
  119949. */
  119950. serialize(): any;
  119951. /**
  119952. * Parse the serialized pipeline
  119953. * @param source Source pipeline.
  119954. * @param scene The scene to load the pipeline to.
  119955. * @param rootUrl The URL of the serialized pipeline.
  119956. * @returns An instantiated pipeline from the serialized object.
  119957. */
  119958. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  119959. }
  119960. }
  119961. declare module BABYLON {
  119962. /** @hidden */
  119963. export var ssaoPixelShader: {
  119964. name: string;
  119965. shader: string;
  119966. };
  119967. }
  119968. declare module BABYLON {
  119969. /**
  119970. * Render pipeline to produce ssao effect
  119971. */
  119972. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  119973. /**
  119974. * @ignore
  119975. * The PassPostProcess id in the pipeline that contains the original scene color
  119976. */
  119977. SSAOOriginalSceneColorEffect: string;
  119978. /**
  119979. * @ignore
  119980. * The SSAO PostProcess id in the pipeline
  119981. */
  119982. SSAORenderEffect: string;
  119983. /**
  119984. * @ignore
  119985. * The horizontal blur PostProcess id in the pipeline
  119986. */
  119987. SSAOBlurHRenderEffect: string;
  119988. /**
  119989. * @ignore
  119990. * The vertical blur PostProcess id in the pipeline
  119991. */
  119992. SSAOBlurVRenderEffect: string;
  119993. /**
  119994. * @ignore
  119995. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119996. */
  119997. SSAOCombineRenderEffect: string;
  119998. /**
  119999. * The output strength of the SSAO post-process. Default value is 1.0.
  120000. */
  120001. totalStrength: number;
  120002. /**
  120003. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  120004. */
  120005. radius: number;
  120006. /**
  120007. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  120008. * Must not be equal to fallOff and superior to fallOff.
  120009. * Default value is 0.0075
  120010. */
  120011. area: number;
  120012. /**
  120013. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  120014. * Must not be equal to area and inferior to area.
  120015. * Default value is 0.000001
  120016. */
  120017. fallOff: number;
  120018. /**
  120019. * The base color of the SSAO post-process
  120020. * The final result is "base + ssao" between [0, 1]
  120021. */
  120022. base: number;
  120023. private _scene;
  120024. private _depthTexture;
  120025. private _randomTexture;
  120026. private _originalColorPostProcess;
  120027. private _ssaoPostProcess;
  120028. private _blurHPostProcess;
  120029. private _blurVPostProcess;
  120030. private _ssaoCombinePostProcess;
  120031. private _firstUpdate;
  120032. /**
  120033. * Gets active scene
  120034. */
  120035. readonly scene: Scene;
  120036. /**
  120037. * @constructor
  120038. * @param name - The rendering pipeline name
  120039. * @param scene - The scene linked to this pipeline
  120040. * @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 }
  120041. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  120042. */
  120043. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  120044. /**
  120045. * Get the class name
  120046. * @returns "SSAORenderingPipeline"
  120047. */
  120048. getClassName(): string;
  120049. /**
  120050. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  120051. */
  120052. dispose(disableDepthRender?: boolean): void;
  120053. private _createBlurPostProcess;
  120054. /** @hidden */
  120055. _rebuild(): void;
  120056. private _createSSAOPostProcess;
  120057. private _createSSAOCombinePostProcess;
  120058. private _createRandomTexture;
  120059. }
  120060. }
  120061. declare module BABYLON {
  120062. /** @hidden */
  120063. export var standardPixelShader: {
  120064. name: string;
  120065. shader: string;
  120066. };
  120067. }
  120068. declare module BABYLON {
  120069. /**
  120070. * Standard rendering pipeline
  120071. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  120072. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  120073. */
  120074. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  120075. /**
  120076. * Public members
  120077. */
  120078. /**
  120079. * Post-process which contains the original scene color before the pipeline applies all the effects
  120080. */
  120081. originalPostProcess: Nullable<PostProcess>;
  120082. /**
  120083. * Post-process used to down scale an image x4
  120084. */
  120085. downSampleX4PostProcess: Nullable<PostProcess>;
  120086. /**
  120087. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  120088. */
  120089. brightPassPostProcess: Nullable<PostProcess>;
  120090. /**
  120091. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  120092. */
  120093. blurHPostProcesses: PostProcess[];
  120094. /**
  120095. * Post-process array storing all the vertical blur post-processes used by the pipeline
  120096. */
  120097. blurVPostProcesses: PostProcess[];
  120098. /**
  120099. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  120100. */
  120101. textureAdderPostProcess: Nullable<PostProcess>;
  120102. /**
  120103. * Post-process used to create volumetric lighting effect
  120104. */
  120105. volumetricLightPostProcess: Nullable<PostProcess>;
  120106. /**
  120107. * Post-process used to smooth the previous volumetric light post-process on the X axis
  120108. */
  120109. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  120110. /**
  120111. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  120112. */
  120113. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  120114. /**
  120115. * Post-process used to merge the volumetric light effect and the real scene color
  120116. */
  120117. volumetricLightMergePostProces: Nullable<PostProcess>;
  120118. /**
  120119. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  120120. */
  120121. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  120122. /**
  120123. * Base post-process used to calculate the average luminance of the final image for HDR
  120124. */
  120125. luminancePostProcess: Nullable<PostProcess>;
  120126. /**
  120127. * Post-processes used to create down sample post-processes in order to get
  120128. * the average luminance of the final image for HDR
  120129. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  120130. */
  120131. luminanceDownSamplePostProcesses: PostProcess[];
  120132. /**
  120133. * Post-process used to create a HDR effect (light adaptation)
  120134. */
  120135. hdrPostProcess: Nullable<PostProcess>;
  120136. /**
  120137. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  120138. */
  120139. textureAdderFinalPostProcess: Nullable<PostProcess>;
  120140. /**
  120141. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  120142. */
  120143. lensFlareFinalPostProcess: Nullable<PostProcess>;
  120144. /**
  120145. * Post-process used to merge the final HDR post-process and the real scene color
  120146. */
  120147. hdrFinalPostProcess: Nullable<PostProcess>;
  120148. /**
  120149. * Post-process used to create a lens flare effect
  120150. */
  120151. lensFlarePostProcess: Nullable<PostProcess>;
  120152. /**
  120153. * Post-process that merges the result of the lens flare post-process and the real scene color
  120154. */
  120155. lensFlareComposePostProcess: Nullable<PostProcess>;
  120156. /**
  120157. * Post-process used to create a motion blur effect
  120158. */
  120159. motionBlurPostProcess: Nullable<PostProcess>;
  120160. /**
  120161. * Post-process used to create a depth of field effect
  120162. */
  120163. depthOfFieldPostProcess: Nullable<PostProcess>;
  120164. /**
  120165. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  120166. */
  120167. fxaaPostProcess: Nullable<FxaaPostProcess>;
  120168. /**
  120169. * Represents the brightness threshold in order to configure the illuminated surfaces
  120170. */
  120171. brightThreshold: number;
  120172. /**
  120173. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  120174. */
  120175. blurWidth: number;
  120176. /**
  120177. * Sets if the blur for highlighted surfaces must be only horizontal
  120178. */
  120179. horizontalBlur: boolean;
  120180. /**
  120181. * Gets the overall exposure used by the pipeline
  120182. */
  120183. /**
  120184. * Sets the overall exposure used by the pipeline
  120185. */
  120186. exposure: number;
  120187. /**
  120188. * Texture used typically to simulate "dirty" on camera lens
  120189. */
  120190. lensTexture: Nullable<Texture>;
  120191. /**
  120192. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  120193. */
  120194. volumetricLightCoefficient: number;
  120195. /**
  120196. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  120197. */
  120198. volumetricLightPower: number;
  120199. /**
  120200. * Used the set the blur intensity to smooth the volumetric lights
  120201. */
  120202. volumetricLightBlurScale: number;
  120203. /**
  120204. * Light (spot or directional) used to generate the volumetric lights rays
  120205. * The source light must have a shadow generate so the pipeline can get its
  120206. * depth map
  120207. */
  120208. sourceLight: Nullable<SpotLight | DirectionalLight>;
  120209. /**
  120210. * For eye adaptation, represents the minimum luminance the eye can see
  120211. */
  120212. hdrMinimumLuminance: number;
  120213. /**
  120214. * For eye adaptation, represents the decrease luminance speed
  120215. */
  120216. hdrDecreaseRate: number;
  120217. /**
  120218. * For eye adaptation, represents the increase luminance speed
  120219. */
  120220. hdrIncreaseRate: number;
  120221. /**
  120222. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  120223. */
  120224. /**
  120225. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  120226. */
  120227. hdrAutoExposure: boolean;
  120228. /**
  120229. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  120230. */
  120231. lensColorTexture: Nullable<Texture>;
  120232. /**
  120233. * The overall strengh for the lens flare effect
  120234. */
  120235. lensFlareStrength: number;
  120236. /**
  120237. * Dispersion coefficient for lens flare ghosts
  120238. */
  120239. lensFlareGhostDispersal: number;
  120240. /**
  120241. * Main lens flare halo width
  120242. */
  120243. lensFlareHaloWidth: number;
  120244. /**
  120245. * Based on the lens distortion effect, defines how much the lens flare result
  120246. * is distorted
  120247. */
  120248. lensFlareDistortionStrength: number;
  120249. /**
  120250. * Lens star texture must be used to simulate rays on the flares and is available
  120251. * in the documentation
  120252. */
  120253. lensStarTexture: Nullable<Texture>;
  120254. /**
  120255. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  120256. * flare effect by taking account of the dirt texture
  120257. */
  120258. lensFlareDirtTexture: Nullable<Texture>;
  120259. /**
  120260. * Represents the focal length for the depth of field effect
  120261. */
  120262. depthOfFieldDistance: number;
  120263. /**
  120264. * Represents the blur intensity for the blurred part of the depth of field effect
  120265. */
  120266. depthOfFieldBlurWidth: number;
  120267. /**
  120268. * Gets how much the image is blurred by the movement while using the motion blur post-process
  120269. */
  120270. /**
  120271. * Sets how much the image is blurred by the movement while using the motion blur post-process
  120272. */
  120273. motionStrength: number;
  120274. /**
  120275. * Gets wether or not the motion blur post-process is object based or screen based.
  120276. */
  120277. /**
  120278. * Sets wether or not the motion blur post-process should be object based or screen based
  120279. */
  120280. objectBasedMotionBlur: boolean;
  120281. /**
  120282. * List of animations for the pipeline (IAnimatable implementation)
  120283. */
  120284. animations: Animation[];
  120285. /**
  120286. * Private members
  120287. */
  120288. private _scene;
  120289. private _currentDepthOfFieldSource;
  120290. private _basePostProcess;
  120291. private _fixedExposure;
  120292. private _currentExposure;
  120293. private _hdrAutoExposure;
  120294. private _hdrCurrentLuminance;
  120295. private _motionStrength;
  120296. private _isObjectBasedMotionBlur;
  120297. private _floatTextureType;
  120298. private _ratio;
  120299. private _bloomEnabled;
  120300. private _depthOfFieldEnabled;
  120301. private _vlsEnabled;
  120302. private _lensFlareEnabled;
  120303. private _hdrEnabled;
  120304. private _motionBlurEnabled;
  120305. private _fxaaEnabled;
  120306. private _motionBlurSamples;
  120307. private _volumetricLightStepsCount;
  120308. private _samples;
  120309. /**
  120310. * @ignore
  120311. * Specifies if the bloom pipeline is enabled
  120312. */
  120313. BloomEnabled: boolean;
  120314. /**
  120315. * @ignore
  120316. * Specifies if the depth of field pipeline is enabed
  120317. */
  120318. DepthOfFieldEnabled: boolean;
  120319. /**
  120320. * @ignore
  120321. * Specifies if the lens flare pipeline is enabed
  120322. */
  120323. LensFlareEnabled: boolean;
  120324. /**
  120325. * @ignore
  120326. * Specifies if the HDR pipeline is enabled
  120327. */
  120328. HDREnabled: boolean;
  120329. /**
  120330. * @ignore
  120331. * Specifies if the volumetric lights scattering effect is enabled
  120332. */
  120333. VLSEnabled: boolean;
  120334. /**
  120335. * @ignore
  120336. * Specifies if the motion blur effect is enabled
  120337. */
  120338. MotionBlurEnabled: boolean;
  120339. /**
  120340. * Specifies if anti-aliasing is enabled
  120341. */
  120342. fxaaEnabled: boolean;
  120343. /**
  120344. * Specifies the number of steps used to calculate the volumetric lights
  120345. * Typically in interval [50, 200]
  120346. */
  120347. volumetricLightStepsCount: number;
  120348. /**
  120349. * Specifies the number of samples used for the motion blur effect
  120350. * Typically in interval [16, 64]
  120351. */
  120352. motionBlurSamples: number;
  120353. /**
  120354. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  120355. */
  120356. samples: number;
  120357. /**
  120358. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  120359. * @constructor
  120360. * @param name The rendering pipeline name
  120361. * @param scene The scene linked to this pipeline
  120362. * @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)
  120363. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  120364. * @param cameras The array of cameras that the rendering pipeline will be attached to
  120365. */
  120366. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  120367. private _buildPipeline;
  120368. private _createDownSampleX4PostProcess;
  120369. private _createBrightPassPostProcess;
  120370. private _createBlurPostProcesses;
  120371. private _createTextureAdderPostProcess;
  120372. private _createVolumetricLightPostProcess;
  120373. private _createLuminancePostProcesses;
  120374. private _createHdrPostProcess;
  120375. private _createLensFlarePostProcess;
  120376. private _createDepthOfFieldPostProcess;
  120377. private _createMotionBlurPostProcess;
  120378. private _getDepthTexture;
  120379. private _disposePostProcesses;
  120380. /**
  120381. * Dispose of the pipeline and stop all post processes
  120382. */
  120383. dispose(): void;
  120384. /**
  120385. * Serialize the rendering pipeline (Used when exporting)
  120386. * @returns the serialized object
  120387. */
  120388. serialize(): any;
  120389. /**
  120390. * Parse the serialized pipeline
  120391. * @param source Source pipeline.
  120392. * @param scene The scene to load the pipeline to.
  120393. * @param rootUrl The URL of the serialized pipeline.
  120394. * @returns An instantiated pipeline from the serialized object.
  120395. */
  120396. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  120397. /**
  120398. * Luminance steps
  120399. */
  120400. static LuminanceSteps: number;
  120401. }
  120402. }
  120403. declare module BABYLON {
  120404. /** @hidden */
  120405. export var tonemapPixelShader: {
  120406. name: string;
  120407. shader: string;
  120408. };
  120409. }
  120410. declare module BABYLON {
  120411. /** Defines operator used for tonemapping */
  120412. export enum TonemappingOperator {
  120413. /** Hable */
  120414. Hable = 0,
  120415. /** Reinhard */
  120416. Reinhard = 1,
  120417. /** HejiDawson */
  120418. HejiDawson = 2,
  120419. /** Photographic */
  120420. Photographic = 3
  120421. }
  120422. /**
  120423. * Defines a post process to apply tone mapping
  120424. */
  120425. export class TonemapPostProcess extends PostProcess {
  120426. private _operator;
  120427. /** Defines the required exposure adjustement */
  120428. exposureAdjustment: number;
  120429. /**
  120430. * Creates a new TonemapPostProcess
  120431. * @param name defines the name of the postprocess
  120432. * @param _operator defines the operator to use
  120433. * @param exposureAdjustment defines the required exposure adjustement
  120434. * @param camera defines the camera to use (can be null)
  120435. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  120436. * @param engine defines the hosting engine (can be ignore if camera is set)
  120437. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  120438. */
  120439. constructor(name: string, _operator: TonemappingOperator,
  120440. /** Defines the required exposure adjustement */
  120441. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  120442. }
  120443. }
  120444. declare module BABYLON {
  120445. /** @hidden */
  120446. export var depthVertexShader: {
  120447. name: string;
  120448. shader: string;
  120449. };
  120450. }
  120451. declare module BABYLON {
  120452. /** @hidden */
  120453. export var volumetricLightScatteringPixelShader: {
  120454. name: string;
  120455. shader: string;
  120456. };
  120457. }
  120458. declare module BABYLON {
  120459. /** @hidden */
  120460. export var volumetricLightScatteringPassPixelShader: {
  120461. name: string;
  120462. shader: string;
  120463. };
  120464. }
  120465. declare module BABYLON {
  120466. /**
  120467. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  120468. */
  120469. export class VolumetricLightScatteringPostProcess extends PostProcess {
  120470. private _volumetricLightScatteringPass;
  120471. private _volumetricLightScatteringRTT;
  120472. private _viewPort;
  120473. private _screenCoordinates;
  120474. private _cachedDefines;
  120475. /**
  120476. * If not undefined, the mesh position is computed from the attached node position
  120477. */
  120478. attachedNode: {
  120479. position: Vector3;
  120480. };
  120481. /**
  120482. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  120483. */
  120484. customMeshPosition: Vector3;
  120485. /**
  120486. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  120487. */
  120488. useCustomMeshPosition: boolean;
  120489. /**
  120490. * If the post-process should inverse the light scattering direction
  120491. */
  120492. invert: boolean;
  120493. /**
  120494. * The internal mesh used by the post-process
  120495. */
  120496. mesh: Mesh;
  120497. /**
  120498. * @hidden
  120499. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  120500. */
  120501. useDiffuseColor: boolean;
  120502. /**
  120503. * Array containing the excluded meshes not rendered in the internal pass
  120504. */
  120505. excludedMeshes: AbstractMesh[];
  120506. /**
  120507. * Controls the overall intensity of the post-process
  120508. */
  120509. exposure: number;
  120510. /**
  120511. * Dissipates each sample's contribution in range [0, 1]
  120512. */
  120513. decay: number;
  120514. /**
  120515. * Controls the overall intensity of each sample
  120516. */
  120517. weight: number;
  120518. /**
  120519. * Controls the density of each sample
  120520. */
  120521. density: number;
  120522. /**
  120523. * @constructor
  120524. * @param name The post-process name
  120525. * @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)
  120526. * @param camera The camera that the post-process will be attached to
  120527. * @param mesh The mesh used to create the light scattering
  120528. * @param samples The post-process quality, default 100
  120529. * @param samplingModeThe post-process filtering mode
  120530. * @param engine The babylon engine
  120531. * @param reusable If the post-process is reusable
  120532. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  120533. */
  120534. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  120535. /**
  120536. * Returns the string "VolumetricLightScatteringPostProcess"
  120537. * @returns "VolumetricLightScatteringPostProcess"
  120538. */
  120539. getClassName(): string;
  120540. private _isReady;
  120541. /**
  120542. * Sets the new light position for light scattering effect
  120543. * @param position The new custom light position
  120544. */
  120545. setCustomMeshPosition(position: Vector3): void;
  120546. /**
  120547. * Returns the light position for light scattering effect
  120548. * @return Vector3 The custom light position
  120549. */
  120550. getCustomMeshPosition(): Vector3;
  120551. /**
  120552. * Disposes the internal assets and detaches the post-process from the camera
  120553. */
  120554. dispose(camera: Camera): void;
  120555. /**
  120556. * Returns the render target texture used by the post-process
  120557. * @return the render target texture used by the post-process
  120558. */
  120559. getPass(): RenderTargetTexture;
  120560. private _meshExcluded;
  120561. private _createPass;
  120562. private _updateMeshScreenCoordinates;
  120563. /**
  120564. * Creates a default mesh for the Volumeric Light Scattering post-process
  120565. * @param name The mesh name
  120566. * @param scene The scene where to create the mesh
  120567. * @return the default mesh
  120568. */
  120569. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  120570. }
  120571. }
  120572. declare module BABYLON {
  120573. interface Scene {
  120574. /** @hidden (Backing field) */
  120575. _boundingBoxRenderer: BoundingBoxRenderer;
  120576. /** @hidden (Backing field) */
  120577. _forceShowBoundingBoxes: boolean;
  120578. /**
  120579. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  120580. */
  120581. forceShowBoundingBoxes: boolean;
  120582. /**
  120583. * Gets the bounding box renderer associated with the scene
  120584. * @returns a BoundingBoxRenderer
  120585. */
  120586. getBoundingBoxRenderer(): BoundingBoxRenderer;
  120587. }
  120588. interface AbstractMesh {
  120589. /** @hidden (Backing field) */
  120590. _showBoundingBox: boolean;
  120591. /**
  120592. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  120593. */
  120594. showBoundingBox: boolean;
  120595. }
  120596. /**
  120597. * Component responsible of rendering the bounding box of the meshes in a scene.
  120598. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  120599. */
  120600. export class BoundingBoxRenderer implements ISceneComponent {
  120601. /**
  120602. * The component name helpfull to identify the component in the list of scene components.
  120603. */
  120604. readonly name: string;
  120605. /**
  120606. * The scene the component belongs to.
  120607. */
  120608. scene: Scene;
  120609. /**
  120610. * Color of the bounding box lines placed in front of an object
  120611. */
  120612. frontColor: Color3;
  120613. /**
  120614. * Color of the bounding box lines placed behind an object
  120615. */
  120616. backColor: Color3;
  120617. /**
  120618. * Defines if the renderer should show the back lines or not
  120619. */
  120620. showBackLines: boolean;
  120621. /**
  120622. * @hidden
  120623. */
  120624. renderList: SmartArray<BoundingBox>;
  120625. private _colorShader;
  120626. private _vertexBuffers;
  120627. private _indexBuffer;
  120628. private _fillIndexBuffer;
  120629. private _fillIndexData;
  120630. /**
  120631. * Instantiates a new bounding box renderer in a scene.
  120632. * @param scene the scene the renderer renders in
  120633. */
  120634. constructor(scene: Scene);
  120635. /**
  120636. * Registers the component in a given scene
  120637. */
  120638. register(): void;
  120639. private _evaluateSubMesh;
  120640. private _activeMesh;
  120641. private _prepareRessources;
  120642. private _createIndexBuffer;
  120643. /**
  120644. * Rebuilds the elements related to this component in case of
  120645. * context lost for instance.
  120646. */
  120647. rebuild(): void;
  120648. /**
  120649. * @hidden
  120650. */
  120651. reset(): void;
  120652. /**
  120653. * Render the bounding boxes of a specific rendering group
  120654. * @param renderingGroupId defines the rendering group to render
  120655. */
  120656. render(renderingGroupId: number): void;
  120657. /**
  120658. * In case of occlusion queries, we can render the occlusion bounding box through this method
  120659. * @param mesh Define the mesh to render the occlusion bounding box for
  120660. */
  120661. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  120662. /**
  120663. * Dispose and release the resources attached to this renderer.
  120664. */
  120665. dispose(): void;
  120666. }
  120667. }
  120668. declare module BABYLON {
  120669. /** @hidden */
  120670. export var depthPixelShader: {
  120671. name: string;
  120672. shader: string;
  120673. };
  120674. }
  120675. declare module BABYLON {
  120676. /**
  120677. * This represents a depth renderer in Babylon.
  120678. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  120679. */
  120680. export class DepthRenderer {
  120681. private _scene;
  120682. private _depthMap;
  120683. private _effect;
  120684. private readonly _storeNonLinearDepth;
  120685. private readonly _clearColor;
  120686. /** Get if the depth renderer is using packed depth or not */
  120687. readonly isPacked: boolean;
  120688. private _cachedDefines;
  120689. private _camera;
  120690. /**
  120691. * Specifiess that the depth renderer will only be used within
  120692. * the camera it is created for.
  120693. * This can help forcing its rendering during the camera processing.
  120694. */
  120695. useOnlyInActiveCamera: boolean;
  120696. /** @hidden */
  120697. static _SceneComponentInitialization: (scene: Scene) => void;
  120698. /**
  120699. * Instantiates a depth renderer
  120700. * @param scene The scene the renderer belongs to
  120701. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  120702. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  120703. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  120704. */
  120705. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  120706. /**
  120707. * Creates the depth rendering effect and checks if the effect is ready.
  120708. * @param subMesh The submesh to be used to render the depth map of
  120709. * @param useInstances If multiple world instances should be used
  120710. * @returns if the depth renderer is ready to render the depth map
  120711. */
  120712. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120713. /**
  120714. * Gets the texture which the depth map will be written to.
  120715. * @returns The depth map texture
  120716. */
  120717. getDepthMap(): RenderTargetTexture;
  120718. /**
  120719. * Disposes of the depth renderer.
  120720. */
  120721. dispose(): void;
  120722. }
  120723. }
  120724. declare module BABYLON {
  120725. interface Scene {
  120726. /** @hidden (Backing field) */
  120727. _depthRenderer: {
  120728. [id: string]: DepthRenderer;
  120729. };
  120730. /**
  120731. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  120732. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  120733. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  120734. * @returns the created depth renderer
  120735. */
  120736. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  120737. /**
  120738. * Disables a depth renderer for a given camera
  120739. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  120740. */
  120741. disableDepthRenderer(camera?: Nullable<Camera>): void;
  120742. }
  120743. /**
  120744. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  120745. * in several rendering techniques.
  120746. */
  120747. export class DepthRendererSceneComponent implements ISceneComponent {
  120748. /**
  120749. * The component name helpfull to identify the component in the list of scene components.
  120750. */
  120751. readonly name: string;
  120752. /**
  120753. * The scene the component belongs to.
  120754. */
  120755. scene: Scene;
  120756. /**
  120757. * Creates a new instance of the component for the given scene
  120758. * @param scene Defines the scene to register the component in
  120759. */
  120760. constructor(scene: Scene);
  120761. /**
  120762. * Registers the component in a given scene
  120763. */
  120764. register(): void;
  120765. /**
  120766. * Rebuilds the elements related to this component in case of
  120767. * context lost for instance.
  120768. */
  120769. rebuild(): void;
  120770. /**
  120771. * Disposes the component and the associated ressources
  120772. */
  120773. dispose(): void;
  120774. private _gatherRenderTargets;
  120775. private _gatherActiveCameraRenderTargets;
  120776. }
  120777. }
  120778. declare module BABYLON {
  120779. /** @hidden */
  120780. export var outlinePixelShader: {
  120781. name: string;
  120782. shader: string;
  120783. };
  120784. }
  120785. declare module BABYLON {
  120786. /** @hidden */
  120787. export var outlineVertexShader: {
  120788. name: string;
  120789. shader: string;
  120790. };
  120791. }
  120792. declare module BABYLON {
  120793. interface Scene {
  120794. /** @hidden */
  120795. _outlineRenderer: OutlineRenderer;
  120796. /**
  120797. * Gets the outline renderer associated with the scene
  120798. * @returns a OutlineRenderer
  120799. */
  120800. getOutlineRenderer(): OutlineRenderer;
  120801. }
  120802. interface AbstractMesh {
  120803. /** @hidden (Backing field) */
  120804. _renderOutline: boolean;
  120805. /**
  120806. * Gets or sets a boolean indicating if the outline must be rendered as well
  120807. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  120808. */
  120809. renderOutline: boolean;
  120810. /** @hidden (Backing field) */
  120811. _renderOverlay: boolean;
  120812. /**
  120813. * Gets or sets a boolean indicating if the overlay must be rendered as well
  120814. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  120815. */
  120816. renderOverlay: boolean;
  120817. }
  120818. /**
  120819. * This class is responsible to draw bothe outline/overlay of meshes.
  120820. * It should not be used directly but through the available method on mesh.
  120821. */
  120822. export class OutlineRenderer implements ISceneComponent {
  120823. /**
  120824. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  120825. */
  120826. private static _StencilReference;
  120827. /**
  120828. * The name of the component. Each component must have a unique name.
  120829. */
  120830. name: string;
  120831. /**
  120832. * The scene the component belongs to.
  120833. */
  120834. scene: Scene;
  120835. /**
  120836. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  120837. */
  120838. zOffset: number;
  120839. private _engine;
  120840. private _effect;
  120841. private _cachedDefines;
  120842. private _savedDepthWrite;
  120843. /**
  120844. * Instantiates a new outline renderer. (There could be only one per scene).
  120845. * @param scene Defines the scene it belongs to
  120846. */
  120847. constructor(scene: Scene);
  120848. /**
  120849. * Register the component to one instance of a scene.
  120850. */
  120851. register(): void;
  120852. /**
  120853. * Rebuilds the elements related to this component in case of
  120854. * context lost for instance.
  120855. */
  120856. rebuild(): void;
  120857. /**
  120858. * Disposes the component and the associated ressources.
  120859. */
  120860. dispose(): void;
  120861. /**
  120862. * Renders the outline in the canvas.
  120863. * @param subMesh Defines the sumesh to render
  120864. * @param batch Defines the batch of meshes in case of instances
  120865. * @param useOverlay Defines if the rendering is for the overlay or the outline
  120866. */
  120867. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  120868. /**
  120869. * Returns whether or not the outline renderer is ready for a given submesh.
  120870. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  120871. * @param subMesh Defines the submesh to check readyness for
  120872. * @param useInstances Defines wheter wee are trying to render instances or not
  120873. * @returns true if ready otherwise false
  120874. */
  120875. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120876. private _beforeRenderingMesh;
  120877. private _afterRenderingMesh;
  120878. }
  120879. }
  120880. declare module BABYLON {
  120881. /**
  120882. * Defines the list of states available for a task inside a AssetsManager
  120883. */
  120884. export enum AssetTaskState {
  120885. /**
  120886. * Initialization
  120887. */
  120888. INIT = 0,
  120889. /**
  120890. * Running
  120891. */
  120892. RUNNING = 1,
  120893. /**
  120894. * Done
  120895. */
  120896. DONE = 2,
  120897. /**
  120898. * Error
  120899. */
  120900. ERROR = 3
  120901. }
  120902. /**
  120903. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  120904. */
  120905. export abstract class AbstractAssetTask {
  120906. /**
  120907. * Task name
  120908. */ name: string;
  120909. /**
  120910. * Callback called when the task is successful
  120911. */
  120912. onSuccess: (task: any) => void;
  120913. /**
  120914. * Callback called when the task is not successful
  120915. */
  120916. onError: (task: any, message?: string, exception?: any) => void;
  120917. /**
  120918. * Creates a new AssetsManager
  120919. * @param name defines the name of the task
  120920. */
  120921. constructor(
  120922. /**
  120923. * Task name
  120924. */ name: string);
  120925. private _isCompleted;
  120926. private _taskState;
  120927. private _errorObject;
  120928. /**
  120929. * Get if the task is completed
  120930. */
  120931. readonly isCompleted: boolean;
  120932. /**
  120933. * Gets the current state of the task
  120934. */
  120935. readonly taskState: AssetTaskState;
  120936. /**
  120937. * Gets the current error object (if task is in error)
  120938. */
  120939. readonly errorObject: {
  120940. message?: string;
  120941. exception?: any;
  120942. };
  120943. /**
  120944. * Internal only
  120945. * @hidden
  120946. */
  120947. _setErrorObject(message?: string, exception?: any): void;
  120948. /**
  120949. * Execute the current task
  120950. * @param scene defines the scene where you want your assets to be loaded
  120951. * @param onSuccess is a callback called when the task is successfully executed
  120952. * @param onError is a callback called if an error occurs
  120953. */
  120954. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120955. /**
  120956. * Execute the current task
  120957. * @param scene defines the scene where you want your assets to be loaded
  120958. * @param onSuccess is a callback called when the task is successfully executed
  120959. * @param onError is a callback called if an error occurs
  120960. */
  120961. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120962. /**
  120963. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  120964. * This can be used with failed tasks that have the reason for failure fixed.
  120965. */
  120966. reset(): void;
  120967. private onErrorCallback;
  120968. private onDoneCallback;
  120969. }
  120970. /**
  120971. * Define the interface used by progress events raised during assets loading
  120972. */
  120973. export interface IAssetsProgressEvent {
  120974. /**
  120975. * Defines the number of remaining tasks to process
  120976. */
  120977. remainingCount: number;
  120978. /**
  120979. * Defines the total number of tasks
  120980. */
  120981. totalCount: number;
  120982. /**
  120983. * Defines the task that was just processed
  120984. */
  120985. task: AbstractAssetTask;
  120986. }
  120987. /**
  120988. * Class used to share progress information about assets loading
  120989. */
  120990. export class AssetsProgressEvent implements IAssetsProgressEvent {
  120991. /**
  120992. * Defines the number of remaining tasks to process
  120993. */
  120994. remainingCount: number;
  120995. /**
  120996. * Defines the total number of tasks
  120997. */
  120998. totalCount: number;
  120999. /**
  121000. * Defines the task that was just processed
  121001. */
  121002. task: AbstractAssetTask;
  121003. /**
  121004. * Creates a AssetsProgressEvent
  121005. * @param remainingCount defines the number of remaining tasks to process
  121006. * @param totalCount defines the total number of tasks
  121007. * @param task defines the task that was just processed
  121008. */
  121009. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  121010. }
  121011. /**
  121012. * Define a task used by AssetsManager to load meshes
  121013. */
  121014. export class MeshAssetTask extends AbstractAssetTask {
  121015. /**
  121016. * Defines the name of the task
  121017. */
  121018. name: string;
  121019. /**
  121020. * Defines the list of mesh's names you want to load
  121021. */
  121022. meshesNames: any;
  121023. /**
  121024. * Defines the root url to use as a base to load your meshes and associated resources
  121025. */
  121026. rootUrl: string;
  121027. /**
  121028. * Defines the filename of the scene to load from
  121029. */
  121030. sceneFilename: string;
  121031. /**
  121032. * Gets the list of loaded meshes
  121033. */
  121034. loadedMeshes: Array<AbstractMesh>;
  121035. /**
  121036. * Gets the list of loaded particle systems
  121037. */
  121038. loadedParticleSystems: Array<IParticleSystem>;
  121039. /**
  121040. * Gets the list of loaded skeletons
  121041. */
  121042. loadedSkeletons: Array<Skeleton>;
  121043. /**
  121044. * Gets the list of loaded animation groups
  121045. */
  121046. loadedAnimationGroups: Array<AnimationGroup>;
  121047. /**
  121048. * Callback called when the task is successful
  121049. */
  121050. onSuccess: (task: MeshAssetTask) => void;
  121051. /**
  121052. * Callback called when the task is successful
  121053. */
  121054. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  121055. /**
  121056. * Creates a new MeshAssetTask
  121057. * @param name defines the name of the task
  121058. * @param meshesNames defines the list of mesh's names you want to load
  121059. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  121060. * @param sceneFilename defines the filename of the scene to load from
  121061. */
  121062. constructor(
  121063. /**
  121064. * Defines the name of the task
  121065. */
  121066. name: string,
  121067. /**
  121068. * Defines the list of mesh's names you want to load
  121069. */
  121070. meshesNames: any,
  121071. /**
  121072. * Defines the root url to use as a base to load your meshes and associated resources
  121073. */
  121074. rootUrl: string,
  121075. /**
  121076. * Defines the filename of the scene to load from
  121077. */
  121078. sceneFilename: string);
  121079. /**
  121080. * Execute the current task
  121081. * @param scene defines the scene where you want your assets to be loaded
  121082. * @param onSuccess is a callback called when the task is successfully executed
  121083. * @param onError is a callback called if an error occurs
  121084. */
  121085. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121086. }
  121087. /**
  121088. * Define a task used by AssetsManager to load text content
  121089. */
  121090. export class TextFileAssetTask extends AbstractAssetTask {
  121091. /**
  121092. * Defines the name of the task
  121093. */
  121094. name: string;
  121095. /**
  121096. * Defines the location of the file to load
  121097. */
  121098. url: string;
  121099. /**
  121100. * Gets the loaded text string
  121101. */
  121102. text: string;
  121103. /**
  121104. * Callback called when the task is successful
  121105. */
  121106. onSuccess: (task: TextFileAssetTask) => void;
  121107. /**
  121108. * Callback called when the task is successful
  121109. */
  121110. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  121111. /**
  121112. * Creates a new TextFileAssetTask object
  121113. * @param name defines the name of the task
  121114. * @param url defines the location of the file to load
  121115. */
  121116. constructor(
  121117. /**
  121118. * Defines the name of the task
  121119. */
  121120. name: string,
  121121. /**
  121122. * Defines the location of the file to load
  121123. */
  121124. url: string);
  121125. /**
  121126. * Execute the current task
  121127. * @param scene defines the scene where you want your assets to be loaded
  121128. * @param onSuccess is a callback called when the task is successfully executed
  121129. * @param onError is a callback called if an error occurs
  121130. */
  121131. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121132. }
  121133. /**
  121134. * Define a task used by AssetsManager to load binary data
  121135. */
  121136. export class BinaryFileAssetTask extends AbstractAssetTask {
  121137. /**
  121138. * Defines the name of the task
  121139. */
  121140. name: string;
  121141. /**
  121142. * Defines the location of the file to load
  121143. */
  121144. url: string;
  121145. /**
  121146. * Gets the lodaded data (as an array buffer)
  121147. */
  121148. data: ArrayBuffer;
  121149. /**
  121150. * Callback called when the task is successful
  121151. */
  121152. onSuccess: (task: BinaryFileAssetTask) => void;
  121153. /**
  121154. * Callback called when the task is successful
  121155. */
  121156. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  121157. /**
  121158. * Creates a new BinaryFileAssetTask object
  121159. * @param name defines the name of the new task
  121160. * @param url defines the location of the file to load
  121161. */
  121162. constructor(
  121163. /**
  121164. * Defines the name of the task
  121165. */
  121166. name: string,
  121167. /**
  121168. * Defines the location of the file to load
  121169. */
  121170. url: string);
  121171. /**
  121172. * Execute the current task
  121173. * @param scene defines the scene where you want your assets to be loaded
  121174. * @param onSuccess is a callback called when the task is successfully executed
  121175. * @param onError is a callback called if an error occurs
  121176. */
  121177. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121178. }
  121179. /**
  121180. * Define a task used by AssetsManager to load images
  121181. */
  121182. export class ImageAssetTask extends AbstractAssetTask {
  121183. /**
  121184. * Defines the name of the task
  121185. */
  121186. name: string;
  121187. /**
  121188. * Defines the location of the image to load
  121189. */
  121190. url: string;
  121191. /**
  121192. * Gets the loaded images
  121193. */
  121194. image: HTMLImageElement;
  121195. /**
  121196. * Callback called when the task is successful
  121197. */
  121198. onSuccess: (task: ImageAssetTask) => void;
  121199. /**
  121200. * Callback called when the task is successful
  121201. */
  121202. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  121203. /**
  121204. * Creates a new ImageAssetTask
  121205. * @param name defines the name of the task
  121206. * @param url defines the location of the image to load
  121207. */
  121208. constructor(
  121209. /**
  121210. * Defines the name of the task
  121211. */
  121212. name: string,
  121213. /**
  121214. * Defines the location of the image to load
  121215. */
  121216. url: string);
  121217. /**
  121218. * Execute the current task
  121219. * @param scene defines the scene where you want your assets to be loaded
  121220. * @param onSuccess is a callback called when the task is successfully executed
  121221. * @param onError is a callback called if an error occurs
  121222. */
  121223. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121224. }
  121225. /**
  121226. * Defines the interface used by texture loading tasks
  121227. */
  121228. export interface ITextureAssetTask<TEX extends BaseTexture> {
  121229. /**
  121230. * Gets the loaded texture
  121231. */
  121232. texture: TEX;
  121233. }
  121234. /**
  121235. * Define a task used by AssetsManager to load 2D textures
  121236. */
  121237. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  121238. /**
  121239. * Defines the name of the task
  121240. */
  121241. name: string;
  121242. /**
  121243. * Defines the location of the file to load
  121244. */
  121245. url: string;
  121246. /**
  121247. * Defines if mipmap should not be generated (default is false)
  121248. */
  121249. noMipmap?: boolean | undefined;
  121250. /**
  121251. * Defines if texture must be inverted on Y axis (default is false)
  121252. */
  121253. invertY?: boolean | undefined;
  121254. /**
  121255. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  121256. */
  121257. samplingMode: number;
  121258. /**
  121259. * Gets the loaded texture
  121260. */
  121261. texture: Texture;
  121262. /**
  121263. * Callback called when the task is successful
  121264. */
  121265. onSuccess: (task: TextureAssetTask) => void;
  121266. /**
  121267. * Callback called when the task is successful
  121268. */
  121269. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  121270. /**
  121271. * Creates a new TextureAssetTask object
  121272. * @param name defines the name of the task
  121273. * @param url defines the location of the file to load
  121274. * @param noMipmap defines if mipmap should not be generated (default is false)
  121275. * @param invertY defines if texture must be inverted on Y axis (default is false)
  121276. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  121277. */
  121278. constructor(
  121279. /**
  121280. * Defines the name of the task
  121281. */
  121282. name: string,
  121283. /**
  121284. * Defines the location of the file to load
  121285. */
  121286. url: string,
  121287. /**
  121288. * Defines if mipmap should not be generated (default is false)
  121289. */
  121290. noMipmap?: boolean | undefined,
  121291. /**
  121292. * Defines if texture must be inverted on Y axis (default is false)
  121293. */
  121294. invertY?: boolean | undefined,
  121295. /**
  121296. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  121297. */
  121298. samplingMode?: number);
  121299. /**
  121300. * Execute the current task
  121301. * @param scene defines the scene where you want your assets to be loaded
  121302. * @param onSuccess is a callback called when the task is successfully executed
  121303. * @param onError is a callback called if an error occurs
  121304. */
  121305. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121306. }
  121307. /**
  121308. * Define a task used by AssetsManager to load cube textures
  121309. */
  121310. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  121311. /**
  121312. * Defines the name of the task
  121313. */
  121314. name: string;
  121315. /**
  121316. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121317. */
  121318. url: string;
  121319. /**
  121320. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121321. */
  121322. extensions?: string[] | undefined;
  121323. /**
  121324. * Defines if mipmaps should not be generated (default is false)
  121325. */
  121326. noMipmap?: boolean | undefined;
  121327. /**
  121328. * Defines the explicit list of files (undefined by default)
  121329. */
  121330. files?: string[] | undefined;
  121331. /**
  121332. * Gets the loaded texture
  121333. */
  121334. texture: CubeTexture;
  121335. /**
  121336. * Callback called when the task is successful
  121337. */
  121338. onSuccess: (task: CubeTextureAssetTask) => void;
  121339. /**
  121340. * Callback called when the task is successful
  121341. */
  121342. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  121343. /**
  121344. * Creates a new CubeTextureAssetTask
  121345. * @param name defines the name of the task
  121346. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121347. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121348. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121349. * @param files defines the explicit list of files (undefined by default)
  121350. */
  121351. constructor(
  121352. /**
  121353. * Defines the name of the task
  121354. */
  121355. name: string,
  121356. /**
  121357. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121358. */
  121359. url: string,
  121360. /**
  121361. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121362. */
  121363. extensions?: string[] | undefined,
  121364. /**
  121365. * Defines if mipmaps should not be generated (default is false)
  121366. */
  121367. noMipmap?: boolean | undefined,
  121368. /**
  121369. * Defines the explicit list of files (undefined by default)
  121370. */
  121371. files?: string[] | undefined);
  121372. /**
  121373. * Execute the current task
  121374. * @param scene defines the scene where you want your assets to be loaded
  121375. * @param onSuccess is a callback called when the task is successfully executed
  121376. * @param onError is a callback called if an error occurs
  121377. */
  121378. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121379. }
  121380. /**
  121381. * Define a task used by AssetsManager to load HDR cube textures
  121382. */
  121383. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  121384. /**
  121385. * Defines the name of the task
  121386. */
  121387. name: string;
  121388. /**
  121389. * Defines the location of the file to load
  121390. */
  121391. url: string;
  121392. /**
  121393. * Defines the desired size (the more it increases the longer the generation will be)
  121394. */
  121395. size: number;
  121396. /**
  121397. * Defines if mipmaps should not be generated (default is false)
  121398. */
  121399. noMipmap: boolean;
  121400. /**
  121401. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121402. */
  121403. generateHarmonics: boolean;
  121404. /**
  121405. * 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)
  121406. */
  121407. gammaSpace: boolean;
  121408. /**
  121409. * Internal Use Only
  121410. */
  121411. reserved: boolean;
  121412. /**
  121413. * Gets the loaded texture
  121414. */
  121415. texture: HDRCubeTexture;
  121416. /**
  121417. * Callback called when the task is successful
  121418. */
  121419. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  121420. /**
  121421. * Callback called when the task is successful
  121422. */
  121423. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  121424. /**
  121425. * Creates a new HDRCubeTextureAssetTask object
  121426. * @param name defines the name of the task
  121427. * @param url defines the location of the file to load
  121428. * @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.
  121429. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121430. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121431. * @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)
  121432. * @param reserved Internal use only
  121433. */
  121434. constructor(
  121435. /**
  121436. * Defines the name of the task
  121437. */
  121438. name: string,
  121439. /**
  121440. * Defines the location of the file to load
  121441. */
  121442. url: string,
  121443. /**
  121444. * Defines the desired size (the more it increases the longer the generation will be)
  121445. */
  121446. size: number,
  121447. /**
  121448. * Defines if mipmaps should not be generated (default is false)
  121449. */
  121450. noMipmap?: boolean,
  121451. /**
  121452. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121453. */
  121454. generateHarmonics?: boolean,
  121455. /**
  121456. * 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)
  121457. */
  121458. gammaSpace?: boolean,
  121459. /**
  121460. * Internal Use Only
  121461. */
  121462. reserved?: boolean);
  121463. /**
  121464. * Execute the current task
  121465. * @param scene defines the scene where you want your assets to be loaded
  121466. * @param onSuccess is a callback called when the task is successfully executed
  121467. * @param onError is a callback called if an error occurs
  121468. */
  121469. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121470. }
  121471. /**
  121472. * Define a task used by AssetsManager to load Equirectangular cube textures
  121473. */
  121474. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  121475. /**
  121476. * Defines the name of the task
  121477. */
  121478. name: string;
  121479. /**
  121480. * Defines the location of the file to load
  121481. */
  121482. url: string;
  121483. /**
  121484. * Defines the desired size (the more it increases the longer the generation will be)
  121485. */
  121486. size: number;
  121487. /**
  121488. * Defines if mipmaps should not be generated (default is false)
  121489. */
  121490. noMipmap: boolean;
  121491. /**
  121492. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  121493. * but the standard material would require them in Gamma space) (default is true)
  121494. */
  121495. gammaSpace: boolean;
  121496. /**
  121497. * Gets the loaded texture
  121498. */
  121499. texture: EquiRectangularCubeTexture;
  121500. /**
  121501. * Callback called when the task is successful
  121502. */
  121503. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  121504. /**
  121505. * Callback called when the task is successful
  121506. */
  121507. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  121508. /**
  121509. * Creates a new EquiRectangularCubeTextureAssetTask object
  121510. * @param name defines the name of the task
  121511. * @param url defines the location of the file to load
  121512. * @param size defines the desired size (the more it increases the longer the generation will be)
  121513. * If the size is omitted this implies you are using a preprocessed cubemap.
  121514. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121515. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  121516. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  121517. * (default is true)
  121518. */
  121519. constructor(
  121520. /**
  121521. * Defines the name of the task
  121522. */
  121523. name: string,
  121524. /**
  121525. * Defines the location of the file to load
  121526. */
  121527. url: string,
  121528. /**
  121529. * Defines the desired size (the more it increases the longer the generation will be)
  121530. */
  121531. size: number,
  121532. /**
  121533. * Defines if mipmaps should not be generated (default is false)
  121534. */
  121535. noMipmap?: boolean,
  121536. /**
  121537. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  121538. * but the standard material would require them in Gamma space) (default is true)
  121539. */
  121540. gammaSpace?: boolean);
  121541. /**
  121542. * Execute the current task
  121543. * @param scene defines the scene where you want your assets to be loaded
  121544. * @param onSuccess is a callback called when the task is successfully executed
  121545. * @param onError is a callback called if an error occurs
  121546. */
  121547. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121548. }
  121549. /**
  121550. * This class can be used to easily import assets into a scene
  121551. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  121552. */
  121553. export class AssetsManager {
  121554. private _scene;
  121555. private _isLoading;
  121556. protected _tasks: AbstractAssetTask[];
  121557. protected _waitingTasksCount: number;
  121558. protected _totalTasksCount: number;
  121559. /**
  121560. * Callback called when all tasks are processed
  121561. */
  121562. onFinish: (tasks: AbstractAssetTask[]) => void;
  121563. /**
  121564. * Callback called when a task is successful
  121565. */
  121566. onTaskSuccess: (task: AbstractAssetTask) => void;
  121567. /**
  121568. * Callback called when a task had an error
  121569. */
  121570. onTaskError: (task: AbstractAssetTask) => void;
  121571. /**
  121572. * Callback called when a task is done (whatever the result is)
  121573. */
  121574. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  121575. /**
  121576. * Observable called when all tasks are processed
  121577. */
  121578. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  121579. /**
  121580. * Observable called when a task had an error
  121581. */
  121582. onTaskErrorObservable: Observable<AbstractAssetTask>;
  121583. /**
  121584. * Observable called when all tasks were executed
  121585. */
  121586. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  121587. /**
  121588. * Observable called when a task is done (whatever the result is)
  121589. */
  121590. onProgressObservable: Observable<IAssetsProgressEvent>;
  121591. /**
  121592. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  121593. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121594. */
  121595. useDefaultLoadingScreen: boolean;
  121596. /**
  121597. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  121598. * when all assets have been downloaded.
  121599. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  121600. */
  121601. autoHideLoadingUI: boolean;
  121602. /**
  121603. * Creates a new AssetsManager
  121604. * @param scene defines the scene to work on
  121605. */
  121606. constructor(scene: Scene);
  121607. /**
  121608. * Add a MeshAssetTask to the list of active tasks
  121609. * @param taskName defines the name of the new task
  121610. * @param meshesNames defines the name of meshes to load
  121611. * @param rootUrl defines the root url to use to locate files
  121612. * @param sceneFilename defines the filename of the scene file
  121613. * @returns a new MeshAssetTask object
  121614. */
  121615. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  121616. /**
  121617. * Add a TextFileAssetTask to the list of active tasks
  121618. * @param taskName defines the name of the new task
  121619. * @param url defines the url of the file to load
  121620. * @returns a new TextFileAssetTask object
  121621. */
  121622. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  121623. /**
  121624. * Add a BinaryFileAssetTask to the list of active tasks
  121625. * @param taskName defines the name of the new task
  121626. * @param url defines the url of the file to load
  121627. * @returns a new BinaryFileAssetTask object
  121628. */
  121629. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  121630. /**
  121631. * Add a ImageAssetTask to the list of active tasks
  121632. * @param taskName defines the name of the new task
  121633. * @param url defines the url of the file to load
  121634. * @returns a new ImageAssetTask object
  121635. */
  121636. addImageTask(taskName: string, url: string): ImageAssetTask;
  121637. /**
  121638. * Add a TextureAssetTask to the list of active tasks
  121639. * @param taskName defines the name of the new task
  121640. * @param url defines the url of the file to load
  121641. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121642. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  121643. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121644. * @returns a new TextureAssetTask object
  121645. */
  121646. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  121647. /**
  121648. * Add a CubeTextureAssetTask to the list of active tasks
  121649. * @param taskName defines the name of the new task
  121650. * @param url defines the url of the file to load
  121651. * @param extensions defines the extension to use to load the cube map (can be null)
  121652. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121653. * @param files defines the list of files to load (can be null)
  121654. * @returns a new CubeTextureAssetTask object
  121655. */
  121656. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  121657. /**
  121658. *
  121659. * Add a HDRCubeTextureAssetTask to the list of active tasks
  121660. * @param taskName defines the name of the new task
  121661. * @param url defines the url of the file to load
  121662. * @param size defines the size you want for the cubemap (can be null)
  121663. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121664. * @param generateHarmonics defines if you want to automatically generate (true by default)
  121665. * @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)
  121666. * @param reserved Internal use only
  121667. * @returns a new HDRCubeTextureAssetTask object
  121668. */
  121669. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  121670. /**
  121671. *
  121672. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  121673. * @param taskName defines the name of the new task
  121674. * @param url defines the url of the file to load
  121675. * @param size defines the size you want for the cubemap (can be null)
  121676. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121677. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  121678. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  121679. * @returns a new EquiRectangularCubeTextureAssetTask object
  121680. */
  121681. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  121682. /**
  121683. * Remove a task from the assets manager.
  121684. * @param task the task to remove
  121685. */
  121686. removeTask(task: AbstractAssetTask): void;
  121687. private _decreaseWaitingTasksCount;
  121688. private _runTask;
  121689. /**
  121690. * Reset the AssetsManager and remove all tasks
  121691. * @return the current instance of the AssetsManager
  121692. */
  121693. reset(): AssetsManager;
  121694. /**
  121695. * Start the loading process
  121696. * @return the current instance of the AssetsManager
  121697. */
  121698. load(): AssetsManager;
  121699. /**
  121700. * Start the loading process as an async operation
  121701. * @return a promise returning the list of failed tasks
  121702. */
  121703. loadAsync(): Promise<void>;
  121704. }
  121705. }
  121706. declare module BABYLON {
  121707. /**
  121708. * Wrapper class for promise with external resolve and reject.
  121709. */
  121710. export class Deferred<T> {
  121711. /**
  121712. * The promise associated with this deferred object.
  121713. */
  121714. readonly promise: Promise<T>;
  121715. private _resolve;
  121716. private _reject;
  121717. /**
  121718. * The resolve method of the promise associated with this deferred object.
  121719. */
  121720. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  121721. /**
  121722. * The reject method of the promise associated with this deferred object.
  121723. */
  121724. readonly reject: (reason?: any) => void;
  121725. /**
  121726. * Constructor for this deferred object.
  121727. */
  121728. constructor();
  121729. }
  121730. }
  121731. declare module BABYLON {
  121732. /**
  121733. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  121734. */
  121735. export class MeshExploder {
  121736. private _centerMesh;
  121737. private _meshes;
  121738. private _meshesOrigins;
  121739. private _toCenterVectors;
  121740. private _scaledDirection;
  121741. private _newPosition;
  121742. private _centerPosition;
  121743. /**
  121744. * Explodes meshes from a center mesh.
  121745. * @param meshes The meshes to explode.
  121746. * @param centerMesh The mesh to be center of explosion.
  121747. */
  121748. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  121749. private _setCenterMesh;
  121750. /**
  121751. * Get class name
  121752. * @returns "MeshExploder"
  121753. */
  121754. getClassName(): string;
  121755. /**
  121756. * "Exploded meshes"
  121757. * @returns Array of meshes with the centerMesh at index 0.
  121758. */
  121759. getMeshes(): Array<Mesh>;
  121760. /**
  121761. * Explodes meshes giving a specific direction
  121762. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  121763. */
  121764. explode(direction?: number): void;
  121765. }
  121766. }
  121767. declare module BABYLON {
  121768. /**
  121769. * Class used to help managing file picking and drag'n'drop
  121770. */
  121771. export class FilesInput {
  121772. /**
  121773. * List of files ready to be loaded
  121774. */
  121775. static readonly FilesToLoad: {
  121776. [key: string]: File;
  121777. };
  121778. /**
  121779. * Callback called when a file is processed
  121780. */
  121781. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  121782. private _engine;
  121783. private _currentScene;
  121784. private _sceneLoadedCallback;
  121785. private _progressCallback;
  121786. private _additionalRenderLoopLogicCallback;
  121787. private _textureLoadingCallback;
  121788. private _startingProcessingFilesCallback;
  121789. private _onReloadCallback;
  121790. private _errorCallback;
  121791. private _elementToMonitor;
  121792. private _sceneFileToLoad;
  121793. private _filesToLoad;
  121794. /**
  121795. * Creates a new FilesInput
  121796. * @param engine defines the rendering engine
  121797. * @param scene defines the hosting scene
  121798. * @param sceneLoadedCallback callback called when scene is loaded
  121799. * @param progressCallback callback called to track progress
  121800. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  121801. * @param textureLoadingCallback callback called when a texture is loading
  121802. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  121803. * @param onReloadCallback callback called when a reload is requested
  121804. * @param errorCallback callback call if an error occurs
  121805. */
  121806. 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);
  121807. private _dragEnterHandler;
  121808. private _dragOverHandler;
  121809. private _dropHandler;
  121810. /**
  121811. * Calls this function to listen to drag'n'drop events on a specific DOM element
  121812. * @param elementToMonitor defines the DOM element to track
  121813. */
  121814. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  121815. /**
  121816. * Release all associated resources
  121817. */
  121818. dispose(): void;
  121819. private renderFunction;
  121820. private drag;
  121821. private drop;
  121822. private _traverseFolder;
  121823. private _processFiles;
  121824. /**
  121825. * Load files from a drop event
  121826. * @param event defines the drop event to use as source
  121827. */
  121828. loadFiles(event: any): void;
  121829. private _processReload;
  121830. /**
  121831. * Reload the current scene from the loaded files
  121832. */
  121833. reload(): void;
  121834. }
  121835. }
  121836. declare module BABYLON {
  121837. /**
  121838. * Defines the root class used to create scene optimization to use with SceneOptimizer
  121839. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121840. */
  121841. export class SceneOptimization {
  121842. /**
  121843. * Defines the priority of this optimization (0 by default which means first in the list)
  121844. */
  121845. priority: number;
  121846. /**
  121847. * Gets a string describing the action executed by the current optimization
  121848. * @returns description string
  121849. */
  121850. getDescription(): string;
  121851. /**
  121852. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121853. * @param scene defines the current scene where to apply this optimization
  121854. * @param optimizer defines the current optimizer
  121855. * @returns true if everything that can be done was applied
  121856. */
  121857. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121858. /**
  121859. * Creates the SceneOptimization object
  121860. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121861. * @param desc defines the description associated with the optimization
  121862. */
  121863. constructor(
  121864. /**
  121865. * Defines the priority of this optimization (0 by default which means first in the list)
  121866. */
  121867. priority?: number);
  121868. }
  121869. /**
  121870. * Defines an optimization used to reduce the size of render target textures
  121871. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121872. */
  121873. export class TextureOptimization extends SceneOptimization {
  121874. /**
  121875. * Defines the priority of this optimization (0 by default which means first in the list)
  121876. */
  121877. priority: number;
  121878. /**
  121879. * 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
  121880. */
  121881. maximumSize: number;
  121882. /**
  121883. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121884. */
  121885. step: number;
  121886. /**
  121887. * Gets a string describing the action executed by the current optimization
  121888. * @returns description string
  121889. */
  121890. getDescription(): string;
  121891. /**
  121892. * Creates the TextureOptimization object
  121893. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121894. * @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
  121895. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121896. */
  121897. constructor(
  121898. /**
  121899. * Defines the priority of this optimization (0 by default which means first in the list)
  121900. */
  121901. priority?: number,
  121902. /**
  121903. * 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
  121904. */
  121905. maximumSize?: number,
  121906. /**
  121907. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121908. */
  121909. step?: number);
  121910. /**
  121911. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121912. * @param scene defines the current scene where to apply this optimization
  121913. * @param optimizer defines the current optimizer
  121914. * @returns true if everything that can be done was applied
  121915. */
  121916. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121917. }
  121918. /**
  121919. * Defines an optimization used to increase or decrease the rendering resolution
  121920. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121921. */
  121922. export class HardwareScalingOptimization extends SceneOptimization {
  121923. /**
  121924. * Defines the priority of this optimization (0 by default which means first in the list)
  121925. */
  121926. priority: number;
  121927. /**
  121928. * Defines the maximum scale to use (2 by default)
  121929. */
  121930. maximumScale: number;
  121931. /**
  121932. * Defines the step to use between two passes (0.5 by default)
  121933. */
  121934. step: number;
  121935. private _currentScale;
  121936. private _directionOffset;
  121937. /**
  121938. * Gets a string describing the action executed by the current optimization
  121939. * @return description string
  121940. */
  121941. getDescription(): string;
  121942. /**
  121943. * Creates the HardwareScalingOptimization object
  121944. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121945. * @param maximumScale defines the maximum scale to use (2 by default)
  121946. * @param step defines the step to use between two passes (0.5 by default)
  121947. */
  121948. constructor(
  121949. /**
  121950. * Defines the priority of this optimization (0 by default which means first in the list)
  121951. */
  121952. priority?: number,
  121953. /**
  121954. * Defines the maximum scale to use (2 by default)
  121955. */
  121956. maximumScale?: number,
  121957. /**
  121958. * Defines the step to use between two passes (0.5 by default)
  121959. */
  121960. step?: number);
  121961. /**
  121962. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121963. * @param scene defines the current scene where to apply this optimization
  121964. * @param optimizer defines the current optimizer
  121965. * @returns true if everything that can be done was applied
  121966. */
  121967. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121968. }
  121969. /**
  121970. * Defines an optimization used to remove shadows
  121971. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121972. */
  121973. export class ShadowsOptimization extends SceneOptimization {
  121974. /**
  121975. * Gets a string describing the action executed by the current optimization
  121976. * @return description string
  121977. */
  121978. getDescription(): string;
  121979. /**
  121980. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121981. * @param scene defines the current scene where to apply this optimization
  121982. * @param optimizer defines the current optimizer
  121983. * @returns true if everything that can be done was applied
  121984. */
  121985. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121986. }
  121987. /**
  121988. * Defines an optimization used to turn post-processes off
  121989. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121990. */
  121991. export class PostProcessesOptimization extends SceneOptimization {
  121992. /**
  121993. * Gets a string describing the action executed by the current optimization
  121994. * @return description string
  121995. */
  121996. getDescription(): string;
  121997. /**
  121998. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121999. * @param scene defines the current scene where to apply this optimization
  122000. * @param optimizer defines the current optimizer
  122001. * @returns true if everything that can be done was applied
  122002. */
  122003. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  122004. }
  122005. /**
  122006. * Defines an optimization used to turn lens flares off
  122007. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  122008. */
  122009. export class LensFlaresOptimization extends SceneOptimization {
  122010. /**
  122011. * Gets a string describing the action executed by the current optimization
  122012. * @return description string
  122013. */
  122014. getDescription(): string;
  122015. /**
  122016. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  122017. * @param scene defines the current scene where to apply this optimization
  122018. * @param optimizer defines the current optimizer
  122019. * @returns true if everything that can be done was applied
  122020. */
  122021. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  122022. }
  122023. /**
  122024. * Defines an optimization based on user defined callback.
  122025. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  122026. */
  122027. export class CustomOptimization extends SceneOptimization {
  122028. /**
  122029. * Callback called to apply the custom optimization.
  122030. */
  122031. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  122032. /**
  122033. * Callback called to get custom description
  122034. */
  122035. onGetDescription: () => string;
  122036. /**
  122037. * Gets a string describing the action executed by the current optimization
  122038. * @returns description string
  122039. */
  122040. getDescription(): string;
  122041. /**
  122042. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  122043. * @param scene defines the current scene where to apply this optimization
  122044. * @param optimizer defines the current optimizer
  122045. * @returns true if everything that can be done was applied
  122046. */
  122047. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  122048. }
  122049. /**
  122050. * Defines an optimization used to turn particles off
  122051. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  122052. */
  122053. export class ParticlesOptimization extends SceneOptimization {
  122054. /**
  122055. * Gets a string describing the action executed by the current optimization
  122056. * @return description string
  122057. */
  122058. getDescription(): string;
  122059. /**
  122060. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  122061. * @param scene defines the current scene where to apply this optimization
  122062. * @param optimizer defines the current optimizer
  122063. * @returns true if everything that can be done was applied
  122064. */
  122065. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  122066. }
  122067. /**
  122068. * Defines an optimization used to turn render targets off
  122069. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  122070. */
  122071. export class RenderTargetsOptimization extends SceneOptimization {
  122072. /**
  122073. * Gets a string describing the action executed by the current optimization
  122074. * @return description string
  122075. */
  122076. getDescription(): string;
  122077. /**
  122078. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  122079. * @param scene defines the current scene where to apply this optimization
  122080. * @param optimizer defines the current optimizer
  122081. * @returns true if everything that can be done was applied
  122082. */
  122083. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  122084. }
  122085. /**
  122086. * Defines an optimization used to merge meshes with compatible materials
  122087. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  122088. */
  122089. export class MergeMeshesOptimization extends SceneOptimization {
  122090. private static _UpdateSelectionTree;
  122091. /**
  122092. * Gets or sets a boolean which defines if optimization octree has to be updated
  122093. */
  122094. /**
  122095. * Gets or sets a boolean which defines if optimization octree has to be updated
  122096. */
  122097. static UpdateSelectionTree: boolean;
  122098. /**
  122099. * Gets a string describing the action executed by the current optimization
  122100. * @return description string
  122101. */
  122102. getDescription(): string;
  122103. private _canBeMerged;
  122104. /**
  122105. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  122106. * @param scene defines the current scene where to apply this optimization
  122107. * @param optimizer defines the current optimizer
  122108. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  122109. * @returns true if everything that can be done was applied
  122110. */
  122111. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  122112. }
  122113. /**
  122114. * Defines a list of options used by SceneOptimizer
  122115. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  122116. */
  122117. export class SceneOptimizerOptions {
  122118. /**
  122119. * Defines the target frame rate to reach (60 by default)
  122120. */
  122121. targetFrameRate: number;
  122122. /**
  122123. * Defines the interval between two checkes (2000ms by default)
  122124. */
  122125. trackerDuration: number;
  122126. /**
  122127. * Gets the list of optimizations to apply
  122128. */
  122129. optimizations: SceneOptimization[];
  122130. /**
  122131. * Creates a new list of options used by SceneOptimizer
  122132. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  122133. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  122134. */
  122135. constructor(
  122136. /**
  122137. * Defines the target frame rate to reach (60 by default)
  122138. */
  122139. targetFrameRate?: number,
  122140. /**
  122141. * Defines the interval between two checkes (2000ms by default)
  122142. */
  122143. trackerDuration?: number);
  122144. /**
  122145. * Add a new optimization
  122146. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  122147. * @returns the current SceneOptimizerOptions
  122148. */
  122149. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  122150. /**
  122151. * Add a new custom optimization
  122152. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  122153. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  122154. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  122155. * @returns the current SceneOptimizerOptions
  122156. */
  122157. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  122158. /**
  122159. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  122160. * @param targetFrameRate defines the target frame rate (60 by default)
  122161. * @returns a SceneOptimizerOptions object
  122162. */
  122163. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  122164. /**
  122165. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  122166. * @param targetFrameRate defines the target frame rate (60 by default)
  122167. * @returns a SceneOptimizerOptions object
  122168. */
  122169. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  122170. /**
  122171. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  122172. * @param targetFrameRate defines the target frame rate (60 by default)
  122173. * @returns a SceneOptimizerOptions object
  122174. */
  122175. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  122176. }
  122177. /**
  122178. * Class used to run optimizations in order to reach a target frame rate
  122179. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  122180. */
  122181. export class SceneOptimizer implements IDisposable {
  122182. private _isRunning;
  122183. private _options;
  122184. private _scene;
  122185. private _currentPriorityLevel;
  122186. private _targetFrameRate;
  122187. private _trackerDuration;
  122188. private _currentFrameRate;
  122189. private _sceneDisposeObserver;
  122190. private _improvementMode;
  122191. /**
  122192. * Defines an observable called when the optimizer reaches the target frame rate
  122193. */
  122194. onSuccessObservable: Observable<SceneOptimizer>;
  122195. /**
  122196. * Defines an observable called when the optimizer enables an optimization
  122197. */
  122198. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  122199. /**
  122200. * Defines an observable called when the optimizer is not able to reach the target frame rate
  122201. */
  122202. onFailureObservable: Observable<SceneOptimizer>;
  122203. /**
  122204. * Gets a boolean indicating if the optimizer is in improvement mode
  122205. */
  122206. readonly isInImprovementMode: boolean;
  122207. /**
  122208. * Gets the current priority level (0 at start)
  122209. */
  122210. readonly currentPriorityLevel: number;
  122211. /**
  122212. * Gets the current frame rate checked by the SceneOptimizer
  122213. */
  122214. readonly currentFrameRate: number;
  122215. /**
  122216. * Gets or sets the current target frame rate (60 by default)
  122217. */
  122218. /**
  122219. * Gets or sets the current target frame rate (60 by default)
  122220. */
  122221. targetFrameRate: number;
  122222. /**
  122223. * Gets or sets the current interval between two checks (every 2000ms by default)
  122224. */
  122225. /**
  122226. * Gets or sets the current interval between two checks (every 2000ms by default)
  122227. */
  122228. trackerDuration: number;
  122229. /**
  122230. * Gets the list of active optimizations
  122231. */
  122232. readonly optimizations: SceneOptimization[];
  122233. /**
  122234. * Creates a new SceneOptimizer
  122235. * @param scene defines the scene to work on
  122236. * @param options defines the options to use with the SceneOptimizer
  122237. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  122238. * @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)
  122239. */
  122240. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  122241. /**
  122242. * Stops the current optimizer
  122243. */
  122244. stop(): void;
  122245. /**
  122246. * Reset the optimizer to initial step (current priority level = 0)
  122247. */
  122248. reset(): void;
  122249. /**
  122250. * Start the optimizer. By default it will try to reach a specific framerate
  122251. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  122252. */
  122253. start(): void;
  122254. private _checkCurrentState;
  122255. /**
  122256. * Release all resources
  122257. */
  122258. dispose(): void;
  122259. /**
  122260. * Helper function to create a SceneOptimizer with one single line of code
  122261. * @param scene defines the scene to work on
  122262. * @param options defines the options to use with the SceneOptimizer
  122263. * @param onSuccess defines a callback to call on success
  122264. * @param onFailure defines a callback to call on failure
  122265. * @returns the new SceneOptimizer object
  122266. */
  122267. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  122268. }
  122269. }
  122270. declare module BABYLON {
  122271. /**
  122272. * Class used to serialize a scene into a string
  122273. */
  122274. export class SceneSerializer {
  122275. /**
  122276. * Clear cache used by a previous serialization
  122277. */
  122278. static ClearCache(): void;
  122279. /**
  122280. * Serialize a scene into a JSON compatible object
  122281. * @param scene defines the scene to serialize
  122282. * @returns a JSON compatible object
  122283. */
  122284. static Serialize(scene: Scene): any;
  122285. /**
  122286. * Serialize a mesh into a JSON compatible object
  122287. * @param toSerialize defines the mesh to serialize
  122288. * @param withParents defines if parents must be serialized as well
  122289. * @param withChildren defines if children must be serialized as well
  122290. * @returns a JSON compatible object
  122291. */
  122292. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  122293. }
  122294. }
  122295. declare module BABYLON {
  122296. /**
  122297. * Class used to host texture specific utilities
  122298. */
  122299. export class TextureTools {
  122300. /**
  122301. * Uses the GPU to create a copy texture rescaled at a given size
  122302. * @param texture Texture to copy from
  122303. * @param width defines the desired width
  122304. * @param height defines the desired height
  122305. * @param useBilinearMode defines if bilinear mode has to be used
  122306. * @return the generated texture
  122307. */
  122308. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  122309. }
  122310. }
  122311. declare module BABYLON {
  122312. /**
  122313. * This represents the different options available for the video capture.
  122314. */
  122315. export interface VideoRecorderOptions {
  122316. /** Defines the mime type of the video. */
  122317. mimeType: string;
  122318. /** Defines the FPS the video should be recorded at. */
  122319. fps: number;
  122320. /** Defines the chunk size for the recording data. */
  122321. recordChunckSize: number;
  122322. /** The audio tracks to attach to the recording. */
  122323. audioTracks?: MediaStreamTrack[];
  122324. }
  122325. /**
  122326. * This can help with recording videos from BabylonJS.
  122327. * This is based on the available WebRTC functionalities of the browser.
  122328. *
  122329. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  122330. */
  122331. export class VideoRecorder {
  122332. private static readonly _defaultOptions;
  122333. /**
  122334. * Returns whether or not the VideoRecorder is available in your browser.
  122335. * @param engine Defines the Babylon Engine.
  122336. * @returns true if supported otherwise false.
  122337. */
  122338. static IsSupported(engine: Engine): boolean;
  122339. private readonly _options;
  122340. private _canvas;
  122341. private _mediaRecorder;
  122342. private _recordedChunks;
  122343. private _fileName;
  122344. private _resolve;
  122345. private _reject;
  122346. /**
  122347. * True when a recording is already in progress.
  122348. */
  122349. readonly isRecording: boolean;
  122350. /**
  122351. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  122352. * @param engine Defines the BabylonJS Engine you wish to record.
  122353. * @param options Defines options that can be used to customize the capture.
  122354. */
  122355. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  122356. /**
  122357. * Stops the current recording before the default capture timeout passed in the startRecording function.
  122358. */
  122359. stopRecording(): void;
  122360. /**
  122361. * Starts recording the canvas for a max duration specified in parameters.
  122362. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  122363. * If null no automatic download will start and you can rely on the promise to get the data back.
  122364. * @param maxDuration Defines the maximum recording time in seconds.
  122365. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  122366. * @return A promise callback at the end of the recording with the video data in Blob.
  122367. */
  122368. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  122369. /**
  122370. * Releases internal resources used during the recording.
  122371. */
  122372. dispose(): void;
  122373. private _handleDataAvailable;
  122374. private _handleError;
  122375. private _handleStop;
  122376. }
  122377. }
  122378. declare module BABYLON {
  122379. /**
  122380. * Class containing a set of static utilities functions for screenshots
  122381. */
  122382. export class ScreenshotTools {
  122383. /**
  122384. * Captures a screenshot of the current rendering
  122385. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  122386. * @param engine defines the rendering engine
  122387. * @param camera defines the source camera
  122388. * @param size This parameter can be set to a single number or to an object with the
  122389. * following (optional) properties: precision, width, height. If a single number is passed,
  122390. * it will be used for both width and height. If an object is passed, the screenshot size
  122391. * will be derived from the parameters. The precision property is a multiplier allowing
  122392. * rendering at a higher or lower resolution
  122393. * @param successCallback defines the callback receives a single parameter which contains the
  122394. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122395. * src parameter of an <img> to display it
  122396. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122397. * Check your browser for supported MIME types
  122398. */
  122399. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  122400. /**
  122401. * Generates an image screenshot from the specified camera.
  122402. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  122403. * @param engine The engine to use for rendering
  122404. * @param camera The camera to use for rendering
  122405. * @param size This parameter can be set to a single number or to an object with the
  122406. * following (optional) properties: precision, width, height. If a single number is passed,
  122407. * it will be used for both width and height. If an object is passed, the screenshot size
  122408. * will be derived from the parameters. The precision property is a multiplier allowing
  122409. * rendering at a higher or lower resolution
  122410. * @param successCallback The callback receives a single parameter which contains the
  122411. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122412. * src parameter of an <img> to display it
  122413. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122414. * Check your browser for supported MIME types
  122415. * @param samples Texture samples (default: 1)
  122416. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122417. * @param fileName A name for for the downloaded file.
  122418. */
  122419. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  122420. }
  122421. }
  122422. declare module BABYLON {
  122423. /**
  122424. * A cursor which tracks a point on a path
  122425. */
  122426. export class PathCursor {
  122427. private path;
  122428. /**
  122429. * Stores path cursor callbacks for when an onchange event is triggered
  122430. */
  122431. private _onchange;
  122432. /**
  122433. * The value of the path cursor
  122434. */
  122435. value: number;
  122436. /**
  122437. * The animation array of the path cursor
  122438. */
  122439. animations: Animation[];
  122440. /**
  122441. * Initializes the path cursor
  122442. * @param path The path to track
  122443. */
  122444. constructor(path: Path2);
  122445. /**
  122446. * Gets the cursor point on the path
  122447. * @returns A point on the path cursor at the cursor location
  122448. */
  122449. getPoint(): Vector3;
  122450. /**
  122451. * Moves the cursor ahead by the step amount
  122452. * @param step The amount to move the cursor forward
  122453. * @returns This path cursor
  122454. */
  122455. moveAhead(step?: number): PathCursor;
  122456. /**
  122457. * Moves the cursor behind by the step amount
  122458. * @param step The amount to move the cursor back
  122459. * @returns This path cursor
  122460. */
  122461. moveBack(step?: number): PathCursor;
  122462. /**
  122463. * Moves the cursor by the step amount
  122464. * If the step amount is greater than one, an exception is thrown
  122465. * @param step The amount to move the cursor
  122466. * @returns This path cursor
  122467. */
  122468. move(step: number): PathCursor;
  122469. /**
  122470. * Ensures that the value is limited between zero and one
  122471. * @returns This path cursor
  122472. */
  122473. private ensureLimits;
  122474. /**
  122475. * Runs onchange callbacks on change (used by the animation engine)
  122476. * @returns This path cursor
  122477. */
  122478. private raiseOnChange;
  122479. /**
  122480. * Executes a function on change
  122481. * @param f A path cursor onchange callback
  122482. * @returns This path cursor
  122483. */
  122484. onchange(f: (cursor: PathCursor) => void): PathCursor;
  122485. }
  122486. }
  122487. declare module BABYLON {
  122488. /** @hidden */
  122489. export var blurPixelShader: {
  122490. name: string;
  122491. shader: string;
  122492. };
  122493. }
  122494. declare module BABYLON {
  122495. /** @hidden */
  122496. export var pointCloudVertexDeclaration: {
  122497. name: string;
  122498. shader: string;
  122499. };
  122500. }
  122501. // Mixins
  122502. interface Window {
  122503. mozIndexedDB: IDBFactory;
  122504. webkitIndexedDB: IDBFactory;
  122505. msIndexedDB: IDBFactory;
  122506. webkitURL: typeof URL;
  122507. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  122508. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  122509. WebGLRenderingContext: WebGLRenderingContext;
  122510. MSGesture: MSGesture;
  122511. CANNON: any;
  122512. AudioContext: AudioContext;
  122513. webkitAudioContext: AudioContext;
  122514. PointerEvent: any;
  122515. Math: Math;
  122516. Uint8Array: Uint8ArrayConstructor;
  122517. Float32Array: Float32ArrayConstructor;
  122518. mozURL: typeof URL;
  122519. msURL: typeof URL;
  122520. VRFrameData: any; // WebVR, from specs 1.1
  122521. DracoDecoderModule: any;
  122522. setImmediate(handler: (...args: any[]) => void): number;
  122523. }
  122524. interface HTMLCanvasElement {
  122525. requestPointerLock(): void;
  122526. msRequestPointerLock?(): void;
  122527. mozRequestPointerLock?(): void;
  122528. webkitRequestPointerLock?(): void;
  122529. /** Track wether a record is in progress */
  122530. isRecording: boolean;
  122531. /** Capture Stream method defined by some browsers */
  122532. captureStream(fps?: number): MediaStream;
  122533. }
  122534. interface CanvasRenderingContext2D {
  122535. msImageSmoothingEnabled: boolean;
  122536. }
  122537. interface MouseEvent {
  122538. mozMovementX: number;
  122539. mozMovementY: number;
  122540. webkitMovementX: number;
  122541. webkitMovementY: number;
  122542. msMovementX: number;
  122543. msMovementY: number;
  122544. }
  122545. interface Navigator {
  122546. mozGetVRDevices: (any: any) => any;
  122547. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122548. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122549. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122550. webkitGetGamepads(): Gamepad[];
  122551. msGetGamepads(): Gamepad[];
  122552. webkitGamepads(): Gamepad[];
  122553. }
  122554. interface HTMLVideoElement {
  122555. mozSrcObject: any;
  122556. }
  122557. interface Math {
  122558. fround(x: number): number;
  122559. imul(a: number, b: number): number;
  122560. }
  122561. interface WebGLRenderingContext {
  122562. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  122563. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  122564. vertexAttribDivisor(index: number, divisor: number): void;
  122565. createVertexArray(): any;
  122566. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  122567. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  122568. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  122569. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  122570. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  122571. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  122572. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  122573. // Queries
  122574. createQuery(): WebGLQuery;
  122575. deleteQuery(query: WebGLQuery): void;
  122576. beginQuery(target: number, query: WebGLQuery): void;
  122577. endQuery(target: number): void;
  122578. getQueryParameter(query: WebGLQuery, pname: number): any;
  122579. getQuery(target: number, pname: number): any;
  122580. MAX_SAMPLES: number;
  122581. RGBA8: number;
  122582. READ_FRAMEBUFFER: number;
  122583. DRAW_FRAMEBUFFER: number;
  122584. UNIFORM_BUFFER: number;
  122585. HALF_FLOAT_OES: number;
  122586. RGBA16F: number;
  122587. RGBA32F: number;
  122588. R32F: number;
  122589. RG32F: number;
  122590. RGB32F: number;
  122591. R16F: number;
  122592. RG16F: number;
  122593. RGB16F: number;
  122594. RED: number;
  122595. RG: number;
  122596. R8: number;
  122597. RG8: number;
  122598. UNSIGNED_INT_24_8: number;
  122599. DEPTH24_STENCIL8: number;
  122600. /* Multiple Render Targets */
  122601. drawBuffers(buffers: number[]): void;
  122602. readBuffer(src: number): void;
  122603. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  122604. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  122605. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  122606. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  122607. // Occlusion Query
  122608. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  122609. ANY_SAMPLES_PASSED: number;
  122610. QUERY_RESULT_AVAILABLE: number;
  122611. QUERY_RESULT: number;
  122612. }
  122613. interface WebGLProgram {
  122614. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  122615. }
  122616. interface EXT_disjoint_timer_query {
  122617. QUERY_COUNTER_BITS_EXT: number;
  122618. TIME_ELAPSED_EXT: number;
  122619. TIMESTAMP_EXT: number;
  122620. GPU_DISJOINT_EXT: number;
  122621. QUERY_RESULT_EXT: number;
  122622. QUERY_RESULT_AVAILABLE_EXT: number;
  122623. queryCounterEXT(query: WebGLQuery, target: number): void;
  122624. createQueryEXT(): WebGLQuery;
  122625. beginQueryEXT(target: number, query: WebGLQuery): void;
  122626. endQueryEXT(target: number): void;
  122627. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  122628. deleteQueryEXT(query: WebGLQuery): void;
  122629. }
  122630. interface WebGLUniformLocation {
  122631. _currentState: any;
  122632. }
  122633. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  122634. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  122635. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  122636. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  122637. interface WebGLRenderingContext {
  122638. readonly RASTERIZER_DISCARD: number;
  122639. readonly DEPTH_COMPONENT24: number;
  122640. readonly TEXTURE_3D: number;
  122641. readonly TEXTURE_2D_ARRAY: number;
  122642. readonly TEXTURE_COMPARE_FUNC: number;
  122643. readonly TEXTURE_COMPARE_MODE: number;
  122644. readonly COMPARE_REF_TO_TEXTURE: number;
  122645. readonly TEXTURE_WRAP_R: number;
  122646. readonly HALF_FLOAT: number;
  122647. readonly RGB8: number;
  122648. readonly RED_INTEGER: number;
  122649. readonly RG_INTEGER: number;
  122650. readonly RGB_INTEGER: number;
  122651. readonly RGBA_INTEGER: number;
  122652. readonly R8_SNORM: number;
  122653. readonly RG8_SNORM: number;
  122654. readonly RGB8_SNORM: number;
  122655. readonly RGBA8_SNORM: number;
  122656. readonly R8I: number;
  122657. readonly RG8I: number;
  122658. readonly RGB8I: number;
  122659. readonly RGBA8I: number;
  122660. readonly R8UI: number;
  122661. readonly RG8UI: number;
  122662. readonly RGB8UI: number;
  122663. readonly RGBA8UI: number;
  122664. readonly R16I: number;
  122665. readonly RG16I: number;
  122666. readonly RGB16I: number;
  122667. readonly RGBA16I: number;
  122668. readonly R16UI: number;
  122669. readonly RG16UI: number;
  122670. readonly RGB16UI: number;
  122671. readonly RGBA16UI: number;
  122672. readonly R32I: number;
  122673. readonly RG32I: number;
  122674. readonly RGB32I: number;
  122675. readonly RGBA32I: number;
  122676. readonly R32UI: number;
  122677. readonly RG32UI: number;
  122678. readonly RGB32UI: number;
  122679. readonly RGBA32UI: number;
  122680. readonly RGB10_A2UI: number;
  122681. readonly R11F_G11F_B10F: number;
  122682. readonly RGB9_E5: number;
  122683. readonly RGB10_A2: number;
  122684. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  122685. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  122686. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  122687. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  122688. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  122689. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  122690. 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;
  122691. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  122692. readonly TRANSFORM_FEEDBACK: number;
  122693. readonly INTERLEAVED_ATTRIBS: number;
  122694. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  122695. createTransformFeedback(): WebGLTransformFeedback;
  122696. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  122697. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  122698. beginTransformFeedback(primitiveMode: number): void;
  122699. endTransformFeedback(): void;
  122700. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  122701. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122702. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122703. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122704. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  122705. }
  122706. interface ImageBitmap {
  122707. readonly width: number;
  122708. readonly height: number;
  122709. close(): void;
  122710. }
  122711. interface WebGLQuery extends WebGLObject {
  122712. }
  122713. declare var WebGLQuery: {
  122714. prototype: WebGLQuery;
  122715. new(): WebGLQuery;
  122716. };
  122717. interface WebGLSampler extends WebGLObject {
  122718. }
  122719. declare var WebGLSampler: {
  122720. prototype: WebGLSampler;
  122721. new(): WebGLSampler;
  122722. };
  122723. interface WebGLSync extends WebGLObject {
  122724. }
  122725. declare var WebGLSync: {
  122726. prototype: WebGLSync;
  122727. new(): WebGLSync;
  122728. };
  122729. interface WebGLTransformFeedback extends WebGLObject {
  122730. }
  122731. declare var WebGLTransformFeedback: {
  122732. prototype: WebGLTransformFeedback;
  122733. new(): WebGLTransformFeedback;
  122734. };
  122735. interface WebGLVertexArrayObject extends WebGLObject {
  122736. }
  122737. declare var WebGLVertexArrayObject: {
  122738. prototype: WebGLVertexArrayObject;
  122739. new(): WebGLVertexArrayObject;
  122740. };
  122741. // Type definitions for WebVR API
  122742. // Project: https://w3c.github.io/webvr/
  122743. // Definitions by: six a <https://github.com/lostfictions>
  122744. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  122745. interface VRDisplay extends EventTarget {
  122746. /**
  122747. * Dictionary of capabilities describing the VRDisplay.
  122748. */
  122749. readonly capabilities: VRDisplayCapabilities;
  122750. /**
  122751. * z-depth defining the far plane of the eye view frustum
  122752. * enables mapping of values in the render target depth
  122753. * attachment to scene coordinates. Initially set to 10000.0.
  122754. */
  122755. depthFar: number;
  122756. /**
  122757. * z-depth defining the near plane of the eye view frustum
  122758. * enables mapping of values in the render target depth
  122759. * attachment to scene coordinates. Initially set to 0.01.
  122760. */
  122761. depthNear: number;
  122762. /**
  122763. * An identifier for this distinct VRDisplay. Used as an
  122764. * association point in the Gamepad API.
  122765. */
  122766. readonly displayId: number;
  122767. /**
  122768. * A display name, a user-readable name identifying it.
  122769. */
  122770. readonly displayName: string;
  122771. readonly isConnected: boolean;
  122772. readonly isPresenting: boolean;
  122773. /**
  122774. * If this VRDisplay supports room-scale experiences, the optional
  122775. * stage attribute contains details on the room-scale parameters.
  122776. */
  122777. readonly stageParameters: VRStageParameters | null;
  122778. /**
  122779. * Passing the value returned by `requestAnimationFrame` to
  122780. * `cancelAnimationFrame` will unregister the callback.
  122781. * @param handle Define the hanle of the request to cancel
  122782. */
  122783. cancelAnimationFrame(handle: number): void;
  122784. /**
  122785. * Stops presenting to the VRDisplay.
  122786. * @returns a promise to know when it stopped
  122787. */
  122788. exitPresent(): Promise<void>;
  122789. /**
  122790. * Return the current VREyeParameters for the given eye.
  122791. * @param whichEye Define the eye we want the parameter for
  122792. * @returns the eye parameters
  122793. */
  122794. getEyeParameters(whichEye: string): VREyeParameters;
  122795. /**
  122796. * Populates the passed VRFrameData with the information required to render
  122797. * the current frame.
  122798. * @param frameData Define the data structure to populate
  122799. * @returns true if ok otherwise false
  122800. */
  122801. getFrameData(frameData: VRFrameData): boolean;
  122802. /**
  122803. * Get the layers currently being presented.
  122804. * @returns the list of VR layers
  122805. */
  122806. getLayers(): VRLayer[];
  122807. /**
  122808. * Return a VRPose containing the future predicted pose of the VRDisplay
  122809. * when the current frame will be presented. The value returned will not
  122810. * change until JavaScript has returned control to the browser.
  122811. *
  122812. * The VRPose will contain the position, orientation, velocity,
  122813. * and acceleration of each of these properties.
  122814. * @returns the pose object
  122815. */
  122816. getPose(): VRPose;
  122817. /**
  122818. * Return the current instantaneous pose of the VRDisplay, with no
  122819. * prediction applied.
  122820. * @returns the current instantaneous pose
  122821. */
  122822. getImmediatePose(): VRPose;
  122823. /**
  122824. * The callback passed to `requestAnimationFrame` will be called
  122825. * any time a new frame should be rendered. When the VRDisplay is
  122826. * presenting the callback will be called at the native refresh
  122827. * rate of the HMD. When not presenting this function acts
  122828. * identically to how window.requestAnimationFrame acts. Content should
  122829. * make no assumptions of frame rate or vsync behavior as the HMD runs
  122830. * asynchronously from other displays and at differing refresh rates.
  122831. * @param callback Define the eaction to run next frame
  122832. * @returns the request handle it
  122833. */
  122834. requestAnimationFrame(callback: FrameRequestCallback): number;
  122835. /**
  122836. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  122837. * Repeat calls while already presenting will update the VRLayers being displayed.
  122838. * @param layers Define the list of layer to present
  122839. * @returns a promise to know when the request has been fulfilled
  122840. */
  122841. requestPresent(layers: VRLayer[]): Promise<void>;
  122842. /**
  122843. * Reset the pose for this display, treating its current position and
  122844. * orientation as the "origin/zero" values. VRPose.position,
  122845. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  122846. * updated when calling resetPose(). This should be called in only
  122847. * sitting-space experiences.
  122848. */
  122849. resetPose(): void;
  122850. /**
  122851. * The VRLayer provided to the VRDisplay will be captured and presented
  122852. * in the HMD. Calling this function has the same effect on the source
  122853. * canvas as any other operation that uses its source image, and canvases
  122854. * created without preserveDrawingBuffer set to true will be cleared.
  122855. * @param pose Define the pose to submit
  122856. */
  122857. submitFrame(pose?: VRPose): void;
  122858. }
  122859. declare var VRDisplay: {
  122860. prototype: VRDisplay;
  122861. new(): VRDisplay;
  122862. };
  122863. interface VRLayer {
  122864. leftBounds?: number[] | Float32Array | null;
  122865. rightBounds?: number[] | Float32Array | null;
  122866. source?: HTMLCanvasElement | null;
  122867. }
  122868. interface VRDisplayCapabilities {
  122869. readonly canPresent: boolean;
  122870. readonly hasExternalDisplay: boolean;
  122871. readonly hasOrientation: boolean;
  122872. readonly hasPosition: boolean;
  122873. readonly maxLayers: number;
  122874. }
  122875. interface VREyeParameters {
  122876. /** @deprecated */
  122877. readonly fieldOfView: VRFieldOfView;
  122878. readonly offset: Float32Array;
  122879. readonly renderHeight: number;
  122880. readonly renderWidth: number;
  122881. }
  122882. interface VRFieldOfView {
  122883. readonly downDegrees: number;
  122884. readonly leftDegrees: number;
  122885. readonly rightDegrees: number;
  122886. readonly upDegrees: number;
  122887. }
  122888. interface VRFrameData {
  122889. readonly leftProjectionMatrix: Float32Array;
  122890. readonly leftViewMatrix: Float32Array;
  122891. readonly pose: VRPose;
  122892. readonly rightProjectionMatrix: Float32Array;
  122893. readonly rightViewMatrix: Float32Array;
  122894. readonly timestamp: number;
  122895. }
  122896. interface VRPose {
  122897. readonly angularAcceleration: Float32Array | null;
  122898. readonly angularVelocity: Float32Array | null;
  122899. readonly linearAcceleration: Float32Array | null;
  122900. readonly linearVelocity: Float32Array | null;
  122901. readonly orientation: Float32Array | null;
  122902. readonly position: Float32Array | null;
  122903. readonly timestamp: number;
  122904. }
  122905. interface VRStageParameters {
  122906. sittingToStandingTransform?: Float32Array;
  122907. sizeX?: number;
  122908. sizeY?: number;
  122909. }
  122910. interface Navigator {
  122911. getVRDisplays(): Promise<VRDisplay[]>;
  122912. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  122913. }
  122914. interface Window {
  122915. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  122916. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  122917. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  122918. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122919. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122920. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  122921. }
  122922. interface Gamepad {
  122923. readonly displayId: number;
  122924. }
  122925. type XRSessionMode =
  122926. | "inline"
  122927. | "immersive-vr"
  122928. | "immersive-ar";
  122929. type XRReferenceSpaceType =
  122930. | "viewer"
  122931. | "local"
  122932. | "local-floor"
  122933. | "bounded-floor"
  122934. | "unbounded";
  122935. type XREnvironmentBlendMode =
  122936. | "opaque"
  122937. | "additive"
  122938. | "alpha-blend";
  122939. type XRVisibilityState =
  122940. | "visible"
  122941. | "visible-blurred"
  122942. | "hidden";
  122943. type XRHandedness =
  122944. | "none"
  122945. | "left"
  122946. | "right";
  122947. type XRTargetRayMode =
  122948. | "gaze"
  122949. | "tracked-pointer"
  122950. | "screen";
  122951. type XREye =
  122952. | "none"
  122953. | "left"
  122954. | "right";
  122955. interface XRSpace extends EventTarget {
  122956. }
  122957. interface XRRenderState {
  122958. depthNear: number ;
  122959. depthFar: number ;
  122960. inlineVerticalFieldOfView: number | undefined;
  122961. baseLayer: XRWebGLLayer | undefined;
  122962. }
  122963. interface XRInputSource {
  122964. handedness: XRHandedness;
  122965. targetRayMode: XRTargetRayMode;
  122966. targetRaySpace: XRSpace;
  122967. gripSpace: XRSpace | undefined;
  122968. gamepad: Gamepad | undefined;
  122969. profiles: Array<string>;
  122970. }
  122971. interface XRSession {
  122972. addEventListener: Function;
  122973. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  122974. updateRenderState(XRRenderStateInit: any): Promise<void>;
  122975. requestAnimationFrame: Function;
  122976. end(): Promise<void>;
  122977. renderState: XRRenderState;
  122978. inputSources: Array<XRInputSource>;
  122979. }
  122980. interface XRReferenceSpace extends XRSpace {
  122981. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  122982. onreset: any;
  122983. }
  122984. interface XRFrame {
  122985. session: XRSession;
  122986. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  122987. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  122988. }
  122989. interface XRViewerPose extends XRPose {
  122990. views: Array<XRView>;
  122991. }
  122992. interface XRPose {
  122993. transform: XRRigidTransform;
  122994. emulatedPosition: boolean;
  122995. }
  122996. declare var XRWebGLLayer: {
  122997. prototype: XRWebGLLayer;
  122998. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  122999. };
  123000. interface XRWebGLLayer {
  123001. framebuffer: WebGLFramebuffer;
  123002. framebufferWidth: number;
  123003. framebufferHeight: number;
  123004. getViewport: Function;
  123005. }
  123006. interface XRRigidTransform {
  123007. position: DOMPointReadOnly;
  123008. orientation: DOMPointReadOnly;
  123009. matrix: Float32Array;
  123010. inverse: XRRigidTransform;
  123011. }
  123012. interface XRView {
  123013. eye: XREye;
  123014. projectionMatrix: Float32Array;
  123015. transform: XRRigidTransform;
  123016. }
  123017. interface XRInputSourceChangeEvent {
  123018. session: XRSession;
  123019. removed: Array<XRInputSource>;
  123020. added: Array<XRInputSource>;
  123021. }